Repository navigation
module: cache compiled WebAssembly modules in the compile cache - #66191
Conversation
|
Review requested:
|
8f2675e to
f0680e2
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66191 +/- ##
==========================================
- Coverage 90.65% 90.65% -0.01%
==========================================
Files 797 797
Lines 278268 278429 +161
Branches 53511 53536 +25
==========================================
+ Hits 252258 252396 +138
- Misses 16384 16394 +10
- Partials 9626 9639 +13
🚀 New features to boost your workflow:
|
This comment was marked as outdated.
This comment was marked as outdated.
f0680e2 to
728cf8c
Compare
|
This pull request has conflicts with its base branch, removing the |
|
This is very cool. |
This comment was marked as outdated.
This comment was marked as outdated.
54ff26d to
6e560d0
Compare
|
This is now rebased and no longer depends on the V8 patch. Will aim to land soon! |
Extends the module compile cache to WebAssembly modules loaded through the ES module integration. A new kWasm entry type is keyed on the module URL with the wire bytes as the hashed source, and stores the serialized CompiledWasmModule. On load, cached code is deserialized through v8::WasmModuleCompilation with the same compile options the translator uses (js-string builtins and imported string constants), falling back to compilation when V8 rejects it. As for JavaScript, the cache entry is generated right after compilation. V8 only serializes optimized tier code, so with the default lazy baseline compilation there is nothing to cache and no entry is written; a complete cache requires --no-liftoff --no-wasm-lazy-compilation, which is documented as the way to use the compile cache for WebAssembly. Signed-off-by: Guy Bedford <guybedford@gmail.com> Assisted-by: Claude Code
6e560d0 to
f291da1
Compare
|
Landed in ec7a28f |
Extends the module compile cache to WebAssembly modules loaded through the ES module integration. A new kWasm entry type is keyed on the module URL with the wire bytes as the hashed source, and stores the serialized CompiledWasmModule. On load, cached code is deserialized through v8::WasmModuleCompilation with the same compile options the translator uses (js-string builtins and imported string constants), falling back to compilation when V8 rejects it. As for JavaScript, the cache entry is generated right after compilation. V8 only serializes optimized tier code, so with the default lazy baseline compilation there is nothing to cache and no entry is written; a complete cache requires --no-liftoff --no-wasm-lazy-compilation, which is documented as the way to use the compile cache for WebAssembly. Signed-off-by: Guy Bedford <guybedford@gmail.com> Assisted-by: Claude Code PR-URL: #66191 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
|
I see the following build failure on v26.x: If we want it there, it would require a manual backport PR |
This extends the module compile cache (
module.enableCompileCache()/NODE_COMPILE_CACHE) to WebAssembly modules loaded through the ES module integration.kWasmcache entry type, keyed on the module URL with the wire bytes as the hashed source, stores V8'sCompiledWasmModuleserialization.v8::WasmModuleCompilationwith the same compile options the wasm translator uses (js-stringbuiltins and imported string constants), falling back tonew WebAssembly.Module()when V8 rejects it.CompileCacheHandler::GetOrInsertgains a raw-bytes overload used by the new entry type; the string overload delegates to it.The
WasmModuleObject::CompileOptionsAPI this relies on is included in the V8 15.5 update now onmain, so no V8 patch is needed.As for JavaScript, the entry is captured right after compilation. V8 only serializes optimized-tier code, so with the default lazy baseline compilation there is nothing to cache and no entry is written. A complete cache requires
--no-liftoff --no-wasm-lazy-compilation, which compiles everything with the optimizing tier at module creation; since V8 flags are part of the cache key, all processes sharing the cache must use the same flags. This is documented in a new section ofmodule.md.The test covers both the eager-compilation case (entry written, then deserialized and accepted on the second run) and the default case (nothing serialized, no entry written).