[wasm] add a total wasm bytes quota to the jiterpreter; adjust parameters #80266
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a configurable quota to the jiterpreter that will stop it from generating more code once a total number of WASM bytes is hit. For some degenerate cases (like massive test suites) we could otherwise end up generating a truckload of modules and potentially hit corner cases in the browser or exhaust memory.
At present System.Runtime.Tests generates around 2 megabytes of WASM in a full run with everything turned on, which is (IMO) pretty reasonable, but also shows how bad it could get. For AOT applications we are way less likely to approach the quota
I also adjusted some of the jiterpreter tuning parameters in this PR. The current ones in main (chosen arbitrarily at the time) cause S.T.J's test suite to be slower than w/o the jiterpreter in some cases, and these adjustments bring its execution times back in line with normal. (It should really be faster, but I believe this is a degenerate case and it is faster in browser-bench.) At some point we'll want to more aggressively evaluate what the right values for these parameters are, but for now I think this is an improvement.