Compiler: auto-size dispatch chunks to stay under JIT HugeMethodLimit#1288
Merged
andreaTP merged 1 commit intodylibso:mainfrom May 6, 2026
Merged
Compiler: auto-size dispatch chunks to stay under JIT HugeMethodLimit#1288andreaTP merged 1 commit intodylibso:mainfrom
andreaTP merged 1 commit intodylibso:mainfrom
Conversation
Contributor
Author
|
I originally did this by simply having |
Contributor
Author
|
Will take a look at CI failures |
70845fd to
1cff1dd
Compare
andreaTP
requested changes
May 5, 2026
Collaborator
andreaTP
left a comment
There was a problem hiding this comment.
Great idea! Thanks, a couple of minor comments/questions.
1cff1dd to
7958f14
Compare
7958f14 to
b2ee7e9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The JVM's C2 JIT compiler has a
HugeMethodLimit(default 8KB bytecode).At the previous chunk size of 1024 entries, the generated dispatch methods exceed 8KB and never get full C2 optimization. This only affects large wasm modules (>1024 functions), but many real-world modules like CPython, SQLite, etc. easily hit this.
Instead of a fixed chunk size, this PR derives it from the bytecode budget:
highestOneBit(hugeMethodLimit / bytesPerEntry), which produces dispatch methods that stay under the limit and get full C2 compilation. The limit is configurable via-Dchicory.hugeMethodLimit=<bytes>for JVMs with non-default settings for the hugemethod limit.Benchmark results (2000-function module, JMH, JDK 25):
In practice in cpython I found this to give about a 15-20% speedup on hot loops.