Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a62b26d
quest: claim quest/m1/quic/fork/switch
kixelated Oct 16, 2026
590d323
feat(moq-tokio): import quinn's async layer and web-transport-moq ver…
kixelated Oct 16, 2026
e8195bd
feat(quic)!: run moq-tokio and moq-uring on moq-quic
kixelated Oct 16, 2026
866b13d
fix(moq-tokio): log a CONNECT stream cut off by the close at debug
kixelated Oct 16, 2026
88a6fae
docs: point fork and advisory guidance at moq-quic
kixelated Oct 16, 2026
2d50267
docs: format the upgrade note
kixelated Oct 16, 2026
c2993ca
quest: finish quest/m1/quic/fork/switch
kixelated Oct 16, 2026
fcd8ea4
Merge origin/main into quest/m1/quic/fork/switch
kixelated Oct 16, 2026
5c7093f
claim quest/m1/quic/receive-credit
kixelated Oct 16, 2026
15d4076
feat(quic): hold connection credit until the receiver releases it
kixelated Oct 16, 2026
e111abf
test(moq-tokio): gate the timed helper with its only caller
kixelated Oct 16, 2026
a945ea1
Merge remote-tracking branch 'origin/quest/m1/quic/fork/switch' into …
kixelated Oct 16, 2026
5b7bff2
Merge origin/main into quest/m1/quic/fork/switch
kixelated Oct 16, 2026
43193f9
Merge remote-tracking branch 'origin/main' into quest-switch-alias
kixelated Oct 16, 2026
188b08c
fix(tokio): mark quic::web and quic::driver error enums non_exhaustive
kixelated Oct 16, 2026
d35e2cd
feat(quic): hand native receivers owned Credit handles
kixelated Oct 16, 2026
5d21b4f
fix(tokio): count in-flight accepts in wait_all_draining
kixelated Oct 16, 2026
50ebb4e
style(moq-tokio): apply quinn formatting to the held credit code
kixelated Oct 16, 2026
21cac2b
fix(tokio): wake draining waiters when accept empties the queue
kixelated Oct 16, 2026
2c3b97b
Merge remote-tracking branch 'origin/quest/m1/quic/fork/switch' into …
kixelated Oct 16, 2026
c1f4cfd
fix(tokio): surface non-WouldBlock receive errors, cap moq_quic logs
kixelated Oct 16, 2026
b389763
refactor(moq-uring): rename Connection::credit to credit_stats
kixelated Oct 16, 2026
420f102
Merge remote-tracking branch 'origin/quest/m1/quic/fork/switch' into …
kixelated Oct 16, 2026
738c16e
refactor(moq-uring): expose Connection::stats instead of credit_stats
kixelated Oct 16, 2026
888523e
Merge remote-tracking branch 'origin/main' into iter/receive-credit
kixelated Oct 16, 2026
c31d16d
Merge remote-tracking branch 'origin/main' into iter/receive-credit
kixelated Oct 16, 2026
78dfcfb
Merge remote-tracking branch 'origin/main' into iter/receive-credit
kixelated Oct 16, 2026
cc58807
fix(moq-quic): bind Credit to the connection that handed it out
kixelated Oct 16, 2026
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/quic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ cache limits remain separate; bitrate pacing composes with this memory cap.

## Required

- [Retain connection credit](/quest/m1/quic/receive-credit.md) - native receivers own connection credit independently of stream reads
- [Bound message assembly](/quest/m1/quic/receive-memory.md) - complete headers and frames return credit, and receiver priority cancellation restores progress
- [Reliable stream reset](/quest/m1/quic/reliable-reset.md) - `RESET_STREAM_AT`,
so a reset WebTransport stream still delivers its header
Expand Down
54 changes: 0 additions & 54 deletions quest/m1/quic/receive-credit.md

This file was deleted.

15 changes: 11 additions & 4 deletions quest/m1/quic/receive-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ peer-visible QUIC flow control instead of a separate header quota error.
The native transport primitive is a separate prerequisite; do not activate
whole-message retention without its recovery policy in this quest.

