Skip to content
Merged
6 changes: 1 addition & 5 deletions quest/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## Goal

Make the origin's failover a state machine with a runtime-free test per
transition, the correctness core of the relay. Alongside it, settle the public contracts of `moq-archive`, `moq-e2ee`, `moq-sock`,
Settle the public contracts of `moq-archive`, `moq-e2ee`, `moq-sock`,
`moq-uring`, `moq-audio`, `moq-video`, `moq-transcode`, and `moq-nvenc`
before the imminent release, while supplying the reusable GPU media support
needed to remove raw-pixel CPU transfers from the Pronto CARLA demo. These are
Expand Down Expand Up @@ -90,9 +89,6 @@ do not add another media abstraction or a renderer crate during stabilization.
## Quests

- [Binding parity](/quest/main/binding-parity.md) - every wrapper reaches every moq-ffi method in its own idiom with moq-net's verbs
- [Origin failover machine](/quest/main/origin-failover-machine.md) - a front's
source selection and track splicing become a pure step function with a
runtime-free test per transition

## Related

Expand Down
101 changes: 0 additions & 101 deletions quest/main/origin-failover-machine.md

This file was deleted.

25 changes: 14 additions & 11 deletions rs/moq-net/benches/origin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SHAPES: [(usize, usize); 3] = [(100, 10), (1_000, 100), (1_000, 1_000)];
struct Fanout {
producer: origin::Producer,
consumer: origin::Consumer,
_driver: origin::Driver,
driver: origin::Driver,
_publishers: Vec<broadcast::Producer>,
subscribers: Vec<announce::Consumer>,
}
Expand All @@ -44,7 +44,7 @@ fn fanout(publishers: usize, subscribers: usize) -> Fanout {
Fanout {
producer,
consumer,
_driver: driver,
driver,
_publishers: publishers,
subscribers,
}
Expand Down Expand Up @@ -165,24 +165,27 @@ fn bench_subscribe(c: &mut Criterion) {
group.finish();
}

/// Resolving one broadcast among `publishers`: a local hit walks the tree to
/// the exact path, and a miss under an advertise-only route walks the route
/// table to prove nothing serves it. Neither may depend on `publishers`.
/// Resolving one broadcast among `publishers`: a local hit walks the table to
/// the exact path and joins the front serving it, and a miss under a broadcast
/// published above it walks the table to prove nothing serves it. Neither may
/// depend on `publishers`.
fn bench_request(c: &mut Criterion) {
let mut group = c.benchmark_group("origin/request");
// A request costs nothing per subscriber, so this sweeps the publisher counts
// in `SHAPES` rather than its shapes, whose last two share one.
for publishers in [100, 1_000] {
let fleet = fanout(publishers, 0);
// An advertise-only route above the misses: it covers them without serving them.
let mut fleet = fanout(publishers, 0);
// A broadcast above the misses covers them without serving them.
let _covering = fleet.producer.publish("room", origin::Route::default()).unwrap();
let waiter = kio::Waiter::noop();
group.bench_function(BenchmarkId::new("local", publishers), |b| {
b.iter(|| {
fleet
.consumer
.request_broadcast("room/0")
let pending = fleet.consumer.request_broadcast("room/0");
// The front's driver resolves the first request; later ones join it.
fleet.driver.poll(moq_net::time::Instant::now(), &waiter).unwrap();
pending
.now_or_never()
.expect("local resolves synchronously")
.expect("resolves once driven")
.expect("local broadcast");
});
});
Expand Down
5 changes: 3 additions & 2 deletions rs/moq-net/src/ietf/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl TrackState {
/// the broadcast now or holds it open for a replacement.
///
/// Only the detach that drops the refcount to zero decides, matching the model's rule
/// for several sources at one path (`detach_source`): an earlier owner that vanished
/// for several sources at one path (the front's source selection): an earlier owner that vanished
/// does not outvote the last one still on the path. That keeps two advertisements on
/// one session behaving like the same two on separate sessions, where the model sees
/// two independent sources and the last one out decides.
Expand Down Expand Up @@ -4220,7 +4220,8 @@ mod tests {
/// is the one that counts: the broadcast survives the first stop and closes on the
/// last, whatever kind each detach is.
///
/// That is the model's own rule for several sources at one path (`detach_source`),
/// That is the model's own rule for several sources at one path (the front's source
/// selection),
/// which is what these advertisements would be had they arrived on two sessions. The
/// refcount is a detail of sharing one `SourceGuard` per session; it must not change
/// what the origin sees.
Expand Down
15 changes: 6 additions & 9 deletions rs/moq-net/src/lite/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2121,11 +2121,7 @@ mod tests {
// The peer's own subscription, excluding the hop the server minted for
// it, is served from the local front before anything is announced back.
let peer = origin.consume().excluding(assigned);
let resolved = peer
.request_broadcast("room/host")
.now_or_never()
.expect("local lookup is synchronous")
.expect("resolves");
let resolved = peer.request_broadcast("room/host").await.expect("resolves");
let mut sub = resolved
.track("video")
.unwrap()
Expand Down Expand Up @@ -2166,10 +2162,11 @@ mod tests {
.unwrap();
assert!(!accepted, "an announce that already names this origin must be dropped");

// The local front is still the one at the path, and still serving.
let still = origin
.consume()
.get_broadcast("room/host")
// The local front is still the one at the path, and still serving: the
// peer's next request joins it rather than minting another.
let still = peer
.request_broadcast("room/host")
.await
.expect("the local front keeps serving");
assert!(
still.is_clone(&resolved),
Expand Down
12 changes: 6 additions & 6 deletions rs/moq-net/src/model/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,19 +524,19 @@ impl Alive {
})
}

/// Retract the path's advertisement, if any.
/// Withdraw the path's advertisement, if any; the broadcast stays servable.
fn unannounce(&self) {
let announcement = self.announcer.lock().as_mut().and_then(Announcer::take);
// Retracted outside the announcer lock: the retraction re-syncs the origin's
// announce cursors under the origin's own lock.
drop(announcement);
if let Some(announcer) = self.announcer.lock().as_mut() {
announcer.withdraw();
}
}

/// End the broadcast's advertising for good: retract the standing advertisement
/// and drop the announcer, so a later `announce` fails with `Closed`.
fn retire(&self) {
let announcer = self.announcer.lock().take();
// Dropped outside the announcer lock, like `unannounce`.
// Dropped outside the announcer lock: the entry's removal re-syncs the
// origin's cursors under the origin's own lock.
drop(announcer);
}
}
Expand Down
Loading
Loading