Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ jobs:
if: ${{ !cancelled() }}
run: nix develop --command cargo bench --locked -p moq-net --features fuzz --bench '*' -- --test

# One relay's stats tick (drain plus plain and compressed encode), swept
# over held paths, tiers, and how many of those paths changed, plus the
# decode table. `--test` runs each tick routine once (decode ignores it
# and runs its whole table), so a panic (a plain
# frame past the cache cap, a drain that drops a held path) fails here
# instead of on the next manual run. Timing is not compared. `bench`
# exposes the hidden producer hook; without it the tick target is skipped.
- name: moq-stats producer tick and decode benchmarks
if: ${{ !cancelled() }}
run: nix develop --command just rs bench-stats --test

# The catalog bench asserts the estimate rate limit's publish counts, so one pass is
# the regression check.
- name: moq-mux catalog estimate fanout benchmark
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion quest/m2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ waiting on an upstream release waits in [m4](/quest/m4/README.md).
- [Capture multi-plane PipeWire cameras](/quest/m2/pipewire-camera-planes.md) - I420 and NV12 cameras that deliver one memory block per plane
- [#2819](/quest/m2/2819-moq-video-carry-pipewire-dma-bufs-safely-into-the-vulkan.md) - moq-video: validate PipeWire DMA-BUFs into the Vulkan renderer on hardware
- [vcpkg registry](/quest/m2/cpp-vcpkg.md) - a registry we own serves the prebuilt package to `vcpkg` manifests
- [Benchmark the moq-stats producer](/quest/m2/stats-producer-bench.md) - a Criterion target for one relay's per-tick stats drain and encode, swept over held paths
- [Binary delta stats](/quest/m2/stats-delta.md) - an on-demand varint delta flavor of every stats track, if relay encode CPU still matters after the JSON fixes
- [#3115](/quest/m2/3115-moqsink-the-publication-has-no-generation-so-a-flush.md) - moqsink: a flushing restart after EOS opens a new publication generation
- [QUIC I/O boundary](/quest/m2/quic-io-boundary.md) - moq-uring receives from the buffer ring and transmits into registered buffers with no copy, once a profile says where
Expand Down
6 changes: 2 additions & 4 deletions quest/m2/bench-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ update, and `moq-auth` token verification.

Deferred to m2 in the 2026-09-30 audit. The `moq-pattern` benchmark is the
one worth doing first, and could return to m1 as its own quest. The
`moq-stats` producer benchmark split out into
[its own quest](/quest/m2/stats-producer-bench.md) in the 2026-10-06 audit,
since [Binary delta stats](/quest/m2/stats-delta.md) gates on it alone.
`moq-stats` producer tick lives in `rs/moq-stats/benches/producer_tick.rs`;
[Binary delta stats](/quest/m2/stats-delta.md) gates on that profile.

- `moq-pattern`: matching swept over pattern count and path depth. Patterns
shipped as `rs/moq-pattern` and `js/pattern`, so the matcher gets one bench
Expand All @@ -34,4 +33,3 @@ Public API: none. Wire: none.
## Related

- [Benchmark regressions in CI](/quest/m1/bench-ci.md) - tracks these targets on PRs and nightly
- [Benchmark the moq-stats producer](/quest/m2/stats-producer-bench.md) - the stats producer target, split out of this quest
11 changes: 4 additions & 7 deletions quest/m2/stats-delta.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ stats subscriber in the worst scenario below), so bytes alone do not justify
a new format. The motivation is relay encode CPU at 10k+ broadcasts and
aggregator fan-in. #4019 already cut `.json.z` decode allocations about 42x
(time 2.5-4x) by dropping per-key path tracking; `rs/moq-stats/benches/decode.rs`
measures it. Proceed only if CPU still matters after a profile of the
moq-json snapshot encoder (about 100 ms per tick at 10k broadcasts) has fixed
or ruled out its cost. Re-run the benchmark against that baseline; if JSON is
measures it. `rs/moq-stats/benches/producer_tick.rs` profiles the encode side:
a full rewrite at 10k held paths is about 22 ms per tick for one tier and
91 ms for four. Proceed only if CPU still matters after that profile has fixed
or ruled out the moq-json snapshot encoder's cost. Re-run the benchmark against that baseline; if JSON is
close enough, abandon this quest with the numbers.

**Evidence.** A prototype benchmark on top of #3955's commit `d86496be2`
Expand Down Expand Up @@ -106,10 +107,6 @@ maintainer's call; ask before writing one.
Public API impact: additive on moq-stats unless the helpers change. Wire
impact: new on-demand tracks; existing tracks unchanged.

## Required

- [Benchmark the moq-stats producer](/quest/m2/stats-producer-bench.md) - the moq-json snapshot encoder profile the gate needs

## Related

- [Stats format page](/doc/concept/stats.md) - where the new flavor is documented
Expand Down
37 changes: 0 additions & 37 deletions quest/m2/stats-producer-bench.md

This file was deleted.

5 changes: 5 additions & 0 deletions rs/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,8 @@ bench-playback:
[positional-arguments]
bench-rtmp *args:
cargo bench --locked -p moq-rtmp --bench chunk_interleaving -- "$@"

# One relay's stats tick, plus the decode table. `--test` runs each tick once; decode ignores it and prints its whole table.
[positional-arguments]
bench-stats *args:
cargo bench --locked -p moq-stats --features bench --bench producer_tick --bench decode -- "$@"
41 changes: 41 additions & 0 deletions rs/moq-net/src/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ pub fn excluding(origin: crate::origin::Consumer, peer: crate::Hop) -> crate::or
origin.excluding(peer)
}

