diff --git a/quest/m1/README.md b/quest/m1/README.md
index 81f1f845876..0c269c669a9 100644
--- a/quest/m1/README.md
+++ b/quest/m1/README.md
@@ -170,7 +170,6 @@ tracks, so per-group stats stop costing cluster announces.
- [Caption store bounds](/quest/m1/caption-store-bounds.md) - a hostile caption track cannot grow a viewer's cue and region store or its per-frame work without bound
- [Auth contract](/quest/m1/auth-contract.md) - the auth server receives the certificate-selecting SNI, documented as client-chosen, and a certificate grants nothing alone
- [Nightly benchmark regressions](/quest/m1/bench-ci.md) - each nightly compares the Rust Criterion benches against the previous nightly's commit on the same hosted runner, publishes it to the git.moq.dev report, and alerts on a regression
-- [Performance audit](/quest/m1/audit-perf.md) - benchmarks that regressed since the m0 run are explained, fixed, or planned, and unbenched hot paths get coverage
- [Interop audit](/quest/m1/audit-interop.md) - our interop runner entries match what we ship, and every red interop cell with a moq.dev side is fixed, reported, or noted as down
## Related
diff --git a/quest/m1/audit-perf.md b/quest/m1/audit-perf.md
deleted file mode 100644
index f92204570c1..00000000000
--- a/quest/m1/audit-perf.md
+++ /dev/null
@@ -1,146 +0,0 @@
-# [M] Performance audit
-
-## Goal
-
-Every benchmark that regressed since the previous run is explained, fixed, or
-planned, and every hot or fan-out path without a benchmark gets one or a
-follow-up.
-
-## Plan
-
-Recurs once per major release (decided 2026-10-19). The PR that finishes
-this run also adds the next one with the same file name at the end of the next
-milestone's `Required` (m0 to m1, m1 to m2). The successor keeps the Goal
-and this paragraph; the rest of its Plan is rewritten with what this run
-learned: baselines, results, and what to check first. A successor placed in m2
-also lists the [release cut](/quest/m2/release/cut.md) under `Required`, so it
-waits for the release in flight to ship. Only `/quest-delete` ends the
-recurrence. Fixes land in the run's PR, one commit each, rather than as follow-ups.
-Only a change that needs a maintainer decision (public API, scope) or is
-independently landable and too large to review alongside the rest becomes a
-follow-up through `/quest-plan`.
-
-### What to check first
-
-- History: Nightly stores every series on `gh-pages` (`bench/costs`,
- `bench/rates`), and flags each series that moved
- beyond its own noise. The m0 run had only three Rust nights (Oct 18 to 20)
- and no JS history. Compare at least five nights; a series that steps and
- stays there is a regression to attribute. Re-runs of the Benchmark site job
- add duplicate points for one commit, so compare by commit.
-- Bindings: the m0 run found no binding regression across five nights of
- `bench-ffi`; Kotlin and Python swing 10-40% between nights. Dart had only two
- nights, so recheck it against the history.
-- JS: the m0 run restored the JS leg (about 3 minutes) and scheduled every JS
- bench, checked by `test_every_js_bench_runs_nightly` in
- `sh/gh/nightly.test.py`. Its first history starts after that run's PR.
-
-### Method: attribute with instruction counts, not wall time
-
-The m0 host ran at load 20-60, where Criterion intervals spanned +/-50% and a
-wall-clock bisect blamed the wrong commit. Count instructions instead:
-
-- Build the bench at each commit in a scratch worktree with
- `CARGO_PROFILE_BENCH_STRIP=none` and `CARGO_PROFILE_BENCH_DEBUG=line-tables-only`.
- Touch the sources first, since worktrees sharing one target dir otherwise reuse
- a stale build.
-- Wrap the timed routine in a `#[inline(never)] fn profiled_inner` that prints a
- marker after each call, run
- `valgrind --tool=callgrind --toggle-collect='*profiled_inner*' --bench --profile-time 5 --exact `,
- and divide the collected instructions by the marker count. Pass `--bench`, or
- Criterion runs one test iteration. Run-to-run spread is about 0.5%.
-- For a loop with no Criterion fixture, a scratch example run at two iteration
- counts gives instructions per iteration from the difference.
-- A bench that is not CPU-bound is not attributable this way:
- `relay_auth_refresh` runs real loopback sockets with 10 samples of 300 ms,
- and moved +27-60% on CI with +0.4% instructions.
-
-### Baselines (m0 run, instructions per iteration)
-
-| Bench | Oct 19 `ad87ad34e` | Oct 20 `f13283b30` | main `4327505086` | m0 PR |
-|---|---|---|---|---|
-| `track_subscriber_join` loop | 3,318 | 6,950 | 7,135 | 4,492 |
-| `annexb-export-frames/1tracks-16frames/256` | 370k | 460k | 492k | 484k |
-| `cmaf-export-frames/4tracks-16frames/4096` | 7.75M | 8.08M | 8.21M | 8.18M |
-| `catalog_estimate_fanout/hang/tracks_4/4` | 94.5M | 97.4M | ~106M | ~106M |
-| `relay_auth_refresh/16/16` | 291.7k | 292.7k | 292.6k | 292.8k |
-
-### Open regressions from the m0 run
-
-The m0 run attributed these, but none has a fix yet. Fix each in this run's PR
-with its own regression bench, unless it needs a maintainer decision or is too
-large to review alongside the rest; those become `/quest-plan` follow-ups:
-
-1. Export reap goes quadratic,
- [#5942](https://github.com/moq-dev/moq/pull/5942) (`49448d2ef`), +42k on
- Annex B export. The lookahead no longer decodes groups ahead of the cursor,
- so on every `poll_event` the reap of aborted groups in
- `rs/moq-mux/src/container/consumer.rs` now calls `group::Consumer::poll_finished`
- on every unbuffered pending group: about 1,070 calls per 16-frame export, so
- frames x pending groups. Recommendation: reap only where an abort can block
- delivery (a hole at the cursor, or before parking), and add an export bench
- swept over buffered groups so the slope shows.
-2. [#6019](https://github.com/moq-dev/moq/pull/6019) (`9f1fc92fe`), reading lower
- buffered groups across route copies, adds +27k to Annex B export, of which
- +12k is `memcpy`: larger values move through the resume read path.
- Recommendation: profile `resume::Reader` and `track::Subscriber::poll_group`
- for by-value moves of the cursor state.
-3. `catalog_estimate_fanout` +5% at [#5677](https://github.com/moq-dev/moq/pull/5677)
- (`ad54a9721`, data consumers return timestamps, which reworked the moq-flate
- snapshot consumer), and +4% across `fc0df978c` and `4327505086`
- ([#6074](https://github.com/moq-dev/moq/pull/6074) time anchors,
- [#5543](https://github.com/moq-dev/moq/pull/5543) VR catalog metadata).
- Bisect the second pair first, and treat a larger catalog as intended.
-4. `annexb` export also gained +9k in `c389bd051`..`eb6ac57cb` and +10k in
- `75d9bf1c0`..`dcd7d2cbb`, and +27k at `fe722cec9` (#5929), of which the m0 PR recovered 8.5k; attribute the rest only if it persists.
-5. The subscribe path's remaining ~1,260 instructions over pre-#5929 stay:
- an inline single-range window ([#6241](https://github.com/moq-dev/moq/pull/6241))
- removed three allocations but regressed join time about 6%, so it was
- dropped (maintainer, 2026-10-22).
-
-### Unbenchmarked hot and fan-out paths, ranked
-
-Each needs a bench, swept over both axes where it fans out, or its own
-follow-up quest:
-
-1. [HLS request fan-out](/quest/m2/performance-survey/hls-serving.md) owns
- repeated segment fetch/remux and playlist rendering, swept over viewers,
- renditions and window segments.
-2. [Session datagrams](/quest/m2/performance-survey/datagram-delivery.md) owns
- complete adapter delivery across publishers and viewers.
-3. LOC and CMAF wire containers in moq-mux: `containers` and `export` only use
- `Container::Legacy`; sweep container x frame size x frames.
-4. [Buffered browser groups](/quest/m2/performance-survey/hang-buffered.md)
- owns per-frame scans and bulk skip work in the Hang consumer.
-5. [Browser media copies](/quest/m2/performance-survey/browser-media-copies.md)
- owns CMAF sample copies and LOC encode allocation. Generic `js/msf` and
- `js/flate` benchmark coverage remains here.
-6. moq-quic loss recovery and real congestion controllers: every bench pins
- `Unlimited`; sweep controller x flight x loss x streams.
-7. [Announcement snapshots](/quest/m2/performance-survey/announced-snapshots.md)
- owns HTTP snapshot/rendering costs across routes and pollers.
-8. [JWT verification](/quest/m2/performance-survey/jwt-verification.md) owns
- key-source I/O, import, lookup, parsing and crypto attribution.
-9. MPEG-TS import with real repeated media (the CLI bench mostly skips null
- padding), and MKV, FLV, H.265, AV1 importers.
-10. JS watch audio ring buffer and publish `Fanout` (lower impact). Include
- capture-to-encoder staging: `audio/framer.ts` copies planes before
- `audio/encoder.ts` joins them. AudioData already uses a transfer list;
- do not count that transfer as another mandatory copy. Sweep publishers
- x renditions, channels and frame duration in a browser.
-
-The [2026-10-22 source survey](/quest/m2/performance-survey/README.md) owns
-the extracted items above and additional algorithmic hypotheses, with paired
-benchmarks required before optimization. This audit still owns nightly
-regression attribution and the remaining coverage; the source survey does not
-complete this run. Its fragmented-MKV child specializes item 9's MKV work.
-
-Single-axis fan-out benches to widen: `session_delivery_paced` (viewers only),
-`track_fanout_*` (subscribers only), `memory` (lite-06 only), and
-`bench/workloads/fanout*.toml` (connections only).
-
-Fan-out paths need a sweep over both axes (AGENTS.md). JS perf is judged in a
-browser, not node or bun. Benchmarks never gate the merge queue (decided
-2026-10-20, maintainer): each Nightly compares them into the git.moq.dev
-report, which the [nightly benchmark regression report](/quest/m1/bench-ci.md)
-owns; don't duplicate it.
diff --git a/quest/m1/bench-ci.md b/quest/m1/bench-ci.md
index fdccc605e10..22eaa6dd3db 100644
--- a/quest/m1/bench-ci.md
+++ b/quest/m1/bench-ci.md
@@ -20,7 +20,7 @@ merge, and main PRs skip cloud CI since #6038. This drops the per-PR sticky
comment design and its `workflow_run` follow-up.
Decided 2026-10-22 (maintainer): the paired run stays on the hosted ARM
-runners. Moved from m2 to m1 so the m1 [performance audit](/quest/m1/audit-perf.md)
+runners. Moved from m2 to m1 so the [performance audit](/quest/m2/audit-perf.md)
reads paired flags instead of raw history. Rejected hosts:
- The merge queue runner (`nixos-moq-ci`) is an nspawn container on a
diff --git a/quest/m1/release-audit/README.md b/quest/m1/release-audit/README.md
index 7a5bccd119b..5f2dbda1c34 100644
--- a/quest/m1/release-audit/README.md
+++ b/quest/m1/release-audit/README.md
@@ -123,7 +123,7 @@ child records whether its behavior is new on main or inherited from release.
- [Compressed tracks](/quest/m1/compress/README.md) - mid-group widening and application migration have existing owners
- [Archive consumer](/quest/m1/archive/consumer.md) - current producer and CLI reader still need the new-format roundtrip
- [Measured release performance](/quest/m1/release-perf/README.md) - existing paired benchmark regressions and their confirmation runs
-- [Transport performance audit](/quest/m1/audit-perf.md) - congestion-control coverage remains outstanding
+- [Transport performance audit](/quest/m2/audit-perf.md) - congestion-control coverage remains outstanding
- [Binding timestamps](/quest/m1/binding-timestamps.md) - exact timestamps across language APIs
- [Dependency audit](/quest/m2/audit-deps.md) - existing advisory inventory
- [Release gates](/quest/m0/ci/release-gates.md) - post-cut ruleset verification
diff --git a/quest/m1/release-perf/README.md b/quest/m1/release-perf/README.md
index b3b29a96056..5b05daa3c39 100644
--- a/quest/m1/release-perf/README.md
+++ b/quest/m1/release-perf/README.md
@@ -10,7 +10,7 @@ and the reason is written here.
This epic's own work: once every child has landed, run the full main against
release comparison again with `just bench origin/release`, and confirm nothing
new regressed. Then add a release-baseline step to the recurring
-[performance audit](/quest/m1/audit-perf.md), so every later cut
+[performance audit](/quest/m2/audit-perf.md), so every later cut
repeats this comparison.
## Plan
@@ -104,5 +104,5 @@ outside the worktree to keep the next one.
## Related
-- [Performance audit](/quest/m1/audit-perf.md) - compares nightly to nightly; this epic compares main to release
+- [Performance audit](/quest/m2/audit-perf.md) - compares nightly to nightly; this epic compares main to release
- [Nightly benchmark regressions](/quest/m1/bench-ci.md) - paired nightly-to-nightly comparison on one runner
diff --git a/quest/m1/release-perf/recheck.md b/quest/m1/release-perf/recheck.md
index 96fe6a23552..96366e428ba 100644
--- a/quest/m1/release-perf/recheck.md
+++ b/quest/m1/release-perf/recheck.md
@@ -9,7 +9,7 @@ epic.
## Plan
-Use the instruction-count method from the [performance audit](/quest/m1/audit-perf.md).
+Use the instruction-count method from the [performance audit](/quest/m2/audit-perf.md).
Wall time on a shared host can't tell these apart. Build each bench at
`origin/release` and at main, and compare instructions per iteration. A
change that needs a maintainer decision, or is too large to review alongside
diff --git a/quest/m2/README.md b/quest/m2/README.md
index b19359eaeb3..aa48fb60eeb 100644
--- a/quest/m2/README.md
+++ b/quest/m2/README.md
@@ -227,3 +227,4 @@ ranked just below deterministic TS legs, which it requires.
- [Quest tree audit](/quest/m2/audit-quests.md) - repeat the whole-tree audit after the release ships, against the m1 baseline
- [CI workflow audit](/quest/m2/audit-ci.md) - repeat the per-workflow and per-job review after the release ships, against the m1 baselines
+- [Performance audit](/quest/m2/audit-perf.md) - benchmarks that regressed since the m1 run are explained, fixed, or planned, and unbenched hot paths get coverage
diff --git a/quest/m2/audit-perf.md b/quest/m2/audit-perf.md
new file mode 100644
index 00000000000..0d4315d8f5b
--- /dev/null
+++ b/quest/m2/audit-perf.md
@@ -0,0 +1,175 @@
+# [M] Performance audit
+
+## Goal
+
+Every benchmark that regressed since the previous run is explained, fixed, or
+planned, and every hot or fan-out path without a benchmark gets one or a
+follow-up.
+
+## Plan
+
+Recurs once per major release (decided 2026-10-19). The PR that finishes
+this run also adds the next one with the same file name at the end of the next
+milestone's `Required` (m0 to m1, m1 to m2). The successor keeps the Goal
+and this paragraph; the rest of its Plan is rewritten with what this run
+learned: baselines, results, and what to check first. A successor placed in m2
+also lists the [release cut](/quest/m2/release/cut.md) under `Required`, so it
+waits for the release in flight to ship. Only `/quest-delete` ends the
+recurrence. Fixes land in the run's PR, one commit each, rather than as follow-ups.
+Only a change that needs a maintainer decision (public API, scope) or is
+independently landable and too large to review alongside the rest becomes a
+follow-up through `/quest-plan`.
+
+### What the m1 run (2026-10-22) fixed
+
+Instruction counts are one optimized `--test --exact` iteration under callgrind,
+collected inside a profiling boundary (see Method).
+
+- The export consumer reaps queued aborted groups only when delivery blocks,
+ not once per delivered frame. `annexb-export-queued-groups` (in the
+ `containers` bench) sweeps queued groups x frames per group:
+ 64 groups x 16 frames went from 12.36M to 4.47M (-64%); one group stays
+ within 1%.
+- `group::Consumer` was 672 bytes because its prefetch batch held eight frames
+ inline, and every layer that hands out a group (track cursor, subscriber,
+ resume reader, mux consumer) moved it by value. The batch is now boxed on its
+ first fill: `annexb-export-queued-groups/64/1` -14.8%,
+ `track_recv_groups/arrival/512` -15.2%, `group_read_frames/single/4` +0.6%.
+ This recovers the m0 run's `memcpy` attribution to
+ [#6019](https://github.com/moq-dev/moq/pull/6019).
+- Each catalog estimate read its rendition through a whole-catalog snapshot
+ three times, so every frame cloned every rendition. It now clones only the
+ entry: `catalog_estimate_fanout/hang/tracks_4/4` 106.2M to 59.0M (-44%),
+ `tracks_16/16` -53%.
+
+### What it attributed without a fix
+
+- `catalog_estimate_fanout` +4% across `fc0df978c`..`4327505086`:
+ [#6074](https://github.com/moq-dev/moq/pull/6074) +0.4%,
+ [#5543](https://github.com/moq-dev/moq/pull/5543) +3.3% (a larger
+ `VideoConfig` cloned on every estimate, which the fix above removed). The
+ [#5677](https://github.com/moq-dev/moq/pull/5677) step was not bisected;
+ the bench is now well below its Oct 19 baseline.
+- Annex B export: per frame it is now below Oct 19 (`1tracks-64frames/256`
+ 1.185M vs 1.495M), but a per-export constant remains (+18.6k at one frame):
+ +8.8k catalog decode, +11k `track::Subscriber::poll_group` through the
+ resume reader, +2.6k track resolve. The duplicate-key check
+ ([#5941](https://github.com/moq-dev/moq/pull/5941)) replaced an equal-cost
+ merge check, so it adds nothing.
+- `track_stamp_groups/append` (nightly +29% on all three depths, stayed):
+ 6,557 instructions per group at Oct 20 `f13283b302`, 7,729 at Oct 21
+ `bc64b9c525`, 8,944 at this run. The first step is #6074's start index
+ (`TrackState::index_start`, a `BTreeMap` insert per group);
+ the second is `group::Handle::start` and `TrackState::wake_landed` taking the
+ track lock again on each group's first frame, partly offset by a cheaper
+ `write_frame`.
+
+Published history had only three distinct commits (Oct 20 `f13283b302`, which
+has two reruns, Oct 21 `bc64b9c525`, Oct 22 `33940b6e33`), so the five-night
+comparison moved here. Across those three, 13 of 1,756 Rust and FFI cost series
+stayed over 25% worse on both later nights and 8 stayed over 25% better, which
+is close to noise. The worse ones beyond the above: `track_pending_tail/repoll`,
+`session_churn_held/moq-transport-22`, `lite_varint/encode/Datagram`,
+`origin/announce/1000p_1000s`, `kio/contended_repoll` (threaded, not
+CPU-attributable), and Kotlin FFI (swings 10-40% nightly). Throughput series
+did not move.
+
+### What to check first
+
+- History: compare at least five nights by commit, now that it exists. Nightly
+ stores every series on `gh-pages` (`bench/costs`, `bench/rates`); re-runs add
+ duplicate points for one commit. Read the
+ [nightly benchmark regression report](/quest/m1/bench-ci.md)'s paired flags
+ instead of raw history once it lands. The first JS series (841) appeared on
+ Oct 22, and Dart still needs a recheck against the bindings history.
+- The per-group write cost above, then the resume reader: at 16 single-frame
+ groups `track::Subscriber::poll_group` is 44% of the Annex B export
+ (174k of 397k), mostly `resume::Reader::poll_lowest`.
+- `catalog::tracks::Rendition::stage` still clones and serializes the whole
+ catalog on every estimate to validate it before retaining it (62% of
+ `catalog_estimate_fanout/hang/tracks_4/4`). Validating only the edited entry
+ would weaken that guarantee for custom configs, so it needs a decision.
+
+### Method: attribute with instruction counts, not wall time
+
+Shared hosts run at load 20-60, where Criterion intervals span +/-50% and a
+wall-clock bisect blames the wrong commit. Count instructions instead:
+
+- Export each commit with `git archive` into a scratch directory and build the
+ bench there with its own `CARGO_TARGET_DIR`, the current dev shell's
+ toolchain, `CARGO_PROFILE_BENCH_STRIP=none` and
+ `CARGO_PROFILE_BENCH_DEBUG=line-tables-only`.
+- Wrap the timed routine in an `#[inline(never)]` function (the `containers`
+ bench's `export_queued_groups` is one) and run
+ `valgrind --tool=callgrind --toggle-collect='**' --test --exact `.
+ One iteration is deterministic to about 1%; for steady state, print a marker
+ per call and run `--bench --profile-time 5` instead. Without a boundary,
+ toggle on the operations the setup repeats (`append_group`, `write_frame`,
+ `finish` for `track_stamp_groups`) and divide by the count.
+- `callgrind_annotate --inclusive=yes` diffs between two commits point at the
+ step; workspace sources show as `${workspace}`, so read them by name.
+- A bench that is not CPU-bound is not attributable this way:
+ `relay_auth_refresh` runs real loopback sockets and moved +27-60% on CI with
+ +0.4% instructions.
+
+### Baselines (m1 run, instructions per iteration)
+
+| Bench | Earliest measured | m1 PR |
+|---|---|---|
+| `annexb-export-frames/1tracks-16frames/256` | 374k (Oct 19 `ad87ad34e`) | 397k |
+| `annexb-export-frames/1tracks-64frames/256` | 1.495M (Oct 19 `ad87ad34e`) | 1.185M |
+| `cmaf-export-frames/4tracks-16frames/4096` | 7.77M (Oct 19 `ad87ad34e`) | 7.87M |
+| `catalog_estimate_fanout/hang/tracks_4/4` | 102.1M (`fecb57131`, before #6074) | 59.0M |
+| `track_stamp_groups/append/512`, per group | 6,557 (Oct 20 `f13283b30`) | 8,944 |
+| `track_recv_groups/arrival/512` | 3.27M (main `2e3ea8484`) | 2.78M |
+
+### Unbenchmarked hot and fan-out paths, ranked
+
+Each needs a bench, swept over both axes where it fans out, or its own
+follow-up quest. The m1 run added none of these:
+
+1. [HLS request fan-out](/quest/m2/performance-survey/hls-serving.md) owns
+ repeated segment fetch/remux and playlist rendering, swept over viewers,
+ renditions and window segments.
+2. [Session datagrams](/quest/m2/performance-survey/datagram-delivery.md) owns
+ complete adapter delivery across publishers and viewers.
+3. LOC and CMAF wire containers in moq-mux: `containers` and `export` only use
+ `Container::Legacy`; sweep container x frame size x frames.
+4. [Buffered browser groups](/quest/m2/performance-survey/hang-buffered.md)
+ owns per-frame scans and bulk skip work in the Hang consumer.
+5. [Browser media copies](/quest/m2/performance-survey/browser-media-copies.md)
+ owns CMAF sample copies and LOC encode allocation. Generic `js/msf` and
+ `js/flate` benchmark coverage remains here.
+6. moq-quic loss recovery and real congestion controllers: every bench pins
+ `Unlimited`; sweep controller x flight x loss x streams.
+7. [Announcement snapshots](/quest/m2/performance-survey/announced-snapshots.md)
+ owns HTTP snapshot/rendering costs across routes and pollers.
+8. [JWT verification](/quest/m2/performance-survey/jwt-verification.md) owns
+ key-source I/O, import, lookup, parsing and crypto attribution.
+9. MPEG-TS import with real repeated media (the CLI bench mostly skips null
+ padding), and MKV, FLV, H.265, AV1 importers.
+10. JS watch audio ring buffer and publish `Fanout` (lower impact). Include
+ capture-to-encoder staging: `audio/framer.ts` copies planes before
+ `audio/encoder.ts` joins them. AudioData already uses a transfer list;
+ do not count that transfer as another mandatory copy. Sweep publishers
+ x renditions, channels and frame duration in a browser.
+
+The [2026-10-22 source survey](/quest/m2/performance-survey/README.md) owns
+the extracted items above and additional algorithmic hypotheses, with paired
+benchmarks required before optimization. This audit still owns nightly
+regression attribution and the remaining coverage. Its fragmented-MKV child
+specializes item 9's MKV work.
+
+Single-axis fan-out benches to widen: `session_delivery_paced` (viewers only),
+`track_fanout_*` (subscribers only), `memory` (lite-06 only), and
+`bench/workloads/fanout*.toml` (connections only).
+
+Fan-out paths need a sweep over both axes (AGENTS.md). JS perf is judged in a
+browser, not node or bun. Benchmarks never gate the merge queue (decided
+2026-10-20, maintainer): each Nightly compares them into the git.moq.dev
+report, which the [nightly benchmark regression report](/quest/m1/bench-ci.md)
+owns; don't duplicate it.
+
+## Required
+
+- [Cut and publish the prepared breaking release](/quest/m2/release/cut.md) - the release in flight ships before this run starts
diff --git a/quest/m2/performance-survey/README.md b/quest/m2/performance-survey/README.md
index 587754fa520..5b79f8d7f87 100644
--- a/quest/m2/performance-survey/README.md
+++ b/quest/m2/performance-survey/README.md
@@ -160,7 +160,7 @@ No duplicate quest or workflow edit belongs here.
- [Route wakes](/quest/m2/route-wakes.md),
[keyed prefix polling](/quest/m2/keyed-prefix-polling.md), and
[front parking](/quest/m2/origin-front-parks.md) own discovery scans/wakes.
-- The [recurring audit](/quest/m1/audit-perf.md) retains real congestion-
+- The [recurring audit](/quest/m2/audit-perf.md) retains real congestion-
controller/loss-recovery coverage, broader importer/container coverage,
and publish Fanout/audio-ring profiling. QUIC protocol microbenchmarks use
`Unlimited`; their numbers cannot establish controller performance. Expand
@@ -196,6 +196,6 @@ No duplicate quest or workflow edit belongs here.
## Related
-- [Performance audit](/quest/m1/audit-perf.md) - nightly regression attribution and remaining coverage
+- [Performance audit](/quest/m2/audit-perf.md) - nightly regression attribution and remaining coverage
- [Benchmark sources](/quest/m2/bench-sources.md) - publishing existing measurements to the trend table
- [Nightly comparisons](/quest/m1/bench-ci.md) - paired nightly regression reporting
diff --git a/rs/moq-mux/benches/containers.rs b/rs/moq-mux/benches/containers.rs
index 62fbe1e97bb..64e40ecb24c 100644
--- a/rs/moq-mux/benches/containers.rs
+++ b/rs/moq-mux/benches/containers.rs
@@ -44,7 +44,18 @@ impl Drop for Fixture {
}
}
-async fn prepare(tracks: usize, frames: usize, payload: &Bytes) -> (moq_mux::Source, impl Stream, Fixture) {
+struct Video {
+ tracks: usize,
+ frames: usize,
+ frames_per_group: usize,
+}
+
+async fn prepare(video: Video, payload: &Bytes) -> (moq_mux::Source, impl Stream, Fixture) {
+ let Video {
+ tracks,
+ frames,
+ frames_per_group,
+ } = video;
let mut broadcast = moq_net::broadcast::Info::new().produce();
let consumer = broadcast.consume();
let mut catalog = moq_mux::catalog::Producer::new(&mut broadcast, Default::default()).unwrap();
@@ -66,7 +77,7 @@ async fn prepare(tracks: usize, frames: usize, payload: &Bytes) -> (moq_mux::Sou
timestamp: timestamp(index),
duration: Some(Timestamp::from_millis(20).unwrap()),
payload: payload.clone(),
- keyframe: true,
+ keyframe: index % frames_per_group == 0,
})
.unwrap();
}
@@ -182,7 +193,14 @@ fn containers(c: &mut Criterion) {
for frames in [1, 16, 64] {
for size in [256, 4096] {
let payload = payload(size);
- let (source, stream, fixture) = runtime.block_on(prepare(*tracks, frames, &payload));
+ let (source, stream, fixture) = runtime.block_on(prepare(
+ Video {
+ tracks: *tracks,
+ frames,
+ frames_per_group: 1,
+ },
+ &payload,
+ ));
let data = runtime.block_on(export(format, source, stream, true));
drop(fixture);
if format == "cmaf" {
@@ -247,7 +265,16 @@ fn containers(c: &mut Criterion) {
}
} else {
b.iter_batched(
- || runtime.block_on(prepare(*tracks, frames, &payload)),
+ || {
+ runtime.block_on(prepare(
+ Video {
+ tracks: *tracks,
+ frames,
+ frames_per_group: 1,
+ },
+ &payload,
+ ))
+ },
|(source, stream, fixture)| {
std::hint::black_box(
runtime.block_on(export(format, source, stream, false)),
@@ -268,5 +295,59 @@ fn containers(c: &mut Criterion) {
}
}
-criterion_group!(benches, containers);
+// A stable profiling boundary excludes publishing and benchmark setup from counts.
+#[inline(never)]
+fn export_queued_groups(runtime: &tokio::runtime::Runtime, source: moq_mux::Source, stream: impl Stream) {
+ std::hint::black_box(runtime.block_on(export("annexb", source, stream, false)));
+}
+
+// Keep both dimensions independent: per-frame scans over queued groups grow with
+// frames per group as well as group count, unlike one constant cost per group.
+fn queued_groups(c: &mut Criterion) {
+ let runtime = tokio::runtime::Builder::new_current_thread()
+ .enable_all()
+ .build()
+ .unwrap();
+ let payload = payload(256);
+ let mut group = c.benchmark_group("annexb-export-queued-groups");
+ for groups in [1, 16, 64] {
+ for frames_per_group in [1, 16] {
+ let frames = groups * frames_per_group;
+ let (source, stream, fixture) = runtime.block_on(prepare(
+ Video {
+ tracks: 1,
+ frames,
+ frames_per_group,
+ },
+ &payload,
+ ));
+ let data = runtime.block_on(export("annexb", source, stream, true));
+ assert_eq!(data.len(), 256 * frames);
+ drop(fixture);
+ group.throughput(Throughput::Elements(frames as u64));
+ group.bench_function(BenchmarkId::new(groups.to_string(), frames_per_group), |b| {
+ b.iter_batched(
+ || {
+ runtime.block_on(prepare(
+ Video {
+ tracks: 1,
+ frames,
+ frames_per_group,
+ },
+ &payload,
+ ))
+ },
+ |(source, stream, fixture)| {
+ export_queued_groups(&runtime, source, stream);
+ fixture
+ },
+ BatchSize::PerIteration,
+ );
+ });
+ }
+ }
+ group.finish();
+}
+
+criterion_group!(benches, containers, queued_groups);
criterion_main!(benches);
diff --git a/rs/moq-mux/src/catalog/producer.rs b/rs/moq-mux/src/catalog/producer.rs
index dd22ffde43e..ddda28b552a 100644
--- a/rs/moq-mux/src/catalog/producer.rs
+++ b/rs/moq-mux/src/catalog/producer.rs
@@ -573,6 +573,11 @@ impl Producer {
take(&self.current).clock
}
+ /// The config `name` holds in `C`'s section, cloned without copying the rest of the catalog.
+ pub(super) fn config>(&self, name: &str) -> Option {
+ C::get_mut(&mut take(&self.current).catalog, name).cloned()
+ }
+
/// Anchor a timebase on its first timestamp `pts`, which happened at `wall` (or arrived now),
/// returning the timebase's offset.
///
diff --git a/rs/moq-mux/src/catalog/tracks.rs b/rs/moq-mux/src/catalog/tracks.rs
index cf5d62fff15..4c1cb8fd793 100644
--- a/rs/moq-mux/src/catalog/tracks.rs
+++ b/rs/moq-mux/src/catalog/tracks.rs
@@ -658,7 +658,8 @@ impl> Rendition {
let mut resolved = Self::resolved(&self.supplied, &estimate);
// A measurement never lowers the published jitter or delay, including one raised through
// `modify`.
- let published = self.config()?.estimate();
+ let mut config = self.config()?;
+ let published = config.estimate();
resolved.jitter = resolved.jitter.max(published.jitter);
resolved.delay = resolved.delay.max(published.delay);
self.detected = estimate;
@@ -676,7 +677,6 @@ impl> Rendition {
let throttled = self.published.as_ref().is_some_and(|published| {
published.bitrate == resolved.bitrate && published.framerate == resolved.framerate
});
- let mut config = self.config()?;
config.set_estimate(resolved.clone());
self.stage(config)?.commit_estimate(throttled)?;
self.published = Some(resolved);
@@ -703,10 +703,7 @@ impl> Rendition {
if !self.present {
return Err(crate::Error::NotPublished);
}
- let mut catalog = self.catalog.snapshot();
- C::get_mut(&mut catalog, &self.name)
- .cloned()
- .ok_or(crate::Error::NotPublished)
+ self.catalog.config::(&self.name).ok_or(crate::Error::NotPublished)
}
pub(crate) fn replace(&mut self, config: C) -> crate::Result<()> {
diff --git a/rs/moq-mux/src/container/consumer.rs b/rs/moq-mux/src/container/consumer.rs
index bfda6f63c9f..89bea924e73 100644
--- a/rs/moq-mux/src/container/consumer.rs
+++ b/rs/moq-mux/src/container/consumer.rs
@@ -375,19 +375,6 @@ impl Consumer {
}
}
- // Reap aborted groups the cursor hasn't reached: nothing below settles them
- // (the read arm only handles the front at the cursor, and neither the skip
- // target scan nor the empty-group check counts an abort), so one left ahead
- // of a sequence gap would park the consumer forever. Buffered frames read
- // before the abort stay deliverable, and a fault found among them waits for
- // its place in delivery order, so a group holding either is kept; the front
- // at the cursor keeps the eviction fast path in the read arm below.
- // poll_aborted registers the waiter on live groups, so a later abort re-polls.
- let current = self.current;
- self.discard(|group| {
- group.sequence > current && group.buffered.is_empty() && group.fault.is_none() && group.poll_aborted(waiter)
- })?;
-
loop {
if self.pending.front().is_none_or(|group| group.sequence <= self.current) {
self.hole_timer = None;
@@ -482,6 +469,18 @@ impl Consumer {
}
}
+ // Reap later aborts only when delivery blocks. An aborted group beyond a
+ // sequence gap must not park the reader forever. Buffered frames and faults
+ // stay in delivery order; the current group has its eviction path above.
+ // Live groups register the waiter here so a later abort wakes the reader.
+ let current = self.current;
+ self.discard(|group| {
+ group.sequence > current
+ && group.buffered.is_empty()
+ && group.fault.is_none()
+ && group.poll_aborted(waiter)
+ })?;
+
// The current group's furthest presentation point (timestamp + duration).
let current_end = if let Some(current) = self.pending.front_mut()
&& current.sequence <= self.current
diff --git a/rs/moq-net/src/model/group.rs b/rs/moq-net/src/model/group.rs
index 73d20ffc7b5..8fa04cbe132 100644
--- a/rs/moq-net/src/model/group.rs
+++ b/rs/moq-net/src/model/group.rs
@@ -2255,16 +2255,19 @@ impl Demand {
}
}
-/// A small inline batch of completed frames, drained from the shared group state
-/// under one lock and then handed out without re-locking.
+/// A small batch of completed frames, drained from the shared group state under one
+/// lock and then handed out without re-locking.
///
/// Each [`Consumer::read_frame`] otherwise takes the group mutex and allocates a
/// waker just to clone one `Bytes`; draining a batch amortizes both across `CAP`
-/// frames. Storage is inline and uninitialized (no heap), so a consumer that never
-/// reads whole frames, or drains through a higher-level buffer, pays nothing.
+/// frames. Storage is uninitialized and allocated by the first non-empty fill, so a
+/// consumer that never reads whole frames, or drains through a higher-level buffer,
+/// pays nothing. Inline storage would triple the size of every [`Consumer`], which
+/// moves by value through each layer that hands out a group.
+#[derive(Default)]
struct Prefetch {
// Initialized, not-yet-taken frames are `frames[pos..len]`; the rest are uninitialized.
- frames: [MaybeUninit; Self::CAP],
+ frames: Option; Self::CAP]>>,
// Relay metadata for `frames`, allocated by the first batch that carries any.
fields: Option>; Self::CAP]>>,
// Inflated sizes for `frames`, filled only by a batch of a compressed group's stored slices.
@@ -2286,8 +2289,9 @@ impl Prefetch {
if self.pos == self.len {
return None;
}
+ let frames = self.frames.as_mut()?;
// SAFETY: `pos < len`, so this slot was written by `fill` and not yet taken.
- let frame = unsafe { self.frames[self.pos].assume_init_read() };
+ let frame = unsafe { frames[self.pos].assume_init_read() };
self.pos += 1;
Some(frame)
}
@@ -2312,9 +2316,14 @@ impl Prefetch {
Some(flate) if !raw && count > 0 => Some(state.inflate(flate, local + count - 1)?),
_ => None,
};
- for frame in state.frames.range(local..local + count) {
- self.frames[self.len].write(frame.clone());
- self.len += 1;
+ if count > 0 {
+ let frames = self
+ .frames
+ .get_or_insert_with(|| Box::new([const { MaybeUninit::uninit() }; Self::CAP]));
+ for frame in state.frames.range(local..local + count) {
+ frames[self.len].write(frame.clone());
+ self.len += 1;
+ }
}
match &state.flate {
Some(flate) if raw => {
@@ -2341,12 +2350,15 @@ impl Prefetch {
/// frames. A frame that fails to inflate ends the batch, failing it if first.
fn inflate(&mut self, job: &Inflate, local: usize, meter: &stats::Meter) -> Result<()> {
job.run(meter);
+ let Some(frames) = &mut self.frames else {
+ return Ok(());
+ };
for i in self.pos..self.len {
match job.get(local + i) {
// SAFETY: slots in `pos..len` are initialized (written by `fill`, not yet popped).
- Ok(payload) => unsafe { self.frames[i].assume_init_mut() }.payload = payload,
+ Ok(payload) => unsafe { frames[i].assume_init_mut() }.payload = payload,
Err(err) => {
- for slot in &mut self.frames[i..self.len] {
+ for slot in &mut frames[i..self.len] {
// SAFETY: as above, and `len` drops below them right after.
unsafe { slot.assume_init_drop() };
}
@@ -2362,7 +2374,10 @@ impl Prefetch {
/// Read once per fill to bump the egress payload counters for the whole batch.
fn buffered(&self) -> (u64, u64) {
let mut bytes = 0u64;
- for slot in &self.frames[self.pos..self.len] {
+ let Some(frames) = &self.frames else {
+ return (0, 0);
+ };
+ for slot in &frames[self.pos..self.len] {
// SAFETY: slots in `pos..len` are initialized (written by `fill`, not yet popped).
bytes += unsafe { slot.assume_init_ref() }.payload.len() as u64;
}
@@ -2370,21 +2385,12 @@ impl Prefetch {
}
}
-impl Default for Prefetch {
- fn default() -> Self {
- Self {
- frames: [const { MaybeUninit::uninit() }; Self::CAP],
- fields: None,
- inflated: None,
- pos: 0,
- len: 0,
- }
- }
-}
-
impl Drop for Prefetch {
fn drop(&mut self) {
- for slot in &mut self.frames[self.pos..self.len] {
+ let Some(frames) = &mut self.frames else {
+ return;
+ };
+ for slot in &mut frames[self.pos..self.len] {
// SAFETY: slots in `pos..len` are initialized and were never taken.
unsafe { slot.assume_init_drop() };
}