Skip to content

Abort pending optimizing compiles before collecting kept boxes in tracing-test - #8621

Merged
danlapid merged 1 commit into
mainfrom
dlapid/tracing-test-external-memory
Nov 22, 2026
Merged

danlapid merged 1 commit into
mainfrom
dlapid/tracing-test-external-memory

Conversation

@danlapid

Copy link
Copy Markdown
Collaborator

tracing-test.c++ "wrappables are charged as external memory while they live" (added in #8496) fails now and then on edgeworker CI. It failed 5 times on 2026-11-18, in both the @ and @all-autogates variants, on release, RBE and ASan builds. The final check fails with nothing released: expected remaining < int64_t(sizeof(NumberBox)) * 16 [1120000 < 1792].

Cause: keepBoxes() builds its 10,000 boxes in a hot loop, which V8 may optimize on a background thread. If that compile job is still pending when the test drops keep and forces its two GCs, the job keeps every box alive.

Evidence:

  • With --concurrent-recompilation-delay=300, which keeps the job pending, the test failed 10 runs out of 10.
  • Both forced GCs ran (two major epilogues, kGCCallbackFlagForced), and neither released anything.
  • A heap snapshot taken after the failed check found no live NumberBox wrappers. Its CollectAllAvailableGarbage() aborts concurrent optimization first.
  • Building the array in a function-local instead of reading the keep global did not help: with the delay, it still failed 10 runs out of 10.

Fix: call v8::Isolate::ClearCachesForTesting() before the GCs. It aborts the pending Turbofan and Maglev jobs and waits for them. With the delay flag, the test then passed 10 runs out of 10.

Testing: run from edgeworker with --config=bazelflare:

  • --runs_per_test=20 on tracing-test@ and tracing-test@all-autogates: all pass.
  • --config=asan, both variants: pass.

🤖 Generated with Claude Code

"wrappables are charged as external memory while they live" builds
its boxes in a 10,000-iteration loop, which V8 may optimize on a
background thread. A compile job still pending when the test
collects them keeps every box alive, and the test sees nothing
released (1120000 bytes remaining). The job usually finishes first,
so this failed only now and then, on release, RBE and ASan builds.

With --concurrent-recompilation-delay=300, which keeps the job
pending, the test failed 10 runs out of 10. A heap snapshot taken
after the failed check found every box collectable: its GC aborts
concurrent optimization first.

Call v8::Isolate::ClearCachesForTesting() before the GCs. It aborts
the pending Turbofan and Maglev jobs and waits for them. With the
delay flag, the test then passed 10 runs out of 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@danlapid
danlapid marked this pull request as ready for review November 22, 2026 01:47
@danlapid
danlapid requested review from a team as code owners November 22, 2026 01:47

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — Small test-only change that fixes a flake. The description's evidence supports the cause and the fix, and I found no problems.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code reviewer: ✅ LGTM

No issues found.


Reviewed commit: bbeba9a8

@danlapid
danlapid enabled auto-merge November 22, 2026 02:00
@danlapid
danlapid merged commit 5ec8aa8 into main Nov 22, 2026
23 checks passed
@danlapid
danlapid deleted the dlapid/tracing-test-external-memory branch November 22, 2026 03:55
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.

2 participants