Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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: 2 additions & 4 deletions quest/m1/bbr-ack-cleanup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ in `moq-quic` without changing public APIs or wire behavior.

## Plan

The fix lives in `moq-quic`'s BBR3, after [BBR3](/quest/m1/quic/fork/bbr3.md)
re-ports it in the hard fork; moq-dev/noq is frozen. In the BBR3 it ports,
`on_end_acks` (`noq-proto/src/congestion/bbr3/mod.rs`) runs `retain` over all
The fix lives in `moq-quic`'s BBR3; moq-dev/noq is frozen. There,
`on_end_acks` (`rs/moq-quic/src/congestion/bbr3/mod.rs`) runs `retain` over all
tracked packets, then scans them again to mark stale entries. Draining a flight with fixed-size ACK batches has quadratic total
cleanup work. [Google QUICHE](https://github.com/google/quiche/blob/c961965aa3ee8f2b6f05ebcac794f7854101adcd/quiche/quic/core/congestion_control/bandwidth_sampler.cc#L377)
uses packet-number lookup and obsolete-prefix reclamation; use that as a
Expand Down Expand Up @@ -52,7 +51,6 @@ packet-lifetime comments inline; no new user guide is needed.

## Required

- [BBR3](/quest/m1/quic/fork/bbr3.md) - the `moq-quic` BBR3 this fixes
- [Hard fork](/quest/m1/quic/fork/README.md) - lands in `moq-quic`, not the frozen fork

## Related
Expand Down
5 changes: 2 additions & 3 deletions quest/m1/quic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ Older quests say "the fork" or "noq"; read that as `moq-quic`. Their steps to
publish a fork release, pin it, or offer a change upstream are superseded:
a change lands in-tree with its consumer, and upstreaming is optional.

The seven BBR correctness fixes shipped in moq-noq 1.3.1 (#4206) and move to
`moq-quic` with the [BBR3 port](/quest/m1/quic/fork/bbr3.md). The remaining
BBR quests here and [BBR ACK cleanup](/quest/m1/bbr-ack-cleanup.md) all edit
The seven BBR correctness fixes shipped in moq-noq 1.3.1 (#4206) are in
`moq-quic`'s BBR3. The remaining BBR quests here and [BBR ACK cleanup](/quest/m1/bbr-ack-cleanup.md) all edit
`bbr3/mod.rs`, so one owner should work there at a time. Controller-level
regressions extend the shared test `Sim` in `bbr3/mod.rs` with only what each
needs, rather than adding another simulation loop; a fix at the transport
Expand Down
1 change: 0 additions & 1 deletion quest/m1/quic/fork/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ is either ported by a child quest or recorded as not applicable in the

## Required

- [Port BBR3](/quest/m1/quic/fork/bbr3.md) - the fork's corrected BBR3 and controller callbacks run on `moq-quic` as the default controller
- [Switch](/quest/m1/quic/fork/switch.md) - quinn's async layer and `web-transport-moq` join moq-tokio, both runtimes run on `moq-quic`, `moq-noq*` is gone, and relay memory matches `moq-noq`

## Related
Expand Down
33 changes: 0 additions & 33 deletions quest/m1/quic/fork/bbr3.md

This file was deleted.

12 changes: 7 additions & 5 deletions quest/m1/quic/fork/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ reviewer can diff it, and extend the cherry-pick recipe in
Move `web-transport-moq` from moq-dev/noq into moq-tokio as a module too. It
derives from web-transport-quinn; its noq-only parts are `PathId::ZERO` and
`path_stats`. Report bandwidth from quinn's `PathStats::bandwidth_estimate`
instead of the current cwnd/rtt guess. moq-uring uses it only in tests,
instead of the current cwnd/rtt guess; it is in bytes per second and
`web-transport-trait` wants bits. moq-uring uses it only in tests,
through moq-tokio.

BBR3 is already `moq-quic`'s default, with `Bbr3Config` and `Bbr3` named as
in noq, so the `Delay` family maps over unchanged. Run the benchmark matrix
against `moq-noq` 1.3.x on the same workloads and report any throughput or
latency difference; the BBR3 port could not, with no relay on `moq-quic` yet.

moq-uring built against both quinn-proto and noq-proto until #3811, behind
about 20 `cfg` lines (stats fields, CID generator, qlog, BBR). Rename
`rs/moq-uring/src/quic/noq` by role and use that history as the map. Keep
Expand All @@ -43,7 +49,3 @@ Re-run #3342's bulk and fanout relay memory workloads after the switch and
report them in the PR. On `moq-noq` they measured 75 MiB (bulk) and 31 MiB
(fanout), against 141 and 97 MiB without lazy slots; `moq-quic` should land
near the former.

## Required

- [Port BBR3](/quest/m1/quic/fork/bbr3.md)
3 changes: 1 addition & 2 deletions quest/m2/quic-bbr-loss-parity.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ citations point at draft-06.
## Plan

The lost-packet sample gap remains after the seven correctness fixes in
BBR3 (`noq-proto/src/congestion/bbr3/mod.rs` today), which the
[hard fork](/quest/m1/quic/fork/README.md) re-ports into `moq-quic`:
`moq-quic`'s BBR3 (`rs/moq-quic/src/congestion/bbr3/mod.rs`):

- Loss handling reuses the shared ACK sample (`self.rs`) as scratch space,
and skips the inflight-too-high check when a loss arrives before any ACK
Expand Down
7 changes: 7 additions & 0 deletions rs/moq-quic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ A `.rustfmt.toml` in each imported directory keeps quinn's formatting; `cargo fm

Changes on top of the upstream commit, besides the renames:

- **BBR3**, from [quinn#2481](https://github.com/quinn-rs/quinn/pull/2481) at [`55f74c0d`](https://github.com/quinn-rs/quinn/pull/2481/commits/55f74c0dd0738b5ad7d7676c0b2869a547783f83) (open upstream), rebased onto the fork point with authorship kept. It replaces quinn's BBR and is the default controller. It carries the BBR correctness fixes moq-dev/noq shipped in `moq-noq` 1.3.1, and with them the `Controller` changes BBR needs: packets named by number and `SpaceId`, `on_packet_sent`, `on_packet_lost`, `on_cwnd_limited`, `on_app_limited`, `on_ack_frequency_update`, and a `pacing_rate` and `send_quantum` the pacer obeys. `ControllerMetrics` rates are bytes per second.
- **Classic ECN for BBR3**, ported from [moq-dev/noq#12](https://github.com/moq-dev/noq/pull/12): CE exits Startup, stops a bandwidth probe, or lowers the short-term model, once per recovery episode, instead of counting as a loss.
- **Pacer rounding**: a wait shorter than a nanosecond rounds up instead of re-arming the pacing timer at the current instant.
- **qlog pacing rate** in bits per second, as qlog defines it.
- moq-dev/noq's congestion-callback regressions, reworked onto quinn's test harness.
- [quinn#2724](https://github.com/quinn-rs/quinn/pull/2724) (`moq_sock::udp`): when the kernel rejects a GSO batch with `EIO` or `EINVAL`, the socket halts GSO and resends the batch as individual datagrams instead of dropping it.
We extend it to resend batches built before GSO was halted too, which upstream's version drops, and to log only the first rejection.
A `WouldBlock` partway through the resend makes the caller retry the whole batch, duplicating the datagrams already sent; QUIC drops the duplicates.
Drop it if upstream lands [quinn#2748](https://github.com/quinn-rs/quinn/pull/2748) and we cherry-pick that.
- Apple fast-path fallback preserves the segmentation of batches prepared before the fast path was disabled, including when a private symbol is unavailable.

Recheck the BBR3 changes when cherry-picking quinn#2481 updates, or if it merges.

### Advisory triage

`cargo audit` cannot match the renamed crate, so security fixes are tracked by hand.
Expand Down
4 changes: 2 additions & 2 deletions rs/moq-quic/src/config/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl TransportConfig {
/// How to construct new `congestion::Controller`s
///
/// Typically the refcounted configuration of a `congestion::Controller`,
/// e.g. a `congestion::NewRenoConfig`.
/// e.g. a `congestion::NewRenoConfig`. Defaults to `congestion::Bbr3Config`.
///
/// # Example
/// ```
Expand Down Expand Up @@ -407,7 +407,7 @@ impl Default for TransportConfig {
#[cfg(test)]
deterministic_packet_numbers: false,

congestion_controller_factory: Arc::new(congestion::CubicConfig::default()),
congestion_controller_factory: Arc::new(congestion::Bbr3Config::default()),

enable_segmentation_offload: true,

Expand Down
81 changes: 75 additions & 6 deletions rs/moq-quic/src/congestion.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
//! Logic for controlling the rate at which data is sent

use crate::Instant;
use crate::connection::RttEstimator;
pub use crate::packet::SpaceId;
use crate::{Duration, Instant};
use std::any::Any;
use std::sync::Arc;

mod bbr;
mod bbr3;
mod cubic;
mod new_reno;

pub use bbr::{Bbr, BbrConfig};
pub use bbr3::{Bbr3, Bbr3Config};
pub use cubic::{Cubic, CubicConfig};
pub use new_reno::{NewReno, NewRenoConfig};

Expand All @@ -19,16 +20,40 @@ pub trait Controller: Send + Sync {
#[allow(unused_variables)]
fn on_sent(&mut self, now: Instant, bytes: u64, last_packet_number: u64) {}

/// One packet was just sent
///
/// `packet_number` identifies the packet only within `space`; every packet number space
/// numbers independently from zero.
#[allow(unused_variables)]
fn on_packet_sent(&mut self, now: Instant, bytes: u16, packet_number: u64, space: SpaceId) {}

/// The connection had data to send but was blocked by the congestion window
///
/// Reports the spec's `C.is_cwnd_limited` signal to the controller: the sender fully utilized
/// the congestion window at this point in the current round trip.
fn on_cwnd_limited(&mut self) {}

/// A transmit poll found nothing to send, and neither the congestion window nor the pacer
/// held a send back
///
/// Reports the spec's `CheckIfApplicationLimited` event: the application ran dry with
/// `in_flight` bytes outstanding.
#[allow(unused_variables)]
fn on_app_limited(&mut self, in_flight: u64) {}

/// Packet deliveries were confirmed
///
/// `app_limited` indicates whether the connection was blocked on outgoing
/// application data prior to receiving these acknowledgements.
/// `pn` identifies the packet only within `space`.
#[allow(unused_variables)]
fn on_ack(
&mut self,
now: Instant,
sent: Instant,
bytes: u64,
pn: u64,
space: SpaceId,
app_limited: bool,
rtt: &RttEstimator,
) {
Expand All @@ -42,6 +67,7 @@ pub trait Controller: Send + Sync {
in_flight: u64,
app_limited: bool,
largest_packet_num_acked: Option<u64>,
space: SpaceId,
) {
}

Expand All @@ -51,15 +77,34 @@ pub trait Controller: Send + Sync {
/// congestion threshold period ending when the most recent packet in this batch was sent were
/// lost.
/// `lost_bytes` indicates how many bytes were lost. This value will be 0 for ECN triggers.
/// `largest_lost` indicates the packet number of the packet with the highest packet number
/// in the congestion event, within `space`, and `sent` is its send time. For ECN, that is the
/// largest packet acknowledged by the ACK whose CE count increased, and the event fires only
/// on such an increase.
fn on_congestion_event(
&mut self,
now: Instant,
sent: Instant,
is_persistent_congestion: bool,
is_ecn: bool,
lost_bytes: u64,
largest_lost: u64,
space: SpaceId,
);

/// One packet was just lost
///
/// `packet_number` identifies the packet only within `space`.
#[allow(unused_variables)]
fn on_packet_lost(
&mut self,
lost_bytes: u16,
packet_number: u64,
space: SpaceId,
now: Instant,
) {
}

/// Packets were incorrectly deemed lost
///
/// This function is called when all packets that were deemed lost (for instance because
Expand All @@ -69,17 +114,37 @@ pub trait Controller: Send + Sync {
/// The known MTU for the current network path has been updated
fn on_mtu_update(&mut self, new_mtu: u16);

/// The peer's ACK-frequency parameters have changed
///
/// `ack_eliciting_threshold` is the number of ack-eliciting packets the peer may receive
/// before being required to send an immediate ACK (per the QUIC ACK frequency extension).
/// `requested_max_ack_delay` is the maximum delay we asked the peer to wait before sending
/// an ACK when the threshold hasn't been reached.
///
/// Controllers can use this to refine estimates that depend on peer ACK behavior (e.g.
/// BBR's offload budget).
#[allow(unused_variables)]
fn on_ack_frequency_update(
&mut self,
ack_eliciting_threshold: u64,
requested_max_ack_delay: Duration,
) {
}

/// Number of ack-eliciting bytes that may be in flight
fn window(&self) -> u64;

/// Retrieve implementation-specific metrics used to populate connection statistics and `qlog`
/// traces when they are enabled
/// This is also used to alter the pacing of the connection with
/// `pacing_rate` and `send_quantum`
fn metrics(&self) -> ControllerMetrics {
ControllerMetrics {
congestion_window: self.window(),
ssthresh: None,
pacing_rate: None,
bandwidth_estimate: None,
send_quantum: None,
}
}

Expand All @@ -93,18 +158,22 @@ pub trait Controller: Send + Sync {
fn into_any(self: Box<Self>) -> Box<dyn Any>;
}

/// Common congestion controller metrics
/// Common congestion controller metrics used both for logging purposes
/// but also to alter the pacing of the connection with
/// `pacing_rate` and `send_quantum`
#[derive(Default)]
#[non_exhaustive]
pub struct ControllerMetrics {
/// Congestion window (bytes)
pub congestion_window: u64,
/// Slow start threshold (bytes)
pub ssthresh: Option<u64>,
/// Pacing rate (bits/s)
/// Pacing rate (bytes/s)
pub pacing_rate: Option<u64>,
/// Estimated sustainable path bandwidth (bits/s)
/// Estimated sustainable path bandwidth (bytes/s)
pub bandwidth_estimate: Option<u64>,
/// Send Quantum (bytes) used to control the size of packet bursts
pub send_quantum: Option<u64>,
}

/// Constructs controllers on demand
Expand Down
Loading
Loading