Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d195c4c
chore(quest): claim quest/m1/release-perf/relay-cpu-bisect.md
kixelated Nov 4, 2026
92b8778
perf(moq-net): walk the live groups through one branch, not a chain
kixelated Nov 4, 2026
c18d11f
docs(bench): attribute the ranged reads' session cost on main
kixelated Nov 4, 2026
428ce1f
fix(bench): keep each revision's checkout so a later run reuses its b…
kixelated Nov 4, 2026
df10b0b
docs(quest): accept the ranged reads' remaining session cost
kixelated Nov 4, 2026
35c904d
docs(bench): attribute qmux, receive leases, and public ingest on the…
kixelated Nov 5, 2026
1081d6a
Merge remote-tracking branch 'origin/main' into t3/34eac047
kixelated Nov 5, 2026
45351ac
Merge remote-tracking branch 'origin/main' into t3/0bd14698
kixelated Nov 5, 2026
c6753bd
perf(net)!: a live read skips the reader's budget and an empty drop r…
kixelated Nov 5, 2026
f2d552c
perf(net): a group read serves its prefetch first; a post-receive dro…
kixelated Nov 5, 2026
978f09a
docs(bench): finish the relay CPU bisect: public ingest's live read a…
kixelated Nov 5, 2026
8fa7235
style(net): rustfmt the drop poll and frame expiry
kixelated Nov 5, 2026
041808e
Merge remote-tracking branch 'origin/main' into t3/0bd14698
kixelated Nov 5, 2026
9b9f214
fix(net)!: keep batch APIs private and merge main
kixelated Nov 5, 2026
bbdb30d
docs(bench): distinguish historical frame batch measurements
kixelated Nov 5, 2026
531c52d
fix(net): retain private batch buffer emptiness check
kixelated Nov 5, 2026
b253b76
docs(bench): record relay object batch baseline
kixelated Nov 5, 2026
32cd099
style(bench): terminate evidence JSON with newline
kixelated Nov 5, 2026
9230042
fix(bench): distinguish relay object batch benchmark IDs
kixelated Nov 5, 2026
8a13e4d
fix(net): a drop poll still lets go of a replaced copy
kixelated Nov 5, 2026
f469f75
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 5, 2026
ba49776
Merge origin/main into relay-cpu-bisect
kixelated Nov 5, 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
2,903 changes: 2,843 additions & 60 deletions .github/relay-cpu-bisect.json

Large diffs are not rendered by default.

119 changes: 104 additions & 15 deletions .github/relay-cpu-bisect.md

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ The relay and generator keep these affinities for every revision. Instructions
mode runs alone.

