Skip to content

fix(net): filter owed drops below a join's start instead of rescanning history - #9783

Draft
kixelated wants to merge 9 commits into
mainfrom
quest/m0/nightly/audio-bursty-regression
Draft

kixelated wants to merge 9 commits into
mainfrom
quest/m0/nightly/audio-bursty-regression

Conversation

@kixelated

@kixelated kixelated commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/nightly/audio-bursty-regression.md and deletes it.

Problem

Nightly's bursty audio rows regressed on 11-25: about 3 s after the join, arrivals stopped for 300 to 800 ms, then landed together. On the runner, native-opus-48000-bursty failed target_ms_p95 and trimmed_ms_per_min on every run, and the chromium rows failed on about half.

Cause: since #9530, a join's SUBSCRIBE_START untells every run given up below its reach. It untells them on the subscription's record and on each of a front's copies. The native player then sends updates that widen its budget, and each one rescans the cache. The copies give every run up again, one poll step per run, and all of those steps run ahead of the next group. On a relay holding a minute of 20 ms timestamp-keyed audio, that came to about 5,000 drops after each widening. Most were stale groups; the rest were final timestamp gaps.

The runner bisect over 5d86f05321..main (3 runs per commit, bursty rows only) put the first bad commit at f031ffe (#9530). Reverting only #9530's publisher.rs change restored the rows. Reverting only its resume.rs change did not.

#9561 then raised audio groups from 20 ms to 100 ms, which cut the history fivefold. That hid the stall: the scheduled Nightly 46038678705 on main passed every bursty row.

Approach

Instead of holding untold runs in a shadow Record::unsent map and partially untelling copies, keep Record::reported truthful (only keys actually told to the wire) and bound drop scanning/reporting directly to the keys the wire owes:

  • Owed-drop filter (Subscriber::set_drop_owed in Rust, hooks.setDropOwed in JS): Once SUBSCRIBE_START resolves, TrackRun::sync_drop_owed (Rust) and syncDropOwed (JS) restrict DropCursor (and every copy of a front, including copies promoted from Pending to Ready and queued front drops in JS) to owed(start) (start.. plus any lite-07 explicit history ranges below it).
    • Read floors stay open so a budget widening still serves cached groups below start, while DropCursor::next and Cursor::write_off_stale only scan/emit drops within owed, eliminating the O(history) rescan and per-run drop flood on both plain and routed tracks.
    • TrackRun::resolve keeps the truthful untell of everything below reach, and lower_start / update simply widen drop_owed (which bumps drop_owed_rev and triggers a rescan over the newly owed span).
  • Direct reaching-drop lookup (Subscriber::reaching_drops in Rust, hooks.reachingDrops in JS): When a budget widening serves (or sheds) a cached group below start, name_reaching queries the contiguous final drops immediately below key directly from the track or serving copy (clipped above any still-feeding replaced copies, and stopping at retryable route failures such as UNROUTABLE on a front, even after state.drops reclaims them) against the logical wire record. No shadow unsent runs are kept or billed, and a debt fold on the logical record cannot erase the reaching verdict. In JS, a failed or throwing reaching-drop write closes the popped group and clears streaming.
  • Debt-safe forgetting for drop readers (Record::fold, Beside::forget_untold, DropCursor::next):
    • On a drop-tracking reader (Standing::drops), Record::fold clears non-empty skipped / written_off and calls Beside::forget_untold(floor, &reported, &pending, self.rescan) before removing received: true entries from pending, without scanning reported or pending as a whole. Misses::forget_untold removes untold given_up verdicts without touching judged, at, or rescan (avoiding per-poll fill churn under sustained debt), keeps queued upstream skips across rescans, and records an O(1) bounding span forgotten_debt with forgotten_narrowest (the minimum budget across all forgotten verdicts) reopened when set_drop_owed widens, set_range lowers the floor, or any range in forgotten_debt widens past forgotten_narrowest.
    • final_end under Fold::Debt for drop readers settles only reported and delivered (guarded by reader.handed), mirrored in rs/moq-net/verify/subscribe/SubscribeAccounting.tla (PubFold).
    • Misses::adopt_drops preserves upstream Hole::Skip in misses.skipped and non-NotFound upstream errors (such as UNROUTABLE or EVICTED) in misses.adopted_errors, so both fold_given_up and final_below reconstruct the exact Hole if TrackState::shed_drops evicts a drop before reporting or reaching-drop lookup, while skipping adopted stale verdicts (which DropCursor::next reads directly from state.drops, preserving supersede_stale).
    • When DropCursor is first created after an ordered read already advanced next_key, it seeds record.pending from misses.fold_given_up clipped to drop_owed and judged per span via budget.runs(part) against the current clamped budget before probe clips misses.
  • JS mirror: js/net mirrors the exact same owed-drop filter (setDropOwed), direct reaching-drop lookup (reachingDrops stopping at routeFailed), truthful WireRecord.untell, and lite-06 update floor alignment (lowering delivery to group 0 only when an update drops an explicit floor).
  • Lite-07 finality (fix(net): name history stale under the track's freshness bound below a resolved start #9791): reversible (Rust and JS) and final_bound treat stale verdicts judged under the track's own freshness bound (or an upstream's unbounded verdict) as final.

Impact

  • Public API: none.
  • Wire: no format change. A lite-05/06/07 publisher sends fewer SUBSCRIBE_DROPs below a subscription's start:
    • no final gap below a stale group, until a group above it is served or the start is lowered;
    • no stale verdict below the start.

Alternatives

  • Revert fix(net): a join names no gap below a group its budget skipped #9530: brings back naming every gap in the history at SUBSCRIBE_START, which fix(net): a join names no gap below a group its budget skipped #9530 removed on purpose.
  • Hold untold drops in Record::unsent with partial untell hooks (untell_stale, untell_misses, untell_copies): earlier rounds tried this, which billed O(history) runs per live subscriber, left DropCursor scanning 0..u64::MAX, and broke under cache pool debt folds (Codex Round 3 findings). Replaced by the owed-drop filter + direct reaching-drop lookup above.
  • Batch the re-yielded drops into one step: keeps the O(history) rescan and wire bytes on every widening.

Caused by

  • moq-dev/moq#9530: it untold runs below the start on the copies as well as the subscription's record. Each budget-widening update then gave the whole cached history up again ahead of every group (found by check: Nightly Audio quality).

Validation

GitHub-hosted ubuntu-24.04-arm (Nightly's runner class), just test audio-quality --profiles bursty --codecs opus --capture, 3 runs each. Budgets: target_ms_p95 at most 350, trimmed_ms_per_min at most 110.

commit groups native-opus-bursty target p95 (ms) trimmed ms/min chromium-opus-bursty
3717c89 (before #9530) 20 ms 232 / 252 / 232 0 pass
f031ffe (#9530) 20 ms 752 / 832 / 812 563 to 677 pass
f031ffe + this fix 20 ms 252 / 252 / 232 0 pass
main + 20 ms groups 20 ms 852 / 972 / 1032 669 to 871 pass
main + 20 ms groups + this fix 20 ms 672 / 732 / 212 482 / 516 / 0 pass
main 414b0bc 100 ms 192 to 212 0 pass
5b02475 (this fix, before merging main) 100 ms 212 / 192 / 192 0 202
  • On f031, this fix restores pre-fix(net): a join names no gap below a group its budget skipped #9530 numbers. main with 20 ms groups still has a separate stall from a later change (see Follow-ups).
  • Instrumented relay logs from the runner:
    • Before this fix, each widening update was followed by a burst of about 2,500 to 5,000 drops.
    • With the fix, those bursts are gone, as in 3717c89.
    • The pre-start skipped collection is the same in both, at about 4,500 drops.
  • Nightly's full Audio quality steps on 5b02475 and 0565d2e: all 14 chromium rows and all 14 native rows within budget (--enforce).
  • Regression tests on 074a8e0abe:
    • a_join_names_no_gap_past_a_skipped_group (Rust and JS): asserts a budget widening takes steps == reaching.len() on both plain and routed tracks, names only the reaching drops, and a lowered start on a front matches a plain track.
    • a_debt_reopens_unreported_verdicts_for_a_drop_reader (rs/moq-net/src/model/record.rs): verifies Record::fold on a drop reader forgets unreported skips/misses without settling them or setting rescan.
    • a_lowered_start_still_names_gaps_after_debt_fold (rs/moq-net/src/lite/publisher.rs): verifies sustained debt causes zero fill churn below start, and a later lowered start still names every gap below start, even when TrackState::shed_drops sheds drops mid-drain.
    • a_widened_budget_still_names_reaching_drop_after_debt_fold (rs/moq-net/src/lite/publisher.rs): verifies widening the budget on a front after logical-record debt still names every reaching drop from the serving copy.
    • a_widened_budget_stops_reaching_drops_at_retryable_route_error (rs/moq-net/src/lite/publisher.rs): verifies UNROUTABLE below a served group is not forwarded as final and stops the contiguous reaching-drop walk, both cached and after state.drops reclaims it.
    • a_shed_adopted_skip_is_reconstructed_as_skip (rs/moq-net/src/model/track.rs): verifies an adopted upstream Hole::Skip shed from state.drops before reporting is reconstructed as Hole::Skip, with and without repeated reader debt folds while queued.
    • a_widening_before_first_drop_poll_does_not_seed_narrow_stale (rs/moq-net/src/model/track.rs): verifies widening before the first poll_drop does not seed an obsolete narrow stale verdict.
    • a_widening_past_a_narrower_forgotten_debt_verdict_rejudges_it (rs/moq-net/src/model/track.rs): verifies forgetting a wider miss then a narrower miss tracks the narrower budget so a later widening past it re-judges the span.
    • a_multi_range_seed_judges_each_span_against_its_own_budget (rs/moq-net/src/model/track.rs): verifies first poll_drop seeding on a multi-range subscription judges each stale segment against its own range budget.
    • a_stale_run_untold_below_the_start_asks_a_fill_once_widened (rs/moq-net/src/model/track.rs): verifies both plain and routed tracks re-ask fills for stale runs untold below start once widened.
  • Model checks (verify-subscribe) on 0fd0f8d60f / 2b95d9bd50 (invariant unchanged on 074a8e0abe):
    • CutGroupEnd.cfg: 97,737 states, 28,943 distinct states, 0 errors.
    • PlainReset.cfg: 149,959,121 states, 32,168,466 distinct states, 0 errors.
    • SubscribeAccounting.cfg: 550,396,373 states, 78,579,506 distinct states, 0 errors.
  • Local checks on 074a8e0abe:
    • cargo fmt --check: passed.
    • just check: all checks passed (check rs, test rs 11,836 passed / 0 failed, check rs_cross, check biome, check js across all 26 packages, test js including 4,012 js/net tests, check dead_code, check audio_quality, check carla_bridge, check coverage_tables, doc/script/quest checks).
    • just test interop --all: all checks passed.

Decisions

  • Leave the 20 ms residual to a follow-up. main with 20 ms audio groups plus this fix still fails native-opus-bursty in 2 of 3 runs. f031 plus this fix passes, so the residual comes from a later change, which the 100 ms groups from feat(audio): audio groups span 100 ms by default #9561 hide.
    • Chose: land this fix and track the residual as a follow-up, since Nightly publishes 100 ms groups and passes.
    • Rejected: bisecting f031..main at 20 ms in this PR (open-ended scope); dropping it untracked.
  • Align the JS lite-06 update floor with Rust. JS lowered delivery to group 0 on any lite-06 update that named no start. That would have untold every held run on each update, recreating the flood.
    • Chose: match Rust and lower only when the update drops a floor.
    • Rejected: keeping the divergence.
  • Replace Record::unsent with set_drop_owed + reaching_drops instead of accepting Round 3's debt-fold findings. Keeping Record::reported truthful and filtering drops to the owed set removes the shadow map, fixes both Round 3 findings by construction, and eliminates the O(history) widening work on plain tracks as well as fronts.
    • Chose: replace Record::unsent with the owed-drop filter and direct reaching-drop lookup.
    • Rejected: accepting Round 3's two debt-fold findings as follow-ups.

Follow-ups

  • Bisect f031..main with 20 ms audio groups for the remaining startup stall on native-opus-bursty. The runner log shows about 450 final drops below the start, still given up after the first update, and serve gaps of about 350 ms while the relay waits on the link.
  • A track's cursor re-offers every stale skip on each budget widening, which is O(history). Re-offer only the groups the new budget covers.
  • One finish python -> c interop failure on an earlier run: the C reader drained 0 of 10 frames, and the cell did not reproduce in 8 reruns (passed on ddda2710ba, 2b95d9bd50, and 074a8e0abe).

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
Implementer: Claude Code, claude-opus-5-5, unknown (review fixes, arm A)
Implementer: Antigravity, gemini-4-neon, high effort

(Written by Gemini 4 Neon with high)

kixelated and others added 2 commits November 27, 2026 09:01
Since #9530, a join's SUBSCRIBE_START left every run given up below its
reach untold, on the subscription's record and on each of a front's
copies. Every later update that widened the budget rescanned the cache
and gave each up again, one poll step at a time ahead of every group: on
a relay holding a minute of 20 ms timestamp-keyed audio, about 5,000
drops after each widening, which stalled the native player's startup.

Final runs below the reach now stay told and are kept aside, named once
owed: those reaching up to a group served below the start, and those an
update lowering the start reaches. Stale runs are forgotten on the
subscription's record alone, as before #9530, so a wider budget may still
serve one while a front's copies give up none again, and a stale run
given up below the start after it resolved goes unnamed too. The JS
publisher mirrors it, and its lite-06 updates naming no start no longer
lower delivery to group 0, as in Rust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title The bursty audio rows pass their budgets again fix(net): a join keeps the history below its start told Nov 28, 2026
kixelated and others added 3 commits November 27, 2026 16:53
Resolves the conflict with #9791: a stale run judged under lite-07's
freshness bound, or an upstream's verdict under no bound at all, counts as
final, so it stays told and is named once it reaches up to the start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bill unsent runs

- A stale run untold below the start is forgotten on a front's copies
  where their fills gave it up, so a widened budget still asks upstream
  for it (`track::Subscriber::untell_stale`). Cached skips stay told on
  the copies, which re-offer those groups regardless.
- A lowered start forgets everything the copies reported below the old
  start (`untell_copies`), so a front names what a plain track does.
- The final runs held unsent below the start live in the reader's
  `Record`, billed and folded with the reports they shadow, instead of
  an unbilled map on the publisher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A debt fold now drops every run the record holds unsent, with its
report, before folding the rest. So the pool reclaims them however their
holes split them, and a later lowered start still owes and names them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace Record::unsent and partial untell hooks (untell_stale,
untell_misses, untell_copies) with an explicit owed-drop filter
(Subscriber::set_drop_owed) and direct track/copy lookup for reaching
drops (Subscriber::reaching_drops), mirrored in js/net.

This keeps Record::reported truthful for every key the wire was told,
eliminates O(history) per-subscriber unsent billing and drop-cursor
rescans on budget widenings (for both plain and routed tracks), and
fixes both Round 3 debt-fold findings by construction:

- Record::fold on a drop-tracking reader (Standing::drops) now reopens
  unreported skips and Misses::given_up verdicts instead of settling
  them into floor/reported, and DropCursor::next falls back to
  non-adopted-stale Misses::given_up verdicts if TrackState::shed_drops
  evicted a queued received drop before it went out.
- Serving a cached group below start queries reaching_drops directly
  from the track or serving copy against the logical wire record, so
  a debt fold on the logical record never drops the reaching verdict.
@kixelated kixelated changed the title fix(net): a join keeps the history below its start told fix(net): filter owed drops below a join's start instead of rescanning history Nov 28, 2026
…ubscribe model

- Stop reaching_drops at retryable route failures (Error::retryable /
  routeFailed) on fronts in both Rust and JS.
- Close the popped group and clear streaming in JS Publisher if
  resolveStart or reaching-drop forwarding fails or throws.
- Replace per-poll Record::fold reported/pending scan and immediate
  Misses::reopen with Beside::forget_untold and an O(1) forgotten_debt
  span on Misses, reopened only when drop_owed widens, set_range lowers
  the floor, or the budget widens past forgotten_budget.
- Preserve Hole::Skip in Misses::adopt_drops so fold_given_up and
  final_below reconstruct Skip if state.drops sheds it.
- Pass the current clamped budget when seeding record.pending on first
  DropCursor creation.
- Mirror drop-reader PubFold eligibility (served or handed) in
  rs/moq-net/verify/subscribe/SubscribeAccounting.tla.
- Name reaching drops for shed groups below start in Rust, and clip
  queued front pending drops in JS #setDropOwed.

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