Skip to content

engine: run pnpm run dev with --no-flush-liftoff-code - #265

Open
ruifigueira wants to merge 1 commit into
mainfrom
rfigueira/dev-no-flush-liftoff
Open

ruifigueira wants to merge 1 commit into
mainfrom
rfigueira/dev-no-flush-liftoff

Conversation

@ruifigueira

Copy link
Copy Markdown
Collaborator

Summary

pnpm run dev now starts workerd with --no-flush-liftoff-code as 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_FLAGS yourself, your value still replaces the default.

Implementation

  • packages/engine/package.json: the dev, dev:wpt and dev:memprof scripts default MINIFLARE_WORKERD_V8_FLAGS to --expose-gc --no-flush-liftoff-code.
  • README.md: explains the new flag, and says to include both flags when you override the default or start wrangler dev directly.

Validation

I ran the engine with pnpm run dev on macOS arm64 (workerd 1.20261123.1) and navigated one tab to the same small page 50 or 60 times over one CDP connection.

Before After
Executable (JIT) code after 50 navigations 651 MB 16 MB
Process footprint (footprint) after 50 navigations 675 MB 265 MB
Mean time per navigation, after the first 5 (2 runs of 60) 127.0 ms, 127.7 ms 72.4 ms, 76.1 ms

The 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-gc with and without the new flag.

  • pnpm run check: 32 of 33 checks pass. //:cargo_lock_test fails on my machine because it can't run rustc through 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

  • workerd logs per-isolate bootstrap compile cache failed its compatibility check at startup. That happens with any non-default V8 flag, including --expose-gc alone on main, so this change doesn't add it. It shows only at startup, not on each navigation.
  • Retired page isolates stay alive until the CDP connection closes #165 follow-up: page isolates are now released before the connection closes. Dedicated workers (new Worker()) still stay in memory until the client disconnects. That needs its own fix.

Checklist

  • This pull request solves one problem; see CONTRIBUTING.md.
  • Every commit has a Signed-off-by line (git commit -s); see CONTRIBUTING.md.
  • Added or updated focused tests for behavior changes. (Doesn't apply: dev script flag only.)
  • Updated documentation and generated files, or confirmed they do not apply.

beep-boop-🤖

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>
@github-actions github-actions Bot added the vouch:trusted Author is vouched, a collaborator, or a bot. label Nov 28, 2026
@BernardoPe BernardoPe assigned BernardoPe and unassigned BernardoPe Nov 28, 2026
@BernardoPe BernardoPe assigned BernardoPe and unassigned BernardoPe Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted Author is vouched, a collaborator, or a bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants