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
3 changes: 2 additions & 1 deletion doc/concept/stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ release costs only that route.

`routes` counts what the label's moq-lite-07 sessions did on the route layer,
each under the label of the session whose peer caused it. Its size never
depends on how many broadcasts or relays the mesh has. When rolling a mesh onto
depends on how many broadcasts or relays the mesh has, and a label with nothing
counted leaves it out, which readers read as zeros. When rolling a mesh onto
a new release one relay at a time, compare a canary's rates with its
neighbours':

Expand Down
2 changes: 2 additions & 0 deletions js/stats/src/stats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ test("a frame names each counter once and a missing counter reads zero", () => {
expect(PresenceSchema.parse({ sessions_started: 4, sessions_ended: 2 })).toMatchObject({
sessions_started: 4,
sessions_ended: 2,
// A label that never routed sends no `routes`.
routes: { changed: 0, closed: { other: 0 } },
});
// The pre-rename spellings are neither read nor kept.
expect(PresenceSchema.parse({ sessions: 4, sessions_closed: 2 })).toMatchObject({
Expand Down
29 changes: 0 additions & 29 deletions quest/m0/nightly/shared-bench-regressions.md

This file was deleted.

2 changes: 1 addition & 1 deletion rs/kio/src/waiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Waiter {

/// Whether this is a [`noop`](Self::noop) waiter.
#[inline]
pub(crate) fn is_noop(&self) -> bool {
pub fn is_noop(&self) -> bool {
self.noop
}

Expand Down
18 changes: 18 additions & 0 deletions rs/moq-net/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,8 @@ pub struct Presence {
/// [`Routes::refused`].
pub routes_refused: u64,
/// What the label's lite-07 sessions did on the route layer.
// Most labels never route, so an all-zero readout stays off the wire; readers default it.
#[serde(skip_serializing_if = "Routes::is_zero")]
pub routes: Routes,
}

Expand Down Expand Up @@ -2319,6 +2321,22 @@ mod tests {
assert_eq!(output["wire_rx"], 29);
}

/// A label that never routed writes no `routes` and reads back as zeros, and one count
/// writes the whole readout.
#[test]
fn presence_routes_stay_off_the_wire_until_counted() {
let mut presence = Presence::default();
let output = serde_json::to_value(presence).unwrap();
assert!(output.get("routes").is_none(), "{output}");
assert_eq!(serde_json::from_value::<Presence>(output).unwrap(), presence);

presence.routes.closed.other = 1;
let output = serde_json::to_value(presence).unwrap();
assert_eq!(output["routes"]["closed"]["other"], 1);
assert_eq!(output["routes"]["changed"], 0);
assert_eq!(serde_json::from_value::<Presence>(output).unwrap(), presence);
}

#[test]
fn outcomes_survive_clones_tier_changes_and_pruning() {
let stats = test_stats();
Expand Down
5 changes: 5 additions & 0 deletions rs/moq-net/src/stats/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ pub struct Routes {
}

impl Routes {
/// Whether nothing has been counted.
pub(crate) fn is_zero(&self) -> bool {
*self == Self::default()
}

/// Add every counter from another readout.
pub fn add(&mut self, other: Self) {
self.changed += other.changed;
Expand Down
9 changes: 4 additions & 5 deletions rs/moq-quic/src/connection/waits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ pub(crate) struct Waits {
impl Waits {
/// Register `waiter` for `wait` on stream `id`
pub(crate) fn register(&mut self, id: StreamId, wait: Wait, waiter: &Waiter) {
let waits = self.streams.entry(id).or_default();
waiter.register(waits.list(wait));
// A no-op waiter registers nothing, so a poll for the answer alone keeps no entry.
if waits.is_empty() {
self.streams.remove(&id);
// A no-op waiter registers nothing, so a poll for the answer alone costs no entry.
if waiter.is_noop() {
return;
}
waiter.register(self.streams.entry(id).or_default().list(wait));
}

/// Wake the waiters for `wait` on stream `id`
Expand Down