diff --git a/quest/m0/nightly/README.md b/quest/m0/nightly/README.md index 9b5b70d8b8d..3ca8bfdbebe 100644 --- a/quest/m0/nightly/README.md +++ b/quest/m0/nightly/README.md @@ -37,7 +37,6 @@ Public API: none. Wire: none. ## Required - [The receive-windows benchmark runs to the end](/quest/m0/nightly/receive-windows-evicted.md) - `benchmark_receive_windows` stops failing `frame: Evicted`, so the Rust benchmark-tests job publishes its report -- [The relay's startup fits its stack under all features](/quest/m0/nightly/relay-stack.md) - `debug_relay_load_and_run_fit_windows_stack` passes under `--all-features`, fixed at the feature that grew the future - [moq-net's ingest fuzz target finds no stall](/quest/m0/nightly/ingest-fuzz.md) - the 13-byte stream that stalls ingest is fixed at its cause and kept as a regression test - [Nightly's shipping-size check passes](/quest/m0/nightly/shipping-size.md) - js/net, js/watch, and moq-relay growth over 5% is traced to its commits, then shrunk or accepted - [Nightly's Miri job stays inside its time budget](/quest/m0/nightly/miri.md) - Miri gets `rust-src`, then finishes inside its 60-minute job and 15-minute-per-test budgets diff --git a/quest/m0/nightly/relay-stack.md b/quest/m0/nightly/relay-stack.md deleted file mode 100644 index 55345f71a71..00000000000 --- a/quest/m0/nightly/relay-stack.md +++ /dev/null @@ -1,26 +0,0 @@ -# [S] The relay's startup fits its stack under all features - -## Goal - -`moq-relay`'s `stack::debug_relay_load_and_run_fit_windows_stack` -(`rs/moq-relay/tests/integration/stack.rs`) passes under `--all-features` -on `main` instead of overflowing its 1 MiB thread. Fixed at the cause, by -shrinking the future that grew, never by raising the stack size the test -models. - -## Plan - -Decided 2026-11-03 (maintainer, follow-up planning after the 2026-11-03 /quest-afk and /quest-complete runs), milestone: - -- ✅ m0, as a child of [Nightly passes on main](/quest/m0/nightly/README.md) -- m1 -- m2 - -- Find which feature grows `Relay::load`/`Relay::run`'s future: run the - test with each feature added to the defaults, then measure the futures' - sizes (`-Zprint-type-sizes`, or `size_of_val` on the futures in a test). -- Box or split the large state that feature adds, the way the default build - already fits. -- Keep the test's 1 MiB stack, which stands for a Windows main thread. - -Public API: none expected. Wire: none. diff --git a/rs/moq-relay/src/cluster.rs b/rs/moq-relay/src/cluster.rs index ddf50d403cc..c220f1e24f7 100644 --- a/rs/moq-relay/src/cluster.rs +++ b/rs/moq-relay/src/cluster.rs @@ -1258,13 +1258,15 @@ pub struct Cluster { peer_quic: crate::limits::Quic, config: Config, /// Dial template every peer dial is built from; see [`Self::peer_client`]. - connect: Option, - quic: Option, + /// The dial state sits behind `Arc`s because it is several KiB inline, and every + /// clone and every future holding one would copy it, on the stack in debug builds. + connect: Option>, + quic: Option>, /// The client static and API peers share when the template binds a fixed /// `[connect]` port, so that port stays the cluster's egress port. Otherwise /// `None`, and every session builds its own client on an ephemeral port. Built /// by [`Self::start`] and joins [`Self::dialers`] once [`Started::run`] begins. - dial: Option, + dial: Option>, /// Every dial client, shared by all clones, for [`Self::close`]. dialers: Dialers, /// Bound listen port and optional generated-certificate fingerprint. @@ -1549,8 +1551,8 @@ impl Cluster { /// Required when any peer is configured; [`start`](Self::start) returns an /// error otherwise. pub fn with_connect(mut self, connect: moq_tokio::connect::Config, quic: moq_tokio::quic::Config) -> Self { - self.connect = Some(connect); - self.quic = Some(quic); + self.connect = Some(Arc::new(connect)); + self.quic = Some(Arc::new(quic)); self } @@ -1815,7 +1817,7 @@ impl Cluster { let client = self .peer_client(!shared, None) .context("cluster peers configured but the dial template is unusable")?; - self.dial = shared.then_some(client); + self.dial = shared.then(|| Arc::new(client)); // After everything fallible, so a failed start leaves no credential behind. #[cfg(feature = "cluster-lan")] @@ -2138,7 +2140,7 @@ impl Cluster { // leaves from a fresh port. A fixed `[connect]` bind port names a single // source port, so static and API peers share the client bound to it instead. let (client, _held) = match (&self.dial, target.lan) { - (Some(shared), false) => (shared.clone(), None), + (Some(shared), false) => (moq_tokio::Client::clone(shared), None), _ => { let client = self.peer_client(true, Some(target))?; let held = self.dialers.hold(&client)?; @@ -2210,7 +2212,8 @@ impl Cluster { fn peer_client(&self, ephemeral: bool, target: Option<&DialTarget>) -> anyhow::Result { let mut connect = self .connect - .clone() + .as_deref() + .cloned() .context("cluster dial without a dial template (call Cluster::with_connect)")?; if ephemeral { let mut bind = connect.resolve().bind; @@ -2232,7 +2235,7 @@ impl Cluster { connect.tls = moq_tokio::tls::Connect::default(); connect.tls.fingerprint = vec![fingerprint.to_string()]; } - let mut quic = self.quic.clone().unwrap_or_default(); + let mut quic = self.quic.as_deref().cloned().unwrap_or_default(); self.peer_quic.dial(&mut quic); Ok(connect.init(quic)?) } diff --git a/rs/moq-relay/src/relay.rs b/rs/moq-relay/src/relay.rs index 5fea35f591a..9165c6aa2e5 100644 --- a/rs/moq-relay/src/relay.rs +++ b/rs/moq-relay/src/relay.rs @@ -766,12 +766,13 @@ impl Relay { let auth = auth.clone(); let shutdown = shutdown.clone(); let sessions = sessions.clone(); - async move { + // Boxed like the serving futures in the `select!` below. + Box::pin(async move { match idle { true => std::future::pending().await, false => serve_listening(server, cluster, auth, shutdown, sessions).await, } - } + }) }; let stun = async move { @@ -783,9 +784,11 @@ impl Relay { #[cfg(not(feature = "stun"))] std::future::pending::>().await }; + // Box the large serving futures: a debug build copies each one into this poll's + // stack frame several times, and an embedder's main thread pays for that frame. let result = tokio::select! { - Err(err) = started.run() => Err(err).context("cluster failed"), - Err(err) = web.serve(web_routes) => Err(err).context("web server failed"), + Err(err) = Box::pin(started.run()) => Err(err).context("cluster failed"), + Err(err) = Box::pin(web.serve(web_routes)) => Err(err).context("web server failed"), Err(err) = stun => Err(err).context("STUN server failed"), Err(err) = internal.serve(internal_routes) => Err(err).context("internal server failed"), Err(err) = serve_shared => Err(err).context("server failed"), diff --git a/rs/moq-relay/src/web.rs b/rs/moq-relay/src/web.rs index 6d9f039f548..5f438e228ef 100644 --- a/rs/moq-relay/src/web.rs +++ b/rs/moq-relay/src/web.rs @@ -492,7 +492,7 @@ impl Web { WebAcceptor::plain(ws, rtmp.clone(), state.clone()), )?; server.http_builder().http2().max_concurrent_streams(streams); - Some(server.serve(app.clone())) + Some(Box::pin(server.serve(app.clone()))) } else { None }; @@ -526,11 +526,13 @@ impl Web { ), )?; server.http_builder().http2().max_concurrent_streams(streams); - Some(server.serve(app)) + Some(Box::pin(server.serve(app))) } else { None }; + // Both servers are boxed, since a debug build copies each one into this poll's + // stack frame several times. tokio::select! { Some(res) = async move { Some(http?.await) } => res?, Some(res) = async move { Some(https?.await) } => res?,