Stop flushing every isolate's Liftoff code when an isolate starts #8645
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 268 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.335
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8645"
general
weight: 0.35
ryanking13
Fixes https://github.com/cloudflare/workerd/issues/8624. Starting an isolate makes every Wasm Worker in the process compile its code again.
Worker::Isolate's constructor callsMemoryPressureNotification(kModerate). We hold the lock, so V8 handles it synchronously:CheckMemoryPressure()callsFreeCachesOnMemoryPressure(kMemoryPressure)and then resets the level to "none". Since V8 14.7 that flushes the Liftoff code of every Wasm module in the process (WasmEngine::FlushLiftoffCode()) and empties the isolate group's memory pools. The next request to each Wasm Worker then recompiles every function it calls that hasn't tiered up. A server hosting many Workers starts isolates all the time, so this is a recurring cost on Python Workers (Pyodide) and every other Wasm Worker. The call has no other effect: the level doesn't stay at "moderate", and the only GC action at "moderate" is starting incremental marking, which we disable.In this patch the
skip-isolate-memory-pressure-hintautogate skips the call. Turning off the flush with--noflush-liftoff-codewould also turn off the flushes V8 makes on critical pressure and when Wasm code space runs out, and a new V8 flag changes the code cache's flag hash. worker-loader-liftoff-test checks with%IsLiftoffFunctionthat a function keeps its Liftoff code after a dynamic Worker starts. It fails with the gate off.| | gate off | gate on | speedup |
|---|---|---|---|
| Python Worker request right after an isolate starts | 7.68 ms | 2.38 ms | 3.2x |
| Rust Wasm Worker request right after an isolate starts | 1.42 ms | 1.05 ms | 1.4x |
| Python Worker request, no isolate start | 1.72 ms | 1.75 ms | 1.0x |
| Rust Wasm Worker request, no isolate start | 0.64 ms | 0.69 ms | 1.0x |
| Process CPU for the run | 12.25 s | 10.19 s | 1.2x |
| RSS at the end | 1587 MB | 1453 MB | 1.1x less |
Linux x86-64 (4 vCPU),
--config=opt: a Pyodide Python Worker (JSON, regex, string work) and a Rust Worker (markdown, regex and JSON in Wasm), warmed up with default tiering, then 300 requests each, each right after a new dynamic Worker starts; median p50 of 3 runs per side.