From 92ec0ec33b81fb0b8b83c2540c06f94f9ec1b3e0 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:27:15 -0700 Subject: [PATCH 01/10] chore: claim performance audit Co-Authored-By: Claude Opus 5.5 From 602fae7e27bbed6f14725330315737f71154c4c2 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:31:29 -0700 Subject: [PATCH 02/10] fix(bench): check JS failover ownership through the resumed front Same-epoch failover keeps the request's broadcast handle and re-sources its tracks (e876c1722), so the requests bench's handle-identity check failed and broke the Nightly JS leg. Use readsFrom, as the origin tests already do. Co-Authored-By: Claude Opus 5.5 --- js/net/bench/requests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/net/bench/requests.ts b/js/net/bench/requests.ts index 2f16119e7ec..f82bbada835 100644 --- a/js/net/bench/requests.ts +++ b/js/net/bench/requests.ts @@ -13,6 +13,7 @@ import { ALPN, Version } from "../src/ietf/version"; import { createMockTransportPair } from "../src/mock"; import { Producer } from "../src/origin"; import * as Path from "../src/path"; +import { readsFrom } from "../src/resume.test-util"; import { Stream } from "../src/stream"; import { wireOf } from "../src/wire"; @@ -149,7 +150,7 @@ for (const failovers of [0, 1, 16, 128]) sources.push(source); pending[i].accept(source); await settle(); - if (entries[i].held.active.peek()?.closed !== source.closed) throw new Error("lost failover"); + if (!readsFrom(entries[i].held.active.peek(), source)) throw new Error("lost failover"); } if (round > 1) samples.push(active / 128); } finally { From b1ffa029a4768d0d2e330265677a362eb43b60a7 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:41:31 -0700 Subject: [PATCH 03/10] fix(bench): keep lite announce diagnostics out of the broadcasts CSV The stalled-announce sweep reaches the lite publisher's console.debug, which Bun prints to stdout and the Nightly report rejected as malformed CSV. Co-Authored-By: Claude Opus 5.5 --- js/net/bench/broadcasts.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/net/bench/broadcasts.ts b/js/net/bench/broadcasts.ts index 39d1b154c0c..a3a4d69707e 100644 --- a/js/net/bench/broadcasts.ts +++ b/js/net/bench/broadcasts.ts @@ -16,6 +16,9 @@ import { Producer } from "../src/origin.ts"; import * as Path from "../src/path.ts"; import { Stream, Writer } from "../src/stream.ts"; +// Keep protocol diagnostics out of the measured CSV on stdout. +console.debug = console.error; + const routeCounts = [8, 32, 128]; const observerCounts = [1, 8, 32]; const updates = 32; From d2a9a8a6e518b237112b3911596b9002ef0ba388 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:41:31 -0700 Subject: [PATCH 04/10] ci(bench): run every JS bench nightly The JS leg now takes minutes, so schedule the six benches Nightly skipped (net observed, json codec and parse, hang slow-group, watch warmup, clock timers), emit report-readable CSV from the four that printed TSV or JSON, and check the inventory like the Rust one. Co-Authored-By: Claude Opus 5.5 --- js/hang/bench/slow-group.ts | 5 +++-- js/json/bench/codec.ts | 4 ++-- js/json/bench/parse.ts | 6 ++---- js/justfile | 17 +++++++++++++++++ js/watch/bench/warmup.ts | 5 +++-- sh/gh/nightly.sh | 7 ++++++- sh/gh/nightly.test.py | 26 +++++++++++++++++++++++++- 7 files changed, 58 insertions(+), 12 deletions(-) diff --git a/js/hang/bench/slow-group.ts b/js/hang/bench/slow-group.ts index df051df0461..127e8405449 100644 --- a/js/hang/bench/slow-group.ts +++ b/js/hang/bench/slow-group.ts @@ -1,4 +1,4 @@ -// Run with `bun js/hang/bench/slow-group.ts` to measure warning traffic per catch-up. +// Measure warning traffic and catch-up time over the groups a slow consumer skips. import { Milli } from "@moq/clock"; import { Group, Time, Track, Varint } from "@moq/net"; @@ -6,6 +6,7 @@ import { Signal } from "@moq/signals"; import { Consumer } from "../src/container/consumer.ts"; import { Format } from "../src/container/legacy.ts"; +console.log("groups,warnings,bytes,catchup_ms"); for (const count of [1, 16, 256, 1024]) { const track = new Track.Producer("tone"); const maxDelay = new Signal(Milli(30_000)); @@ -35,7 +36,7 @@ for (const count of [1, 16, 256, 1024]) { const started = performance.now(); write(count); await buffered(count); - console.log(JSON.stringify({ groups: count, warnings, bytes, catchupMs: performance.now() - started })); + console.log(`${count},${warnings},${bytes},${(performance.now() - started).toFixed(3)}`); } finally { consumer.close(); track.close(); diff --git a/js/json/bench/codec.ts b/js/json/bench/codec.ts index 1abc04c5a9a..750d94a2ef3 100644 --- a/js/json/bench/codec.ts +++ b/js/json/bench/codec.ts @@ -3,7 +3,7 @@ import { Decoder } from "../src/snapshot/decoder.ts"; import { Encoder } from "../src/snapshot/encoder.ts"; const updates = 256; -console.log("keys\tchanged\tcompression\tms/update"); +console.log("keys,changed,compression,ms_per_update"); for (const keys of [1, 10, 100, 1000]) { for (const changed of new Set([1, Math.min(10, keys)])) { for (const compression of ["none", "deflate"] as const) { @@ -28,7 +28,7 @@ for (const keys of [1, 10, 100, 1000]) { samples.push((performance.now() - start) / updates); } samples.sort((a, b) => a - b); - console.log(`${keys}\t${changed}\t${compression}\t${samples[1]?.toFixed(6)}`); + console.log(`${keys},${changed},${compression},${samples[1]?.toFixed(6)}`); } } } diff --git a/js/json/bench/parse.ts b/js/json/bench/parse.ts index 2cc6a7f0fc7..2eeed3a9f4c 100644 --- a/js/json/bench/parse.ts +++ b/js/json/bench/parse.ts @@ -63,11 +63,9 @@ function time(bytes: Uint8Array, decode: (bytes: Uint8Array) => unknown): number return samples[2] ?? 0; } -console.log("frame\tbytes\tJSON.parse µs\tparse µs\tratio"); +console.log("frame,bytes,json_parse_us,parse_us"); for (const [name, bytes] of cases) { const baseline = time(bytes, (bytes) => JSON.parse(decoder.decode(bytes))); const strict = time(bytes, parse); - console.log( - `${name}\t${bytes.length}\t${baseline.toFixed(2)}\t${strict.toFixed(2)}\t${(strict / baseline).toFixed(2)}`, - ); + console.log(`${name},${bytes.length},${baseline.toFixed(2)},${strict.toFixed(2)}`); } diff --git a/js/justfile b/js/justfile index 2ea94f5d0ee..4542eefc79d 100644 --- a/js/justfile +++ b/js/justfile @@ -116,6 +116,23 @@ json-stream-bench: bunx tsc --noEmit --project json/bench/tsconfig.json bun json/bench/stream.ts +# Sweep snapshot codec cost over document size and changed keys. +json-codec-bench: + bun install --frozen-lockfile + bunx tsc --noEmit --project json/bench/tsconfig.json + bun json/bench/codec.ts + +# Compare the duplicate-refusing JSON frame parse against bare JSON.parse. +json-parse-bench: + bun install --frozen-lockfile + bunx tsc --noEmit --project json/bench/tsconfig.json + bun json/bench/parse.ts + +# Sweep a slow hang consumer's skipped groups against its warning traffic and catch-up time. +slow-group-bench: + bun install --frozen-lockfile + bun hang/bench/slow-group.ts + # Sweep decoder count against PCM callback size during audio warmup. audio-warmup-bench: bun install --frozen-lockfile diff --git a/js/watch/bench/warmup.ts b/js/watch/bench/warmup.ts index ffd03c19a3b..be636bcaae4 100644 --- a/js/watch/bench/warmup.ts +++ b/js/watch/bench/warmup.ts @@ -4,7 +4,8 @@ import { Terminal } from "../src/audio/terminal"; // Decoder count × callback size checks that trimming costs a span calculation, // independent of the PCM payload size. Periodic gaps exercise the priming path. const CALLBACKS = 4096; -console.log("decoders,frames,warmup_us,ns_per_callback"); +// No timing suffix on warmup: the trend report would read that dimension as a measurement. +console.log("decoders,frames,warmup,ns_per_callback"); let retained = 0; for (const count of [1, 16, 64]) { for (const frames of [120, 960, 2880]) { @@ -30,7 +31,7 @@ for (const count of [1, 16, 64]) { timings.push(((performance.now() - start) * 1e6) / (CALLBACKS * count)); } timings.sort((a, b) => a - b); - console.log(`${count},${frames},${warmup},${timings[1]?.toFixed(1)}`); + console.log(`${count},${frames},${warmup / 1000}ms,${timings[1]?.toFixed(1)}`); } } } diff --git a/sh/gh/nightly.sh b/sh/gh/nightly.sh index 357ccece72f..909b9b3268c 100755 --- a/sh/gh/nightly.sh +++ b/sh/gh/nightly.sh @@ -102,7 +102,7 @@ case "$1" in done ;; js) - for benchmark in broadcasts request-ids requests forward reader frames varint lite-varint track resume interests priority subscribe-drop refresh; do + for benchmark in broadcasts request-ids requests forward reader frames varint lite-varint track resume interests priority subscribe-drop refresh observed; do javascript "$benchmark" just js bench "$benchmark" done javascript catalog just js catalog-bench @@ -111,6 +111,11 @@ case "$1" in javascript e2ee just js e2ee-bench javascript json-stream just js json-stream-bench javascript signals just js signals-bench + javascript json-codec just js json-codec-bench + javascript json-parse just js json-parse-bench + javascript slow-group just js slow-group-bench + javascript audio-warmup just js audio-warmup-bench + javascript clock just js clock-bench ;; esac diff --git a/sh/gh/nightly.test.py b/sh/gh/nightly.test.py index a0ba8603208..a4d09095843 100644 --- a/sh/gh/nightly.test.py +++ b/sh/gh/nightly.test.py @@ -36,7 +36,7 @@ def test_failed_js_benchmark_does_not_hide_later_work(self): result, calls = self.run_group("js", "js bench reader") self.assertEqual(result.returncode, 1) self.assertIn("just js bench frames", calls) - self.assertEqual(calls[-1], "just js signals-bench") + self.assertEqual(calls[-1], "just js clock-bench") self.assertIn("failed: just js bench reader", result.stderr) def test_bench_targets_share_one_invocation(self): @@ -83,6 +83,30 @@ def test_every_cargo_bench_target_runs_nightly(self): for bench in tomllib.loads(manifest.read_text()).get("bench", [])} self.assertEqual(declared - covered, set(), "Cargo bench targets missing from Nightly") + def test_every_js_bench_runs_nightly(self): + recipes = {} + for block in re.split(r"\n(?=\S)", (ROOT / "js/justfile").read_text()): + if match := re.match(r"([\w-]+)( \w+)?:\n", block): + recipes[match[1]] = re.findall(r"^ bun (.+\.ts)$", block, re.M) + result, calls = self.run_group("js") + self.assertEqual(result.returncode, 0, result.stderr) + # The browser benches run in their own Nightly job. + workflow = (ROOT / ".github/workflows/nightly.yml").read_text() + calls += re.findall(r"just js \S+-bench\b", workflow) + entries = set() + for call in calls: + args = shlex.split(call) + if args[:2] != ["just", "js"]: + continue + for path in recipes[args[2]]: + entries.add(ROOT / "js" / path.replace("{{ name }}", args[-1])) + # Bundled helpers only run through the entry that names them. + helpers = {path for entry in entries for path in entry.parent.glob("*.ts") + if f"/{path.name}" in entry.read_text()} + declared = {path for path in (ROOT / "js").glob("*/bench/*.ts") if not path.name.endswith(".test.ts")} + missing = {str(path.relative_to(ROOT)) for path in declared - entries - helpers} + self.assertEqual(missing, set(), "JS benches missing from Nightly") + def test_dev_shell_jobs_trust_the_nix_cache(self): # Without the flake's substituter, the dev shell builds uncached tools from # source and outlasts short jobs: the benchmark site timed out before publishing. From 99c372de80e84ffb4d3accadcf9f5be7c9d8d850 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:58:37 -0700 Subject: [PATCH 05/10] fix(bench): give feed fetch setup its own sim polls The sim spin check (#5990) counts ready polls per task poll, and the feed fetch benchmark never yields, so its setup crossed the limit at 64 held fetches and failed the Nightly benchmark tests leg. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/lite/subscriber.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 825dcbe86ec..003486bac3f 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -2289,6 +2289,9 @@ mod tests { let waiter = kio::Waiter::noop(); let mut fixtures = Vec::new(); for _ in 0..tracks { + // The sim counts ready polls per task poll to catch spinning loops, so + // give each track's setup, and the timed loop below, a poll of its own. + moq_clock::sim::yield_now().await; let (track, callers, requests) = feed_batch(1_000_000..1_000_000 + held); let tail = kio::Producer::new(Tail::default()); let sub = feed_sub(&tail).await; @@ -2312,6 +2315,7 @@ mod tests { fixtures.push((track, callers, tail, sub, scan, fetches)); } let (track, _callers, tail, sub, scan, fetches) = &mut fixtures[0]; + moq_clock::sim::yield_now().await; #[allow(clippy::disallowed_methods)] let began = std::time::Instant::now(); for sequence in runs * 2..runs * 2 + EVENTS { From 3d332e0f6c07a3cb97c798077731393b002a7f38 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Tue, 20 Oct 2026 16:32:49 -0700 Subject: [PATCH 06/10] chore(quest): record third performance audit checkpoint Co-Authored-By: Claude Opus 5.5 --- quest/m0/audit-perf.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/quest/m0/audit-perf.md b/quest/m0/audit-perf.md index fec60519466..c82149e9ed0 100644 --- a/quest/m0/audit-perf.md +++ b/quest/m0/audit-perf.md @@ -103,6 +103,25 @@ Audit evidence (2026-10-19, second checkpoint, incomplete): Single-axis fan-out benches to widen: `session_delivery_paced` (viewers only), `track_fanout_*` (subscribers only), `memory` (lite-06 only), `bench/workloads/fanout*.toml` (connections only). +- Third checkpoint (2026-10-20): the Oct 20 Nightly (`f13283b30`) ran the + JS leg in 3 minutes, so it fits its hour. It failed on the `requests` bench + (stale failover check after `e876c1722`), and the `broadcasts` bench's new + stalled-announce sweep leaked `console.debug` into its CSV; both are fixed. + The six unscheduled JS benches now run nightly with an inventory test in + `sh/gh/nightly.test.py`. The Rust benchmark-tests leg failed on + `benchmark_feed_fetch_wakes` tripping the sim spin check from `3899eea20`; + fixed by yielding between setup phases. +- Rust regression (open): Oct 19 to Oct 20 moved 84 series past +25%, while + the median moved only +0.4%. `track_subscriber_join` went 300 to 670 ns on CI, + and `track_subscriber_churn*` and `track_datagram_subscriber_join` also rose + 80-110%. `annexb`/`cmaf` export, `catalog_estimate_fanout` and + `relay_auth_refresh` rose 27-60% but are not attributed yet. A local bisect of + `track_subscriber_join/1000` (one sample per commit at load 30-50) points to + `b004c0b07` (#5930, refresh on join): 232 ns at `45f2a548e`, 362 ns at + `b004c0b07`. Disabling kio's `sim` feature did not change it. An A/B + removing the `Cursor::new` join check (`joins_live` plus `TrackState::join`) + gave 562 ns vs 409 ns with it, inconclusive under load. Next: profile + subscribe at `45f2a548e` vs `b004c0b07` on a quiet host and fix the source. - Still required before completing this run: confirm `gh-pages` history accumulates and compare at least five nights of Rust and binding series, restore the JS leg and its history, and turn the ranked gaps into From cd13ed531792d6dff7fc3b320960a86c1cf68bf4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 20:24:23 -0700 Subject: [PATCH 07/10] perf(net): resolve a subscriber's servable window once, off the heap #5929 (fe722cec9) doubled the instructions per track subscribe (3,233 to 6,950 in the track_subscriber_join loop under callgrind): Cursor::new published a placeholder window and then ran update_servable, whose closure ran twice and built the window's runs into a fresh RangeInclusiveSet each time, plus one more set per cap. Every join paid about five BTreeMap and three Arc allocations for a window that is almost always one run. Build the published window directly in Cursor::new, resolve the runs once per update, and keep them as a Servable, which holds a single run inline and caps it in place. A subscribe now takes 4,492 instructions; what remains over the pre-#5929 cost is the Window itself. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/track.rs | 130 +++++++++++++++++++++++++++------- 1 file changed, 106 insertions(+), 24 deletions(-) diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 435d44158b4..176fe7803b7 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -5025,7 +5025,7 @@ fn below(runs: impl Iterator>, cap: Option) #[derive(Clone, PartialEq)] struct Published { /// The window's groups, resolved for `revision` of the ranges. - runs: Arc>, + runs: Servable, /// The [`Preferences::ranges_revision`] `runs` were resolved for. revision: u64, cap: Option, @@ -5034,8 +5034,8 @@ struct Published { } impl Published { - fn new(runs: Arc>, revision: u64, cap: Option) -> Self { - let servable = Servable::new(below(runs.iter().cloned(), cap)); + fn new(runs: Servable, revision: u64, cap: Option) -> Self { + let servable = runs.below(cap); Self { runs, revision, @@ -5061,16 +5061,54 @@ impl Servable { /// Every group, for a reader no window narrows. const ALL: Self = Self::Run { start: 0, end: None }; - /// The groups in `runs`. - fn new(runs: RangeInclusiveSet) -> Self { - let mut iter = runs.iter(); - match (iter.next(), iter.next()) { - (None, _) => Self::Run { start: 0, end: Some(0) }, - (Some(run), None) => Self::Run { - start: *run.start(), - end: run.end().checked_add(1), - }, - _ => Self::Runs(Arc::new(runs)), + /// No group. + const NONE: Self = Self::Run { start: 0, end: Some(0) }; + + /// The groups in `runs`, disjoint and lowest first. Only several runs allocate: every + /// subscriber resolves one, so the common single run stays off the heap. + fn new(runs: impl Iterator>) -> Self { + let mut runs = runs.peekable(); + let Some(first) = runs.next() else { + return Self::NONE; + }; + if runs.peek().is_none() { + return Self::Run { + start: *first.start(), + end: first.end().checked_add(1), + }; + } + let mut set = RangeInclusiveSet::new(); + set.insert(first); + set.extend(runs); + Self::Runs(Arc::new(set)) + } + + /// These groups below the exclusive `cap`. + fn below(&self, cap: Option) -> Self { + let Some(cap) = cap else { + return self.clone(); + }; + match self { + Self::Run { start, end } => { + let end = end.map_or(cap, |end| end.min(cap)); + match end > *start { + true => Self::Run { + start: *start, + end: Some(end), + }, + false => Self::NONE, + } + } + Self::Runs(runs) => { + let Some(last) = cap.checked_sub(1) else { + return Self::NONE; + }; + Self::new( + runs.iter() + .take_while(|run| *run.start() <= last) + .map(|run| *run.start()..=(*run.end()).min(last)), + ) + } } } } @@ -5296,7 +5334,8 @@ impl Cursor { }; (filter, state.datagram_offset + start) }; - let mut cursor = Self { + let published = Published::new(Servable::new(filter.window.runs(0)), filter.resolved, None); + Self { state, subscription, min_sequence: 0, @@ -5306,15 +5345,13 @@ impl Cursor { next_sequence: Some(0), peeked: None, end_sequence: None, - servable: Servable::ALL, - // Replaced by the cursor's own below, before anything is handed out. - published: kio::Producer::new(Published::new(Arc::default(), 0, None)), + // Uncapped, the servable groups are the window's. + servable: published.servable.clone(), + published: kio::Producer::new(published), stale: stats::Content::default(), seek_pending: BTreeMap::new(), drops: None, - }; - cursor.update_servable(); - cursor + } } #[cfg_attr(not(feature = "async"), allow(dead_code))] @@ -5346,14 +5383,15 @@ impl Cursor { /// Resolve [`Self::servable`] again once the window or cap moved, and publish it to the /// groups already handed out. Costs the ranges, never the cache. fn update_servable(&mut self) { - self.servable = Servable::new(self.admitted(0, self.end_sequence)); + let runs = Servable::new(self.filter.window.runs(0)); let (revision, cap) = (self.filter.resolved, self.end_sequence); + self.servable = runs.below(cap); let next = |current: &Published| { // Ranges a `Control` republished past this window stay until this cursor syncs // to them; the cap is this cursor's own. let runs = match current.revision > revision { true => current.runs.clone(), - false => Arc::new(self.admitted(0, None)), + false => runs.clone(), }; let next = Published::new(runs, revision.max(current.revision), cap); (next != *current).then_some(next) @@ -5932,7 +5970,7 @@ impl Republish { return; }; drop(state); - let runs = Arc::new(admitted(&window, 0, None)); + let runs = Servable::new(window.runs(0)); if let Ok(mut current) = published.write() && current.revision < revision { @@ -10696,7 +10734,7 @@ mod test { }; let ranges = Subscription::default().with_groups(10..20); // Nothing in 10..20 sits below a cap at 5. - let expected = (Servable::new(RangeInclusiveSet::new()), Some(5)); + let expected = (Servable::NONE, Some(5)); for order in ["ranges first", "cap first", "cap between"] { let producer = track_producer("test", Info::timed()); let mut subscriber = producer.subscribe(Subscription::default()); @@ -10722,6 +10760,50 @@ mod test { } } + /// Capping a servable window in place keeps exactly the groups the set of its runs + /// keeps below the cap, so the single run stays off the heap without moving a bound. + #[test] + fn servable_below_matches_its_runs_below_the_cap() { + // Inclusive (first, last) bounds, lowest first. + let windows: [&[(u64, u64)]; 5] = [ + &[], + &[(0, u64::MAX)], + &[(5, 9)], + &[(5, u64::MAX)], + &[(2, 3), (6, 8), (12, u64::MAX)], + ]; + let caps = [ + None, + Some(0), + Some(2), + Some(3), + Some(5), + Some(7), + Some(9), + Some(10), + Some(13), + Some(u64::MAX), + ]; + for bounds in windows { + let runs = || bounds.iter().map(|&(first, last)| first..=last); + let servable = Servable::new(runs()); + if let [(first, last)] = bounds { + assert!( + servable + == Servable::Run { + start: *first, + end: last.checked_add(1) + }, + "{bounds:?}" + ); + } + for cap in caps { + let expected = Servable::new(below(runs(), cap).into_iter()); + assert!(servable.below(cap) == expected, "{bounds:?} below {cap:?}"); + } + } + } + /// Ranges replaced through a [`Control`] republish what a held group is judged against /// at once, before the cursor next reads: group 0 is judged against the run's own /// group 10, not group 1, which the new ranges never read. From bdb9aec308dba04dc02685f20c60038b199b423c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 21:32:06 -0700 Subject: [PATCH 08/10] chore(quest): record the instruction-count attribution of the Oct 20 regressions Co-Authored-By: Claude Opus 5.5 --- quest/m0/audit-perf.md | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/quest/m0/audit-perf.md b/quest/m0/audit-perf.md index 33c7b072f5b..de88c0aeac4 100644 --- a/quest/m0/audit-perf.md +++ b/quest/m0/audit-perf.md @@ -111,17 +111,31 @@ Audit evidence (2026-10-19, second checkpoint, incomplete): `sh/gh/nightly.test.py`. The Rust benchmark-tests leg failed on `benchmark_feed_fetch_wakes` tripping the sim spin check from `3899eea20`; fixed by yielding between setup phases. -- Rust regression (open): Oct 19 to Oct 20 moved 84 series past +25%, while - the median moved only +0.4%. `track_subscriber_join` went 300 to 670 ns on CI, - and `track_subscriber_churn*` and `track_datagram_subscriber_join` also rose - 80-110%. `annexb`/`cmaf` export, `catalog_estimate_fanout` and - `relay_auth_refresh` rose 27-60% but are not attributed yet. A local bisect of - `track_subscriber_join/1000` (one sample per commit at load 30-50) points to - `b004c0b07` (#5930, refresh on join): 232 ns at `45f2a548e`, 362 ns at - `b004c0b07`. Disabling kio's `sim` feature did not change it. An A/B - removing the `Cursor::new` join check (`joins_live` plus `TrackState::join`) - gave 562 ns vs 409 ns with it, inconclusive under load. Next: profile - subscribe at `45f2a548e` vs `b004c0b07` on a quiet host and fix the source. +- Rust regression (fourth checkpoint, 2026-10-20): attributed with callgrind + instruction counts per iteration, which load does not move. Wall-clock + bisects on this shared host were wrong: `b004c0b07` (#5930) lowers a join + from 3,328 to 3,219 instructions. + - `track_subscriber_join` (and churn, datagram join): `fe722cec9` (#5929) + doubled a subscribe, 3,233 to 6,950 instructions. `Cursor::new` built a + placeholder window, then `update_servable` built the runs into fresh + `RangeInclusiveSet`s about five times. Fixed in this run's PR: 7,135 to + 4,492 at the merged head. The remaining ~1,260 over the pre-#5929 cost is + `Window::new`'s three allocations (ranges, spans, groups). + - `relay_auth_refresh/16/16`: 291.7k to 292.7k (+0.4%). Not a regression; + the bench runs real loopback sockets with 10 samples of 300 ms, so CI + noise. + - `annexb-export-frames/1tracks-16frames/256`: 370k to 460k (+24%). +51k + lands in `c389bd051`..`49448d2ef` (#5921, #5932, #5948, #5958, #5942), +10k + in the commits after through `dcd7d2cbb`, +27k at `fe722cec9`. Main since + added +28k at `9f1fc92fe` or `32d691916` (#6019, #5998). The new cost sits + in `container::Consumer::discard` and `group::Consumer::poll_finished`. The + fix above recovers 8.5k. CMAF export moved +4%. + - `catalog_estimate_fanout/hang/tracks_4/4`: 94.5M to 97.4M (+3%, from + `fe722cec9`), so most of the CI +27-60% is noise. Main since added +9%: + +5M in `ad54a9721`..`76b2f499b` and +4M in `9b5214381`..`4327505086`. + - Next: finish both bisects with the scratch method (bench routine wrapped + in a never-inlined function, `--toggle-collect`, calls counted), then + fix at the source. - Still required before completing this run: confirm `gh-pages` history accumulates and compare at least five nights of Rust and binding series, restore the JS leg and its history, and turn the ranked gaps into From 2c1543422d83dbb59026d2c898b40ecbe3f7b52d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:32:58 -0700 Subject: [PATCH 09/10] chore(quest): finish the m0 performance audit and plan its m1 successor Delete the m0 run, add the m1 successor with the instruction-count method, baselines, the attributed open regressions, and the ranked unbenchmarked paths, and add the allocation-free subscriber window quest. Co-Authored-By: Claude Opus 5.5 --- quest/m0/README.md | 1 - quest/m0/audit-perf.md | 143 --------------------------------------- quest/m1/README.md | 3 + quest/m1/audit-perf.md | 136 +++++++++++++++++++++++++++++++++++++ quest/m1/window-alloc.md | 28 ++++++++ 5 files changed, 167 insertions(+), 144 deletions(-) delete mode 100644 quest/m0/audit-perf.md create mode 100644 quest/m1/audit-perf.md create mode 100644 quest/m1/window-alloc.md diff --git a/quest/m0/README.md b/quest/m0/README.md index d08374ee92e..a7cbeff67b2 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -86,7 +86,6 @@ Each lands its fixes in its own PR and plans only what needs a decision. - [Release builds link](/quest/m0/release-link.md) - the Linux zigbuild release binaries and moq-gst packages link again after the 2026-10-11 nixpkgs bump, so the next release cut can publish - [Namespace advert errors](/quest/m0/namespace-advert-error.md) - one PUBLISH_NAMESPACE stream failing withdraws only that namespace instead of closing the Rust session - [Broadcast epochs](/quest/m0/broadcast-epoch/README.md) - every first-party publisher that can restart mints a fresh route epoch, the newest wins a path, and only routes with the same epoch resume a subscription -- [Performance audit](/quest/m0/audit-perf.md) - benchmarks that regressed since the last run are explained, fixed, or planned, and unbenched hot paths get coverage - [Compile time audit](/quest/m0/audit-compile-time.md) - build-time hotspots are measured against a baseline and the worst are fixed or planned - [Simplification audit](/quest/m0/audit-simplify.md) - overbuilt code and APIs are collapsed, merged, or narrowed into a net simpler whole - [Quest tree audit](/quest/m0/audit-quests.md) - the tree agrees with itself and with main diff --git a/quest/m0/audit-perf.md b/quest/m0/audit-perf.md deleted file mode 100644 index de88c0aeac4..00000000000 --- a/quest/m0/audit-perf.md +++ /dev/null @@ -1,143 +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`. - -Starting points (2026-10-19): there are 55 `[[bench]]` targets across 14 crates -(counted from `rs/*/Cargo.toml`) and 27 JS bench files. Nightly stores their history with -`github-action-benchmark` (`bench/costs`, `bench/rates`), and - flags each series that moved beyond its own noise. Compare against -that history and against the numbers this Plan records. The audit found -`sh/gh/nightly.sh` skipped 13 targets: moq-e2ee, moq-json, moq-archive and -moq-cli benches, mux `jitter`, and 5 of 6 moq-uring benches. The current fix -schedules all 55 targets and checks the manifest inventory in the existing -nightly tooling tests. Supplemental and io_uring measurements have separate -one-hour jobs. Handwritten allocation, window, and playback-buffer tables -remain in the raw run logs; only Criterion estimates enter the chart report. -Fan-out paths need a sweep over both axes -(AGENTS.md). JS perf is judged in a browser, not node or bun. PR-time gating -belongs to [benchmark regressions in CI](/quest/m2/bench-ci.md); don't -duplicate it. - -Audit evidence (2026-10-19, second checkpoint, incomplete): - -- History (updated 2026-10-20): `gh-pages` gains a commit per night, and Pages first deployed on - 2026-10-20; - renders it as a regression table. Re-runs of the Benchmark site job add duplicate - points for one commit, so compare by commit. -- Rust: both the October 18 (`50da59e67`) and October 19 (`ad87ad34e`) - Nightlies retain `bench-rust` (1,527 series each); the earlier note that - the 19th had none was wrong. Across 1,682 cost series the median change is - +0.2% (p5 -5%, p95 +16%). The largest moves go both ways in moq-net: - `retirement` +36% median over 18 series, `track_wall/repoll/10000x1` - +125%, moq-transport `session_idle` +40-90%, while - `session_delivery_group_cost` improved 40-47%. kio `waiter_register_live` - moved +46% with no kio change. The only moq-net source change between the - commits is the fetch fix `5c3120840` (frame read and fetch routing), which - none of `retirement`, `track_wall` or `session_idle` exercises; the rest is - a Cargo.lock bump (`8f13d08d1`). Both nights ran on Neoverse N2 runners. - Treat these as run-to-run variance of fat-LTO micro-benches, not - regressions. A paired local A/B of the two commits was built but stopped: - at a host load of 46-81 Criterion intervals spanned +/-50%. Re-check once - `gh-pages` holds five or more nights; a series that steps and stays there - is a regression to attribute. -- Bindings: five nights of `bench-ffi` (Oct 16, 17 twice, 18, 19) bound the - noise. Kotlin 1 KiB 4x4 CPU reads 104.5, 146.1, 117.5, 79.1, 122.7 ms/MB, - so the +55% flagged last checkpoint was a low outlier on the 18th. Go 1 KiB - 1x4 throughput reads 185.7, 205.7, 206.7, 208.0, 181.4 MB/s, back to the - 16th's level. Python swings 10-16% between nights. Dart has only two - nights; its -12% on small frames sits inside that band, and both nights - used Dart 3.13.0 (the nixpkgs bump `4109d3893` did not change it). No - binding regression is established. Recheck Dart against `gh-pages`. -- JS: the Nightly JS leg was cancelled at one hour by the forward fixture, - which the test-cost audit fixed in - [#5976](https://github.com/moq-dev/moq/pull/5976). Until a Nightly runs - with it there is no JS history. Nightly never runs these JS benches: - net `observed`; json `codec` and `parse`; hang `slow-group`; watch - `warmup`; clock `timers` (`qmux` and `serve-browser` run, uncharted, in - the audio-quality job). Add them, with an inventory test like the Rust - one, only after the leg fits its hour. - Browser smoke artifacts remain one-round correctness runs. -- Inventory: moq-uring `timers` (`cdff3c8f9`) landed after the Rust - inventory test and failed it; this run schedules it in the io_uring group. -- Unbenchmarked hot and fan-out paths, ranked (each needs a bench or a - follow-up quest): - 1. HLS/DASH serving (`rs/moq-hls/src/export/rendition.rs` `segment()`, - `media_playlist()`, `mpd.rs`): every request refetches and remuxes; - sweep viewers x renditions x window segments. - 2. Session-level datagram delivery (`lite/publisher.rs` `serve_datagram`, - `ietf/datagram.rs`): per object per subscriber; add a - `session_delivery_datagram` group sweeping publishers x 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. JS hang container `Consumer` walks every buffered group per frame - (`consumer.ts` `#updateBuffered`, `#checkMaxDelay`); browser bench. - 5. JS per-sample copies in CMAF decode and LOC encode; `js/loc`, - `js/msf`, `js/flate` have no benches. - 6. moq-quic loss recovery and real congestion controllers: every bench - pins `Unlimited`; sweep controller x flight x loss x streams. - 7. Relay `/announced` copies the route table per request (`web.rs`); - sweep routes x pollers. - 8. JWT verification per connect and fetch (`moq-auth`, no benches); - sweep algorithm x key-set size. - 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). - Single-axis fan-out benches to widen: `session_delivery_paced` (viewers - only), `track_fanout_*` (subscribers only), `memory` (lite-06 only), - `bench/workloads/fanout*.toml` (connections only). -- Third checkpoint (2026-10-20): the Oct 20 Nightly (`f13283b30`) ran the - JS leg in 3 minutes, so it fits its hour. It failed on the `requests` bench - (stale failover check after `e876c1722`), and the `broadcasts` bench's new - stalled-announce sweep leaked `console.debug` into its CSV; both are fixed. - The six unscheduled JS benches now run nightly with an inventory test in - `sh/gh/nightly.test.py`. The Rust benchmark-tests leg failed on - `benchmark_feed_fetch_wakes` tripping the sim spin check from `3899eea20`; - fixed by yielding between setup phases. -- Rust regression (fourth checkpoint, 2026-10-20): attributed with callgrind - instruction counts per iteration, which load does not move. Wall-clock - bisects on this shared host were wrong: `b004c0b07` (#5930) lowers a join - from 3,328 to 3,219 instructions. - - `track_subscriber_join` (and churn, datagram join): `fe722cec9` (#5929) - doubled a subscribe, 3,233 to 6,950 instructions. `Cursor::new` built a - placeholder window, then `update_servable` built the runs into fresh - `RangeInclusiveSet`s about five times. Fixed in this run's PR: 7,135 to - 4,492 at the merged head. The remaining ~1,260 over the pre-#5929 cost is - `Window::new`'s three allocations (ranges, spans, groups). - - `relay_auth_refresh/16/16`: 291.7k to 292.7k (+0.4%). Not a regression; - the bench runs real loopback sockets with 10 samples of 300 ms, so CI - noise. - - `annexb-export-frames/1tracks-16frames/256`: 370k to 460k (+24%). +51k - lands in `c389bd051`..`49448d2ef` (#5921, #5932, #5948, #5958, #5942), +10k - in the commits after through `dcd7d2cbb`, +27k at `fe722cec9`. Main since - added +28k at `9f1fc92fe` or `32d691916` (#6019, #5998). The new cost sits - in `container::Consumer::discard` and `group::Consumer::poll_finished`. The - fix above recovers 8.5k. CMAF export moved +4%. - - `catalog_estimate_fanout/hang/tracks_4/4`: 94.5M to 97.4M (+3%, from - `fe722cec9`), so most of the CI +27-60% is noise. Main since added +9%: - +5M in `ad54a9721`..`76b2f499b` and +4M in `9b5214381`..`4327505086`. - - Next: finish both bisects with the scratch method (bench routine wrapped - in a never-inlined function, `--toggle-collect`, calls counted), then - fix at the source. -- Still required before completing this run: confirm `gh-pages` history - accumulates and compare at least five nights of Rust and binding series, - restore the JS leg and its history, and turn the ranked gaps into - benchmarks or follow-up quests through `/quest-plan`. Keep this quest in - m0 until then; add its m1 successor only when it completes. diff --git a/quest/m1/README.md b/quest/m1/README.md index b9592b2094c..1eb1f6cec07 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -126,6 +126,8 @@ lands before the cut. - [Nightly media players](/quest/m1/media-engines-nightly.md) - the Firefox and WebKit player rows pass, or an engine that cannot play leaves the nightly matrix +- [Allocation-free single-range subscriber window](/quest/m1/window-alloc.md) - a one-range subscribe resolves its window without a heap allocation, recovering the join cost per-subscriber ranges added + - [moq-net compiles once](/quest/m1/net-erase-transport.md) - the session drivers stop monomorphizing per transport and per crate, saving several MiB of the relay, FFI library, `libmoq` and CLI - [Dead code and API surface audit](/quest/m1/audit-dead-code.md) - repeat the removal audit before the next major release @@ -136,6 +138,7 @@ lands before the cut. - [CI workflow audit](/quest/m1/audit-ci.md) - every workflow and job gives a signal someone sees, at a cost that signal justifies, or is fixed, moved, or deleted - [Documentation audit](/quest/m1/audit-docs.md) - stale pages, examples, links, and undocumented exports are fixed or planned - [Artifact size audit](/quest/m1/audit-size.md) - binary, FFI, WASM, and bundle growth since the m0 run is explained, fixed, or planned +- [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 ## Related diff --git a/quest/m1/audit-perf.md b/quest/m1/audit-perf.md new file mode 100644 index 00000000000..320a042a930 --- /dev/null +++ b/quest/m1/audit-perf.md @@ -0,0 +1,136 @@ +# [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. Each is independently +landable with its own regression bench, so recommend each as a `/quest-plan` +follow-up unless it turns out trivial: + +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 belong to + [Allocation-free single-range subscriber window](/quest/m1/window-alloc.md). + +### 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/DASH serving (`rs/moq-hls/src/export/rendition.rs` `segment()`, + `media_playlist()`, `mpd.rs`): every request refetches and remuxes; sweep + viewers x renditions x window segments. +2. Session-level datagram delivery (`lite/publisher.rs` `serve_datagram`, + `ietf/datagram.rs`): per object per subscriber; add a + `session_delivery_datagram` group sweeping publishers x 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. JS hang container `Consumer` walks every buffered group per frame + (`consumer.ts` `#updateBuffered`, `#checkMaxDelay`); browser bench. +5. JS per-sample copies in CMAF decode and LOC encode; `js/loc`, `js/msf`, + `js/flate` have no benches. +6. moq-quic loss recovery and real congestion controllers: every bench pins + `Unlimited`; sweep controller x flight x loss x streams. +7. Relay `/announced` copies the route table per request (`web.rs`); sweep + routes x pollers. +8. JWT verification per connect and fetch (`moq-auth`, no benches); sweep + algorithm x key-set size. +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). + +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. PR-time gating belongs to +[benchmark regressions in CI](/quest/m2/bench-ci.md); don't duplicate it. + +## Related + +- [Allocation-free single-range subscriber window](/quest/m1/window-alloc.md) - the subscribe cost the m0 run left after its fix diff --git a/quest/m1/window-alloc.md b/quest/m1/window-alloc.md new file mode 100644 index 00000000000..74e84686151 --- /dev/null +++ b/quest/m1/window-alloc.md @@ -0,0 +1,28 @@ +# [S] Allocation-free single-range subscriber window + +## Goal + +Subscribing with one range, as nearly every subscriber does, resolves its +`Window` without a heap allocation, so a join costs what it did before +per-subscriber ranges ([#5929](https://github.com/moq-dev/moq/pull/5929)). + +## Plan + +The m0 performance audit measured `track_subscriber_join` with callgrind: +3,233 instructions per join before #5929, 6,950 after it, and 4,492 once the +audit's PR resolved the servable window once and kept a single run inline +(`Servable`). The remaining ~1,260 instructions are `Window::new` in +`rs/moq-net/src/model/subscription/window.rs` and its drop: it clones the +ranges into a `Vec`, pushes the spans into another, and inserts the groups into +a `RangeInclusiveSet`, so a default subscription allocates three times. + +Give the common case an inline representation: one range, one span, and its +groups as a single run, spilling to the current collections only for several +ranges. This is private to moq-net. Measure instructions per join the way the +audit did (a loop of `subscribe` plus `poll_subscription_changed`, the +difference of two iteration counts under callgrind), and keep +`track_subscriber_join` and `track_subscriber_churn` as the Nightly check. + +## Related + +- [Performance audit](/quest/m1/audit-perf.md) - the recurring audit that found the cost From c76a88cd7b34ecc178885b96f3a30188be6fdce3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 22:59:44 -0700 Subject: [PATCH 10/10] chore(quest): fix the successor's open regressions in its own run's PR Co-Authored-By: Claude Opus 5.5 --- quest/m1/audit-perf.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quest/m1/audit-perf.md b/quest/m1/audit-perf.md index 320a042a930..ea919752465 100644 --- a/quest/m1/audit-perf.md +++ b/quest/m1/audit-perf.md @@ -67,9 +67,9 @@ wall-clock bisect blamed the wrong commit. Count instructions instead: ### Open regressions from the m0 run -The m0 run attributed these, but none has a fix yet. Each is independently -landable with its own regression bench, so recommend each as a `/quest-plan` -follow-up unless it turns out trivial: +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