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
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 0 additions & 17 deletions quest/m1/session-burst-hang.md

This file was deleted.

2 changes: 1 addition & 1 deletion quest/m1/spinning-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
67 changes: 58 additions & 9 deletions rs/moq-net/benches/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ struct Cluster {
_origins: Vec<origin::Producer>,
_pairs: Vec<MockPair>,
next_hop: u64,
/// The relay and publisher caches; each viewer owns its own.
pools: Vec<cache::Pool>,
}

impl Cluster {
Expand All @@ -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
Expand All @@ -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())
Expand All @@ -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));
Expand All @@ -296,6 +302,7 @@ impl Cluster {
subscribers: Vec::new(),
_pair: pair,
origin,
pool,
}
}
}
Expand All @@ -304,6 +311,7 @@ struct Viewer {
subscribers: Vec<track::Subscriber>,
_pair: MockPair,
origin: origin::Producer,
pool: cache::Pool,
}

impl Viewer {
Expand Down Expand Up @@ -337,6 +345,7 @@ struct Room {
writing: Vec<Option<group::Producer>>,
/// The group each viewer's subscriber is reading, when paced, flattened in viewer order.
reading: Vec<Option<group::Consumer>>,
cache_now: moq_net::time::Instant,
}

impl Room {
Expand Down Expand Up @@ -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<Item = &cache::Pool> {
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;
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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,
Expand Down
Loading