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/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ moves what remains of them once their claims merge.
- [Routing guide](/quest/m1/routing-guide.md) - concepts and practical outbound federation setup
- [A reader on a failed copy continues on the held re-offer](/quest/m1/copy-recover.md) - a live reader keeps a group whose copy fails by continuing on the same track's re-offer at the same frame
- [Group errors are cached by kind](/quest/m1/group-error-cache.md) - permanent group errors bind every reader, retryable ones are kept only for a bounded time, and a live SUBSCRIBE_DROP or FETCH answered `Old` no longer caches it for good
- [A route answer behind its idle copy's cache fails the copy](/quest/m1/answer-behind-cache.md) - a resuming copy whose route answers behind its cache fails loud instead of refusing the feed's groups as duplicates, so readers resubscribe onto a fresh copy
- [The overcommitted receive-window cells run again](/quest/m1/receive-windows-evicted.md) - `benchmark_receive_windows` measures its 256-stream and 4 MiB-frame cells again, reporting delivered frames and evictions instead of stalling
- [Stream credit by priority](/quest/m1/stream-credit/README.md) - every stream opens through one priority entry point, and a higher-priority group takes over or resets a lower one when credit runs out
- [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - the playout target is default in both languages; time-stretched browser playback without steady-state underruns and a native trace replay remain
Expand Down
64 changes: 0 additions & 64 deletions quest/m1/answer-behind-cache.md

This file was deleted.

51 changes: 42 additions & 9 deletions rs/moq-net/src/ietf/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14446,7 +14446,7 @@ mod serve_tests {
IdleEnded,
/// An idle copy whose track ends after its newest group: that group's last object.
IdleFinished,
/// A live feed whose newest group was aborted mid-write: unknown.
/// A live feed whose newest group was aborted mid-write: the last object before it.
Aborted,
}

Expand Down Expand Up @@ -14512,7 +14512,7 @@ mod serve_tests {
)
.await;
match largest {
Largest::Finished | Largest::Live | Largest::IdleFinished => assert_eq!(
Largest::Finished | Largest::Live | Largest::IdleFinished | Largest::Aborted => assert_eq!(
fetch_refusal(buf, version),
INVALID_RANGE,
"{version} {largest:?} start={start}"
Expand Down Expand Up @@ -20551,13 +20551,14 @@ mod tests {
struct LiveEdge {
/// The newest group sequence, `None` before any group exists.
latest: Option<u64>,
/// The precise Largest Object. `None` when the track is empty, or when the newest
/// group's frames cannot be read right now (none written yet), in which case nothing
/// is advertised and no fill is servable.
/// The precise Largest Object: the newest object held, skipping a newest group whose
/// frames cannot be read. `None` when no object is held, in which case nothing is
/// advertised and no fill is servable.
largest: Option<Location>,
/// One past the Largest Object, which is where a Next Object subscription begins.
/// When the edge is imprecise this falls back to the next group boundary: never below
/// the true Next Object, at worst under-delivering the current group's tail.
/// Where a Next Object subscription begins: one past the Largest Object, or past a
/// newest group that cannot be read. When the edge is imprecise this falls back to the
/// next group boundary: never below the true Next Object, at worst under-delivering the
/// current group's tail.
next: Option<Location>,
}

Expand Down Expand Up @@ -20621,9 +20622,12 @@ fn cached_edge(track: &track::Consumer) -> LiveEdge {
next: Some(next),
}
}
// The newest group cannot be read, such as one aborted when this copy went idle, so
// the largest is the last object held before it, and nothing of the newest group
// can be served, so a subscription starts past it.
_ => LiveEdge {
latest: Some(latest),
largest: None,
largest: largest_before(track, latest),
next: Some(Location {
group: latest.saturating_add(1),
object: 0,
Expand Down Expand Up @@ -21177,6 +21181,35 @@ mod range_tests {
assert_eq!(edge.next, Some(Location { group: 0, object: 1 }));
}

/// A newest group that cannot be read, such as one aborted when an idle copy cancelled
/// it, leaves the last object held before it as the largest, while a subscription still
/// starts past it so nothing is stranded behind its floor.
#[test]
fn an_aborted_newest_group_leaves_the_earlier_largest() {
let track = track::Producer::new(
std::sync::Arc::new(crate::broadcast::Info::default()),
"video",
crate::track::Info::timed(),
);
let mut first = track.create_group(group::Info { sequence: 0 }).unwrap();
for _ in 0..2 {
first
.write_frame(crate::Timestamp::from_millis(0).unwrap(), b"frame".as_slice())
.unwrap();
}
first.finish().unwrap();
let mut newest = track.create_group(group::Info { sequence: 1 }).unwrap();
newest
.write_frame(crate::Timestamp::from_millis(0).unwrap(), b"frame".as_slice())
.unwrap();
newest.abort(Error::Cancel).unwrap();

let edge = live_edge(&track.consume());
assert_eq!(edge.latest, Some(1));
assert_eq!(edge.largest, Some(Location { group: 0, object: 1 }));
assert_eq!(edge.next, Some(Location { group: 2, object: 0 }));
}

/// Both ends carry through, object bounds included, so the boundary groups can be
/// trimmed rather than widened.
#[test]
Expand Down
9 changes: 7 additions & 2 deletions rs/moq-net/src/ietf/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4593,15 +4593,20 @@ impl SubscribeOnce {
// An absolute feed starts where it asked, whatever the answer's Largest; a
// live join's starts there.
let from = live.sent_bounds.0.filter(|_| !self.live);
match largest {
let answered = match largest {
// A feed ending before the answer's Largest never shows it, so the
// answer alone makes the copy current. A live join's feed is open.
Some(largest) if !self.live && live.sent_bounds.1.is_some_and(|end| end <= largest.group) => {
track.set_live_ahead(largest, from)
}
largest => track.set_live(largest, from),
}
};
live.resuming = None;
// An answer behind the copy's cache fails it.
if let Err(err) = answered {
tracing::warn!(%err, "subscribe ok behind the cache");
return Poll::Ready(ServeEnd::Invalid(err));
}
}
// The last subscriber left: the upstream subscription goes with it, as on
// lite, and the copy lingers for fetches and a returning subscriber.
Expand Down
8 changes: 5 additions & 3 deletions rs/moq-net/src/lite/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl TrackEntry {
self.start = self.start.or(start);
self.first = self.first.or(first);
if let (Some(start), Some(first), Some(copy)) = (self.start, self.first, &mut self.copy) {
copy.producer.set_live(Some(first), Some(start));
copy.producer.set_live_from(first, Some(start));
}
}
}
Expand Down Expand Up @@ -402,11 +402,11 @@ impl TrackEntry {
frame: hdr.frame_start,
};
if !version.has_track_stream() {
producer.set_live(Some(first), None);
producer.set_live_from(first, None);
} else if !version.has_largest() {
self.first = self.first.or(Some(first));
if let (Some(start), Some(first)) = (self.start, self.first) {
producer.set_live(Some(first), Some(start));
producer.set_live_from(first, Some(start));
}
}
}
Expand Down Expand Up @@ -11712,10 +11712,12 @@ impl ServeLoop {
} else if serve.subscriber.version.has_largest() {
// A bounded feed that never delivers Largest goes live at the
// answer alone; one that does waits for it to show.
// An answer behind the copy's cache fails it.
match active.never_serves(start.largest) {
Some(largest) => self.serving.set_live_ahead(largest, served),
None => self.serving.set_live(start.largest, served),
}
.inspect_err(|err| tracing::warn!(track = %serve.name, %err, "subscribe start behind the cache"))?;
if let Some(largest) = start.largest {
self.serving.report_largest(largest);
}
Expand Down
10 changes: 10 additions & 0 deletions rs/moq-net/src/model/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2591,6 +2591,16 @@ impl Handle {
self.state.read().next_index
}

/// The newest object's ID, by its moq-transport object ID when the group carries one,
/// else its frame index; `None` before the first frame.
pub(crate) fn last_object(&self) -> Option<u64> {
let state = self.state.read();
match state.wire() {
Some(wire) => wire.last,
None => (state.next_index as u64).checked_sub(1),
}
}

/// Cap the group at `frames`, for a track end inside it, or lift the cap with `None`:
/// later writes past the cap are [`Error::Closed`]. A frame already at or past the cap is
/// [`Error::ProtocolViolation`]. An aborted group gets no more frames, so it takes no cap.
Expand Down
Loading
Loading