perf(java): pre-compile WASM module once and reuse across instances#279
perf(java): pre-compile WASM module once and reuse across instances#279
Conversation
Use MachineFactoryCompiler.compile(WasmModule) to compile once in the SwapWasmResolverApi constructor and pass the pre-compiled factory to all WasmResolveApi instances. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3cd6aad to
3b51d57
Compare
Benchmark ResultsRan a 2-minute CPU benchmark comparing this branch against
~53% CPU reduction — the savings come from eliminating How the benchmark worksA JUnit test creates a |
| private final MaterializationStore materializationStore; | ||
| private final WasmFlagLogger flagLogger; | ||
| private final WasmModule wasmModule; | ||
| private final Function<Instance, Machine> machineFactory; |
There was a problem hiding this comment.
Actually feels like this should be static for this to be any speedup?
Summary
SwapWasmResolverApiconstructor usingMachineFactoryCompiler.compile(WasmModule)and reuse the compiled machine factory across allWasmResolveApiinstances.updateStateAndFlushLogscall created a newWasmResolveApi, triggering full AOT WASM-to-JVM bytecode compilation each time viaMachineFactoryCompiler::compile(Instance).Test plan
mvn compilepasses🤖 Generated with Claude Code