Each base builds into its own target under `target/bench/revisions/<sha>`,
from a detached worktree in `.tmp/` that the run removes when it exits, so a
later run reuses that build. The revisions build side by side on every allowed
from a detached worktree at `.tmp/bench-revisions/<sha>` that later runs keep
using, so a later run reuses that build without a compiler cache. The revisions build side by side on every allowed
CPU, since fat LTO links on one thread, `BENCH_BUILD_JOBS` (default 4) at a
time: each link takes gigabytes, so lower it on a host with little memory.
Every round measures each base and the
Expand Down Expand Up @@ -424,7 +424,8 @@ nix develop --command just bench-fanout "cdff3c8f95 21d6da9fc1"
nix develop --command just bench-fanout "" "model" "1 512"
```

Two scenarios run every subscriber count on one thread:
Each scenario runs every subscriber count on one thread. `model` and `session`
run by default:

- `model`: one finished group a cycle through the track model, which every
subscriber takes before parking again, as moq-net's `track_fanout_group`
Expand All @@ -435,6 +436,11 @@ Two scenarios run every subscriber count on one thread:
runtime. It counts the publisher, relay, and viewer sessions together, but no
QUIC: in-tree qmux, receive leases, and crypto only show in relay counts. A
revision whose session API predates this harness reports it unsupported.
- `group`, on request: every subscriber drains one finished 512-frame group in
object batches through the relay's private reader, as moq-net's
`group_relay_objects/plain/512/*` bench does, so that bench's cost is counted
without its wall-clock noise. Revisions before the hidden `ObjectBatch` helper
report unsupported; historical frame-batch counts remain in the bisect report.

Each `bench/fanout/<scenario>` crate builds against each base's and the current
tree's own crates and lock, `BENCH_BUILD_JOBS` at a time, into
Expand Down
5 changes: 3 additions & 2 deletions bench/fanout.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
from pathlib import Path

# Group deliveries per measurement: subscribers times cycles, so every subscriber count
# runs about as long. The session harness costs about ten times the model's per group.
UNITS = {"model": 1_000_000, "session": 100_000}
# runs about as long. The session harness costs about ten times the model's per group, and
# the group harness's 512-frame groups about five hundred times.
UNITS = {"model": 1_000_000, "session": 100_000, "group": 2_000}


def cycles(scenario, subscribers):
Expand Down
18 changes: 18 additions & 0 deletions bench/fanout/group/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Built by `bench/run.sh --fanout` against each revision's moq-net, outside the workspace,
# so a historical checkout measures the same scenario. Its own lock is that revision's.
[package]
name = "fanout-group"
version = "0.0.0"
edition = "2024"
publish = false

[workspace]

[dependencies]
kio = { path = "../../../rs/kio" }
moq-net = { path = "../../../rs/moq-net", features = ["fuzz"] }

[profile.release]
codegen-units = 1
debug = "line-tables-only"
lto = "fat"
31 changes: 31 additions & 0 deletions bench/fanout/group/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//! A relay's frame fan-out: every subscriber drains one finished 512-frame group in batches,
//! as moq-net's `group_relay_objects/plain/512/*` bench does.
//! Usage: `fanout-group SUBSCRIBERS CYCLES`. The work is deterministic, so its retired
//! instructions, less a run of zero cycles, are the per-group cost whatever the host does.
use std::task::Poll;

const FRAMES: usize = 512;

fn main() {
let mut args = std::env::args().skip(1).map(|a| a.parse::<usize>().unwrap());
let (subscribers, cycles) = (args.next().unwrap(), args.next().unwrap());
let (broadcast, track, group) = moq_net::fuzz::object_group(FRAMES, false);
let mut buffer = moq_net::fuzz::ObjectBatch::<16>::new();
for _ in 0..cycles {
for _ in 0..subscribers {
let mut reader = group.consume();
loop {
let Poll::Ready(count) = buffer.poll_read(&kio::Waiter::noop(), &mut reader) else {
panic!("finished group blocked")
};
if count.unwrap() == 0 {
break;
}
buffer.inspect();
}
}
}
// Left standing, so teardown stays out of the count.
std::mem::forget((broadcast, track, group));
std::process::exit(0);
}
24 changes: 14 additions & 10 deletions bench/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ case $MODE in
FANOUT_SCENARIOS=${BENCH_FANOUT_SCENARIOS:-model session}
FANOUT_SUBSCRIBERS=${BENCH_FANOUT_SUBSCRIBERS:-1 64 512}
for value in $FANOUT_SCENARIOS; do
if [[ ! $value =~ ^(model|session)$ ]]; then
printf 'unknown fan-out scenario %q; expected model or session\n' "$value" >&2
if [[ ! $value =~ ^(model|session|group)$ ]]; then
printf 'unknown fan-out scenario %q; expected model, session, or group\n' "$value" >&2
exit 1
fi
done
Expand Down Expand Up @@ -976,15 +976,19 @@ run_queued_builds() {
done
}

# Check out one revision for this run, in the checkout's ignored scratch space,
# where it loads only its own Cargo configuration. Its target persists, keyed by
# revision; the compiler cache keys on remapped paths, so a fresh checkout reuses it.
# Check out one revision in the checkout's ignored scratch space, where it loads
# only its own Cargo configuration. Both the checkout and its target persist,
# keyed by revision: a fresh checkout's new mtimes would rebuild every workspace
# crate on a host without a compiler cache.
revision_checkout() {
local sha=$1 label=$2 worktree
mkdir -p "$ROOT/.tmp"
worktree=$(mktemp -d "$ROOT/.tmp/moq-bench-base.XXXXXX")
WORKTREES+=("$worktree")
git worktree add --detach "$worktree" "$sha" >/dev/null
local sha=$1 label=$2 worktree=$ROOT/.tmp/bench-revisions/$1
if [[ ! -f $worktree/.git || $(git -C "$worktree" rev-parse HEAD 2>/dev/null) != "$sha" ]] ||
[[ -n $(git -C "$worktree" status --porcelain 2>/dev/null) ]]; then
git worktree remove --force "$worktree" >/dev/null 2>&1 || rm -rf "$worktree"
git worktree prune
mkdir -p "$ROOT/.tmp/bench-revisions"
git worktree add --detach "$worktree" "$sha" >/dev/null
fi
mkdir -p "$RUN/base-context/$label"
(cd "$worktree" && python3 "$ROOT/bench/metadata.py" "$RUN/base-context/$label" "$sha" --profile)
REVISION_CHECKOUT=$worktree
Expand Down
45 changes: 41 additions & 4 deletions quest/m1/release-perf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,47 @@ The first four were counted with frame pointers forced and the last two
without, so compare each only with its own parent. None grows with
subscribers.

## Required

- [Relay CPU per frame since #5926](/quest/m1/release-perf/relay-cpu-bisect.md) - the 18-56% rise in relay instructions per delivered frame is bisected, attributed, and its avoidable cost fixed
- [Pacing's per-frame report](/quest/m1/release-perf/pacing-report.md) - relay fan-out reads with pacing are within noise of the pre-pacing parent
Re-measured on `main` with the probe fast path, as that decision asked, and
accepted under it (see the
[report](/.github/relay-cpu-bisect.md#the-ranged-reads-session-cost-on-main)),
per delivered group at 512 subscribers through the in-process session:

- Filling linearly in range count and span
([moq-dev/moq#6995](https://github.com/moq-dev/moq/pull/6995)): +3,288
when it landed, mostly the live index's walk, which the drift edge reads on
every poll. The fast path never reached it; walking it through one branch
took back 891 (session) and 270 (model). What remains looks up the live
groups apart from fetched backfill, which keeps backfill out of every
search for live content.
- Layered windows
([moq-dev/moq#7542](https://github.com/moq-dev/moq/pull/7542)): +3,049
when it landed, the window queries `runs::Layered::first` and `last`. They
cost 2,117 on `main`, about 40 queries per delivery at about 50
instructions each: per-reader windows answered by search, not a walk.

In-tree qmux ([moq-dev/moq#6231](https://github.com/moq-dev/moq/pull/6231))
and receive leases ([moq-dev/moq#5878](https://github.com/moq-dev/moq/pull/5878))
add no measurable relay cost on chat over io\_uring, each against its parent
on the quiet test host, so neither needs accepting.

Public ingest ([moq-dev/moq#6111](https://github.com/moq-dev/moq/pull/6111))
cost the relay +10.5k per frame on chat over io\_uring, far above the model's
+200, because each viewer's read now reaches a group before its first frame.
Decided 2026-11-05 (maintainer): cut what a live read pays for nothing.
[moq-dev/moq#7874](https://github.com/moq-dev/moq/pull/7874) took 3,729 per
delivered group off the in-process session at 512 subscribers (110,581 to
106,852, -3.4%): a blocked read asks the reader's budget only once a group
landed above it, and the forward-drop poll skips judging copies with nothing
to report and re-probing right after a receive. What remains of each viewer's
live read is accepted, per delivered group through the session (see the
[report](/.github/relay-cpu-bisect.md#public-ingests-per-viewer-read-on-main)):

- The forward-drop poll's probe, about 3.5k over three polls a group, and the
receive's, about 3.5k over three: each wake of the track side checks for
groups the reader missed before taking or parking.
- The expiry checks of a read blocked before its group's first frame and of a
group waiting for stream credit, 0.9k: each parks on the next landing so a
stalled group expires.

## Related

Expand Down
22 changes: 0 additions & 22 deletions quest/m1/release-perf/pacing-report.md

This file was deleted.

61 changes: 0 additions & 61 deletions quest/m1/release-perf/relay-cpu-bisect.md

This file was deleted.

2 changes: 1 addition & 1 deletion rs/moq-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ required-features = ["fuzz"]
[[bench]]
name = "group"
harness = false
required-features = ["async"]
required-features = ["fuzz"]

[[bench]]
name = "track"
Expand Down
5 changes: 5 additions & 0 deletions rs/moq-net/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ How to update your code for each breaking change, newest first.

## Unreleased

### Group batch operations and `poll_next_frame` are crate-private ([#7874](https://github.com/moq-dev/moq/pull/7874))

Read a frame in chunks with the async `group::Consumer::next_frame`, or read whole frames with `poll_read_frame` from a poll loop.
`group::Consumer::{read_frames, poll_read_frames, keep_alive}`, `frame::Buffer`, and `group::Producer::write_frames` are now crate-private. Replace batch reads with repeated `read_frame` or `poll_read_frame` calls, and batch writes with `write_frame`. Cache access is refreshed by those reads.

### Readers at a shed frame ask a `track::Requests` handler for a flight ([#7944](https://github.com/moq-dev/moq/pull/7944))

A reader that reaches a frame its group copy shed no longer gets `Error::Evicted` when the track has a live `track::Requests` handle: the handler receives a `Fill` of that one group from that frame (`Fill::start`), or from frame 0 on a compressed track, even though the group is still cached and live.
Expand Down
Loading
Loading