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
6 changes: 6 additions & 0 deletions quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ bench all require its crate.
Added 2026-10-10 by maintainer priority: HTTP fetch stats, ranked just above
session outcomes, and embedder refusals inside session outcomes.

Added 2026-10-12: PROBE on demand in Rust and js/net, ranked after the viewer
up-switch, from the idle-session wake fix that found every client holds PROBE
open.

Imported 2026-10-12 from GitHub issues: the 0.17 warm FETCH stall and the
moq-lite malformed-input closes rank just below Dropped sources, and #5347
folded into Dropped sources.
Expand Down Expand Up @@ -127,6 +131,8 @@ folded into Dropped sources.
- [Simulcast rung disable](/quest/m1/simulcast-rung-disable.md) - JS, Rust/FFI, and OBS publishers stop encoding the top renditions their grant cannot fund, advertise `enabled: false`, and re-enable with hysteresis
- [Discover media headroom](/quest/m1/quic-probe.md) - test useful-media pacing before adding redundant probe traffic
- [Viewer up-switch](/quest/m1/viewer-upswitch.md) - a viewer capped by its small rendition finds headroom through PROBE and moves up
- [Rust PROBE on demand](/quest/m1/probe-on-demand-rs.md) - a Rust client opens PROBE only while a `recv_bandwidth()` consumer is held, and `Stats` drops `estimated_recv_rate`
- [JS PROBE on demand](/quest/m1/probe-on-demand-js.md) - js/net opens PROBE only while something reads the estimate
- [Own the QUIC stack](/quest/m1/quic/README.md) - quinn hard-forked in-tree as `moq-quic`, carrying BBR, reliable reset, hierarchical scheduling, peer limits, and endpoint sharding
- [QoS](/quest/m1/qos/README.md) - broadcast health: relay starvation and timeliness histograms
- [HTTP fetch stats](/quest/m1/http-fetch-stats.md) - each HTTP `/fetch` counts one `requests` and its bytes under the token's tier and root, not a session
Expand Down
28 changes: 28 additions & 0 deletions quest/m1/probe-on-demand-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# [M] js/net opens PROBE only while something reads it

## Goal

A js/net connection opens its PROBE stream only while something observes the
receive estimate, and closes it when the last reader goes. A `@moq/watch` that
is playing still gets the estimate (its sync RTT and ABR read it); a connection
nothing reads holds no PROBE stream. The PROBE wire is unchanged.

## Plan

Today `js/net/src/lite/connection.ts` runs `subscriber.runProbe()` for the
whole connection, unconditionally.

Decided (2026-10-12, quest-plan): demand comes from readers, either through
`@moq/signals` observation tracking (subscriber count, mirroring kio's
used/unused) or through an explicit consumer handle mirroring Rust's
`Session::recv_bandwidth()`. Either is acceptable; pick the simpler one once in
the code. With observation, `peek()` does not count, so the watch stats panel
subscribes while it is open. A consumer handle has no `Drop` in JS, so it must
be released by the effect that holds it.

Reconnects (`connection/reload.ts`) carry demand to the new connection.

## Related

- [Rust PROBE on demand](/quest/m1/probe-on-demand-rs.md) - the same outcome for Rust clients
- [Viewer up-switch](/quest/m1/viewer-upswitch.md) - also sends PROBE targets, so it reads the estimate while choosing renditions
35 changes: 35 additions & 0 deletions quest/m1/probe-on-demand-rs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# [L] Rust clients open PROBE only while a consumer reads it

## Goal

A Rust client opens a PROBE stream only while some `Session::recv_bandwidth()`
consumer is held, and closes it when the last one drops. The handle itself is
never demand, and `Stats` no longer carries `estimated_recv_rate`: the consumer
is the only way to the receive estimate. The PROBE wire is unchanged.

## Plan

Today `moq_net::Session` keeps its own `recv_bandwidth` consumer, so the lite
subscriber's `RecvBandwidth` always sees demand and every session keeps a PROBE
stream open, and moq-tokio's `Connection` holds another across reconnects. The
send side had the same bug, fixed by having the handle hold a weak reference
(`bandwidth::Weak`), and the receive side should follow it.

Decided (2026-10-12, quest-plan):
- Only a held consumer is demand. A `stats()` read is not, because a stats field
that silently reads `None` unless something else holds a consumer is a trap.
- Remove `Stats::estimated_recv_rate`. That breaks the API, which `main`
allows. moq-ffi and moq-c replace their `estimated_recv_rate` stats field with
a receive-bandwidth consumer handle, and every binding and `doc/lib` page
follows (see the Cross-Package Sync table).
- moq-tokio's `Connection` forwards demand across reconnects instead of holding
a consumer: it consumes the inner session's estimate only while its own
consumer is used.

Test: a session nobody holds a consumer for opens no PROBE stream, and one that
holds then drops a consumer opens and then resets it. Reuse the mock transport
stats and the harness in `rs/moq-net/tests/idle_session.rs`.

## Related