That primitive landed as a provisional seam to finalize here: both native
drivers' receive streams have a copying `poll_read_held` that yields a
`Credit` for exactly the bytes read. Dropping a `Credit` returns it, so a
reader buffer keeps one merged `Credit` and drops `split(n)` for each
complete unit; read-ahead stays in the remainder. io_uring's `poll_closed`
read-ahead keeps its credit until the application reads it. Both drivers'
`Connection::stats().credit` reports held and still-available credit.
`poll_read_held` stays separate until this quest folds it into `poll_read`.
moq-net's transport trait and the WebTransport wrappers do not carry it yet;
reshape any of it to fit the consumer.

Hold connection credit through reader buffers, type/length prefixes, headers,
extensions, and frame assembly. Attribute read-ahead bytes to the next unit
rather than releasing them with the completed one. Release on complete-unit
Expand Down Expand Up @@ -86,10 +97,6 @@ Browser/iroh receive-side guarantees and completed-cache limits are outside
this quest. Update existing configuration and transport docs inline; no
separate guide quest is needed.

## Required

- [Retain connection credit](/quest/m1/quic/receive-credit.md) - core and native adapters support separate byte ownership and stream-credit release

## Related

- [Scope track priority](/quest/m1/track-priority-scope.md) - broadcast fairness domains and subscription priority semantics
Expand Down
33 changes: 31 additions & 2 deletions rs/moq-quic/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,30 @@ use spaces::Retransmits;
use spaces::{PacketNumberFilter, PacketSpace, SendableFrames, SentPacket, ThinRetransmits};

mod stats;
pub use stats::{ConnectionStats, FrameStats, PathStats, UdpStats};

/// Identifies one connection, so state handed out by it cannot be returned to another.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub(crate) struct ConnectionTag(u64);

impl ConnectionTag {
/// No connection, for state that has not come from one yet.
pub(crate) const NONE: Self = Self(0);

/// A tag no other connection in this process has.
pub(crate) fn next() -> Self {
static NEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
Self(NEXT.fetch_add(1, std::sync::atomic::Ordering::Relaxed))
}
}
pub use stats::{ConnectionStats, CreditStats, FrameStats, PathStats, UdpStats};

mod streams;
#[cfg(fuzzing)]
pub use streams::StreamsState;
#[cfg(not(fuzzing))]
use streams::StreamsState;
pub use streams::{
Chunks, ClosedStream, FinishError, ReadError, ReadableError, RecvStream, SendStream,
Chunks, ClosedStream, Credit, FinishError, ReadError, ReadableError, RecvStream, SendStream,
ShouldTransmit, StreamEvent, Streams, WriteError, Written,
};

Expand Down Expand Up @@ -1358,10 +1373,24 @@ impl Connection {
stats.path.cwnd = self.path.congestion.window();
stats.path.bandwidth_estimate = self.path.congestion.metrics().bandwidth_estimate;
stats.path.current_mtu = self.path.mtud.current_mtu();
stats.credit = self.streams.credit_stats();

stats
}

/// Return connection flow control credit taken by [`Chunks::hold()`] to the peer.
///
/// If [`ShouldTransmit::should_transmit()`] returns `true`, call
/// [`Self::poll_transmit()`] soon so the peer learns of the larger window.
///
/// # Panics
/// If `credit` came from another connection.
pub fn release(&mut self, credit: Credit) -> ShouldTransmit {
let transmit = self.streams.release(credit);
self.spaces[SpaceId::Data].pending.max_data |= transmit.should_transmit();
transmit
}

/// Ping the remote endpoint
///
/// Causes an ACK-eliciting packet to be transmitted.
Expand Down
13 changes: 13 additions & 0 deletions rs/moq-quic/src/connection/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,17 @@ pub struct ConnectionStats {
pub frame_rx: FrameStats,
/// Statistics related to the current transmission path
pub path: PathStats,
/// Connection-level receive flow control
pub credit: CreditStats,
}

