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/m2/unbounded-groups/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,3 @@ the model layer (maintainer, 2026-10-30).
- [Byte holes](/quest/m2/unbounded-groups/byte-holes.md) - segments inside a frame shed like front frames and flights start at `(frame, byte)` on the current lite wip; the frame cap goes
- [JS byte holes](/quest/m2/unbounded-groups/js-byte-holes.md) - `@moq/net` mirrors the byte-offset wire and continues a frame cut off mid-way
- [Compressed frames have no size cap and inflate as a bounded stream](/quest/m2/unbounded-groups/compressed-stream.md) - A compressed frame of any size publishes and is received in Rust and `@moq/net`, like a plain one
- [Remove FETCH-run pacing](/quest/m2/unbounded-groups/fetch-run-unpaced.md) - a moq-transport FETCH run is no longer held at group boundaries for a slow reader, matching lite-07
36 changes: 0 additions & 36 deletions quest/m2/unbounded-groups/fetch-run-unpaced.md

This file was deleted.

7 changes: 3 additions & 4 deletions rs/moq-net/src/coding/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,12 @@ impl<S: RecvStream, V: StreamCodes> Reader<S, V> {
self.poll_pace(waiter, group.poll_admit(waiter, header, self.stream.window()))
}

/// Wait out `paced`, a pace gate on what this stream writes next, if the session has room
/// for the credit this stream holds while paused (see [`Pause`]); otherwise read on,
/// unpaced.
/// Wait out `paced`, the group's pace gate, if the session has room for the credit this
/// stream holds while paused (see [`Pause`]); otherwise read on, and the group sheds.
///
/// A paused stream is not read, so it is watched for a reset instead, which fails the
/// wait rather than leaving it to the group's reader to notice.
pub(crate) fn poll_pace(&mut self, waiter: &kio::Waiter, paced: Poll<()>) -> Poll<Result<(), Error>>
fn poll_pace(&mut self, waiter: &kio::Waiter, paced: Poll<()>) -> Poll<Result<(), Error>>
where
S: Pause,
{
Expand Down
170 changes: 16 additions & 154 deletions rs/moq-net/src/ietf/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7573,12 +7573,6 @@ impl RecvGroupFetch {
/// properties, never past FETCH_OK's End Location. A group's objects end where the next
/// group's begin, since a FETCH carries every object of its range in order. Before
/// draft-22 the stream must also reach an object bound inside the last group.
///
/// Once a reader of the track lost a group to eviction, each group after the first waits,
/// its stream unread, until a reader picked up the one before, so a run wider than the
/// cache never evicts its own groups ahead of its readers (see [`track::Fill::poll_run_paced`]).
/// The pause holds receive credit, so it is taken only while the session's paused streams
/// leave room for it, as within a group.
struct GroupFetchObjects {
version: Version,
/// The next Object ID expected in the current group.
Expand All @@ -7587,9 +7581,6 @@ struct GroupFetchObjects {
first: bool,
/// The object whose payload is being read: its group, its Object ID, and where it goes.
payload: Option<(u64, u64, FetchPayloadRead)>,
/// The first object of the next group and its sequence, read while the run waits for its
/// readers to pick up the group before.
paced: Option<(FetchedObject, u64)>,
}

/// Where a fetch object's payload goes.
Expand All @@ -7611,7 +7602,6 @@ impl GroupFetchObjects {
prior_group: None,
first: true,
payload: None,
paced: None,
}
}

Expand Down Expand Up @@ -7640,38 +7630,22 @@ impl GroupFetchObjects {
}
}

let (object, sequence) = match self.paced.take() {
Some(paced) => paced,
None => {
let Some(object) = ready!(poll_fetch_object(stream, self.first, waiter))? else {
break;
};
self.first = false;
if !object.subgroup_ok && !object.datagram {
tracing::warn!("subgroup ID is not supported, dropping group fetch");
return Poll::Ready(Err(Error::Unsupported));
}

let group = resolve_fetch_group(self.prior_group, object.group)?;
if let Some(group) = group {
self.prior_group = Some(group);
}
// The first object always names its group, so a later one leaving it out stays in it.
let sequence = group.or(writer.sequence()).ok_or(Error::ProtocolViolation)?;
(object, sequence)
}
let Some(object) = ready!(poll_fetch_object(stream, self.first, waiter))? else {
break;
};
self.first = false;
if !object.subgroup_ok && !object.datagram {
tracing::warn!("subgroup ID is not supported, dropping group fetch");
return Poll::Ready(Err(Error::Unsupported));
}

let group = resolve_fetch_group(self.prior_group, object.group)?;
if let Some(group) = group {
self.prior_group = Some(group);
}
// The first object always names its group, so a later one leaving it out stays in it.
let sequence = group.or(writer.sequence()).ok_or(Error::ProtocolViolation)?;
if writer.sequence() != Some(sequence) {
// The group before is whole, so its readers see it end while the stream waits,
// unread, for them to pick it up: flow control then holds the publisher back.
writer.finish()?;
match stream.poll_pace(waiter, writer.fetch.fill.poll_run_paced(waiter)) {
Poll::Ready(res) => res?,
Poll::Pending => {
self.paced = Some((object, sequence));
return Poll::Pending;
}
}
self.next = writer.open(sequence, object.datagram)?;
} else if object.datagram {
// A datagram group has one object, so it never shares one with a stream.
Expand Down Expand Up @@ -17186,116 +17160,6 @@ mod stitch_tests {
assert!(matches!(receive.await, Err(Error::Evicted)));
}

/// What a slow reader of a FETCH run ten times wider than the cache gets, taking a group
/// each time the run's stream is polled, once a reader of the track lost a group to
/// eviction or not. An ascending reader reads in sequence, a descending one as groups
/// arrive.
async fn read_a_fetch_run_slowly(outran: bool, order: track::Order) -> Vec<u64> {
const GROUPS: u64 = 40;
const SIZE: usize = 10_000;
let payload = vec![0u8; SIZE];
let mut objects = Vec::new();
// The first Group ID is 0, and each later one, a delta, 0 again: the next group.
for _ in 0..GROUPS {
objects.extend(group_fetch_objects(0, 0, &[&payload[..]]));
}
// The session grants a stream credit of one group, so a paused stream holds one.
let window = crate::transport::ReceiveWindow::new(GROUPS * SIZE as u64, SIZE as u64);
let session = ScriptedSession::per_stream_eof(vec![objects]).with_receive_window(window);
let mut run = GroupFetchRun::with_session(VERSION, session).await;
let pool = crate::cache::Pool::new(crate::cache::Config::default().with_capacity(4 * SIZE as u64));
run.track = track::Producer::new(
std::sync::Arc::new(crate::broadcast::Info {
pool,
..Default::default()
}),
"video",
track::Info::default().with_timescale(None).with_max_age(None),
);
let dynamic = run.track.requests();
run.track.start_at(GROUPS).unwrap();
let mut live = run.track.create_group(group::Info { sequence: GROUPS }).unwrap();
live.write_frame(None, &payload[..]).unwrap();
let waiter = kio::Waiter::noop();
if outran {
// A reader judges the live edge cached and loses it before taking it.
let mut lost = run
.track
.subscribe(
track::Subscription::default()
.with_ranges([track::Range::groups(0..GROUPS + 1)])
.with_delay(track::Delay::default().with_max(None)),
)
.ordered();
assert!(lost.poll_next_group(&waiter).is_pending());
run.track.evict(GROUPS);
}

let subscriber = run.track.subscribe(
track::Subscription::default()
.with_ranges([track::Range::groups(0..GROUPS)])
.with_order(order)
.with_delay(track::Delay::default().with_max(None)),
);
type Read = Box<dyn FnMut(&kio::Waiter) -> Poll<crate::Result<Option<group::Consumer>>>>;
let mut reader: Read = match order {
track::Order::Ascending => {
let mut ordered = subscriber.ordered();
Box::new(move |waiter| ordered.poll_next_group(waiter))
}
track::Order::Descending => {
let mut subscriber = subscriber;
Box::new(move |waiter| subscriber.poll_recv_group(waiter))
}
};
assert!(reader(&waiter).is_pending(), "group 0 is a miss");
let fill = dynamic.requested_fill().await.expect("the reader asked for the run");
assert_eq!((fill.start().group, fill.end()), (0, GROUPS));
let slot = kio::Producer::new(GroupFetch::Ready(RangeFetch {
fill: std::sync::Arc::new(fill),
timescale: None,
first: 0,
last: GROUPS - 1,
start: 0,
end: None,
}));
let mut receiving = run.subscriber.clone();
let mut receive = std::pin::pin!(receiving.recv_group_fetch(&mut run.stream, slot));
let (mut read, mut received) = (Vec::new(), false);
for _ in 0..4 * GROUPS {
if !received && let Poll::Ready(res) = futures::poll!(&mut receive) {
res.expect("the run is received");
received = true;
}
match reader(&waiter) {
Poll::Ready(Ok(Some(group))) => read.push(group.sequence),
// What it lost is given up, which ends its range.
Poll::Ready(Ok(None)) => break,
Poll::Ready(Err(err)) => panic!("the reader failed: {err}"),
Poll::Pending if received => break,
Poll::Pending => {}
}
}
read
}

/// Once a reader of the track lost a group to eviction, a FETCH run writes its next group
/// only once a reader picked up the one before, leaving the stream unread meanwhile, so a
/// slow reader of a run far wider than the cache gets all of it. Until then the run moves
/// at the stream's speed and evicts what the reader has yet to take.
#[kio::test]
async fn a_fetch_run_waits_for_its_reader_once_one_lost_a_group() {
for order in [track::Order::Ascending, track::Order::Descending] {
let paced = read_a_fetch_run_slowly(true, order).await;
assert_eq!(paced, (0..40).collect::<Vec<_>>(), "{order:?}");
let unpaced = read_a_fetch_run_slowly(false, order).await;
assert!(
unpaced.len() < 40,
"the unpaced run outran its {order:?} reader: {unpaced:?}"
);
}
}

#[kio::test]
async fn internal_group_fetch_setup_cancellation_is_cancel() {
let mut run = GroupFetchRun::new(VERSION, Vec::new()).await;
Expand Down Expand Up @@ -17341,9 +17205,7 @@ mod stitch_tests {
tasks.0.clone(),
Default::default(),
);
// Through the subscriber's transport, so it pauses as a session's stream does where
// the session grants a receive window.
let stream = Stream::open(&subscriber.session, version).await.unwrap();
let (_, recv) = session.open_bi(Default::default()).await.unwrap();
let track = track::Producer::new(
std::sync::Arc::new(crate::broadcast::Info::default()),
"video",
Expand All @@ -17352,7 +17214,7 @@ mod stitch_tests {

Self {
subscriber,
stream: stream.reader,
stream: Reader::new(crate::transport::boxed::RecvStream::new(recv), version),
track,
_tasks: tasks,
}
Expand Down
14 changes: 0 additions & 14 deletions rs/moq-net/src/lite/test_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,6 @@ pub struct ScriptedSession {
groups: bool,
/// Set by [`Self::with_send_window`].
send_window: Option<usize>,
/// Set by [`Self::with_receive_window`].
receive_window: Option<crate::transport::ReceiveWindow>,
}

impl ScriptedSession {
Expand Down Expand Up @@ -1016,17 +1014,9 @@ impl ScriptedSession {
unacked_unis: Default::default(),
groups: false,
send_window: None,
receive_window: None,
}
}

/// Report `window` as the receive windows in force, so a stream the session stops reading
/// holds credit.
pub fn with_receive_window(mut self, window: crate::transport::ReceiveWindow) -> Self {
self.receive_window = Some(window);
self
}

/// Let each opened bidi stream send only its first `bytes`, then park its writes for good,
/// like a peer that never grants more send credit.
pub fn with_send_window(mut self, bytes: usize) -> Self {
Expand Down Expand Up @@ -1157,10 +1147,6 @@ impl poll::Session for ScriptedSession {
type RecvStream = ScriptedRecv;
type Error = SinkError;

fn receive_window(&self) -> Option<crate::transport::ReceiveWindow> {
self.receive_window
}

fn poll_accept_uni(&self, waiter: &kio::Waiter) -> Poll<Result<Self::RecvStream, Self::Error>> {
let Some(script) = self.incoming_unis.lock().unwrap().pop_front() else {
return self.log.poll_closed(waiter).map(Err);
Expand Down
11 changes: 0 additions & 11 deletions rs/moq-net/src/model/track/fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,17 +1060,6 @@ impl Fill {
.map(drop)
}

/// Poll until a run's next group may be written: at once until a reader of the track lost
/// a group to eviction, then as [`Self::poll_paced`]. An unpaced run moves at its source's
/// speed, which is fine while every reader keeps up.
#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))]
pub(crate) fn poll_run_paced(&self, waiter: &kio::Waiter) -> Poll<()> {
if self.inner.state.read().evictions == 0 {
return Poll::Ready(());
}
self.poll_paced(waiter)
}

/// Refuse every group still owed with `err`, which says nothing about whether the source
/// has them, so nothing is recorded dropped.
#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))]
Expand Down
Loading