From bb48c96b19c73fa2197e5428f47eb53421e646cf Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 18 Nov 2026 09:41:10 -0800 Subject: [PATCH] fix(bench): export benches freeze the clock between setup and the timed drain A finished track's last group ages out of a live-edge export once its span passes on the clock (#8638), so a host as slow as CodSpeed's simulation exported only the header and failed container-export/flv/1x16. Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/benches/export.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/rs/moq-mux/benches/export.rs b/rs/moq-mux/benches/export.rs index 1234d49f94b..69e87948cae 100644 --- a/rs/moq-mux/benches/export.rs +++ b/rs/moq-mux/benches/export.rs @@ -145,11 +145,19 @@ fn profiled_export(runtime: &tokio::runtime::Runtime, opened: Export) -> usize { runtime.block_on(export(opened)) } -fn bench_export(c: &mut Criterion) { - let runtime = tokio::runtime::Builder::new_current_thread() +/// A runtime whose clock stands still between setup and the timed drain. A finished track's last +/// group ages out of a live-edge export once its span passes on the clock, so a host slow +/// enough to spend that long between the two would export nothing. +fn paused() -> tokio::runtime::Runtime { + tokio::runtime::Builder::new_current_thread() .enable_all() + .start_paused(true) .build() - .unwrap(); + .unwrap() +} + +fn bench_export(c: &mut Criterion) { + let runtime = paused(); let mut group = c.benchmark_group("container-export"); group.sample_size(10); group.measurement_time(Duration::from_secs(1)); @@ -308,10 +316,7 @@ async fn prepare_video( } fn video_reorder(c: &mut Criterion) { - let runtime = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .unwrap(); + let runtime = paused(); let mut group = c.benchmark_group("video-reorder"); group.sample_size(10); group.warm_up_time(Duration::from_millis(50));