/// Connection-level receive flow control, from the receiver's side
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct CreditStats {
/// Bytes read with [`Chunks::hold()`](crate::Chunks::hold) whose credit is not released yet
pub held: u64,
/// Bytes the peer may still send before it needs more credit, including credit not yet
/// advertised
pub available: u64,
}
2 changes: 1 addition & 1 deletion rs/moq-quic/src/connection/streams/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{Dir, StreamId, VarInt, connection::streams::state::get_or_insert_rec

mod recv;
use recv::Recv;
pub use recv::{Chunks, ReadError, ReadableError};
pub use recv::{Chunks, Credit, ReadError, ReadableError};

mod send;
pub(crate) use send::{ByteSlice, BytesArray};
Expand Down
79 changes: 79 additions & 0 deletions rs/moq-quic/src/connection/streams/recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tracing::debug;

use super::state::get_or_insert_recv;
use super::{ClosedStream, Retransmits, ShouldTransmit, StreamId, StreamsState};
use crate::connection::ConnectionTag;
use crate::connection::assembler::{Assembler, Chunk, IllegalOrderedRead};
use crate::connection::streams::state::StreamRecv;
use crate::{TransportError, VarInt, frame};
Expand Down Expand Up @@ -336,10 +337,25 @@ impl<'a> Chunks<'a> {
}
}

/// Keep the connection flow control credit for the bytes read so far.
///
/// Stream credit still advances on [`Self::finalize()`], but the connection credit for these
/// bytes is withheld from the peer until the returned [`Credit`] is passed to
/// [`Connection::release()`][crate::Connection::release].
pub fn hold(&mut self) -> Credit {
let bytes = mem::take(&mut self.read);
self.streams.held += bytes;
Credit {
bytes,
tag: self.streams.tag,
}
}

/// Mark the read data as consumed from the stream.
///
/// The number of read bytes will be released from the congestion window,
/// allowing the remote peer to send more data if it was previously blocked.
/// Bytes taken by [`Self::hold()`] keep their connection credit.
///
/// If [`ShouldTransmit::should_transmit()`] returns `true`,
/// a packet needs to be sent to the peer informing them that the stream is unblocked.
Expand Down Expand Up @@ -388,6 +404,69 @@ impl Drop for Chunks<'_> {
}
}

/// Connection flow control credit for bytes read with [`Chunks::hold()`].
///
/// The peer cannot reuse this credit until it is passed to
/// [`Connection::release()`][crate::Connection::release] on the connection it came from, so
/// dropping it leaks receive window. A default `Credit` is empty and belongs to no connection
/// until it merges one that does.
#[must_use = "dropping Credit leaks connection flow control credit"]
#[derive(Debug, Default, PartialEq, Eq)]
pub struct Credit {
bytes: u64,
pub(super) tag: ConnectionTag,
}

impl Credit {
/// The number of bytes this credit covers.
pub fn len(&self) -> u64 {
self.bytes
}

/// Whether this credit covers no bytes.
pub fn is_empty(&self) -> bool {
self.bytes == 0
}

/// Split off the credit for the first `bytes`, keeping the rest.
///
/// # Panics
/// If `bytes` exceeds [`Self::len()`].
pub fn split(&mut self, bytes: u64) -> Self {
assert!(
bytes <= self.bytes,
"split {bytes} of {} held bytes",
self.bytes
);
self.bytes -= bytes;
Self {
bytes,
tag: self.tag,
}
}

/// Take over the bytes covered by `other`.
///
/// # Panics
/// If `other` came from another connection.
pub fn merge(&mut self, other: Self) {
if other.tag != self.tag {
assert!(
self.tag == ConnectionTag::NONE || other.tag == ConnectionTag::NONE,
"merged credit from another connection"
);
if self.tag == ConnectionTag::NONE {
self.tag = other.tag;
}
}
self.bytes += other.bytes;
}

pub(super) fn into_bytes(self) -> u64 {
self.bytes
}
}

enum ChunksState {
Readable(Box<Recv>),
Reset(VarInt),
Expand Down
Loading
Loading