Repository navigation
perf(moq-mux): a container export steps to the next group before scanning every pending one - #8865
Conversation
…ning every pending one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the change to the container consumer's read loop that lets the cursor move to a continuing group before it runs the O(pending) reap and scans.
- Early step to the next group — when the front pending group is past the cursor, is not
reapable, andpoll_continuesholds, the loop setscurrentto its start, callsnote_group_edge, and continues. It no longer reaps every pending group first. poll_continuesextracted — the existing "declared skipped or contiguous" rule now lives in one helper, and the hole path reuses it, so its decision is unchanged.GroupBuffer::reapableextracted — the reap predicate (aborted, nothing buffered, no fault) is now a method shared by the fast path's guard anddiscard.
I checked that the fast path makes the same choice the hole path made. Between the old reap and the old hole check, nothing else could change the front group. The current_end block only applies when front.start <= current, and the reap only removes groups that are reapable, which the fast path excludes for the front. So whenever the old code would have stepped, the new code steps too. Three things differ, and none affect what the reader sees:
- The early step skips
look_allon the front group, but the nextpoll_readreads those frames anyway. - It no longer logs the
skipping missing groupsdebug line for these steps. - Aborted groups further back are reaped later, once delivery blocks.
claude-opus-5-5 | 𝕏
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|

Problem
The scheduled Nightly's paired comparison (run 43724172821) confirmed
moq-mux/containersregressions between 4fec611 and 505a86f:annexb-export-*+68%,cmaf-export-*+47..54%, andmkv-payloads/payload-1024/*+30%.Bisecting the bench binaries puts both on moq-dev/moq#8638 (466f2f6 fast, 7d1bee7 slow). The export side is unintended: group starts are now timestamps, so after a group finishes,
current += 1no longer lands on the next group's start. Every group transition took the hole path, which first reaps aborts over every pending group (poll_finishedon each), then scans for the newest content, before the "declared skipped or contiguous" check stepped to the next group. With a queued backlog that is O(pending) per group, so O(groups²) per export. A profile of the 7d1bee7 export spent 12% under that reap alone.Approach
The container consumer checks whether the cursor can step to the next pending group (
poll_continues: the run between is declared skipped, or the group's first frame continues the content read) before the reap and the scans. A front group that is reapable (aborted, nothing buffered, no fault) still goes through the reap first, as before. The hole path reusespoll_continuesfor its own judgement, so the rule lives in one place.Validation
Bench binaries built at each commit, run alternately on one host (criterion, 1 s warmup, 2 s measurement), the quietest round:
annexb-export-frames/1tracks-64frames/4096annexb-export-queued-groups/64/1annexb-export-queued-groups/64/16cmaf-export-frames/4tracks-64frames/256origin/main(527e301) reads the same as 505a86f (319 µs onqueued-groups/64/1).The remaining ~+23% on these micro cases is spread across moq-net's subscriber, not the consumer: with sparse keys, the reader's
Deliveredrecord holds a gap between every pair of handed-out groups, soCursor::forget_past_budgetand the miss judge now run on each take (about 5% of the export profile). See Follow-ups.just checkpasses (moq-mux's 2121 tests included).Impact
Alternatives
currentstraight to the next pending group's start when a group finishes: wrong when a group between them is still in flight.Follow-ups
mkv-payloads/payload-1024(+30%) is not addressed here. It is the producer's cost of declaring skips: everyappend_grouprecords the span since the previous append as a Skip run (TrackState::appended->skip_groups->change_drops), about 0.9 µs per group, 13% of that import profile. feat(moq-net)!: address groups by their start #8638 chose declared skips on purpose; a cheaper representation (an append watermark rather than one run per gap) is a moq-net model change.Delivered, so an ordered sparse read leaves no gaps forforget_past_budgetto walk.Caused by
current += 1after a finished group, so every transition took the hole path's O(pending) reap and scans (found by check: the Nightly's paired bench comparison).Models
Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: a42c1ac
Base: origin/main at 39e1682
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1e079-f166-7cc3-b3a3-49d1275196dd, round 1Score: 9/10,
No actionable regressions were found; the fast path preserves existing continuity checks while avoiding unnecessary pending-group scans, though builds and tests were not run as instructed.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none