← Back to Pull requests

Stop flushing every isolate's Liftoff code when an isolate starts #8645

Closed
unknown closed this pull request without merging on Nov 19, 2026 07:24 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 04:00 UTC
Author

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 calls MemoryPressureNotification(kModerate). We hold the lock, so V8 handles it synchronously: CheckMemoryPressure() calls FreeCachesOnMemoryPressure(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-hint autogate skips the call. Turning off the flush with --noflush-liftoff-code would 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 %IsLiftoffFunction that 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.

Diff: 268 lines (+201 / -67) across 3 files Reviewer: ryanking13 Review duration: 203m
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
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.4% (MEDIUM) · Higher = larger blast radius
39.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17% · Safe to merge
17%