Skip to content

fix(bench): resume-history compiles on the main thread so its control sees releases - #9086

Merged
kixelated merged 2 commits into
mainfrom
quest/m0/nightly/resume-history-control
Nov 18, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest/m0/nightly/resume-history-control

Conversation

@kixelated

@kixelated kixelated commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The Nightly browser smoke's resume-history control ("the control kept {"sessions":1,"transports":1,"broadcasts":8,"bytes":0} after concluding", runs 43601796176 and 44127032469) failed because of V8's concurrent optimizing compiler, not a leak in @moq/net.

A queued background optimization job (TurboFan or Maglev) holds persistent handles to the closure it compiles and that closure's context. Those are strong GC roots. On a cold page, a hot closure that captured a route's session keeps that route reachable until the job lands. drain returns once two consecutive collections count the same, so a job still queued across both rounds read as "kept".

Fix: the resume-history Chromium now runs with --no-concurrent-recompilation, so every optimizing compile finishes on the main thread and none spans a collect(). It also passes --concurrent-recompilation-delay=300, which does nothing while compiles are synchronous. If concurrent compiles ever come back, though, the delay makes the smoke fail on every cold run, not one night in six. That makes the smoke itself the deterministic regression test.

Deletes quest/m0/nightly/resume-history-control.md.

Evidence

  • In both failing runs, the throw happens during the warm-up measure() of the first page: right after the browser launch, before any warmed current. That's the only run on cold code. Both failed at the first 8-front case of a block, on ubuntu-24.04-arm. The earlier "36 local sweeps" included only about 3 cold first-page runs, which is why they never reproduced it. The run artifacts carry only the other fixtures' JSON, so the evidence was the log line.
  • Last 12 Nightlies: this control failed on 11-14 and 11-17 only.

Validation

All runs pinned to 4 cores (taskset -c 0-3, the arm runner's vCPU count), on a fresh Chromium per cold run.

  • Baseline: a cold-run driver (new browser, one measure()) passed 22 of 22 with the default flags. That's the rare flake.
  • Reproduced: with --concurrent-recompilation-delay=300, which only stretches background compile jobs, the cold run failed 4/4 (and 1/1 at 5000 ms) with the Nightly signature.
  • Retainer identified: at each point where drain stalled with a nonzero count, I ran recovery steps in order inside the page. Out of 164 stalls in 4 runs:
    • 152 survived two more async major gcs and a host task, then released right after %FinalizeOptimization() (which installs pending concurrent jobs).
    • 2 released on the next collection, once their job finished on its own.
    • 10 released only after 1 s of real time, once jobs that finalizing hadn't covered landed.
    • A heap snapshot taken at the stall found no surviving Connection, consistent with a transient VM root rather than a JS reference.
  • Fix, probe: the same delayed probe build with --no-concurrent-recompilation gave 0 stalls and 0 failures in 4 runs, finishing in about 14 s versus about 90 s.
  • Fix, real harness: bun micro.ts --bench resume-history --rounds 1 current=../.. aa=../.. with this PR's flags passed 3/3 (18 page runs, 6 cold).
  • Counterfactual: the same harness with only --no-concurrent-recompilation removed (delay kept) failed 3/3 with the control kept {"sessions":1,"transports":3,"broadcasts":8,"bytes":0} after concluding.
  • just check and quest check --base origin/main pass.

Choices made

  • Disabled concurrent recompilation for this one benchmark, rather than calling %FinalizeOptimization() in collect(). The intrinsic needs --allow-natives-syntax and an eval'd % call, and it missed 10 of 164 stalls. Disabling also avoids weakening the "two equal collections" rule with a retry.
  • serve_us/read_us now include main-thread compile time on cold code. Every variant runs under the same flags, so the A/A comparison still holds.

Caused by

  • moq-dev/moq#7514 - added the resume-history control and its Chromium launch, which counted reachability as exact while background compile jobs could still hold a route (found by check: Nightly browser smoke)

Impact

Public API: none. Wire: none. Benchmark harness and its docs only.

Follow-ups

None.

Models

Size: M
Implementer: Claude, claude-opus-5-5, high effort

(Written by Claude Opus 5.5 with high)

Review

Rewritten by quest review after each round.

  • Head: 3a07133

  • Base: origin/main at 7c803f0

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a1ef3f-fb90-7a40-be12-c694bc68eab4, round 1

  • Score: 9/10, No actionable defects were found in the narrowly scoped resume-history benchmark compilation change, though runtime verification was not performed as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 18, 2026 06:15
… sees releases

A queued background optimization job holds persistent handles to its closure
and context, which are strong GC roots. On a cold run, a hot closure that
captured the serving route kept that route reachable across drain's two
matching collections, so the control intermittently reported the route as
kept. Launch the resume-history Chromium with --no-concurrent-recompilation,
and add --concurrent-recompilation-delay=300, inert while compiles are
synchronous, so reverting the fix fails every cold run instead of some.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title The browser resume-history control releases its last route fix(bench): resume-history compiles on the main thread so its control sees releases Nov 18, 2026
@kixelated
kixelated marked this pull request as ready for review November 18, 2026 15:22
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef3f4779-f312-4d9a-9e27-195561e34b83
Commits

Reviewing files that changed from the base of the PR and between 7c803f0 and 3a07133.

Files selected for processing: 4

  • bench/README.md
  • bench/browser/micro.ts
  • js/net/bench/resume-history.ts
  • quest/m0/nightly/resume-history-control.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kixelated
kixelated enabled auto-merge November 18, 2026 15:22

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. It fixes the flake at its cause, where V8 background compile jobs hold strong roots, and the benchmark's own control stays exact. It does not paper over it with a retry or a loosened "two equal collections" rule.

Reviewed changes

Reviewed the full diff, covering the 4 changed files.

  • bench/browser/micro.ts: the resume-history Chromium launch now passes --no-concurrent-recompilation. It also passes --concurrent-recompilation-delay=300, which is inert today but makes any return to concurrent compiles fail every cold run.
  • bench/README.md and js/net/bench/resume-history.ts: docs and doc comment now explain why compilation stays on the main thread.
  • quest/m0/nightly/resume-history-control.md: the quest file is removed now that the cause is found.

Flags are scoped to this one benchmark and the other fixtures are unaffected. The PR's counterfactual run, which drops only --no-concurrent-recompilation, is a good regression check.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 05b32bd Nov 18, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m0/nightly/resume-history-control branch November 18, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant