Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm jiterpreter cleanup and bug fixes pt. 4 #79324

Merged
merged 5 commits into from
Dec 20, 2022

Conversation

kg
Copy link
Member

@kg kg commented Dec 7, 2022

Blocks #78428

  • Instead of jitting interp_entry wrappers for every entry point, record a hit count for each one and then queue it for JIT compilation once it's hit enough times
  • Add prefs controlling interp entry queue thresholds
  • Add support for using imported globals for pointer constants (to enable future threading/caching), off by default
  • Use base 36 for jiterpreter import names to save space

@kg kg added the arch-wasm WebAssembly architecture label Dec 7, 2022
@ghost ghost assigned kg Dec 7, 2022
@ghost
Copy link

ghost commented Dec 7, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Blocks #78428

  • Instead of jitting interp_entry wrappers for every entry point, record a hit count for each one and then queue it for JIT compilation once it's hit enough times
  • Add prefs controlling interp entry queue thresholds
  • Add support for using imported globals for pointer constants (to enable future threading/caching), off by default
  • Use base 36 for jiterpreter import names to save space
Author: kg
Assignees: -
Labels:

arch-wasm

Milestone: -

// The solution is likely to put the address of the scratch buffer in a global that we provide
// at module instantiation time, so each thread can malloc its own copy of the buffer
// and then pass it in when instantiating instead of compiling the constant into the module
// FIXME: Pre-allocate these buffers and their constant slots at the start before we
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would have to be dealocated when the worker shuts down, otherwise it would leak memory long term.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is worker shutdown a common occurrence?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lambdageek could tell you more, but I think yes.

#if HOST_BROWSER
#define INTERP_ENTRY_UPDATE_HIT_COUNT(_method) \
mono_interp_record_interp_entry (_method)
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this call into js for every interp entry ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only until it gets jitted, I can move some of this tracking into C if necessary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should have some kind of fastpath like if (jiterpreter_enabled) etc. Also, shouldn't this be in interp_entry () ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting it in the generic entry is bad since those never get jitted, no point. Will put in a fast path, good point

…number of times. Reduces number in s.r.t from ~700 to ~90

Add C prefs controlling interp entry queue thresholds
Use imported globals for pointer constants (will make threading/caching easier)

Use base 36 for jiterpreter import names to save space

Add an option controlling the use of wasm global constants (off by default)
Adjust thresholds
@kg kg force-pushed the wasm-jiterpreter-cleanup-4 branch from e95bb55 to 6df022d Compare December 19, 2022 23:13
@kg kg merged commit 429cda7 into dotnet:main Dec 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants