perf: let worker.stream take chunks as they arrive #1237
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 282 lines diff across 3 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.338
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1237"
general
weight: 0.35
avivkeller
<!--
Please read the Code of Conduct and the Contributing Guidelines before opening a pull request.
-->
Description
This PR lets
worker.streamtake an async iterable of batches as well as an array, starting a batch's work while earlier ones still run. It's the first part of a stack that splits #1205, which lets generators start on their dependency's first chunk instead of waiting for all of it.CHUNKS_PER_THREAD, 3), whether its input is an array or streamed, so generators running at once share the worker pool instead of one filling it. It reads the next batch once there's room for its chunks, and yields results in the order the chunks were submitted.stricterFIFO. By default it puts a task it can't hand out yet at the back of its queue, so early heavy tasks like module pages ran last.enqueuestarts a batch's chunks, waiting while the limit is reached, and the consumer waits on an inlinePromise.withResolvers()as chunks start. An array is read as[items], so its first chunks start right away.Nothing passes
worker.streama stream yet. With one thread nothing changes, and with more, an array's chunks now start a few per thread at a time instead of all at once, with the same output.Validation
Added tests in
parallel.test.mjsfor the streamed input: the limit on chunks in flight and its refill, the order tasks start in, a failure reading the batches arriving after the chunks before it, a single thread running each batch as it arrives, and no batches. 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.