- [JS PROBE on demand](/quest/m1/probe-on-demand-js.md) - the same outcome for js/net
63 changes: 62 additions & 1 deletion rs/moq-net/benches/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
//! one small frame per track per tick. Throughput counts tracks, so a flat
//! elements/s across a sweep means the cost per track stays constant.
//!
//! `session_idle` times one second of idle viewer sessions, swept over sessions. Each
//! viewer keeps a PROBE stream open, as a browser does, and nothing else happens, so
//! the time is whatever the sessions do on their own. Paused time skips the waiting.
//!
//! `session_churn_*` times one request opened and closed by a session that already
//! holds others open, swept over sessions and requests held per session. On
//! moq-transport 14 every close is credited back through the MAX_REQUEST_ID window,
Expand All @@ -44,6 +48,7 @@ use bytes::Bytes;
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
use moq_net::{Hop, Timestamp, Version, broadcast, cache, group, origin, track};
use support::harness::{MockConnectOptions, MockPair, connect_mock};
use support::mock::MockStats;

/// A millisecond track: the frames written here carry timestamps.
fn timed() -> track::Info {
Expand Down Expand Up @@ -854,6 +859,62 @@ fn churn(c: &mut Criterion, name: &str, shapes: impl IntoIterator<Item = Churn>)
group.finish();
}

/// Viewer sessions to one relay, each holding a PROBE stream and otherwise idle.
struct IdleRoom {
_viewers: Vec<(MockPair, moq_net::bandwidth::Consumer)>,
}

impl IdleRoom {
async fn new(sessions: usize) -> Self {
let (relay, driver) = origin::Producer::new(origin::Config::new(Hop::new(1).unwrap()));
support::harness::spawn(driver);
let mut viewers = Vec::new();
for _ in 0..sessions {
let mut options = MockConnectOptions::new("moq-lite-06".parse().unwrap());
options.server_publish = Some(relay.consume());
// A QUIC backend reports both, so the relay serves PROBE.
options.stats = MockStats {
estimated_send_rate: Some(1_000_000),
rtt: Some(Duration::from_millis(40)),
};
let pair = connect_mock(options).await;
let mut probe = pair.client.recv_bandwidth().unwrap();
probe.changed().await.unwrap();
viewers.push((pair, probe));
}
Self { _viewers: viewers }
}

/// Let a second of protocol time pass per iteration.
async fn measure(&self, iters: u64) -> Duration {
let start = Instant::now();
for _ in 0..iters {
tokio::time::sleep(Duration::from_secs(1)).await;
}
start.elapsed()
}
}

fn idle(c: &mut Criterion) {
let mut group = c.benchmark_group("session_idle");
for sessions in [1, 64, 1024] {
group.throughput(Throughput::Elements(sessions as u64));
// Its own runtime, so its paused clock and its sessions end with the shape.
let rt = runtime();
let mut room = None;
group.bench_function(BenchmarkId::from_parameter(format!("sessions={sessions}")), |b| {
let room = room.get_or_insert_with(|| {
rt.block_on(async {
tokio::time::pause();
IdleRoom::new(sessions).await
})
});
b.iter_custom(|iters| rt.block_on(room.measure(iters)))
});
}
group.finish();
}

/// Withdraw a batch across a full mesh, sweeping both peers and prefixes.
/// Paused protocol time lets the quiet-point timeout drain pending work without
/// including a real wait in the measured duration.
Expand Down Expand Up @@ -1049,5 +1110,5 @@ fn session(c: &mut Criterion) {
);
}

criterion_group!(benches, session, withdrawal);
criterion_group!(benches, session, withdrawal, idle);
criterion_main!(benches);
20 changes: 16 additions & 4 deletions rs/moq-net/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl Client {
goaway: start.goaway,
auth: start.auth,
setup: start.setup,
estimate: Some(start.estimate),
},
))
}
Expand Down Expand Up @@ -319,7 +320,12 @@ impl Client {
v,
None,
crate::driver::Protocol::Ietf(protocol),
crate::session::Handles { goaway, auth, setup },
crate::session::Handles {
goaway,
auth,
setup,
estimate: None,
},
));
}
Some(ALPN_16) => {
Expand Down Expand Up @@ -412,7 +418,7 @@ impl Client {
.copied()
.ok_or(Error::Version)?;

let (recv_bw, protocol, goaway, auth, setup) = match version {
let (recv_bw, protocol, goaway, auth, setup, estimate) = match version {
Version::Lite(v) => {
let stream = stream.with_version(v);
let start = lite::start(lite::Config {
Expand All @@ -439,6 +445,7 @@ impl Client {
start.goaway,
start.auth,
start.setup,
Some(start.estimate),
)
}
Version::Ietf(v) => {
Expand Down Expand Up @@ -479,7 +486,7 @@ impl Client {
early_unis: Vec::new(),
extensions: self.extensions,
})?;
(None, crate::driver::Protocol::Ietf(protocol), goaway, auth, setup)
(None, crate::driver::Protocol::Ietf(protocol), goaway, auth, setup, None)
}
};

Expand All @@ -489,7 +496,12 @@ impl Client {
version,
recv_bw,
protocol,
crate::session::Handles { goaway, auth, setup },
crate::session::Handles {
goaway,
auth,
setup,
estimate,
},
))
}
}
Expand Down
Loading
Loading