Skip to content

feat(producer): log a chunk's capture worker sizing - #9119

Merged
jrusso1020 merged 1 commit into
mainfrom
chunk-capture-sizing-log
Nov 30, 2026
Merged

jrusso1020 merged 1 commit into
mainfrom
chunk-capture-sizing-log

Conversation

@jrusso1020

Copy link
Copy Markdown
Collaborator

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

renderChunk calls computeWorkerSizing where it called calculateOptimalWorkers; 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

  • Unit tests added/updated
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

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 --noEmit for producer, oxlint, oxfmt and the comment checks pass. Not tested: the line as emitted by a full chunk render.

Signed: Rames Jusso

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 275 (base branch 273), smooth 56 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Quarantined, measured but not gated (0)

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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: calculateOptimalWorkers is defined as computeWorkerSizing(...).workers (packages/engine/src/services/parallelCoordinator.ts:459-465). So calling computeWorkerSizing once at renderChunk.ts:801 and passing .workers on 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 the nulls 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 same chunkWorkerCount the sidecar and the chunk result report (:1228, :1274). Logs and sidecar can't disagree.

Checked

  • Merge with main: this branch is behind main by the box-measuring change in the same file (#9127). The merge is clean, and on the merged tree tsc --noEmit for the producer exits 0.
  • Tests on the merged tree: all pass.
    • renderChunk.test.ts 40 of 40.
    • renderChunkFallback 17, renderChunkFrameRange and renderChunkVideoMetadata 13.
    • renderChunk.verifyInWorker and renderChunk.stall 9.
  • The line on real renders: the real chunk renders in renderChunk.test.ts print 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 with captureStageMs / frames.
  • CI: every required check passes at this head; one is skipped.

Nits

  • Planned count, not browsers run: workers is 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 renderChunk emits the line, so deleting the log.info at renderChunk.ts:1238 leaves 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.

@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 245dc80 Nov 30, 2026
100 checks passed
@jrusso1020
jrusso1020 deleted the chunk-capture-sizing-log branch November 30, 2026 06:21
@miguel-heygen miguel-heygen mentioned this pull request Nov 30, 2026
4 of 5 tasks
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