perf: keep none of the CLI's target output #1239
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 579 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.381
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1239"
general
weight: 0.35
avivkeller
<!--
Please read the Code of Conduct and the Contributing Guidelines before opening a pull request.
-->
Description
This PR lets
runGeneratorskeep none of the requested generators' output. It's the third part of a stack that splits #1205.generateandpreviewcollected every target's output into the arraysrunGeneratorsreturns, though neither reads them. WithdiscardResults: truein the configuration it drains them instead: each generator still runs to its end, and once nothing else reads its output, its chunks go as they're produced. Both commands now set it, anddocs/configuration.mdlists it next tothreadsandchunkSize.Why it's built this way
Why keep nothing? The targets write their own files, but collecting still costs memory:
consumegathers a streamed target into one array, and every target's result sits in the returned array until the last target ends. In the site build that'sjson's 70 documents (15 MB as written files), plusorama-db's database,llms-txt's text andsection-pages' entries. The payoff grows in later layers: from #1240 on,section-pagesstreams and yields every metadata entry, whichconsumewould hold until the run ends. It's off by default, so other callers get the same arrays as before.Why does
drainawaitendedinstead of reading the chunks? Since #1238 the tee runs its generator to the end by itself, whether anyone reads it or not. Sodrainonly has to count as one read and wait, and it never holds a chunk. Oncereleasecallsforget()and no other reader is left, nothing references a chunk after it's produced, and a failure still reachesrunGeneratorsbecauseendedrejects with it. Onshare()(15ca206) the generator only moved when a reader pulled it, sodrainhad to pull every chunk itself.share()also kept every chunk it handed out until its last reader ended, sodrainread the raw generator when it was the only read, and kept them all whenever another generator read the same target. On the real cache, one reader over 40 chunks of 4 MB peaked at 1 chunk (4 MB) live with the tee and 40 chunks (153 MB) withshare().Why is
teeOfcalled beforerelease? Whendrainis the last read,releaseforgets the tee and deletes it, so callingteeOffirst means the tee that gets forgotten is the one already running. In the other order,teeOfwould start a second tee after eviction. If nothing else read the target, nothing would ever forget it and it would keep every chunk; if others were already reading, the two tees would split the generator's chunks between them.Benchmarks
Full Node.js docs on Node 26, compared with #1238 (the layer below). Medians of 5 interleaved runs (4 at 6 threads), peak is RSS summed over the process tree. Site is
-t orama-db -t json -t llms-txt -t section-pages, legacy is-t legacy-html-all -t legacy-json-all.| Build | Threads | #1238 | This PR | Time | Memory |
| --- | --- | --- | --- | --- | --- |
| site | 4 | 9.26 s, 1749 MB | 9.37 s, 1686 MB | +1% | -4% |
| site | 6 | 8.39 s, 2304 MB | 8.27 s, 2306 MB | -1% | +0% |
| legacy | 4 | 4.40 s, 1578 MB | 4.37 s, 1531 MB | -1% | -3% |
| legacy | 6 | 4.21 s, 2033 MB | 4.14 s, 1980 MB | -2% | -3% |
On its own this PR is flat, and the time changes are noise. Legacy's -3% is mostly #1238 measuring high (+3% and +4% against
main; this PR is +0% and +1%), and its per-run peaks overlap. The site build's -4% at 4 threads fits the results no longer being kept, but the per-run peaks barely separate (1682-1729 MB against 1728-1772 MB), and at 6 threads they overlap fully.Validation
Added tests for draining a result alongside its other readers, a non-streaming result and a generator that fails, for the chunks of a drained result being let go as they are produced, and for
runGeneratorsreturning no results withdiscardResults, and rejecting with a dependency's failure, leaving none unhandled, with or without it. Built on 12 of Node.js's API docs at 1 and 4 threads, the output is byte-identical tomain's.Related Issues
Refs: #1205
Check List
node --run testand all tests passed.node --run format:check&node --run lint.