diff --git a/Cargo.lock b/Cargo.lock index 3bb883965a7..52339444b00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5011,6 +5011,7 @@ dependencies = [ "h264-reader 0.9.0", "hang", "kio 0.6.2", + "libc", "memchr", "moq-clock", "moq-flate", diff --git a/quest/m0/nightly/README.md b/quest/m0/nightly/README.md index 330a865a317..0f3e7a9f861 100644 --- a/quest/m0/nightly/README.md +++ b/quest/m0/nightly/README.md @@ -34,6 +34,5 @@ Public API: none. Wire: none. ## Required - [Feature shapes in the gate](/quest/m0/nightly/feature-shapes.md) - feature-gated dead code fails the PR that adds it, not the next Nightly -- [ts_schedule regression](/quest/m0/nightly/ts-schedule.md) - the moq-mux `ts_schedule` benches return to their old cost - [Nightly's base in a shallow checkout](/quest/m0/nightly/shallow-base.md) - `sh/gh/nightly.test.py` passes in Nightly's depth-1 checkout - [Advisory bumps](/quest/m0/nightly/advisories.md) - both audits pass on today's advisories diff --git a/quest/m0/nightly/ts-schedule.md b/quest/m0/nightly/ts-schedule.md deleted file mode 100644 index 37eb7aeec30..00000000000 --- a/quest/m0/nightly/ts-schedule.md +++ /dev/null @@ -1,21 +0,0 @@ -# [S] ts_schedule regression - -## Goal - -`rust/shared/ts_schedule/{1/1, 1/16, 4/1}` (`rs/moq-mux/benches/ts_schedule.rs`) -return to their cost before the regression, and Nightly's paired gate on -the shared bench targets passes. - -## Plan - -Nightly's first paired run (0513c07369 against 4381af6f0) measured them -400 to 460% slower, too large for noise. The window holds -[moq-dev/moq#6417](https://github.com/moq-dev/moq/pull/6417), -[moq-dev/moq#6533](https://github.com/moq-dev/moq/pull/6533), and -[moq-dev/moq#6527](https://github.com/moq-dev/moq/pull/6527). Bisect, then -fix the cost at its source, or show the bench now measures more work and -rebaseline with that reason. The smaller `server_admission` (+20%) and -`uring-session_lite/no-gso` (+11%) deltas belong to the threshold -calibration in [bench CI](/quest/m1/bench-ci.md). - -Public API: none. Wire: none. diff --git a/rs/moq-mux/Cargo.toml b/rs/moq-mux/Cargo.toml index 02e306534df..4359aa26a77 100644 --- a/rs/moq-mux/Cargo.toml +++ b/rs/moq-mux/Cargo.toml @@ -50,6 +50,10 @@ moq-clock = { workspace = true, features = ["sim"] } tokio = { workspace = true, features = ["test-util"] } tracing-test = { workspace = true, features = ["no-env-filter"] } +# The ts_schedule bench pins glibc's heap. +[target.'cfg(all(target_os = "linux", target_env = "gnu"))'.dev-dependencies] +libc = { workspace = true } + [[bench]] name = "catalog" harness = false diff --git a/rs/moq-mux/benches/ts_schedule.rs b/rs/moq-mux/benches/ts_schedule.rs index 40cf20bc333..89be607de95 100644 --- a/rs/moq-mux/benches/ts_schedule.rs +++ b/rs/moq-mux/benches/ts_schedule.rs @@ -22,7 +22,22 @@ fn packet(pid: u16) -> [u8; 188] { packet } +/// Pin glibc's heap so every slot reuses it. A padded slot at 100 Mb/s lays out about 300 KB, +/// right at the size where glibc adapts between `mmap` and the heap and trims the heap's +/// top, so which one a run settles on, and with it fresh page faults on every slot, flips +/// with the process's heap history alone: that was a 5x swing on the ARM runners with no +/// change to the schedule. +fn hold_heap() { + #[cfg(all(target_os = "linux", target_env = "gnu"))] + // SAFETY: mallopt only tunes the allocator, called before anything is measured. + unsafe { + assert_eq!(libc::mallopt(libc::M_MMAP_THRESHOLD, 32 << 20), 1); + assert_eq!(libc::mallopt(libc::M_TRIM_THRESHOLD, libc::c_int::MAX), 1); + } +} + fn admission(c: &mut Criterion) { + hold_heap(); let mut group = c.benchmark_group("ts_schedule"); group.measurement_time(Duration::from_secs(1)); group.warm_up_time(Duration::from_millis(200)); @@ -76,6 +91,7 @@ fn admission(c: &mut Criterion) { /// Padded layout across queued tracks and access-unit size, each track's first unit with the /// tables ahead of it, the larger units spanning several slots. fn tables(c: &mut Criterion) { + hold_heap(); let mut group = c.benchmark_group("ts_schedule_tables"); group.measurement_time(Duration::from_secs(1)); group.warm_up_time(Duration::from_millis(200));