Skip to content

fix(bench): export benches freeze the clock between setup and the timed drain - #9089

Open
kixelated wants to merge 1 commit into
mainfrom
fix/bench-export-paused-clock
Open

kixelated wants to merge 1 commit into
mainfrom
fix/bench-export-paused-clock

Conversation

@kixelated

@kixelated kixelated commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Every scheduled CodSpeed (mux) run since 2026-11-15 panics in container-export/flv/1x16: assert_eq!(chunks, 1 + tracks * frames), left 1, right 17. The export emits only its header.

The bench writes a finished broadcast (16 frames, 20 ms apart, one group) in setup, then drains a live-edge export (max delay zero) in the timed routine. Since moq-dev/moq#8638, moq-net ages a finished track's last group from its arrival plus its span (TrackState::ended_at in rs/moq-net/src/model/track.rs). Once the clock passes that, a zero-budget subscription is served nothing. CodSpeed's simulation is slow enough that more than the 300 ms span passes between setup and drain, so the only group is stale before the export reads it.

This is the documented, maintainer-accepted behavior from #8638 ("a finished or paused track's last group expires without a successor, but not before that end"), not a moq-mux consumer bug: with a 400 ms gap the container consumer never receives a group from the subscription.

Approach

The export and video-reorder benches run on a paused tokio runtime, so the clock stands still between setup and the timed drain and the result no longer depends on how fast the host is. This follows benches/catalog.rs and benches/jitter.rs. The idle-poll bench is unchanged: its track is live, so nothing ages.

Validation

  • Reproduced on the simulated clock first: an FLV export of a finished 16-frame broadcast started 400 ms late returned 1 chunk (0 and 200 ms returned 17), and the consumer's subscription delivered no group, which led to moq-net's ended_at.
  • Delay experiment: with std::thread::sleep(400ms) before profiled_export, cargo bench -p moq-mux --bench export -- container-export/ --test passes all 27 cases on the paused runtime; with start_paused removed it panics at flv/1x16, left 1, right 17. The experiment is not committed.
  • cargo bench -p moq-mux --bench export -- --test: all 66 cases pass.
  • just check passes.

Caused by

  • moq-dev/moq#8638 - aged a finished track's last group out on the wall clock, which the export bench's setup-then-drain timing on a real clock did not survive on slow hosts (found by check)

Impact

None: bench-only. No public API or wire change.

Alternatives

  • Serve a finished track's last group forever (age only a paused track's): reverts part of feat(moq-net)!: address groups by their start #8638's accepted decision. See Waiting.
  • Export with a recording max delay in the bench: TS takes one delay as both min and max, so its jitter buffer would hold frames on the real clock.
  • Fix moq-mux's consumer or @moq/hang's: neither drops the group; the subscription never delivers it.

Waiting

  • Should a finished track's last group still age out for a live-edge (max delay zero) reader? feat(moq-net)!: address groups by their start #8638 ages both finished and paused tracks; a late moq export of a finished broadcast at the default delay gets nothing. Recommendation: keep it, since a live-edge reader asked for nothing older than the edge and a recorder asks for history with a max delay, as the FLV tests' RECORDING_MAX_DELAY does.

Follow-ups

  • Under CodSpeed the TS cases only asserted chunks > 0, which the PAT/PMT satisfy, so they likely measured a header-only export since 11-15 too. The paused clock fixes that; tightening the TS assertion is optional.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort

(Written by Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: bb48c96

  • Base: origin/main at 4f3ba33

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1efc1-00e0-7580-b57b-91d7b90f486d, round 1

  • Score: 9/10, The change narrowly prevents host delays from expiring benchmark fixtures without changing production behavior, and no actionable defect was found; builds and tests were not run.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

…ed drain

A finished track's last group ages out of a live-edge export once its span
passes on the clock (#8638), so a host as slow as CodSpeed's simulation
exported only the header and failed container-export/flv/1x16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 18, 2026 17:43

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Approach: sound. Pausing the tokio clock in the bench removes the host-speed dependence directly, and the bench is the right place to fix it because moq-net's aging behavior from #8638 is intended.

Reviewed changes

Reviewed the single commit touching rs/moq-mux/benches/export.rs.

  • paused() helper: builds a current-thread runtime with start_paused(true), so the clock stands still between setup and the timed drain.
  • bench_export and video_reorder: both use the helper instead of their own unpaused runtimes. This matches benches/catalog.rs and benches/jitter.rs.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

A new helper builds a current-thread Tokio runtime with all drivers enabled and the clock initially paused. bench_export and video_reorder now use this helper instead of constructing runtimes with an advancing clock.

Merge Risk: Minimal · up to bb48c

This change only affects benchmark runtime setup, so it keeps results from depending on host speed. It has no public API or wire impact, and there are no known merge-blocking risks.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the export and video-reorder benches now freeze the Tokio clock between setup and the timed drain. It matches the changeset, which adds a paused runtime helper to rs/m…
Description check Passed The description states the problem (CodSpeed export bench panics since 2026-11-15), the cause (moq-net aging a finished track's last group), and the fix (paused tokio runtime for the export and video-…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the export and video-reorder benches now freeze the Tokio clock between setup and the timed drain. It matches the changeset, which adds a paused runtime helper to rs/moq-mux/benches/export.rs. The title is long but specific.

Full details: Description check

Explanation

The description states the problem (CodSpeed export bench panics since 2026-11-15), the cause (moq-net aging a finished track's last group), and the fix (paused tokio runtime for the export and video-reorder benches). This directly relates to the changeset, which switches those benches to a paused runtime.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 721c10ae-b096-4949-8cfb-b6e639c426db
Commits

Reviewing files that changed from the base of the PR and between 4f3ba33 and bb48c96.

Files selected for processing: 1

  • rs/moq-mux/benches/export.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
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.

1 participant