From f6d31891fc36f8c7b1dbc9f0389fb0be536c13f1 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 15:03:48 -0700 Subject: [PATCH 1/3] chore(quest): claim quest/m0/nightly/paired-net.md Quest-Claim: 5ba8752a8eb79b0c From f282144066fa911966533e4433475d70c3db2c6d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 17:12:43 -0700 Subject: [PATCH 2/3] perf(net): move batched payloads and split paths without flattening write_frames cloned every payload into its prepared entries and then dropped the originals, two atomic refcount writes per frame that only a canonical conflict needed, and only shared canonical content can refuse a frame. Path::parts flattened an optional split, which the route table walks on every lookup. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/group.rs | 50 ++++++++++++++++++++--------------- rs/moq-net/src/path/mod.rs | 6 ++--- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/rs/moq-net/src/model/group.rs b/rs/moq-net/src/model/group.rs index f524af12831..2de8da67895 100644 --- a/rs/moq-net/src/model/group.rs +++ b/rs/moq-net/src/model/group.rs @@ -678,6 +678,21 @@ impl GroupState { slots } + /// Store a whole frame: count its bytes, extend the timeline, and charge its slot plus, + /// unless canonical content already owns the payload, its bytes. + /// + /// Returns the coarse tick it stamped, like [`cache::Charge::add`]. + fn commit(&mut self, entry: Entry) -> Option { + let size = entry.frame.payload.len() as u64; + if let Some(flate) = &mut self.flate { + flate.inflated += entry.inflated; + } + self.cache += size; + self.stamp(entry.frame.timestamp); + let slots = self.push(entry); + self.charge.add(slots + if self.content.is_none() { size } else { 0 }) + } + /// Whether a compressed group's content failed to inflate. fn malformed(&self) -> bool { self.flate.as_ref().is_some_and(|flate| flate.plain.malformed()) @@ -1435,15 +1450,8 @@ impl Producer { if let Err(err) = state.canonicalize(state.next_index, &mut entry) { return Err(self.abort_conflict(state, err)); } - state.cache += size; - if let Some(flate) = &mut state.flate { - flate.inflated += inflated; - } - let slots = state.push(entry); - let charged = slots + if state.content.is_none() { size } else { 0 }; - let now = state.charge.add(charged); + let now = state.commit(entry); state.next_index = next_index; - state.stamp(timestamp); let bound = state.settle(origin); self.handle.alive.checked.store(true, Ordering::Relaxed); self.advance_largest(&state); @@ -1529,8 +1537,13 @@ impl Producer { let mut latest = None; let mut deflated = deflated.into_iter(); let arrived = super::clock::now(); + // Validation is done, so the batch is taken by value: a conflict below fails the group, + // which the buffer need not survive, and moving each payload spares a refcount round trip. + // Only shared canonical content can refuse a frame, so only a group holding it prepares + // the whole batch before storing any; any other stores each frame as it goes. + let canonical = state.content.is_some(); let mut prepared = arrayvec::ArrayVec::::new(); - for (index, frame) in frames.filled().iter().enumerate() { + for (index, frame) in frames.drain().enumerate() { let timestamp = on_track(frame.timestamp, self.handle.track.timescale).expect("timestamp scale checked above"); let (payload, inflated) = match state.flate.is_some() { @@ -1538,7 +1551,7 @@ impl Producer { deflated.next().expect("one slice per frame"), frame.payload.len() as u64, ), - false => (frame.payload.clone(), 0), + false => (frame.payload, 0), }; let mut entry = Entry::plain( Cached { @@ -1548,23 +1561,18 @@ impl Producer { }, inflated, ); + latest = latest.max(timestamp); + if !canonical { + now = state.commit(entry); + continue; + } if let Err(err) = state.canonicalize(state.next_index + index, &mut entry) { return Err(self.abort_conflict(state, err)); } prepared.push(entry); } - frames.drain().for_each(drop); for entry in prepared { - let size = entry.frame.payload.len() as u64; - if let Some(flate) = &mut state.flate { - flate.inflated += entry.inflated; - } - state.cache += size; - state.stamp(entry.frame.timestamp); - latest = latest.max(entry.frame.timestamp); - let slots = state.push(entry); - let charged = slots + if state.content.is_none() { size } else { 0 }; - now = state.charge.add(charged); + now = state.commit(entry); } state.next_index = next_index; let bound = state.settle(origin); diff --git a/rs/moq-net/src/path/mod.rs b/rs/moq-net/src/path/mod.rs index 2810c453063..4b52a80d1dc 100644 --- a/rs/moq-net/src/path/mod.rs +++ b/rs/moq-net/src/path/mod.rs @@ -263,9 +263,9 @@ impl Path { /// assert_eq!(Path::empty().parts().count(), 0); /// ``` pub fn parts(&self) -> impl Iterator { - // Segments are never empty, but splitting the empty path would yield one. - let s = self.as_str(); - (!s.is_empty()).then(|| s.split('/')).into_iter().flatten() + // Segments are never empty, so only the empty path ends in an empty substring, + // which a terminator split skips; the route table walks this on every lookup. + self.as_str().split_terminator('/') } /// Whether a segment starts with `.`, which hides the path from announce From d817d7ddd17401c0aef8e9061fa1ea06fbc1d9ab Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 17:35:47 -0700 Subject: [PATCH 3/3] quest: finish paired-net and record its layout-only deltas for bench-ci Co-Authored-By: Claude Opus 5.5 --- quest/m0/nightly/README.md | 1 - quest/m0/nightly/paired-net.md | 22 ---------------------- quest/m1/bench-ci.md | 9 +++++++++ 3 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 quest/m0/nightly/paired-net.md diff --git a/quest/m0/nightly/README.md b/quest/m0/nightly/README.md index 22bfd31dfb1..a53ace1748b 100644 --- a/quest/m0/nightly/README.md +++ b/quest/m0/nightly/README.md @@ -38,7 +38,6 @@ Public API: none. Wire: none. - [The browser backend baseline completes on IETF22](/quest/m0/nightly/browser-baseline.md) - the WASM and UniFFI backend baseline completes every supported transport case without an internal error - [A Firefox late join reaches live playback](/quest/m0/nightly/firefox-late-join.md) - a Firefox player joining a live broadcast catches up within the media harness's derived playback deadline - [A stitched restart signals every TS discontinuity](/quest/m0/nightly/stitch-discontinuity.md) - a restarted publisher exported with stitching signals the program break on every affected PID -- [Resolve the paired network microbenchmark regressions](/quest/m0/nightly/paired-net.md) - the reported network microbenchmark regressions are attributed and genuine extra costs are fixed with paired measurements - [Resolve the paired catalog fanout regressions](/quest/m0/nightly/paired-shared.md) - the reported catalog fanout regressions are attributed and genuine extra costs are fixed with paired measurements - [Resolve the paired relay-session regressions](/quest/m0/nightly/paired-relay.md) - the reported relay-session regressions are attributed and genuine extra costs are fixed with paired measurements - [Probing beside Cubic](/quest/m0/nightly/competing-cubic.md) - the `competing_cubic` probe test stays within its deadline budget diff --git a/quest/m0/nightly/paired-net.md b/quest/m0/nightly/paired-net.md deleted file mode 100644 index 60f9266bbee..00000000000 --- a/quest/m0/nightly/paired-net.md +++ /dev/null @@ -1,22 +0,0 @@ -# [M] Resolve the paired network microbenchmark regressions - -## Goal - -The reported network microbenchmark regressions are attributed and genuine extra costs are fixed with paired measurements. - -## Plan - -[Rust bench targets](https://github.com/moq-dev/moq/actions/runs/40698329026/job/122851001853) compares `270395a337` -against `22808bbb2f` and flags fourteen cases: lite codec decode +31.2%, encode -+67.7%; group relaying +23.2%; batched group writes +16.6% to +45.3%; origin -route churn +14.4% and idle serving +46.2%; and four track-budget widening -cases +12.9% to +24.5%. The `bench-rust` artifact retains paired samples. - -Attribute the deltas using same-host comparisons, separating production work -from changed benchmark workloads and runner/allocator noise. The codec's -borrowed-message change landed between these revisions; inspect it without -assuming it explains every case. Fix genuine regressions and retain a swept -benchmark for each affected scaling dimension. Threshold calibration remains -in [bench CI](/quest/m1/bench-ci.md), not a reason to dismiss these deltas. - -Public API: none expected. Wire: none expected. diff --git a/quest/m1/bench-ci.md b/quest/m1/bench-ci.md index 9ffea2695bb..c05aad77987 100644 --- a/quest/m1/bench-ci.md +++ b/quest/m1/bench-ci.md @@ -62,6 +62,15 @@ The A/A calibration includes moq-quic's windowed `benches/streams.rs` cases: on a shared host the unchanged base alone varied 17 to 43% between back-to-back runs ([moq-dev/moq#6950](https://github.com/moq-dev/moq/pull/6950)). +Confirmed regressions with no extra work behind them, found by +[moq-dev/moq#7139](https://github.com/moq-dev/moq/pull/7139): every round of +`moq-net/group_relay_frames/plain/*` (+23%) and `moq-net/origin/serve_idle/3000r` +(+46%) agreed, yet callgrind counts the same instructions per frame read and per +poll on both builds. A paired round reruns the same two binaries, so a code or +heap layout shift between them reads as a stable regression that rounds cannot +filter. `codec_messages/*/lite` (+31%, +68%) moved only because a new bench group +in the same binary changed what LTO inlines. + ## Related - [Benchmark reporting](/bench/README.md) - the paired comparison and the trend table