Repository navigation
perf(producer): size a chunk's capture browsers by its frame cost, not its frame count - #6319
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 2 nits · head 176d0e4b
- nit:
Comments(comment-ratchet) is red. The comment share rose inchunkWeights.ts(9/109 vs 7/90) andfreezePlan.ts(99/429 vs 98/427). The check is not required; trimming a doc line in each file fixes it. - nit: the body's Lambda section still reads "Table to follow". Please fill it in before merge so the cost claim has its numbers.
Scope
I read the full diff (7 files). Checks I made:
- Weights are floored at
PAGE_BASE_WEIGHT0.7, solightestis never 0 and the cost can't be NaN or Infinity, whichparseChunkSliceswould reject. - A
captureCostof 1.00 after rounding is left unstamped, which matches the parser's> 1check. - Older readers ignore the extra key, and plans without it size chunks as before.
- If cost inflates the worker count past the frame count,
distributeFramesdrops the empty ranges, andmaxCaptureWorkersstill caps the count.
chunkWeights.test.ts (20 tests) and resolveChunkCaptureWorkers (5 tests) pass locally. No prior reviews.
Contributor
Edit accuracy: accurate 271 (base branch 271), smooth 126 of thoseThe gate passes. Quarantined, measured but not gated (0) Unstable (3)
|
miguel-heygen
force-pushed
the
perf/chunk-workers-by-cost
branch
from
October 25, 2026 15:47
176d0e4 to
b8f493c
Compare
miguel-heygen
force-pushed
the
perf/chunk-workers-by-cost
branch
from
October 25, 2026 16:13
b8f493c to
6252086
Compare
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 25, 2026
…t its frame count
miguel-heygen
force-pushed
the
perf/chunk-workers-by-cost
branch
from
October 25, 2026 18:34
6252086 to
ab6c72b
Compare
This was referenced Oct 25, 2026
Merged
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.
What
A chunk's capture browser count now follows its estimated capture cost, not its raw frame count. Each chunk slice carries
captureCost(mean frame cost over the plan's cheapest frame, from the same weights the cost-weighted cut uses).effectiveChunkFramesturns frames into cost-scaled frames once, and bothcalculateOptimalWorkersandresolveChunkCaptureWorkersread that one number.Why
The cost-weighted cut (#6295) makes the chunks over a video-heavy stretch short, and worker sizing gives a browser per 20-30 raw frames. Chunks of 28-59 frames over the heavy stretch ran with 1-2 browsers while the other chunks ran 3, so the busiest frames were captured at a third of the throughput on a function billed for all of its memory. On the 4K Lambda fixture, per-chunk logs across 5 same-hour 0.8.197 vs 0.8.198 pairs:
The sum of chunk wall rose 556.7 s -> 576.9 s (+3.6%) while the slowest chunk fell 59 s -> 45 s.
How
ChunkSliceJson.captureCost(optional, absent when 1) is stamped bywithChunkCaptureCostinbuildPlanChunkSlices, so it applies to every plan cut, and read back byparseChunkSlices(validated finite and above 1).renderChunksizes workers fromeffectiveChunkFrames(framesInChunk, slice.captureCost).captureCost, so their sizing is unchanged.Test plan
resolveChunkCaptureWorkers: a 28-frame chunk at 3.6x cost gets 3 browsers (1 at its raw frame count); a light 75-frame chunk is unchanged.chunkWeights: a costly window's chunks are stamped, light chunks are not, and a short costly chunk is sized like the longer light chunks beside it.effectiveChunkFramesreturns the raw frame count. oxlint and oxfmt clean.renderChunkcall site itself; it is checked by the Lambda run below.Mean cost -4.3% (95% CI -8.5% to -0.2%), median $0.0748 -> $0.0732; median wall 43.6 -> 40.1 s (-8%). Cost never rose by more than the run-to-run spread of the stock side.
Limits
captureCostcomes from the video-pixel weights, so heavy page content without video is not counted (same limit as the cut).captureCost.Size
The producer package grows by 746 B packed (stock main 773,896 -> 774,642 by
npm pack), inside the budget's 1% tolerance on current main, soscripts/package-size-budgets.jsonis untouched.