From c07558355c123865e746e592edf463212ef88a96 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 10:46:51 -0800 Subject: [PATCH 1/5] chore(quest): claim quest/m0/ts-congested-path.md Quest-Claim: 0ea35be052a446fc From cc4ed1d833f5bb6b07f18b0d077f96950e369056 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 13:02:31 -0800 Subject: [PATCH 2/5] fix(mux): a live-start export joins at the live edge A TS export subscribed each live track with `Live { min: delay }`, so the relay sent up to two groups of history that the export's newest-group reader then skipped. Since #9316 forwards that join upstream exactly, on a congested path the backlog delayed the newest keyframe by a group, and the scheduled `TS congested path` step started a group late, its audio one frame past the 3 s join. A live-start `ExportSource` now joins with a zero min; a replay still reaches back the whole delay, and the max still bounds every group. Co-Authored-By: Claude Opus 5.5 --- quest/m0/ts-congested-path.md | 35 --------------- quest/m4/congested-whole-groups.md | 38 ++++++++++++++++ rs/moq-mux/src/container/source.rs | 23 +++++++--- rs/moq-mux/src/container/ts/export.rs | 3 +- rs/moq-mux/src/container/ts/export_test.rs | 52 +++++++++++++--------- 5 files changed, 90 insertions(+), 61 deletions(-) delete mode 100644 quest/m0/ts-congested-path.md create mode 100644 quest/m4/congested-whole-groups.md diff --git a/quest/m0/ts-congested-path.md b/quest/m0/ts-congested-path.md deleted file mode 100644 index 9927a802781..00000000000 --- a/quest/m0/ts-congested-path.md +++ /dev/null @@ -1,35 +0,0 @@ -# [M] The scheduled TS congested path keeps its audio - -## Goal - -The `TS congested path` step of the scheduled `TS` workflow -(`just test ts --headroom --rate 7000000 --duration 120`) passes on `main` -again, fixed at its cause: the export sheds whole video groups, and keeps -every audio frame from the join on. - -## Plan - -It passed on the 2026-11-21 run at `d1c532d3e4` and failed on the next two: - -- [45040473444](https://github.com/moq-dev/moq/actions/runs/45040473444) at - `f2eab6d3c2`: each audio PID shed frames (MP2 PIDs 4, 12 and 37 frames, - AC-3 2). `holes.py` grades audio under `--shed` with the same whole-group - rule as video, so these losses fail only if the run reports a mid-group - resume, unmatched frames, a lost tail, or a late start for that PID. -- [45251919956](https://github.com/moq-dev/moq/actions/runs/45251919956) at - `a04b99fbc9`: no audio shed, but each audio PID starts 3.008 to 3.024 s - after its source (at 4.49 s of 1.47 s), one frame past the 3.0 s join - allowance. Video shed 67.4 s of 117 s through `current group evicted; - skipping to next buffered group` every second. - -The moq-mux and `test/ts` commits between `d1c532d3e4` and `f2eab6d3c2` -include `3d1bb40f2a` (a live join asked upstream per join, -[moq-dev/moq#9316](https://github.com/moq-dev/moq/pull/9316)), `c145046a74` -(lite-07 group streams) and `a748733392` (group presentation order), each a -candidate for the later audio start. Reproduce locally through `quest gate` -and bisect that range before changing anything; neither run's failure was -rerun to see whether it repeats. - -Decided 2026-11-24 (maintainer, /quest-plan, from -[moq-dev/moq#9551](https://github.com/moq-dev/moq/pull/9551)): ✅ keep this quest in m0 -(rejected: m1, drop), since it fails every scheduled TS run and m0 owns CI failures on `main`. diff --git a/quest/m4/congested-whole-groups.md b/quest/m4/congested-whole-groups.md new file mode 100644 index 00000000000..8ce0adb388d --- /dev/null +++ b/quest/m4/congested-whole-groups.md @@ -0,0 +1,38 @@ +# [L] A congested path sheds whole video groups, not each group's tail + +## Goal + +When a subscriber's path is narrower than a track, the publisher (or relay) +drops whole groups so the ones it sends arrive whole, instead of starting +every group and cutting each one short. A viewer then sees continuous video +broken by a skipped GOP, not a freeze in every GOP. + +Today the scheduled `TS congested path` step (7 Mb/s, behind a 2 s queue, +under 9 Mb/s video and four audio PIDs, so the path carries about 73% of +the media) keeps only 42 to 47% of the video's frames. Each second the +export logs `current group evicted; skipping to next buffered group` and +resumes at the next group: every group plays its first 0.3 to 0.7 s, and +then the next group's start supersedes it, which is newest-first serving +under a 1 s max delay. Shedding whole groups at that rate would keep about +70%. The 2026-11-21 run kept 42% too (68 s of 117 s shed), so this +predates [moq-dev/moq#9316](https://github.com/moq-dev/moq/pull/9316). + +## Plan + +Measure first, at the relay and the publisher: which group streams are open +at once, how the congestion window is split between them, and when each is +reset. `just test ts --headroom --rate 7000000 --duration 20` with +`RUST_LOG=info,moq_net::lite=debug` and `HARNESS_KEEP=1` shows each served +group in the run's `relay.log`. Then change where the measurement points, +in Rust and `@moq/net` alike, and grade it with a `holes.py` bound on the +kept video share under `--shed`. + +## Waiting + +- Maintainer: which groups a narrow path keeps. (a) Newest first, as now: + every group starts and loses its tail. (b) A started group keeps the path + until it finishes or ages past the subscription's max, and a newer group + that cannot also arrive inside the max is skipped whole. Recommended: (b), + since a group is only decodable from its start, so a tail cut wastes the + bandwidth that carried its start, and the max already says how long an + older group stays worth sending. diff --git a/rs/moq-mux/src/container/source.rs b/rs/moq-mux/src/container/source.rs index b7da1730359..15fc75a7590 100644 --- a/rs/moq-mux/src/container/source.rs +++ b/rs/moq-mux/src/container/source.rs @@ -402,7 +402,8 @@ impl ExportSource { } /// Start at the newest group, the live edge, rather than the oldest one the max delay still - /// reaches. The subscription carries the max delay from the start: under a zero budget every + /// reaches. The subscription joins at the edge too, whatever the delay's min, so no hop spends + /// the path on groups this reader skips. It carries the max delay from the start: under a zero budget every /// hop drops each group a newer one supersedes, and raising it later cannot recover the /// groups that follow the edge. pub fn live(mut self) -> Self { @@ -595,7 +596,13 @@ impl ExportSource { .with_ranges([moq_net::track::Range::from(moq_net::track::Start::Time(after))]), None => moq_net::track::Subscription::default().with_ranges([moq_net::track::Range::ALL]), }; - let subscription = self.delay.subscription(subscription); + // A live start reads from the newest group, so it joins there: history behind the edge + // would only be skipped, after crowding out the newest group on a narrow path. + let delay = match start.live { + true => self.delay.with_min(Duration::ZERO), + false => self.delay, + }; + let subscription = delay.subscription(subscription); let track = match broadcast.track(&self.target.track) { Ok(track) => track, Err(_) if instance.as_ref().is_some_and(|i| i.poll_closed(waiter).is_ready()) => return self.end(), @@ -1202,7 +1209,9 @@ mod tests { /// The requested budget must be present on the first SUBSCRIBE, a live start's too. Updating /// it after SUBSCRIBE_OK cannot recover backlog the publisher already skipped, nor the groups a - /// zero budget drops as superseded before the update lands. + /// zero budget drops as superseded before the update lands. A live start joins at the edge, + /// since it would skip any history behind it, and on a narrow path that history delays the + /// newest group by a group or two. #[tokio::test] async fn latency_is_sent_with_the_initial_subscription() { for live_start in [false, true] { @@ -1221,7 +1230,7 @@ mod tests { let _ = export.poll_read(waiter); match live.track.subscription() { Some(subscription) => Poll::Ready(subscription.ranges.iter().find_map(|range| match range.start { - moq_net::track::Start::Live { max, .. } => Some(max), + moq_net::track::Start::Live { min, max } => Some((min, max)), _ => None, })), None => Poll::Pending, @@ -1229,7 +1238,11 @@ mod tests { }) .await; - assert_eq!(observed, Some(Some(max_delay)), "live start: {live_start}"); + let min = match live_start { + true => std::time::Duration::ZERO, + false => max_delay, + }; + assert_eq!(observed, Some((Some(min), Some(max_delay))), "live start: {live_start}"); } } diff --git a/rs/moq-mux/src/container/ts/export.rs b/rs/moq-mux/src/container/ts/export.rs index a6b9716a496..4ec58c22adc 100644 --- a/rs/moq-mux/src/container/ts/export.rs +++ b/rs/moq-mux/src/container/ts/export.rs @@ -4595,7 +4595,8 @@ fn video_kind(config: &VideoConfig, name: &str) -> Result { } /// The delay a track subscription states for an export running `delay` behind: all of it, as both -/// bounds, so a relay resets a group only once it is that old. +/// bounds, so a relay resets a group only once it is that old and a replay reaches back that far. +/// A live start joins at the edge whatever the min ([`ExportSource::live`]). pub(super) fn subscribed(delay: Duration) -> crate::container::Delay { crate::container::Delay::default().with_min(delay).with_max(delay) } diff --git a/rs/moq-mux/src/container/ts/export_test.rs b/rs/moq-mux/src/container/ts/export_test.rs index 2091b279b3c..11b515d4fd0 100644 --- a/rs/moq-mux/src/container/ts/export_test.rs +++ b/rs/moq-mux/src/container/ts/export_test.rs @@ -10618,28 +10618,40 @@ async fn a_follower_keeps_a_return_awaiting_its_catalog_when_a_stitch_goes() { assert_eq!(start.elapsed(), follow); } -/// Each track subscription joins live the whole delay back and states it as its max, so a relay -/// holds a group as long as the export could still play it. +/// Each track subscription states the whole delay as its max, so a relay holds a group as long as +/// the export could still play it. A live export joins at the edge, where it starts reading, so no +/// backlog it would skip crowds out the newest group; a replay reaches back the whole delay. #[tokio::test(start_paused = true)] async fn a_subscription_states_the_whole_delay() { - let origin = crate::source::produce_origin(); - let (live, mut catalog) = publish_bare(&origin, None); - let mut audio = aac_rendition(&mut live.broadcast().clone(), &mut catalog, "a.aac"); - write_aac(&mut audio, 0); - let delay = Duration::from_secs(2); - let mut export = open_export(crate::source::resolved(&origin, "live").await, delay) - .await - .unwrap(); - let _ = kio::clock::timeout(Duration::from_secs(1), export.next()).await; - let subscription = audio.track().subscription().unwrap(); - assert_eq!( - subscription.ranges, - [moq_net::track::Range::from(moq_net::track::Start::Live { - min: Some(delay), - max: Some(delay), - })] - ); - drop((live, catalog)); + for replay in [false, true] { + let origin = crate::source::produce_origin(); + let (live, mut catalog) = publish_bare(&origin, None); + let mut audio = aac_rendition(&mut live.broadcast().clone(), &mut catalog, "a.aac"); + write_aac(&mut audio, 0); + let delay = Duration::from_secs(2); + let export = open_export(crate::source::resolved(&origin, "live").await, delay) + .await + .unwrap(); + let mut export = match replay { + true => export.with_replay(), + false => export, + }; + let _ = kio::clock::timeout(Duration::from_secs(1), export.next()).await; + let subscription = audio.track().subscription().unwrap(); + let min = match replay { + true => delay, + false => Duration::ZERO, + }; + assert_eq!( + subscription.ranges, + [moq_net::track::Range::from(moq_net::track::Start::Live { + min: Some(min), + max: Some(delay), + })], + "replay: {replay}" + ); + drop((live, catalog)); + } } /// A program that ends while stitching, then returns after the unresolved replacement goes, From 3a6a2a8af03aaf8f27efdb7d557c3ed46fd308d4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 13:37:09 -0800 Subject: [PATCH 3/5] docs(mux): a live join's edge request holds only where a hop carries its min Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/container/source.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rs/moq-mux/src/container/source.rs b/rs/moq-mux/src/container/source.rs index 15fc75a7590..73b3f50abdd 100644 --- a/rs/moq-mux/src/container/source.rs +++ b/rs/moq-mux/src/container/source.rs @@ -402,10 +402,10 @@ impl ExportSource { } /// Start at the newest group, the live edge, rather than the oldest one the max delay still - /// reaches. The subscription joins at the edge too, whatever the delay's min, so no hop spends - /// the path on groups this reader skips. It carries the max delay from the start: under a zero budget every - /// hop drops each group a newer one supersedes, and raising it later cannot recover the - /// groups that follow the edge. + /// reaches. The subscription asks to join at the edge too, whatever the delay's min, so a hop + /// whose protocol carries a join's min spends no path on groups this reader skips. It carries + /// the max delay from the start: under a zero budget every hop drops each group a newer one + /// supersedes, and raising it later cannot recover the groups that follow the edge. pub fn live(mut self) -> Self { self.start().live = true; self From a8db42dbafcf4b7ca24e29b99fcd16eb111f8206 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 26 Nov 2026 10:11:11 -0800 Subject: [PATCH 4/5] docs(mux): a live TS export joins at the edge Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/container/ts/export.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rs/moq-mux/src/container/ts/export.rs b/rs/moq-mux/src/container/ts/export.rs index 6e1715e34cc..7551ec80ec9 100644 --- a/rs/moq-mux/src/container/ts/export.rs +++ b/rs/moq-mux/src/container/ts/export.rs @@ -1705,8 +1705,8 @@ where /// video track that dropped one resumes at its next keyframe. A source whose clock runs /// further off ours than 13818-1 lets the PCR follow fails the export once it has used half /// the delay, where a brief network stall only drops what it made late. Every track is - /// subscribed with the whole delay as its min and max, so a relay resets a group only once it - /// is that old. The export skips a stalled group once it falls the whole delay behind the + /// subscribed with the whole delay as its max, so a relay resets a group only once it is that + /// old; a live export joins at the edge, and a replay reaches back the whole delay. The export skips a stalled group once it falls the whole delay behind the /// newest content (see [`Consumer`](crate::container::Consumer)), so a stall shorter than the /// delay loses nothing, while a group whose tail never arrives makes the start of the next one /// late. From f74f35ed4314d3a2cd72317b50c74e1d54593929 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 26 Nov 2026 10:39:21 -0800 Subject: [PATCH 5/5] quest: drop the congested whole-groups follow-up The maintainer keeps newest-first serving: a narrow path drops group tails to keep latency low. Co-Authored-By: Claude Opus 5.5 --- quest/m4/congested-whole-groups.md | 38 ------------------------------ 1 file changed, 38 deletions(-) delete mode 100644 quest/m4/congested-whole-groups.md diff --git a/quest/m4/congested-whole-groups.md b/quest/m4/congested-whole-groups.md deleted file mode 100644 index 8ce0adb388d..00000000000 --- a/quest/m4/congested-whole-groups.md +++ /dev/null @@ -1,38 +0,0 @@ -# [L] A congested path sheds whole video groups, not each group's tail - -## Goal - -When a subscriber's path is narrower than a track, the publisher (or relay) -drops whole groups so the ones it sends arrive whole, instead of starting -every group and cutting each one short. A viewer then sees continuous video -broken by a skipped GOP, not a freeze in every GOP. - -Today the scheduled `TS congested path` step (7 Mb/s, behind a 2 s queue, -under 9 Mb/s video and four audio PIDs, so the path carries about 73% of -the media) keeps only 42 to 47% of the video's frames. Each second the -export logs `current group evicted; skipping to next buffered group` and -resumes at the next group: every group plays its first 0.3 to 0.7 s, and -then the next group's start supersedes it, which is newest-first serving -under a 1 s max delay. Shedding whole groups at that rate would keep about -70%. The 2026-11-21 run kept 42% too (68 s of 117 s shed), so this -predates [moq-dev/moq#9316](https://github.com/moq-dev/moq/pull/9316). - -## Plan - -Measure first, at the relay and the publisher: which group streams are open -at once, how the congestion window is split between them, and when each is -reset. `just test ts --headroom --rate 7000000 --duration 20` with -`RUST_LOG=info,moq_net::lite=debug` and `HARNESS_KEEP=1` shows each served -group in the run's `relay.log`. Then change where the measurement points, -in Rust and `@moq/net` alike, and grade it with a `holes.py` bound on the -kept video share under `--shed`. - -## Waiting - -- Maintainer: which groups a narrow path keeps. (a) Newest first, as now: - every group starts and loses its tail. (b) A started group keeps the path - until it finishes or ages past the subscription's max, and a newer group - that cannot also arrive inside the max is skipped whole. Recommended: (b), - since a group is only decodable from its start, so a tail cut wastes the - bandwidth that carried its start, and the max already says how long an - older group stays worth sending.