From 6f6a3ae21432a3df74d4c432451f3909da339bee Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 26 Oct 2026 22:58:52 -0700 Subject: [PATCH 01/10] chore(quest): claim quest/m0/ci/slow-tests.md Quest-Claim: 263d25ccaa7a1636 From 56b17a04d8f5a48e67fba9389605546c6457cfd1 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 26 Oct 2026 23:12:16 -0700 Subject: [PATCH 02/10] test(mux): sweep jitter lead queries across frame rates Co-Authored-By: GPT-6 --- rs/moq-mux/benches/jitter.rs | 39 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/rs/moq-mux/benches/jitter.rs b/rs/moq-mux/benches/jitter.rs index 07c2fc93d63..74a35683ffc 100644 --- a/rs/moq-mux/benches/jitter.rs +++ b/rs/moq-mux/benches/jitter.rs @@ -12,21 +12,22 @@ use moq_net::Timestamp; )] mod jitter; -/// Every track sends a frame a second as it decodes, for as many two-second steering steps as -/// fill the rate window with `floors`, each step measuring every track heard. -async fn steer(tracks: u16, floors: u64) -> u64 { +/// Every track sends at its frame rate, for as many two-second steering steps as fill the +/// rate window with `floors`, each step measuring every track heard. +async fn steer(tracks: u16, floors: u64, frames_per_second: u64) -> u64 { let start = moq_clock::now(); let mut buffer = jitter::Buffer::new(Duration::from_millis(500)); buffer.expect(1..=tracks); let waiter = kio::Waiter::noop(); - for second in 0..floors * 2 { - let at = start + Duration::from_secs(second); + for frame in 0..floors * 2 * frames_per_second { + let elapsed = Duration::from_secs_f64(frame as f64 / frames_per_second as f64); + let at = start + elapsed; tokio::time::advance(at.saturating_duration_since(moq_clock::now())).await; for track in 1..=tracks { let arrival = jitter::Arrival { arrived: at, read: at, - decode: Timestamp::from_millis(second * 1_000).unwrap().into(), + decode: Timestamp::from_micros(elapsed.as_micros() as u64).unwrap().into(), restart: 0, skip: 0, cut: 0, @@ -54,7 +55,29 @@ fn steering(c: &mut Criterion) { for tracks in [1u16, 4, 16, 64] { for floors in [10u64, 100, 300] { group.bench_function(BenchmarkId::new(tracks.to_string(), floors), |b| { - b.iter(|| assert_eq!(runtime.block_on(steer(tracks, floors)), 0)); + b.iter(|| assert_eq!(runtime.block_on(steer(tracks, floors, 1)), 0)); + }); + } + } + group.finish(); +} + +/// Frame rates multiply lead queries between the same two-second steering updates. Keep a +/// full rate window and sweep track count independently of the number of frames it carries. +fn frame_rate(c: &mut Criterion) { + let runtime = tokio::runtime::Builder::new_current_thread() + .enable_time() + .start_paused(true) + .build() + .unwrap(); + let mut group = c.benchmark_group("jitter_frame_rate"); + group.measurement_time(Duration::from_secs(1)); + group.warm_up_time(Duration::from_millis(200)); + group.sample_size(10); + for tracks in [1u16, 4, 16] { + for frames_per_second in [1u64, 25, 100] { + group.bench_function(BenchmarkId::new(tracks.to_string(), frames_per_second), |b| { + b.iter(|| assert_eq!(runtime.block_on(steer(tracks, 300, frames_per_second)), 0)); }); } } @@ -109,5 +132,5 @@ fn acquisition(c: &mut Criterion) { group.finish(); } -criterion_group!(benches, steering, acquisition); +criterion_group!(benches, steering, frame_rate, acquisition); criterion_main!(benches); From b00c5ad60f74f0e10fbfac1d3f23deec20cd45d4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 26 Oct 2026 23:23:04 -0700 Subject: [PATCH 03/10] perf(mux): avoid repeated lead sorting and idle reset output Co-Authored-By: GPT-6 --- rs/moq-mux/src/container/ts/import.rs | 84 ++++++++++++++++----------- rs/moq-mux/src/jitter.rs | 49 +++++++++++++--- 2 files changed, 91 insertions(+), 42 deletions(-) diff --git a/rs/moq-mux/src/container/ts/import.rs b/rs/moq-mux/src/container/ts/import.rs index 4e9bc23fdbd..e7b07cc8640 100644 --- a/rs/moq-mux/src/container/ts/import.rs +++ b/rs/moq-mux/src/container/ts/import.rs @@ -10144,6 +10144,41 @@ pub(super) mod test { } } + /// Each reset stimulus has eight PES packets of two 72 ms MP2 frames. + const RESET_PES: u64 = 8; + const RESET_PES_TICKS: u64 = 2 * 72 * 90; + const RESET_LEAP_TICKS: u64 = 30 * 90_000; + + /// Drain queued media on its existing deadlines, stopping when the live export is idle. + async fn exported_discontinuities( + exporter: &mut crate::container::ts::Export, + ) -> (usize, usize) { + let waiter = kio::Waiter::noop(); + let mut frames = 0; + let mut flagged = 0; + loop { + match exporter.poll_next(&waiter) { + std::task::Poll::Ready(Ok(Some(frame))) => { + frames += 1; + flagged += frame + .payload + .as_chunks::<188>() + .0 + .iter() + .filter(|p| p[3] & 0x20 != 0 && p[4] > 0 && p[5] & 0x80 != 0) + .count(); + } + std::task::Poll::Ready(Ok(None)) => break, + std::task::Poll::Ready(Err(err)) => panic!("exporter error: {err}"), + std::task::Poll::Pending => { + let Some(deadline) = exporter.next_due() else { break }; + moq_clock::sleep_until(deadline).await; + } + } + } + (frames, flagged) + } + /// Import `before`, re-export the broadcast to MPEG-TS until it has gone out, then import /// `after` and count the exported packets whose adaptation field sets /// `discontinuity_indicator`. @@ -10154,37 +10189,24 @@ pub(super) mod test { let mut import = super::Import::new(broadcast, catalog.reserve()); import.decode(&bytes::BytesMut::from(before)).unwrap(); - // `import` and `catalog` stay alive so the exporter can subscribe to the retained - // tracks. A generous delay, since the default of zero would shed the earlier groups - // and the boundary with them. The paused clock runs out the delay and every gap in - // the media without a real wait. - let delay = std::time::Duration::from_secs(3600); + // Retain the complete stimulus span, the 30 s leap included: less sheds earlier + // groups and their boundary. Queued media is drained on its deadlines, without + // generating output through an arbitrary silence before feeding the next phase. + let delay = std::time::Duration::from_millis((RESET_LEAP_TICKS + RESET_PES * RESET_PES_TICKS) / 90); let mut exporter = crate::container::ts::export_test::open_export(crate::source::announced(&consumer).await) .await .unwrap() .with_delay(delay) .with_replay(); - let flags = |frame: crate::container::Frame| { - frame - .payload - .as_chunks::<188>() - .0 - .iter() - .filter(|p| p[3] & 0x20 != 0 && p[4] > 0 && p[5] & 0x80 != 0) - .count() - }; // A discontinuity before anything went out moves no clock, so the media before the // boundary goes out first, as it would live. - let mut flagged = 0; - while let Ok(Ok(Some(frame))) = tokio::time::timeout(2 * delay, exporter.next()).await { - flagged += flags(frame); - } + let (frames, before_flags) = exported_discontinuities(&mut exporter).await; + assert!(frames > 0, "media before the boundary must reach the output"); import.decode(&bytes::BytesMut::from(after)).unwrap(); import.finish().unwrap(); - while let Ok(Ok(Some(frame))) = tokio::time::timeout(2 * delay, exporter.next()).await { - flagged += flags(frame); - } - flagged + let (frames, after_flags) = exported_discontinuities(&mut exporter).await; + assert!(frames > 0, "media after the boundary must reach the output"); + before_flags + after_flags } /// The end-to-end shape the #2833 stimulus campaign graded: source, MoQ frames, exported @@ -10196,12 +10218,10 @@ pub(super) mod test { #[tokio::test(start_paused = true)] async fn a_signalled_reset_reaches_the_exported_clock() { const PID: u16 = 0x0061; - // One PES is two 72 ms MP2 frames. - const PES_TICKS: u64 = 2 * 72 * 90; let media = |ts: &mut Vec, cc: &mut u8, base: u64| { - for i in 0..8 { - ts.extend_from_slice(&mp2_pes(PID, *cc, base + i * PES_TICKS, [0xAA, 0xBB])); + for i in 0..RESET_PES { + ts.extend_from_slice(&mp2_pes(PID, *cc, base + i * RESET_PES_TICKS, [0xAA, 0xBB])); *cc = (*cc + 1) & 0x0f; } }; @@ -10212,8 +10232,8 @@ pub(super) mod test { let mut signalled = clock_break_packet(PID); let mut unsignalled = Vec::new(); let mut peer_cc = cc; - media(&mut signalled, &mut cc, 31 * 90_000); - media(&mut unsignalled, &mut peer_cc, 31 * 90_000); + media(&mut signalled, &mut cc, 90_000 + RESET_LEAP_TICKS); + media(&mut unsignalled, &mut peer_cc, 90_000 + RESET_LEAP_TICKS); assert_eq!( export_discontinuities(&before, &signalled).await, @@ -10231,16 +10251,14 @@ pub(super) mod test { /// generation, so the clock flags it once however many tracks declared the marker. #[tokio::test(start_paused = true)] async fn a_shared_forward_boundary_resets_once_per_rendition() { - const PES_TICKS: u64 = 2 * 72 * 90; - let mut stimulus = synth_pmt( &[(StreamType::Mpeg1Audio, PCR_PID), (StreamType::Mpeg1Audio, PEER_PID)], false, ); let media = |ts: &mut Vec, cc: &mut u8, base: u64| { - for i in 0..8 { + for i in 0..RESET_PES { for pid in [PCR_PID, PEER_PID] { - ts.extend_from_slice(&mp2_pes(pid, *cc, base + i * PES_TICKS, [0xAA, 0xBB])); + ts.extend_from_slice(&mp2_pes(pid, *cc, base + i * RESET_PES_TICKS, [0xAA, 0xBB])); } *cc = (*cc + 1) & 0x0f; } @@ -10249,7 +10267,7 @@ pub(super) mod test { let mut cc = 0; media(&mut stimulus, &mut cc, 90_000); let mut after = clock_break_packet(PCR_PID); - media(&mut after, &mut cc, 31 * 90_000); + media(&mut after, &mut cc, 90_000 + RESET_LEAP_TICKS); assert_eq!( export_discontinuities(&stimulus, &after).await, diff --git a/rs/moq-mux/src/jitter.rs b/rs/moq-mux/src/jitter.rs index 55ea0a3972d..d977b76ef82 100644 --- a/rs/moq-mux/src/jitter.rs +++ b/rs/moq-mux/src/jitter.rs @@ -183,7 +183,7 @@ pub(crate) struct Buffer { /// of its decode time a source sends each track belongs to its mux, not to one generation, /// so a new generation keeps the track sent latest at the delay even before that track /// reaches it, and a step that does not hear that track still measures against it. - leads: BTreeMap>, + leads: BTreeMap, timer: Option>>, dropped: u64, trimmed: u64, @@ -207,6 +207,25 @@ const RATE_WINDOW: f64 = 600.0; /// How many steering steps a track's lead is the median of: a window's worth, so a spell of /// queueing shorter than half of it does not move the lead either. const LEADS: usize = (RATE_WINDOW / STEER.as_secs_f64()) as usize; +/// A track's rolling lead, queried between steering updates without re-sorting its samples. +#[derive(Default)] +struct Lead { + samples: VecDeque, + median: f64, +} + +impl Lead { + fn push(&mut self, value: f64) { + self.samples.push_back(value); + if self.samples.len() > LEADS { + self.samples.pop_front(); + } + let mut sorted: Vec<_> = self.samples.iter().copied().collect(); + sorted.sort_by(f64::total_cmp); + self.median = sorted[sorted.len() / 2]; + } +} + /// How quickly the clock pulls the slack back to the delay: it closes the gap over this /// many seconds, or slower where the slew limit could not stop it in time. const RESPONSE: f64 = 600.0; @@ -758,11 +777,7 @@ impl Buffer { base = unheard + (phase - placed); } for (key, (track, _)) in &floor.tracks { - let leads = self.leads.entry(key.clone()).or_default(); - leads.push_back(track - phase + base); - if leads.len() > LEADS { - leads.pop_front(); - } + self.leads.entry(key.clone()).or_default().push(track - phase + base); } self.steer.steered += elapsed * clock.drift; let window = |series: &mut VecDeque<(f64, f64)>| { @@ -912,9 +927,7 @@ impl Buffer { /// How much more slack a track has than the track sent latest, in seconds: the median of /// its last [`LEADS`], so a spell of queueing does not move it. fn lead(&self, key: &K) -> Option { - let mut leads: Vec = self.leads.get(key)?.iter().copied().collect(); - leads.sort_by(f64::total_cmp); - Some(leads[leads.len() / 2]) + Some(self.leads.get(key)?.median) } /// When `acquire` ends: a track not yet heard from may be the one sent latest, so until @@ -1167,6 +1180,24 @@ fn depth(points: &VecDeque<(f64, f64)>, slope: f64, at: f64, now: f64) -> f64 { mod tests { use super::*; + /// The cached upper median changes with the rolling window, including when its old + /// majority expires; reads between updates keep the same result. + #[test] + fn a_lead_follows_its_rolling_window() { + let mut lead = Lead::default(); + for value in 1..=LEADS { + lead.push(value as f64); + } + assert_eq!(lead.median, (LEADS / 2 + 1) as f64); + for _ in 0..LEADS / 2 { + lead.push(-100.0); + } + assert_eq!(lead.median, (LEADS / 2 + 1) as f64); + lead.push(-100.0); + assert_eq!(lead.median, -100.0); + assert_eq!(lead.samples.len(), LEADS); + } + const DELAY: Duration = Duration::from_millis(100); #[moq_clock::test] From a1cab3ace311e272b350558871b1967b64f61aa9 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 26 Oct 2026 23:42:19 -0700 Subject: [PATCH 04/10] test(net): sweep sparse reads across subscriber counts Drop the jitter cache hypothesis after benchmark evaluation. Co-Authored-By: GPT-6 --- rs/moq-mux/benches/jitter.rs | 39 ++++++--------------------- rs/moq-mux/src/jitter.rs | 49 +++++++-------------------------- rs/moq-net/benches/track.rs | 52 +++++++++++++++++++++++++++--------- 3 files changed, 57 insertions(+), 83 deletions(-) diff --git a/rs/moq-mux/benches/jitter.rs b/rs/moq-mux/benches/jitter.rs index 74a35683ffc..07c2fc93d63 100644 --- a/rs/moq-mux/benches/jitter.rs +++ b/rs/moq-mux/benches/jitter.rs @@ -12,22 +12,21 @@ use moq_net::Timestamp; )] mod jitter; -/// Every track sends at its frame rate, for as many two-second steering steps as fill the -/// rate window with `floors`, each step measuring every track heard. -async fn steer(tracks: u16, floors: u64, frames_per_second: u64) -> u64 { +/// Every track sends a frame a second as it decodes, for as many two-second steering steps as +/// fill the rate window with `floors`, each step measuring every track heard. +async fn steer(tracks: u16, floors: u64) -> u64 { let start = moq_clock::now(); let mut buffer = jitter::Buffer::new(Duration::from_millis(500)); buffer.expect(1..=tracks); let waiter = kio::Waiter::noop(); - for frame in 0..floors * 2 * frames_per_second { - let elapsed = Duration::from_secs_f64(frame as f64 / frames_per_second as f64); - let at = start + elapsed; + for second in 0..floors * 2 { + let at = start + Duration::from_secs(second); tokio::time::advance(at.saturating_duration_since(moq_clock::now())).await; for track in 1..=tracks { let arrival = jitter::Arrival { arrived: at, read: at, - decode: Timestamp::from_micros(elapsed.as_micros() as u64).unwrap().into(), + decode: Timestamp::from_millis(second * 1_000).unwrap().into(), restart: 0, skip: 0, cut: 0, @@ -55,29 +54,7 @@ fn steering(c: &mut Criterion) { for tracks in [1u16, 4, 16, 64] { for floors in [10u64, 100, 300] { group.bench_function(BenchmarkId::new(tracks.to_string(), floors), |b| { - b.iter(|| assert_eq!(runtime.block_on(steer(tracks, floors, 1)), 0)); - }); - } - } - group.finish(); -} - -/// Frame rates multiply lead queries between the same two-second steering updates. Keep a -/// full rate window and sweep track count independently of the number of frames it carries. -fn frame_rate(c: &mut Criterion) { - let runtime = tokio::runtime::Builder::new_current_thread() - .enable_time() - .start_paused(true) - .build() - .unwrap(); - let mut group = c.benchmark_group("jitter_frame_rate"); - group.measurement_time(Duration::from_secs(1)); - group.warm_up_time(Duration::from_millis(200)); - group.sample_size(10); - for tracks in [1u16, 4, 16] { - for frames_per_second in [1u64, 25, 100] { - group.bench_function(BenchmarkId::new(tracks.to_string(), frames_per_second), |b| { - b.iter(|| assert_eq!(runtime.block_on(steer(tracks, 300, frames_per_second)), 0)); + b.iter(|| assert_eq!(runtime.block_on(steer(tracks, floors)), 0)); }); } } @@ -132,5 +109,5 @@ fn acquisition(c: &mut Criterion) { group.finish(); } -criterion_group!(benches, steering, frame_rate, acquisition); +criterion_group!(benches, steering, acquisition); criterion_main!(benches); diff --git a/rs/moq-mux/src/jitter.rs b/rs/moq-mux/src/jitter.rs index d977b76ef82..55ea0a3972d 100644 --- a/rs/moq-mux/src/jitter.rs +++ b/rs/moq-mux/src/jitter.rs @@ -183,7 +183,7 @@ pub(crate) struct Buffer { /// of its decode time a source sends each track belongs to its mux, not to one generation, /// so a new generation keeps the track sent latest at the delay even before that track /// reaches it, and a step that does not hear that track still measures against it. - leads: BTreeMap, + leads: BTreeMap>, timer: Option>>, dropped: u64, trimmed: u64, @@ -207,25 +207,6 @@ const RATE_WINDOW: f64 = 600.0; /// How many steering steps a track's lead is the median of: a window's worth, so a spell of /// queueing shorter than half of it does not move the lead either. const LEADS: usize = (RATE_WINDOW / STEER.as_secs_f64()) as usize; -/// A track's rolling lead, queried between steering updates without re-sorting its samples. -#[derive(Default)] -struct Lead { - samples: VecDeque, - median: f64, -} - -impl Lead { - fn push(&mut self, value: f64) { - self.samples.push_back(value); - if self.samples.len() > LEADS { - self.samples.pop_front(); - } - let mut sorted: Vec<_> = self.samples.iter().copied().collect(); - sorted.sort_by(f64::total_cmp); - self.median = sorted[sorted.len() / 2]; - } -} - /// How quickly the clock pulls the slack back to the delay: it closes the gap over this /// many seconds, or slower where the slew limit could not stop it in time. const RESPONSE: f64 = 600.0; @@ -777,7 +758,11 @@ impl Buffer { base = unheard + (phase - placed); } for (key, (track, _)) in &floor.tracks { - self.leads.entry(key.clone()).or_default().push(track - phase + base); + let leads = self.leads.entry(key.clone()).or_default(); + leads.push_back(track - phase + base); + if leads.len() > LEADS { + leads.pop_front(); + } } self.steer.steered += elapsed * clock.drift; let window = |series: &mut VecDeque<(f64, f64)>| { @@ -927,7 +912,9 @@ impl Buffer { /// How much more slack a track has than the track sent latest, in seconds: the median of /// its last [`LEADS`], so a spell of queueing does not move it. fn lead(&self, key: &K) -> Option { - Some(self.leads.get(key)?.median) + let mut leads: Vec = self.leads.get(key)?.iter().copied().collect(); + leads.sort_by(f64::total_cmp); + Some(leads[leads.len() / 2]) } /// When `acquire` ends: a track not yet heard from may be the one sent latest, so until @@ -1180,24 +1167,6 @@ fn depth(points: &VecDeque<(f64, f64)>, slope: f64, at: f64, now: f64) -> f64 { mod tests { use super::*; - /// The cached upper median changes with the rolling window, including when its old - /// majority expires; reads between updates keep the same result. - #[test] - fn a_lead_follows_its_rolling_window() { - let mut lead = Lead::default(); - for value in 1..=LEADS { - lead.push(value as f64); - } - assert_eq!(lead.median, (LEADS / 2 + 1) as f64); - for _ in 0..LEADS / 2 { - lead.push(-100.0); - } - assert_eq!(lead.median, (LEADS / 2 + 1) as f64); - lead.push(-100.0); - assert_eq!(lead.median, -100.0); - assert_eq!(lead.samples.len(), LEADS); - } - const DELAY: Duration = Duration::from_millis(100); #[moq_clock::test] diff --git a/rs/moq-net/benches/track.rs b/rs/moq-net/benches/track.rs index 40d84446c0f..1e47b00874a 100644 --- a/rs/moq-net/benches/track.rs +++ b/rs/moq-net/benches/track.rs @@ -1217,21 +1217,23 @@ fn bench_parked_read(c: &mut Criterion) { struct Sparse { _broadcast: broadcast::Producer, track: track::Producer, - sub: track::Subscriber, + subs: Vec, next: u64, missing: u64, timed: bool, } impl Sparse { - fn new(info: track::Info, gaps: u64) -> Self { + fn new(info: track::Info, gaps: u64, readers: usize) -> Self { let broadcast = broadcast::Info::default().produce(); let track = broadcast.create_track("bench", info.clone()).unwrap(); - let sub = track.subscribe(track::Subscription::default().with_max_delay(Duration::from_secs(3600))); + let subs = (0..readers) + .map(|_| track.subscribe(track::Subscription::default().with_max_delay(Duration::from_secs(3600)))) + .collect(); let mut sparse = Self { _broadcast: broadcast, track, - sub, + subs, next: gaps * 2, missing: 1, timed: info.timescale.is_some(), @@ -1252,10 +1254,12 @@ impl Sparse { let mut group = self.track.create_group(moq_net::group::Info { sequence }).unwrap(); group.write_frame(timestamp, Bytes::from_static(b"x")).unwrap(); group.finish().unwrap(); - let Poll::Ready(Ok(Some(read))) = self.sub.poll_recv_group(&kio::Waiter::noop()) else { - panic!("the group is cached"); - }; - black_box(read); + for sub in &mut self.subs { + let Poll::Ready(Ok(Some(read))) = sub.poll_recv_group(&kio::Waiter::noop()) else { + panic!("the group is cached"); + }; + black_box(read); + } } // A profiling boundary excludes filling the initial sparse backlog. @@ -1279,7 +1283,7 @@ fn bench_sparse_read(c: &mut Criterion) { for gaps in [16u64, 256, 4096] { group.bench_function(BenchmarkId::new(name, gaps), |b| { b.iter_custom(|iterations| { - let mut sparse = Sparse::new(info.clone(), gaps); + let mut sparse = Sparse::new(info.clone(), gaps, 1); let start = WallInstant::now(); for _ in 0..iterations { sparse.read_pair(); @@ -1292,6 +1296,30 @@ fn bench_sparse_read(c: &mut Criterion) { group.finish(); } +/// Several subscribers share the same sparse track: growth across both axes exposes +/// per-cursor walks multiplied by the audience, without including setup in the sample. +fn bench_sparse_subscribers(c: &mut Criterion) { + let mut group = c.benchmark_group("track_sparse_subscribers"); + for (name, info) in [("untimed", track::Info::default()), ("timed", timed())] { + for gaps in [16u64, 256] { + for readers in [1usize, 4, 16] { + group.throughput(Throughput::Elements(2 * readers as u64)); + group.bench_function(BenchmarkId::new(format!("{name}/{gaps}"), readers), |b| { + b.iter_custom(|iterations| { + let mut sparse = Sparse::new(info.clone(), gaps, readers); + let start = WallInstant::now(); + for _ in 0..iterations { + sparse.read_pair(); + } + start.elapsed() + }); + }); + } + } + } + group.finish(); +} + /// A sparse feed that opens one gap per millisecond, keeping `gaps` within its budget. struct Expiring { sparse: Sparse, @@ -1301,9 +1329,8 @@ struct Expiring { impl Expiring { fn new(gaps: u64) -> Self { - let mut sparse = Sparse::new(track::Info::default(), 0); - sparse - .sub + let mut sparse = Sparse::new(track::Info::default(), 0, 1); + sparse.subs[0] .update(track::Subscription::default().with_max_delay(Duration::from_millis(gaps))) .unwrap(); let pool = sparse._broadcast.info().pool.clone(); @@ -1940,6 +1967,7 @@ criterion_group!( bench_datagram_pressure, bench_parked_read, bench_sparse_read, + bench_sparse_subscribers, bench_sparse_expire, bench_gap_flush, bench_wall, From eeef505a5c860923bf159bcdf2f4960d9f400170 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 26 Oct 2026 23:52:27 -0700 Subject: [PATCH 05/10] perf(net): retain verdict sets already inside the reader span Drive pure jitter state-machine fixtures with explicit deadlines. Co-Authored-By: GPT-6 --- rs/moq-mux/src/jitter.rs | 8 +++-- rs/moq-net/src/model/track/miss.rs | 53 ++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 15 deletions(-) diff --git a/rs/moq-mux/src/jitter.rs b/rs/moq-mux/src/jitter.rs index 55ea0a3972d..40476def9d7 100644 --- a/rs/moq-mux/src/jitter.rs +++ b/rs/moq-mux/src/jitter.rs @@ -1849,6 +1849,8 @@ mod tests { async fn drift(ppm: f64, hours: f64, settled: f64, queueing: impl Fn(f64) -> Duration) -> Run { let delay = Duration::from_millis(500); let start = moq_clock::now(); + let clock = moq_clock::Deadlines::new(start); + let _entered = clock.enter(); let mut buffer = Buffer::new(delay); let mut run = Run { err: None, @@ -1875,7 +1877,7 @@ mod tests { } let source = decode.as_secs_f64() * (1.0 + ppm * 1e-6); let arrived = start + Duration::from_secs_f64(source) + queued; - tokio::time::advance(arrived.saturating_duration_since(moq_clock::now())).await; + clock.advance(arrived.max(clock.now())); let frame = Arrival { arrived, read: arrived, @@ -2037,6 +2039,8 @@ mod tests { /// that is later, or never if `None`, in the order they reach us, until a push fails. async fn feed(shape: &Shape, ppm: f64, secs: f64, arrive: impl Fn(u16, f64) -> Option) -> Fed { let start = moq_clock::now(); + let clock = moq_clock::Deadlines::new(start); + let _entered = clock.enter(); let mut buffer = Buffer::new(shape.delay); let mut frames = Vec::new(); for &track in shape.tracks { @@ -2061,7 +2065,7 @@ mod tests { }; for (sent, track, decode) in frames { let arrived = start + Duration::from_secs_f64(sent); - tokio::time::advance(arrived.saturating_duration_since(moq_clock::now())).await; + clock.advance(arrived.max(clock.now())); let frame = Arrival { arrived, read: arrived, diff --git a/rs/moq-net/src/model/track/miss.rs b/rs/moq-net/src/model/track/miss.rs index ebc7083c32e..287bd821eae 100644 --- a/rs/moq-net/src/model/track/miss.rs +++ b/rs/moq-net/src/model/track/miss.rs @@ -289,24 +289,15 @@ impl Misses { } // What left the span is forgotten, so it is judged afresh if it comes back, and a // verdict behind the reader's floor stops costing it memory. - let clip = |set: &RangeSet| -> RangeSet { - set.iter() - .flat_map(|run| { - span.overlapping(run) - .map(move |s| s.start.max(run.start)..s.end.min(run.end)) - }) - .collect() - }; - let judged = clip(&self.judged); - self.refused = clip(&self.refused); - self.given_up = clip(&self.given_up); - let mut candidates: RangeSet = span.iter().flat_map(|run| judged.gaps(run)).collect(); + intersect(&mut self.judged, &span); + intersect(&mut self.refused, &span); + intersect(&mut self.given_up, &span); + let mut candidates: RangeSet = span.iter().flat_map(|run| self.judged.gaps(run)).collect(); for run in std::mem::take(&mut self.deferred).iter() { for s in span.overlapping(run) { candidates.insert(s.start.max(run.start)..s.end.min(run.end)); } } - self.judged = judged; for run in candidates.iter() { self.judged.insert(run.clone()); } @@ -572,6 +563,23 @@ pub(super) fn holes(state: &TrackState, run: ops::Range) -> Vec, span: &RangeSet) { + let Some(first) = set.first() else { return }; + let last = set.last().expect("the set is nonempty"); + if span.get(&first.start).is_some_and(|cover| last.end <= cover.end) { + return; + } + *set = set + .iter() + .flat_map(|run| { + span.overlapping(run) + .map(move |s| s.start.max(run.start)..s.end.min(run.end)) + }) + .collect(); +} + /// The parts of `run` at or above `from` inside `admitted`. fn clip(run: ops::Range, from: u64, admitted: &RangeInclusiveSet) -> Vec> { let run = run.start.max(from)..run.end; @@ -594,3 +602,22 @@ fn looser(ours: Option, asked: Option) -> bool { (None, _) => false, } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn verdict_intersection_keeps_holes_and_exclusive_ends() { + let mut set: RangeSet<_> = [1..4, 7..10].into_iter().collect(); + intersect(&mut set, &std::iter::once(0..11).collect()); + assert_eq!(set.iter().cloned().collect::>(), [1..4, 7..10]); + // Covering both endpoints in different runs cannot take the containment path. + intersect(&mut set, &[1..2, 3..8, 9..10].into_iter().collect()); + assert_eq!(set.iter().cloned().collect::>(), [1..2, 3..4, 7..8, 9..10]); + intersect(&mut set, &[2..3, 8..9].into_iter().collect()); + assert!(set.is_empty(), "touching exclusive ends do not overlap"); + intersect(&mut set, &RangeSet::new()); + assert!(set.is_empty()); + } +} From a6aa64383a1939f3bdffef1dd7e43460933b2c6c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 27 Oct 2026 00:02:38 -0700 Subject: [PATCH 06/10] chore: discard unproven sparse miss optimization Co-Authored-By: GPT-6 --- rs/moq-net/benches/track.rs | 52 +++++++---------------------- rs/moq-net/src/model/track/miss.rs | 53 ++++++++---------------------- 2 files changed, 25 insertions(+), 80 deletions(-) diff --git a/rs/moq-net/benches/track.rs b/rs/moq-net/benches/track.rs index 1e47b00874a..40d84446c0f 100644 --- a/rs/moq-net/benches/track.rs +++ b/rs/moq-net/benches/track.rs @@ -1217,23 +1217,21 @@ fn bench_parked_read(c: &mut Criterion) { struct Sparse { _broadcast: broadcast::Producer, track: track::Producer, - subs: Vec, + sub: track::Subscriber, next: u64, missing: u64, timed: bool, } impl Sparse { - fn new(info: track::Info, gaps: u64, readers: usize) -> Self { + fn new(info: track::Info, gaps: u64) -> Self { let broadcast = broadcast::Info::default().produce(); let track = broadcast.create_track("bench", info.clone()).unwrap(); - let subs = (0..readers) - .map(|_| track.subscribe(track::Subscription::default().with_max_delay(Duration::from_secs(3600)))) - .collect(); + let sub = track.subscribe(track::Subscription::default().with_max_delay(Duration::from_secs(3600))); let mut sparse = Self { _broadcast: broadcast, track, - subs, + sub, next: gaps * 2, missing: 1, timed: info.timescale.is_some(), @@ -1254,12 +1252,10 @@ impl Sparse { let mut group = self.track.create_group(moq_net::group::Info { sequence }).unwrap(); group.write_frame(timestamp, Bytes::from_static(b"x")).unwrap(); group.finish().unwrap(); - for sub in &mut self.subs { - let Poll::Ready(Ok(Some(read))) = sub.poll_recv_group(&kio::Waiter::noop()) else { - panic!("the group is cached"); - }; - black_box(read); - } + let Poll::Ready(Ok(Some(read))) = self.sub.poll_recv_group(&kio::Waiter::noop()) else { + panic!("the group is cached"); + }; + black_box(read); } // A profiling boundary excludes filling the initial sparse backlog. @@ -1283,7 +1279,7 @@ fn bench_sparse_read(c: &mut Criterion) { for gaps in [16u64, 256, 4096] { group.bench_function(BenchmarkId::new(name, gaps), |b| { b.iter_custom(|iterations| { - let mut sparse = Sparse::new(info.clone(), gaps, 1); + let mut sparse = Sparse::new(info.clone(), gaps); let start = WallInstant::now(); for _ in 0..iterations { sparse.read_pair(); @@ -1296,30 +1292,6 @@ fn bench_sparse_read(c: &mut Criterion) { group.finish(); } -/// Several subscribers share the same sparse track: growth across both axes exposes -/// per-cursor walks multiplied by the audience, without including setup in the sample. -fn bench_sparse_subscribers(c: &mut Criterion) { - let mut group = c.benchmark_group("track_sparse_subscribers"); - for (name, info) in [("untimed", track::Info::default()), ("timed", timed())] { - for gaps in [16u64, 256] { - for readers in [1usize, 4, 16] { - group.throughput(Throughput::Elements(2 * readers as u64)); - group.bench_function(BenchmarkId::new(format!("{name}/{gaps}"), readers), |b| { - b.iter_custom(|iterations| { - let mut sparse = Sparse::new(info.clone(), gaps, readers); - let start = WallInstant::now(); - for _ in 0..iterations { - sparse.read_pair(); - } - start.elapsed() - }); - }); - } - } - } - group.finish(); -} - /// A sparse feed that opens one gap per millisecond, keeping `gaps` within its budget. struct Expiring { sparse: Sparse, @@ -1329,8 +1301,9 @@ struct Expiring { impl Expiring { fn new(gaps: u64) -> Self { - let mut sparse = Sparse::new(track::Info::default(), 0, 1); - sparse.subs[0] + let mut sparse = Sparse::new(track::Info::default(), 0); + sparse + .sub .update(track::Subscription::default().with_max_delay(Duration::from_millis(gaps))) .unwrap(); let pool = sparse._broadcast.info().pool.clone(); @@ -1967,7 +1940,6 @@ criterion_group!( bench_datagram_pressure, bench_parked_read, bench_sparse_read, - bench_sparse_subscribers, bench_sparse_expire, bench_gap_flush, bench_wall, diff --git a/rs/moq-net/src/model/track/miss.rs b/rs/moq-net/src/model/track/miss.rs index 287bd821eae..ebc7083c32e 100644 --- a/rs/moq-net/src/model/track/miss.rs +++ b/rs/moq-net/src/model/track/miss.rs @@ -289,15 +289,24 @@ impl Misses { } // What left the span is forgotten, so it is judged afresh if it comes back, and a // verdict behind the reader's floor stops costing it memory. - intersect(&mut self.judged, &span); - intersect(&mut self.refused, &span); - intersect(&mut self.given_up, &span); - let mut candidates: RangeSet = span.iter().flat_map(|run| self.judged.gaps(run)).collect(); + let clip = |set: &RangeSet| -> RangeSet { + set.iter() + .flat_map(|run| { + span.overlapping(run) + .map(move |s| s.start.max(run.start)..s.end.min(run.end)) + }) + .collect() + }; + let judged = clip(&self.judged); + self.refused = clip(&self.refused); + self.given_up = clip(&self.given_up); + let mut candidates: RangeSet = span.iter().flat_map(|run| judged.gaps(run)).collect(); for run in std::mem::take(&mut self.deferred).iter() { for s in span.overlapping(run) { candidates.insert(s.start.max(run.start)..s.end.min(run.end)); } } + self.judged = judged; for run in candidates.iter() { self.judged.insert(run.clone()); } @@ -563,23 +572,6 @@ pub(super) fn holes(state: &TrackState, run: ops::Range) -> Vec, span: &RangeSet) { - let Some(first) = set.first() else { return }; - let last = set.last().expect("the set is nonempty"); - if span.get(&first.start).is_some_and(|cover| last.end <= cover.end) { - return; - } - *set = set - .iter() - .flat_map(|run| { - span.overlapping(run) - .map(move |s| s.start.max(run.start)..s.end.min(run.end)) - }) - .collect(); -} - /// The parts of `run` at or above `from` inside `admitted`. fn clip(run: ops::Range, from: u64, admitted: &RangeInclusiveSet) -> Vec> { let run = run.start.max(from)..run.end; @@ -602,22 +594,3 @@ fn looser(ours: Option, asked: Option) -> bool { (None, _) => false, } } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn verdict_intersection_keeps_holes_and_exclusive_ends() { - let mut set: RangeSet<_> = [1..4, 7..10].into_iter().collect(); - intersect(&mut set, &std::iter::once(0..11).collect()); - assert_eq!(set.iter().cloned().collect::>(), [1..4, 7..10]); - // Covering both endpoints in different runs cannot take the containment path. - intersect(&mut set, &[1..2, 3..8, 9..10].into_iter().collect()); - assert_eq!(set.iter().cloned().collect::>(), [1..2, 3..4, 7..8, 9..10]); - intersect(&mut set, &[2..3, 8..9].into_iter().collect()); - assert!(set.is_empty(), "touching exclusive ends do not overlap"); - intersect(&mut set, &RangeSet::new()); - assert!(set.is_empty()); - } -} From 7f8911eed45fda66c229130a3a6487b61a3daf52 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 27 Oct 2026 00:12:29 -0700 Subject: [PATCH 07/10] docs(quest): checkpoint frozen CPU cohort below target Co-Authored-By: GPT-6 --- quest/m0/ci/slow-tests.md | 68 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/quest/m0/ci/slow-tests.md b/quest/m0/ci/slow-tests.md index cc48b812f62..a69d486f907 100644 --- a/quest/m0/ci/slow-tests.md +++ b/quest/m0/ci/slow-tests.md @@ -2,11 +2,12 @@ ## Goal -moq's slowest 1% of tests (103 tests, 289 of 501 test CPU-seconds in one full run) -take under half that CPU, with no loss of coverage. Before any change, freeze the -cohort by test ID from one full `cargo nextest` run and list it in this quest's PR; -measure that same set after, on the same machine. Per-test CPU is each test process's -user plus system time, not nextest's wall-clock duration. +Before any source edit, freeze the slowest `ceil(N / 100)` test IDs from one full +normal `cargo nextest` run and list them in the quest's PR. Those same cases take +under half their baseline user-plus-system CPU on the same machine, with every +case and its coverage preserved. Per-test CPU is the test process's user plus +system time, not nextest's wall-clock duration. Missing or failed cases are not +imputed. ## Plan @@ -23,3 +24,60 @@ would run, so cutting them beats building a selector. coverage tradeoff for each. Public API: none. + +### Checkpoint, 2026-10-27 + +[moq-dev/moq#6914](https://github.com/moq-dev/moq/pull/6914) retains useful test-only +changes but **does not complete this Goal**. No cases, durations, assertions, or +coverage were retired or moved to nightly. + +- One full actual-nextest baseline before edits, Rust source + `6f6a3ae21432a3df74d4c432451f3909da339bee` (main + `88620648e0a236d28a01a4a797f58ae9ae720489`): 10,275 passed, 104 skipped, + 253.449958 test CPU-seconds. The frozen 103 IDs cost **137.834631 CPU-seconds**, + so the target is **below 68.9173155 CPU-seconds**. The PR lists each ID and its + user/system cost. Before source edits, the initial floor-rounded 102-row list + was corrected once to `ceil(10,275 / 100) = 103`, using that same completed run. +- The final retained Rust source, `a6aa64383a1939f3bdffef1dd7e43460933b2c6c`, + passed the same 10,275 tests with the same 104 skips. Every baseline ID and all + 103 frozen IDs reconciled. The cohort cost **116.833263 CPU-seconds**, a measured + 15.2366% reduction, still above the target. No base merge, new baseline, missing + case imputation, or cohort reselection is included. +- Both runs used the same actual nextest command, native runner wrapper, local + four-worker admission, groups, zero retries, timeouts, toolchain and lockfile. + The wrapper recorded child `wait4` user plus system CPU, excluding wrapper and + build CPU. Unchanged controls varied too; their differences are not attributed + savings. The historical report's 103 tests / 289 of 501 CPU-seconds are + motivation, not this run's baseline or savings. + +Retained changes: + +- The two MPEG-TS reset tests drain queued media on the exporter's existing + deadlines and stop when idle. Their retention covers the entire original + 30-second leap plus eight PES packets of two 72 ms frames, rather than an + arbitrary hour. Their combined CPU fell from 12.982402 to 0.178783 seconds; + both phases must actually emit output. A per-phase-only retention trial failed + the unsignalled-reset assertion and was discarded. +- The pure jitter `drift` and `feed` loops advance an existing explicit deadline + queue synchronously. Undoing only these two clock drivers reproduces the + original file exactly: every arrival/decode formula, frame count, duration, + queueing spell, order, error branch, bound and assertion is unchanged. All 42 + jitter controls pass, including the full 24-hour drift cases. + +Discarded experiments and remaining work: + +- A cached lead median was dropped: the frame-rate benchmark was mostly within + noise, and one cell regressed about 6%. No production jitter changes remain. +- A no-op containment shortcut for miss-verdict intersections was dropped. The + sparse gap and shared-subscriber/range sweeps remained essentially unchanged; + timed 4096-gap reads were about 2.796 ms before and 2.783 ms after. No net model + or benchmark changes remain. The existing + [incremental sparse-misses quest](/quest/m1/release-perf/sparse-misses.md) + still owns its broader deferred-set rescans and O(log gaps) Goal; this PR does + not complete it, range-cost, fill-linear, or drop-set. +- The same frozen 103 cases still need a further reduction to below 68.9173155 + CPU-seconds. Broader miss-ledger/lifecycle algorithms and coverage/fixture + tradeoffs were not selected while the user was away. Keep this checkpoint a + draft with the Goal unfinished rather than claim the target or tune it away. + +Public API: none. Wire: none. Production behavior is unchanged. From 8551c7163f637b17a1e4d4c34491486ca0195c60 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 27 Oct 2026 12:46:10 -0700 Subject: [PATCH 08/10] docs(quest): rewrite slow-tests to the remaining 68.9 s goal Record the frozen cohort's measurement method, what this PR cut, what was tried and dropped, and the remaining cost by module. Co-Authored-By: Claude Opus 5.5 --- quest/m0/ci/slow-tests.md | 122 ++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 65 deletions(-) diff --git a/quest/m0/ci/slow-tests.md b/quest/m0/ci/slow-tests.md index a69d486f907..e8fb82436c1 100644 --- a/quest/m0/ci/slow-tests.md +++ b/quest/m0/ci/slow-tests.md @@ -2,12 +2,12 @@ ## Goal -Before any source edit, freeze the slowest `ceil(N / 100)` test IDs from one full -normal `cargo nextest` run and list them in the quest's PR. Those same cases take -under half their baseline user-plus-system CPU on the same machine, with every -case and its coverage preserved. Per-test CPU is the test process's user plus -system time, not nextest's wall-clock duration. Missing or failed cases are not -imputed. +The 103 test IDs frozen in [moq-dev/moq#6914](https://github.com/moq-dev/moq/pull/6914) +(the slowest `ceil(10,275 / 100)` of one full normal `cargo nextest` run) take under +68.92 CPU-seconds together, half their 137.83 s baseline, with every case and its +coverage preserved. Per-test CPU is the test process's user plus system time, not +nextest's wall-clock duration. Measure the same IDs on the same machine as the baseline +it is compared against; missing or failed cases are not imputed. ## Plan @@ -16,68 +16,60 @@ Decided with the maintainer on 2026-10-26, from kixelated/rust2's of tests make up 57% of what either package selection or a function-level selector would run, so cutting them beats building a selector. -- Start with moq-mux's container import tests (137 s) and moq-net's integration tests - (42 s). - Prefer making a test cheaper: smaller fixtures, shared setup, simulated time instead of real waits, fewer redundant cases. - Moving a test to nightly only follows this epic's rule: evidence and an explicit coverage tradeoff for each. -Public API: none. +### Measurement + +[moq-dev/moq#6914](https://github.com/moq-dev/moq/pull/6914) holds the frozen list with +per-test baseline and after CPU, plus the runner wrapper and command. The wrapper is a +`CARGO_TARGET__RUNNER` that records each nextest test child's `wait4` user plus +system time, run under the normal `just rs test --workspace --exclude moq-net-fuzz +--exclude moq-quic-fuzz` with zero retries. On a different machine, re-measure the +baseline source (`6f6a3ae21432a3df74d4c432451f3909da339bee`) and the candidate with the +same wrapper rather than comparing against these numbers. Unchanged tests vary a few +percent between runs on a shared host, so credit only the tests a change touches. + +### Done so far + +[moq-dev/moq#6914](https://github.com/moq-dev/moq/pull/6914) cut the cohort from +137.83 s to 116.83 s with fixture-only changes: the two MPEG-TS reset tests in +`container::ts::import` drain on the exporter's deadlines with a retention derived from +their stimulus instead of an hour of idle output (12.98 s to 0.18 s), and the jitter +`drift` and `feed` helpers advance a `moq_clock::Deadlines` queue instead of the tokio +paused clock (10.16 s to 6.80 s across 8 tests). About 48 s remains to cut. + +Tried and dropped, so don't redo them without new evidence: + +- Caching the jitter lead median: the frame-rate benchmark stayed within noise and one + cell regressed about 6%. +- A containment shortcut for miss-verdict intersections in moq-net: sparse gap and + range sweeps were unchanged (4096 timed gaps, 2.796 ms to 2.783 ms). The broader + algorithmic fix belongs to + [incremental sparse misses](/quest/m1/release-perf/sparse-misses.md). +- Retaining only one phase's span in the TS reset tests: it shed the boundary and + failed the unsignalled-reset assertion. -### Checkpoint, 2026-10-27 - -[moq-dev/moq#6914](https://github.com/moq-dev/moq/pull/6914) retains useful test-only -changes but **does not complete this Goal**. No cases, durations, assertions, or -coverage were retired or moved to nightly. - -- One full actual-nextest baseline before edits, Rust source - `6f6a3ae21432a3df74d4c432451f3909da339bee` (main - `88620648e0a236d28a01a4a797f58ae9ae720489`): 10,275 passed, 104 skipped, - 253.449958 test CPU-seconds. The frozen 103 IDs cost **137.834631 CPU-seconds**, - so the target is **below 68.9173155 CPU-seconds**. The PR lists each ID and its - user/system cost. Before source edits, the initial floor-rounded 102-row list - was corrected once to `ceil(10,275 / 100) = 103`, using that same completed run. -- The final retained Rust source, `a6aa64383a1939f3bdffef1dd7e43460933b2c6c`, - passed the same 10,275 tests with the same 104 skips. Every baseline ID and all - 103 frozen IDs reconciled. The cohort cost **116.833263 CPU-seconds**, a measured - 15.2366% reduction, still above the target. No base merge, new baseline, missing - case imputation, or cohort reselection is included. -- Both runs used the same actual nextest command, native runner wrapper, local - four-worker admission, groups, zero retries, timeouts, toolchain and lockfile. - The wrapper recorded child `wait4` user plus system CPU, excluding wrapper and - build CPU. Unchanged controls varied too; their differences are not attributed - savings. The historical report's 103 tests / 289 of 501 CPU-seconds are - motivation, not this run's baseline or savings. - -Retained changes: - -- The two MPEG-TS reset tests drain queued media on the exporter's existing - deadlines and stop when idle. Their retention covers the entire original - 30-second leap plus eight PES packets of two 72 ms frames, rather than an - arbitrary hour. Their combined CPU fell from 12.982402 to 0.178783 seconds; - both phases must actually emit output. A per-phase-only retention trial failed - the unsignalled-reset assertion and was discarded. -- The pure jitter `drift` and `feed` loops advance an existing explicit deadline - queue synchronously. Undoing only these two clock drivers reproduces the - original file exactly: every arrival/decode formula, frame count, duration, - queueing spell, order, error branch, bound and assertion is unchanged. All 42 - jitter controls pass, including the full 24-hour drift cases. - -Discarded experiments and remaining work: - -- A cached lead median was dropped: the frame-rate benchmark was mostly within - noise, and one cell regressed about 6%. No production jitter changes remain. -- A no-op containment shortcut for miss-verdict intersections was dropped. The - sparse gap and shared-subscriber/range sweeps remained essentially unchanged; - timed 4096-gap reads were about 2.796 ms before and 2.783 ms after. No net model - or benchmark changes remain. The existing - [incremental sparse-misses quest](/quest/m1/release-perf/sparse-misses.md) - still owns its broader deferred-set rescans and O(log gaps) Goal; this PR does - not complete it, range-cost, fill-linear, or drop-set. -- The same frozen 103 cases still need a further reduction to below 68.9173155 - CPU-seconds. Broader miss-ledger/lifecycle algorithms and coverage/fixture - tradeoffs were not selected while the user was away. Keep this checkpoint a - draft with the Goal unfinished rather than claim the target or tune it away. - -Public API: none. Wire: none. Production behavior is unchanged. +### Remaining cost + +After CPU of the frozen cohort by module, largest first: + +| Module | Tests | CPU s | +| --- | ---: | ---: | +| moq-mux `container::ts::export_timing_test` | 14 | 22.2 | +| moq-net `model::track::test` | 5 | 17.3 | +| moq-mux `container::ts::recovery_test` | 18 | 11.6 | +| moq-net integration `mesh_withdraw` | 6 | 9.7 | +| moq-net integration `routing_contracts::handoff` | 3 | 8.3 | +| moq-mux `jitter::tests` | 8 | 6.8 | +| moq-quic `tests::sim` | 3 | 4.6 | +| moq-stats `produce::tests` | 4 | 4.0 | +| everything else | 42 | 32.4 | + +The moq-net `model::track::test` gap tests run through the same miss judging, so +[incremental sparse misses](/quest/m1/release-perf/sparse-misses.md) may cut them as a +side effect; the export timing and recovery tests are the largest fixture-only target. + +Public API: none. From c15e8666967dba92e65580e8cb096ef757938b38 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 27 Oct 2026 12:48:45 -0700 Subject: [PATCH 09/10] docs(quest): note the measured run-to-run noise Co-Authored-By: Claude Opus 5.5 --- quest/m0/ci/slow-tests.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quest/m0/ci/slow-tests.md b/quest/m0/ci/slow-tests.md index e8fb82436c1..588b22c5710 100644 --- a/quest/m0/ci/slow-tests.md +++ b/quest/m0/ci/slow-tests.md @@ -29,8 +29,9 @@ per-test baseline and after CPU, plus the runner wrapper and command. The wrappe system time, run under the normal `just rs test --workspace --exclude moq-net-fuzz --exclude moq-quic-fuzz` with zero retries. On a different machine, re-measure the baseline source (`6f6a3ae21432a3df74d4c432451f3909da339bee`) and the candidate with the -same wrapper rather than comparing against these numbers. Unchanged tests vary a few -percent between runs on a shared host, so credit only the tests a change touches. +same wrapper rather than comparing against these numbers. Unchanged tests varied +between runs on a shared host (moq-stats' `produce::tests` by up to 40%), so credit only +the tests a change touches. ### Done so far From f69ded9eb4160c0746eed20a9ff3bcf6cca8ccc0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 27 Oct 2026 14:01:01 -0700 Subject: [PATCH 10/10] quest(ci): point the sparse-miss notes at the landed fix Co-Authored-By: Claude Opus 5.5 --- quest/m0/ci/slow-tests.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/quest/m0/ci/slow-tests.md b/quest/m0/ci/slow-tests.md index 588b22c5710..9a41aa83fbf 100644 --- a/quest/m0/ci/slow-tests.md +++ b/quest/m0/ci/slow-tests.md @@ -48,8 +48,8 @@ Tried and dropped, so don't redo them without new evidence: cell regressed about 6%. - A containment shortcut for miss-verdict intersections in moq-net: sparse gap and range sweeps were unchanged (4096 timed gaps, 2.796 ms to 2.783 ms). The broader - algorithmic fix belongs to - [incremental sparse misses](/quest/m1/release-perf/sparse-misses.md). + algorithmic fix landed in + [moq-dev/moq#6921](https://github.com/moq-dev/moq/pull/6921). - Retaining only one phase's span in the TS reset tests: it shed the boundary and failed the unsignalled-reset assertion. @@ -69,8 +69,9 @@ After CPU of the frozen cohort by module, largest first: | moq-stats `produce::tests` | 4 | 4.0 | | everything else | 42 | 32.4 | -The moq-net `model::track::test` gap tests run through the same miss judging, so -[incremental sparse misses](/quest/m1/release-perf/sparse-misses.md) may cut them as a -side effect; the export timing and recovery tests are the largest fixture-only target. +The moq-net `model::track::test` gap tests run through the same miss judging, which +[moq-dev/moq#6921](https://github.com/moq-dev/moq/pull/6921) made incremental after this +measurement, so re-measure them first; the export timing and recovery tests are the +largest fixture-only target. Public API: none.