Repository navigation
engine: run pnpm run dev with --no-flush-liftoff-code - #265
Open
ruifigueira wants to merge 1 commit into
Open
ruifigueira wants to merge 1 commit into
ruifigueira wants to merge 1 commit into
Conversation
workerd signals memory pressure for every new isolate, so V8 drops the engine's shared Liftoff code on each navigation and the next page isolate compiles it again. The old code is not freed, so a local dev engine grew by about 5 MiB of executable code per navigation: 50 navigations on one page reached a 675 MB footprint, against 265 MB with the flag. The recompile also slowed navigations: warm navigations took 127 ms without the flag and 72 to 76 ms with it. The Docker image and the WPT runner already pass the flag. The dev, dev:wpt and dev:memprof scripts now pass it too, and the README says to include it when you override MINIFLARE_WORKERD_V8_FLAGS. beep-boop-🤖 Signed-off-by: Rui Figueira <rfigueira@cloudflare.com>
ruifigueira
requested review from
BernardoPe,
LuisDuarte1,
celso and
jonnyparris
as code owners
November 28, 2026 10:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pnpm run devnow starts workerd with--no-flush-liftoff-codeas well as--expose-gc. The Docker image and the WPT runner already use both flags.workerd signals memory pressure each time it creates an isolate. On that signal, V8 throws away the engine's shared Liftoff code (V8's baseline compiled wasm), and the next page isolate compiles it again. The old code isn't freed, so a dev engine grows by about 5 MiB of executable code per navigation. I found this while checking whether #165 still reproduces: it was most of the growth I measured, and it isn't the page-isolate retention that #165 reports.
Behavior and API impact
None for the engine. Local dev uses less memory and navigates faster. If you set
MINIFLARE_WORKERD_V8_FLAGSyourself, your value still replaces the default.Implementation
packages/engine/package.json: thedev,dev:wptanddev:memprofscripts defaultMINIFLARE_WORKERD_V8_FLAGSto--expose-gc --no-flush-liftoff-code.README.md: explains the new flag, and says to include both flags when you override the default or startwrangler devdirectly.Validation
I ran the engine with
pnpm run devon macOS arm64 (workerd 1.20261123.1) and navigated one tab to the same small page 50 or 60 times over one CDP connection.footprint) after 50 navigationsThe two memory rows came from separate runs. The "before" memory run used
--no-expose-gc, and the "after" run used the new default. The timing rows used--expose-gcwith and without the new flag.pnpm run check: 32 of 33 checks pass.//:cargo_lock_testfails on my machine because it can't runrustcthrough a local wrapper (cask-rustc, "No such file or directory"). This change doesn't touch Rust or Cargo files.pnpm run test:e2e: not run. The change only affects the dev scripts, and the e2e config sets its own flags.I did not check Linux.
Risks and follow-ups
per-isolate bootstrap compile cache failed its compatibility checkat startup. That happens with any non-default V8 flag, including--expose-gcalone onmain, so this change doesn't add it. It shows only at startup, not on each navigation.new Worker()) still stay in memory until the client disconnects. That needs its own fix.Checklist
Signed-off-byline (git commit -s); see CONTRIBUTING.md.beep-boop-🤖