Repository navigation
feat(producer): log a chunk's capture worker sizing - #9119
Conversation
A distributed chunk now logs one line after capture: how many browsers it ran, what bounded the machine-wide sizing, and the wall time per frame. No change to how a chunk is sized or captured. Signed: Rames Jusso Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Edit accuracy: accurate 275 (base branch 273), smooth 56 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
miguel-heygen
left a comment
There was a problem hiding this comment.
Review at 69a5a25. I read the diff and the engine's sizing functions. I ran the producer type check and the render chunk tests on this head merged with current main, and read the new line from real chunk renders.
Strengths
- Worker count unchanged:
calculateOptimalWorkersis defined ascomputeWorkerSizing(...).workers(packages/engine/src/services/parallelCoordinator.ts:459-465). So callingcomputeWorkerSizingonce atrenderChunk.ts:801and passing.workerson picks the same count, with the same inputs. - Pure helper: the line's fields come from
chunkCaptureSizingLog(renderChunk.ts:253), which the tests pin field by field. That covers the rounding of the time per frame and thenulls for a chunk with no frames and for no budget. - Same count as the sidecar: the line is written after the perf sidecar (
renderChunk.ts:1237) and uses the samechunkWorkerCountthe sidecar and the chunk result report (:1228,:1274). Logs and sidecar can't disagree.
Checked
- Merge with
main: this branch is behindmainby the box-measuring change in the same file (#9127). The merge is clean, and on the merged treetsc --noEmitfor the producer exits 0. - Tests on the merged tree: all pass.
renderChunk.test.ts40 of 40.renderChunkFallback17,renderChunkFrameRangeandrenderChunkVideoMetadata13.renderChunk.verifyInWorkerandrenderChunk.stall9.
- The line on real renders: the real chunk renders in
renderChunk.test.tsprint it 25 times, in both screenshot and beginframe mode, for example:[INFO] [renderChunk] capture sizing {"chunkIndex":1,"frames":36,"workers":1,"machineSizedWorkers":1,"boundBy":"too_few_frames",...,"captureStageMs":1631,"captureMsPerFrame":45.3}. The per-frame time agrees withcaptureStageMs / frames. - CI: every required check passes at this head; one is skipped.
Nits
- Planned count, not browsers run:
workersis the count the chunk asked for. If the first browser's memory sample caps the workers (parallelCoordinator.ts:1251-1259), fewer browsers run than the line says. The engine's own "capture workers capped to fit memory" warning covers that case, so this is only wording: the body's "how many browsers it ran". - The hookup is unpinned: no test checks that
renderChunkemits the line, so deleting thelog.infoatrenderChunk.ts:1238leaves the suite green. The helper is pinned, the call is not. - Success path only: a chunk whose capture throws logs nothing, though that may be exactly when the sizing is wanted. Fine as is if that's deliberate.
Not checked: a multi-worker chunk. Every chunk the tests render is small enough to size to one worker.
Verdict: APPROVE
Reasoning: Log only, as described. The worker count goes through the same function as before, and the line appears with correct values on real chunk renders, including on the tree merged with current main. Required CI is green at this head.
What
A distributed chunk logs one line after capture,
[renderChunk] capture sizing: how many browsers it ran, what bounded the machine-wide sizing, and the wall time per frame.Why
An in-process render already reports why it ran N capture workers. A chunk wrote the worker count only to its perf sidecar file and did not say what bounded it, so from logs alone one could not tell whether a slow chunk was short of CPU, memory or frames.
Related work
None open. Independent of #9116.
How
renderChunkcallscomputeWorkerSizingwhere it calledcalculateOptimalWorkers; the second is defined as the first's.workers, so the worker count is unchanged. The line's fields come from a small pure function,chunkCaptureSizingLog:chunkIndex,frames,workers,machineSizedWorkers,boundBy,cpuBasedWorkers,memoryBasedWorkers,frameBasedWorkers,maxCaptureWorkers,captureMode,captureStageMs,captureMsPerFrame.Log only: no change to how a chunk is sized, captured or encoded, and no change to the perf sidecar or the chunk result.
Test plan
packages/producer/src/services/distributed/renderChunk.test.ts(40 passed): the line's fields for a sized chunk, and no per-frame time for a chunk that encoded no frame.tsc --noEmitfor producer,oxlint,oxfmtand the comment checks pass. Not tested: the line as emitted by a full chunk render.Signed: Rames Jusso
🤖 Generated with Claude Code