Repository navigation
bench: run each section in its own process (#231) - #310
Merged
Merged
Conversation
jsdom permanently retains memory on every string-path DOMPurify sanitize call, so in one process the bench's string-path fixtures table (~3.5 GB retained) carried into every later section and kept the job at a heap cliff. The bench is now a runner that spawns one child per section, sequentially, and collects each child's memory over IPC. - Each section prints a `memory [...]` line (rss / heapUsed / peak RSS). - The runner ends with a per-section summary (result, wall time, peak RSS) and names any section that failed; other sections still run. - `--section <name>` runs one section in-process; `--in-process` keeps the old single-process behaviour for comparison. - Docs: ARCHITECTURE bench section, a jsdom SSR note in SECURITY, and an updated ci.yml comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F6vooHKVSXCabQW89yiiDs
jonathanKingston
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review of 08991632: no blocking findings. Two small robustness nits in the runner.
runSectionInChildresolves on the child's'exit'. Node can emit'exit'before the last IPC'message'has been delivered, so a section's memory can occasionally show as—in the summary. Resolving on'close'(which waits for stdio and IPC to close) avoids that.- There's no
'error'listener on the child. If the spawn itself fails, the promise may never settle and the runner hangs rather than naming the section. Resolving with a failed result on'error'would fix it. - Small: the comment "Exit code 134 is a V8 heap OOM (SIGABRT)" doesn't match what the summary shows. An abort reaches the parent as
signal: SIGABRTwithcode: null, which the table already reports askilled SIGABRT.
Checked: with git diff -w, the section bodies are unchanged apart from being wrapped in functions. Loading jsdom and the library lazily keeps the runner process free of jsdom. parseArgs handles the value-less --in-process without swallowing the next flag. forwardedArgs strips the runner-only flags, and NODE_OPTIONS (the per-section heap cap) is inherited.
Generated by Claude Code
jonathanKingston
marked this pull request as ready for review
November 26, 2026 10:27
Resolve on 'close' so the last IPC memory message is always delivered, record a failed spawn as a failed section instead of hanging, and correct the comment: an OOM abort shows as 'killed SIGABRT', not exit 134. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F6vooHKVSXCabQW89yiiDs
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.
Addresses durable fixes 1, 2 and 4 from #231. Item 3 (filing upstream against jsdom) is left for a person to do.
Problem
jsdom permanently retains memory on every string-path DOMPurify
sanitizecall. The bench ran every section in one process, so the retention from the string-pathfixturestable carried into every later section and the job sat close to its heap cap.Change
scripts/bench-streaming.mtsis now a runner. It spawns one child process per section (fixtures,scaling,footnote-scaling,incremental-scan,code-block,real-document,work-shape), one after another so timings don't contend. Each child gets a fresh jsdom and sends its memory back over IPC.memory [name]: rss / heapUsed / peak rss.bench failed in section(s): …), the other sections still run, and the job exits 1.--section <name>runs one section in-process.--in-processkeeps the old single-process behaviour.git diff -wshows the real diff (+247/−24).sanitizeIntoDOM path or recycle workers), and an updated ci.yml comment. The 12288 MB cap stays and now applies to each section.Measured locally (node 22, jsdom 31)
With
--in-process, the heap climbs from 3.5 GB afterfixturesto 4.4 GB by the end, and every section runs on top of whatfixturesleft behind.real-document, the section that OOM'd in #229, now peaks at about 290 MB. Total wall time went from about 63 s to 69 s, mostly spent starting the child processes.To check the failure path, I ran with
NODE_OPTIONS=--max-old-space-size=300. Onlyfixturesdied (SIGABRT), the other six sections passed, the summary namedfixtures, and the exit code was 1.Follow-up (not in this PR)
fixturesis now the only section that needs gigabytes. Running each of its four fixtures in its own child would cut that further if it matters.Generated by Claude Code