Let an embedder subclass CompiledWasmModuleHolder #8101
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 288 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.339
Real PR Conversation Timeline
1 comments
"Review active on #8101"
general
weight: 0.35
ryanking13
jsg::CompiledWasmModuleHolder(added in #7706) keeps the compiled code of one builtin Wasm module, today Pyodide'spyodide.asm.wasm, alive for its own lifetime, so that every isolate in the process that loads the module instantiates it from the same compiled code instead of compiling it again.ModuleRegistry::addBuiltinModule(),addBuiltinBundle()and the Python module registration take a holder by reference and callgetOrCompile()on it whenever an isolate loads the module. The holder guarantees that concurrent callers on any thread get a module compiled with their isolate's Wasm ESM integration builtins setting, compiling at most once per setting except for concurrent first loads.The holder is a concrete class with a non-virtual
getOrCompile()that always keeps the compiled modules in its own two slots. An embedder that keeps compiled Wasm code in a store of its own, such as a process-wide, size-bounded store keyed by content hash that also serves user modules, therefore can't pass an entry of that store to the module registry. It would have to keep a second copy of Pyodide's compiled code in a separate holder, retaining the wire bytes and machine code twice and reporting them outside its store, or change the registry's signatures to accept something other than a holder.This change makes
getOrCompile()virtual and gives the class a virtual destructor, so an embedder can subclass the holder and routegetOrCompile()to its own store while the registry APIs stay as they are. The default implementation is unchanged, and so is every existing caller. The class comment now states the contract an override has to keep: it may be called concurrently from any thread, and it returns a module compiled with the calling isolate's setting.The cost is one virtual call per module load, next to a Wasm instantiation, and a subclass still carries the base class's two unused slots (two empty mutex-guarded
kj::Maybes). The existing holder test inmodules-new-test("CompiledWasmModuleHolder keeps compiled code after its isolate is gone") continues to cover the default path. Cloudflare's runtime will use the subclass to keep Pyodide's interpreter pinned in a process-wide store of compiled Wasm modules.🤖 Generated with Claude Code