diff --git a/quest/m1/README.md b/quest/m1/README.md index 25c59174d55..b02b209548e 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -132,7 +132,6 @@ ladders. - [Parked-read bench budget](/quest/m1/parked-read-bench-budget.md) - `track_parked_read` completes at default settings instead of expiring its parked reads mid-warm-up - [Mergeable bench buckets](/quest/m1/bench-buckets.md) - moq-bench emits per-interval latency buckets that sum across processes and hosts - [Relay session bench](/quest/m1/bench-relay.md) - the same scenario through moq-relay's own connection handling -- [Session burst hang](/quest/m1/session-burst-hang.md) - the burst sweep completes at 16 subscriptions and 16+ groups per round - [Read-only lookup](/quest/m1/read-only-lookup.md) - a live track lookup stops waking the front and every demand watcher - [Generated @moq/net](/quest/m1/rs2ts/README.md) - the browser runs moq-net as TypeScript generated from the Rust source, retiring js/net's hand-written protocol and model code - [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - the playout target is default in both languages; a manual browser proof and a native trace replay remain diff --git a/quest/m1/session-burst-hang.md b/quest/m1/session-burst-hang.md deleted file mode 100644 index bfda5fbc1ef..00000000000 --- a/quest/m1/session-burst-hang.md +++ /dev/null @@ -1,17 +0,0 @@ -# [S] The session burst bench completes at every shape - -## Goal - -`rs/moq-net/benches/session.rs`'s `burst` sweep runs to completion at 16 -subscriptions and 16 or more groups per round, with or without the serve -budgets, and the sweep covers those shapes again. - -## Plan - -Found while landing serve-budget -([#5088](https://github.com/moq-dev/moq/pull/5088)), which adds the `burst` -axis: with that axis applied, the bench hangs at those shapes without the -budget too, so the sweep was limited to shapes that complete. Decided 2026-10-08: -treat it as a possible session stall, not a bench setup limit. Find whether -it is cache size, stream credit, or a real stall, fix it at the cause, and -add a regression test if the cause is in the session rather than the bench. diff --git a/quest/m1/spinning-loops.md b/quest/m1/spinning-loops.md index a6ce372f850..3c2f0342dad 100644 --- a/quest/m1/spinning-loops.md +++ b/quest/m1/spinning-loops.md @@ -34,5 +34,5 @@ Decided 2026-10-09 while reworking #5088: ## Related -- [Session burst hang](/quest/m1/session-burst-hang.md) - the same bench shapes that hang +- [Session burst hang](https://github.com/moq-dev/moq/pull/5238) - the same bench shapes that hang - [FFI runtime](/quest/m1/ffi-runtime.md) - FFI apps run on more than one thread diff --git a/rs/moq-net/benches/session.rs b/rs/moq-net/benches/session.rs index 6078d923458..916a3a9cf4d 100644 --- a/rs/moq-net/benches/session.rs +++ b/rs/moq-net/benches/session.rs @@ -220,6 +220,8 @@ struct Cluster { _origins: Vec, _pairs: Vec, next_hop: u64, + /// The relay and publisher caches; each viewer owns its own. + pools: Vec, } impl Cluster { @@ -232,11 +234,13 @@ impl Cluster { _origins: Vec::new(), _pairs: Vec::new(), next_hop: 0, + pools: Vec::new(), }; for _ in 0..shape.relays { - let relay = this.origin(RELAY_CACHE); + let (relay, pool) = this.origin(RELAY_CACHE); this.relays.push(relay); + this.pools.push(pool); } // Peer every pair the way a cluster dial does: each side publishes its @@ -255,7 +259,8 @@ impl Cluster { } for publisher in 0..shape.publishers { - let origin = this.origin(CLIENT_CACHE); + let (origin, pool) = this.origin(CLIENT_CACHE); + this.pools.push(pool); for index in 0..shape.broadcasts { let broadcast = origin .publish(path(publisher * shape.broadcasts + index), Default::default()) @@ -274,18 +279,19 @@ impl Cluster { this } - fn origin(&mut self, capacity: u64) -> origin::Producer { + fn origin(&mut self, capacity: u64) -> (origin::Producer, cache::Pool) { self.next_hop += 1; let mut config = origin::Config::new(Hop::new(self.next_hop).unwrap()); - config.pool = cache::Pool::new(cache::Config::default().with_capacity(capacity)); + let pool = cache::Pool::new(cache::Config::default().with_capacity(capacity)); + config.pool = pool.clone(); let (producer, driver) = origin::Producer::new(config); support::harness::spawn(driver); - producer + (producer, pool) } /// Connect a viewer session to `relay`. async fn join(&mut self, relay: usize) -> Viewer { - let origin = self.origin(CLIENT_CACHE); + let (origin, pool) = self.origin(CLIENT_CACHE); let mut options = MockConnectOptions::new(self.version); // Hidden included, as the dash's `.stats/` scope sees its subtree. options.server_publish = Some(self.relays[relay].consume().with_hidden(true)); @@ -296,6 +302,7 @@ impl Cluster { subscribers: Vec::new(), _pair: pair, origin, + pool, } } } @@ -304,6 +311,7 @@ struct Viewer { subscribers: Vec, _pair: MockPair, origin: origin::Producer, + pool: cache::Pool, } impl Viewer { @@ -337,6 +345,7 @@ struct Room { writing: Vec>, /// The group each viewer's subscriber is reading, when paced, flattened in viewer order. reading: Vec>, + cache_now: moq_net::time::Instant, } impl Room { @@ -382,16 +391,51 @@ impl Room { written: 0, writing: Vec::new(), reading: Vec::new(), + cache_now: moq_net::time::Instant::now(), }; room.writing.resize_with(room.watched.len(), || None); room.reading.resize_with(shape.viewers * shape.watch, || None); + + // First measure the complete batch without eviction. The delivery benchmark must + // fit its working set; cache-pressure loss is a different workload. + let capacities: Vec<_> = room.pools().map(cache::Pool::capacity).collect(); + for pool in room.pools() { + pool.resize(None); + } // Warm every path so the timed rounds skip first-group setup. for _ in 0..FRAMES / shape.frames() { + room.tick(); + room.round().await; + } + for (pool, capacity) in room.pools().zip(capacities) { + // Keep the old and current batch resident during the handover, including + // bookkeeping rather than estimating a group from payload bytes alone. + pool.resize(capacity.map(|capacity| capacity.max(pool.used() * 2))); + } + // Exercise turnover as well as the empty cache, including Criterion's one-pass + // nightly smoke mode. + for _ in 0..4 { + room.tick(); room.round().await; } room } + fn pools(&self) -> impl Iterator { + let viewers = self.viewers.iter().map(|viewer| &viewer.pool); + self.cluster.pools.iter().chain(viewers) + } + + /// Unpaced rounds otherwise collapse many complete batches into one cache tick, + /// where yesterday's read outranks today's unread write. Sample a new recency + /// epoch per round without sleeping or changing protocol time. + fn tick(&mut self) { + self.cache_now += Duration::from_secs(1); + for pool in self.pools() { + pool.gc(self.cache_now); + } + } + async fn round(&mut self) { if self.shape.paced { return self.paced_round().await; @@ -444,12 +488,17 @@ impl Room { assert_eq!(bytes, self.shape.expected()); } + /// Time `iters` rounds, excluding each round's cache tick: its cost grows with the + /// number of pools, not with the delivery being measured. async fn measure(&mut self, iters: u64) -> Duration { - let start = Instant::now(); + let mut elapsed = Duration::ZERO; for _ in 0..iters { + self.tick(); + let start = Instant::now(); self.round().await; + elapsed += start.elapsed(); } - start.elapsed() + elapsed } } @@ -888,7 +937,7 @@ fn session(c: &mut Criterion) { delivery( c, "burst", - [(1, 1), (1, 8), (1, 64), (8, 1), (8, 8)].map(|(watch, burst)| Shape { + [(1, 1), (1, 8), (1, 64), (8, 1), (8, 8), (16, 16), (16, 64)].map(|(watch, burst)| Shape { publishers: 1, broadcasts: 16, viewers: 1,