Skip to content

fix(moq-net): whether drops cover a span is one lookup, not a walk of every run - #9020

Merged
kixelated merged 2 commits into
mainfrom
fix/net-dropped-cover
Nov 17, 2026
Merged

kixelated merged 2 commits into
mainfrom
fix/net-dropped-cover

Conversation

@kixelated

@kixelated kixelated commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The nightly "Rust bench targets" job has timed out at 55 minutes since 11-15 (run 43909101837, and again today in run 44127032469). moq-net/publisher stops printing at publisher_covered_before_start/wake/8192, and the harness kills it after 600 silent seconds on each side of the pair. That is 20 of the 55 minutes. This is too much work, not a hang: building the fixture's 8192 drops took about 17 minutes locally.

TrackState::containing asks holes_cover(0..time + 1) when no held group starts at or before time. holes_cover walks every drop run in the span, so each call costs O(drops). A window resolves every unresolved range on each step, so the cost grows as ranges × drops on every step, and as roughly drops³ across the fixture. A relay hits the same cost when a subscription holds many ranges while its upstream gives up many separately-reasoned runs.

Approach

TrackState keeps dropped, a coalesced RangeSet of every key in drops regardless of reason. change_drops is the only place that writes drops, and it updates both. "Drops cover this span" is now one lookup. never_produced asks the same question for skips only. Equal skip runs already coalesce in the RangeMap, so that is one get_key_value. The old walk (holes_cover) is gone.

RUN_OVERHEAD now also bills the coalesced run, at most one per drops run, so the pool still bounds what a peer fragmenting its drops can make the track hold.

Impact

  • No public API or wire change.
  • A track bills size_of::<Range<u64>>() × 2 more pool bytes per drop run.

Validation

  • publisher bench (cargo bench -p moq-net --features fuzz --bench publisher), locally:
    • before: the whole bench did not finish; wake/8192 alone took 17m42s (wall time).
    • after: the whole bench took 42 s (wall time). Per-wake times are unchanged at about 39 ns from wake/1 through wake/8192.
  • Profile before the fix: 88% of cycles were in <TrackState as Holdings>::containing, all of it in the drop walk.
  • Second check: a new proptest, dropped_cover_matches_a_walk_of_the_drops, applies random drops (two errors), skips, and forgets. After each one it checks that dropped equals the union of drops, and that both lookups agree with the old walk on random spans.
  • cargo test -p moq-net --all-features passes. just check passes.

Caused by

  • moq-dev/moq#8638: made containing answer the no-group-held case with holes_cover(0..time + 1), a walk of every drop run below time. That turned each time-anchor resolution into an O(drops) call (found by check: the nightly bench's 600 s silence guard).

Alternatives

  • Caching the covered prefix from 0 only. This fixes containing but not containing_received, which asks about spans starting past a held group.
  • Shrinking the bench's SKIPPED sweep. This hides the cost a relay pays.

Follow-ups

None.

Models

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

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 6eed4f4

  • Base: origin/main at 2dcb5f8

  • 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: 01a1eadb-10d4-7911-a362-a4bc3a36f130, round 1

  • Score: 9/10, Source inspection found no actionable defects: the coalesced index stays synchronized, preserves coverage behavior, and accounts for memory overhead, though tests were not run as instructed.

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

  • Findings: none

kixelated and others added 2 commits November 17, 2026 09:43
… every run

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

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)
Reviewed commit: 6eed4f45f5ed538129fe508383af68634f43bf51

No blocker found. The coalesced index removes the reason-by-reason walk without changing the reason map. Recreated groups, stale reversal, expiry, and pool shedding all update the index through change_drops. Billing one extra range per reasoned run is conservative because the union can never have more runs than the reason map.

The differential proptest checks both lookups against the old walk. Static review; I did not rerun tests or independently measure the benchmark speedup.

@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. It keeps a coalesced RangeSet next to drops and updates it in the one function that writes drops. That turns the O(drops) coverage walk into a single lookup and fixes the cause of the bench timeout without trimming the bench.

Reviewed changes

I reviewed the full diff to rs/moq-net/src/model/track.rs.

  • TrackState::dropped: a coalesced union of every drops key, written only in change_drops. A grep confirms change_drops holds the only insert/remove on TrackState::drops; the drops in resume.rs belongs to a different struct.
  • dropped_cover replaces holes_cover: containing and containing_received now do one RangeSet::get on the span start.
  • never_produced: one get_key_value lookup. This is correct because equal Hole::Skip runs always coalesce in the RangeMap, so a skip-only cover is always a single run.
  • RUN_OVERHEAD: now also bills one Range<u64> per drops run. That bounds dropped, which never has more runs than drops.
  • Proptest: checks after every drop, skip, and forget that dropped equals the union of drops, and that both lookups agree with the old walk.

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

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

TrackState now maintains a coalesced index of ranges covered by drops and includes its range entries in RUN_OVERHEAD accounting. Coverage checks use the index, while never_produced checks whether a Skip run at the requested start covers the range. A property test compares the index and these checks with run-based results across drop, skip, and forget operations.

Merge Risk: Minimal · up to 6eed4

This change speeds up drop-coverage checks in the track model and removes a cubic-work pattern. It has no public API or wire change. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: whether drops cover a span becomes one RangeSet lookup instead of a walk over every drop run. The raw summary confirms the coalesced dropped index replaces the drop-ru…
Description check Passed The description is detailed and on-topic. It explains the nightly benchmark timeout, the root cause in TrackState::containing and holes_cover, the coalesced dropped RangeSet approach, RUN_OVERHEAD acc…
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: whether drops cover a span becomes one RangeSet lookup instead of a walk over every drop run. The raw summary confirms the coalesced dropped index replaces the drop-run walk in coverage checks and skip runs. The title is specific to the core fix, though it is a bit long at 79 characters.

Full details: Description check

Explanation

The description is detailed and on-topic. It explains the nightly benchmark timeout, the root cause in TrackState::containing and holes_cover, the coalesced dropped RangeSet approach, RUN_OVERHEAD accounting, validation timings, the new proptest, and the regression source PR. It matches the changeset in raw_summary and objectives.

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: a114b097-9339-4f16-ae9a-c893e2f1c580
Commits

Reviewing files that changed from the base of the PR and between 2dcb5f8 and 6eed4f4.

Files selected for processing: 1

  • rs/moq-net/src/model/track.rs

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

@kixelated
kixelated added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit d99aada Nov 17, 2026
7 checks passed
@kixelated
kixelated deleted the fix/net-dropped-cover branch November 17, 2026 20:31
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