/// Add `n` publisher-side payload bytes on `(path, tier)`, creating the entry
/// when the path is tracked. The stats producer bench marks a share of held
/// paths changed this way, without a media frame. A later [`crate::stats::Registry::report`]
/// drops the entry unless some guard still holds it. Not a public API.
pub fn bump_publisher_bytes(
registry: &crate::stats::Registry,
path: impl crate::AsPath,
tier: &crate::stats::Tier,
n: u64,
) {
registry.bump_publisher_bytes(path, tier, n);
}

/// Encode `announced` as a fresh [`AnnounceWriter`] stream.
pub fn encode_announces(announced: &[Announced], compress: bool) -> Vec<u8> {
let mut writer = AnnounceWriter::new(compress);
Expand Down Expand Up @@ -1163,6 +1176,34 @@ mod tests {

use std::collections::BTreeSet;

/// The bump lands on the publisher side and survives a second drain while
/// an announce guard still holds the entry.
#[test]
fn bump_publisher_bytes_stays_while_announced() {
use futures::FutureExt;

let registry = crate::stats::Registry::new(crate::stats::Config::new());
let (origin, driver) = crate::origin::Producer::new(crate::origin::Config::default());
let _driver = driver;
let tier = crate::stats::Tier::new("t");
let session = registry.tier(tier.clone()).session("root");
let _broadcast = origin.publish("room/1", crate::origin::Route::default()).unwrap();
let mut cursor = origin.consume().with_stats(session).announced();
while cursor.next().now_or_never().flatten().is_some() {}

bump_publisher_bytes(&registry, "room/1", &tier, 5);
let mut report = crate::stats::Report::default();
registry.report(&mut report);
registry.report(&mut report);
let entry = report
.traffic
.iter()
.find(|entry| entry.path.as_str() == "room/1")
.expect("announced path");
assert_eq!(entry.publisher.bytes, 5);
assert_eq!(entry.tier, tier);
}

fn target(name: &str) -> Target {
TARGETS
.iter()
Expand Down
11 changes: 11 additions & 0 deletions rs/moq-net/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,17 @@ impl Registry {
}
}

/// Add `n` publisher-side payload bytes on `(path, tier)`. The hidden `fuzz`
/// module exposes this to the stats producer bench. A report drops the entry
/// unless a guard still holds it.
#[cfg(any(test, feature = "fuzz"))]
pub(crate) fn bump_publisher_bytes(&self, path: impl AsPath, tier: &Tier, n: u64) {
let Some(entry) = self.entry(path) else {
return;
};
entry.tier(tier).publisher.bytes.fetch_add(n, Ordering::Relaxed);
}

fn entry(&self, path: impl AsPath) -> Option<Arc<BroadcastEntry>> {
// A disabled registry never allocates state.
let shared = self.shared.as_ref()?;
Expand Down
13 changes: 13 additions & 0 deletions rs/moq-stats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ rust-version.workspace = true
keywords = ["quic", "http3", "webtransport", "stats", "live"]
categories = ["multimedia", "network-programming", "web-programming"]

[features]
# Exposes one producer tick to the producer_tick bench, through the hidden
# `produce::bench` module, and moq-net's hidden counter bump. Off by default
# and hidden from the docs. Not a supported API.
bench = ["moq-net/fuzz"]

[dependencies]
moq-json = { workspace = true }
moq-net = { workspace = true }
Expand All @@ -22,6 +28,7 @@ tracing = { workspace = true }
web-async = { workspace = true }

[dev-dependencies]
criterion = { workspace = true }
futures = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt", "test-util", "time"] }

Expand All @@ -32,3 +39,9 @@ harness = false
[[bench]]
name = "aggregate"
harness = false

# Reaches the producer drain through the hidden `bench` module.
[[bench]]
name = "producer_tick"
harness = false
required-features = ["bench"]
Loading
Loading