Repository navigation
Java wasm build flags - #4533
Merged
Merged
Conversation
`-O2 -Oz` compiled at -Oz. Built at -Os, Prism on Redline takes 24-26% less time to parse JRuby's standard library than at -Oz, for 17% more machine code per platform. -O2 and -O3 save another 8-10%, but carry 48-51% more machine code than -Oz and leave the bytecode fallback 1.6-2.3x as slow once oversized methods are split. -fno-sanitize=all, -fno-stack-protector and -lc++ -lc++abi leave the module byte-identical. -fPIC does not: dropping it makes the module and its machine code slightly smaller, with no measurable speed difference. --export-all stays, so the module exports the same symbols and Prism_ModuleExports keeps its API.
HotSpot never JIT-compiles a method over 8000 bytes of bytecode, and several of Prism's functions compile to more than that, the largest to 55 KB at -Os, close to the JVM's 64 KB limit. On the bytecode fallback they stay in the interpreter however hot they get. Endive 1.3.0's method splitting breaks them up, and the fallback then parses JRuby's standard library 5-9x as fast. Redline's machine code is byte-identical with and without it. The option is experimental in Endive.
With method splitting, the fallback takes 26-32% less time to parse JRuby's standard library on ByteArrayMemory than on Endive's default ByteBufferMemory. Redline's runner installs its own native memory, so the memory factory is only set when nativeProvider() is empty.
kddnewton
approved these changes
Dec 3, 2026
kddnewton
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me, but I'll wait for someone from JRuby to approve.
headius
approved these changes
Dec 3, 2026
headius
left a comment
Contributor
There was a problem hiding this comment.
Looks great! Using -Os makes so much sense and I'm looking forward to the method splitting experiments.
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.
Java Wasm: build at -Os, split large methods, ByteArrayMemory for the bytecode fallback
Three independent commits, measured by parsing JRuby's stdlib (825 files) on GitHub-hosted runners with JDK 25, wasi-sdk 33 and Endive 1.3.0. Parse output was identical across all builds.
-Osinstead of-O2 -Oz(which compiles at-Oz). On Redline, parsing takes 24–26% less time. In JRuby, warm parsing goes from 1.27–1.29x the default parser's time to 0.98–1.06x. x86_64 machine code grows 17% (3.00 → 3.52 MB).-O2and-O3save another 8–10%, but add 48–51% machine code and make the bytecode fallback 1.6–2.3x slower. This commit also drops-fno-sanitize=all,-fno-stack-protectorand-lc++ -lc++abi, which don't change the module, and-fPIC, which made no measurable difference.--export-allstays, so the exports are unchanged.methodSplitting(experimental in Endive). Prism's largest functions become JVM methods of up to 55 KB, which HotSpot never JIT-compiles. Splitting them makes the bytecode fallback 5–9x faster, and Redline's machine code is byte-identical.ByteArrayMemoryfor the bytecode fallback: 26–32% less time than the defaultByteBufferMemory. It's set only whennativeProvider()is empty, because Redline uses its own native memory.Tests pass on Redline and with the fallback forced (
-Dendive.redline.os.arch=riscv64).cc. @headius @enebo