Skip to content

perf(net): fix the 11-26 Nightly bench regressions in capture fanout and arrival reads - #9747

Merged
kixelated merged 4 commits into
mainfrom
quest/m0/nightly/bench-regressions-1126
Nov 27, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m0/nightly/bench-regressions-1126

Conversation

@kixelated

@kixelated kixelated commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/nightly/bench-regressions-1126.md.

Problem

Nightly 45867457463 (4fba5df73f against 420b8dcb0d) flagged capture_fanout/* (+14% to +17%) and one lite-07 session_delivery_group_cost_cpu cell (+11.2%). Both still reproduce on main (83e10f008a), so the PRs that landed since did not clear them.

Approach

Measured in user instructions per iteration on one pinned core, since wall time on the shared host varied by up to 30% between runs. Bisected each one to its PR:

  • capture_fanout: moq-dev/moq#9675. kio's source is byte-identical across the move, but once kio left the workspace, cargo hakari started unifying its features: the workspace-hack gained kio = { features = ["manual", "serde", "sim"] }, so every bench and test build compiled kio's sim poll accounting (13 more instructions per read). Release builds never had it, since the workspace-hack is a dev-dependency. Fix: list kio under final-excludes in .config/hakari.toml, which is how kio was built when it was a workspace member.
  • lite-07 group cost: moq-dev/moq#9529, not #9686 (about 1,000 instructions). It added 6 allocations and about 11,000 instructions per viewer-group on every version. DHAT showed where the allocations came from: TrackState::poll_arrivals built a new Vec on every walk, and Cursor::write_off_oldest consumed the oldest held group (an Arc<Delivery>) only to judge whether it was stale, then dropped it. Fix: the cursor's Filter keeps one arrived buffer for the walk, shrunk back to 4 keys after a catch-up, and poll_stale judges a key, so only a group actually written off gets consumed. The remaining +2.3% is accepted (see Decisions).

The epic README records the bisect, matching how the routes/lagging regression was recorded.

Impact

  • Public API: none. Wire: none. Behavior: none. The arrival read hands out the same keys and judges staleness the same way.
  • Build: kio may now compile with more than one feature set within a test build (as it did before refactor(kio): move rs/kio to kixel-ai/kio #9675). kio is small.

Caused by

  • moq-dev/moq#9675 - moving kio out of the workspace let cargo hakari unify kio's test-only sim/manual features into every bench and test build (found by check: Nightly paired benchmarks)
  • moq-dev/moq#9529 - the Group Order arrival read allocated a Vec per walk and consumed a group only to judge it stale (found by check: Nightly paired benchmarks)

Validation

capture_fanout instructions per iteration (base 420b8dcb0d / main / this PR), from perf stat at N and 2N iterations of a scratch driver running the bench's own loop:

cell base main this PR
sources_1/1 335 348 (+3.9%) 335
sources_1/16 2,150 2,358 (+9.7%) 2,150
sources_4/4 2,771 2,979 (+7.5%) 2,771
sources_16/16 34,295 37,623 (+9.7%) 34,295

All nine cells match the base exactly, and cycles do too (within 0.2%).

The lite-07 cell (relays=1/publishers=16/broadcasts=1/viewers=1/watch=1/frame=64) per viewer-group, from the bench's SESSION_ALLOCS counter:

allocations instructions
base 420b8dcb0d 329.95 487,300
#9529 7cab21e65b 335.95 498,400
main 337.95 500,200
this PR 331.95 498,500

The review's fix (each reader keeps at most 4 keys of scratch between walks) leaves this unchanged: 331.95 allocations, 498,300 instructions.

The fastest of six cycle counts: base 279.0k, main 285.7k (+2.4%), this PR 282.8k (+1.4%). The +11% Nightly reported shows up only in wall time on a loaded host, not in cycles.

  • just ci: passed (13,691 tests). An earlier run failed moq-tokio migrate::a_predecessor_serves_until_its_last_subscription_leaves once (group 6 skipped) under full-suite load. It did not fail in 40 stress runs or in 800 runs at 16 to 32 in parallel, and this PR's read changes keep the same keys and stale judgments, so I treated it as a one-off.
  • cargo hakari generate --diff, just rs cargo-nix, and quest check are clean.

Alternatives

Decisions

  • Accept the remaining +2.3% instructions per viewer-group from feat(net): an arrival read serves held groups in Group Order, in Rust and JS #9529 as the cost of serving held groups in Group Order. Taken without the maintainer (away); recommended.
  • Pin kio's rev in .config/hakari.toml as well, next to the existing pins in Cargo.toml, nix/Cargo.nix, and the fanout bench manifests. A stale pin makes cargo hakari generate fail with an error, so the gate catches it. Taken without the maintainer (away); recommended.

Follow-ups

None. Dropped: moq-net's Nightly benches build with --features fuzz, which turns on kio's sim. Base and head both carry it, so paired deltas stay valid.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: a7b4678

  • Base: origin/main at 17fe706

  • Risk: medium, What could break: the track.rs changes alter internal delivery order and stale write-off in the subscriber read path (arrival buffer reuse, Group Order pick, consuming only written-off groups), which could misdeliver or skip groups for subscribers of shipped moq-net; the hakari.toml and workspace-hack/Cargo.lock/nix edits change how the workspace-hack unifies kio features in builds and benches, not what ships. Both are undone by reverting the commits, with no API, wire, auth, release-script, or stored-data change, and no RISK.md high path is touched, so the change is medium (it changes shipped behavior that a revert fully undoes), and the quest/README edits are low.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 3644a622-cb6a-4447-b1de-e93cfdd0c033

  • Risk file: bb7b1c0de60b

  • Reviewer: Codex, gpt-6.2-sol, high effort

  • Session: 01a21cc4-4209-7d60-b8cb-cf1134ce808d, round 2

  • Score: 10/10, The head releases backlog-sized scratch storage after each arrival scan, and the follow-up introduced no new findings.

  • Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

  • The last round's findings, at 9cdb5ee:

    • Fixed: medium, rs/moq-net/src/model/track.rs:12345: Release arrival scratch storage after large scans; `owe_arrivals` drains the keys and calls `shrink_to(ARRIVED_KEPT)` with a four-key limit before returning the buffer to the cursor (`rs/moq-net/src/model/track.rs:12351`).

kixelated and others added 3 commits November 26, 2026 23:43
…ead allocations

kio left the workspace in #9675, so cargo-hakari began unifying its features,
compiling kio's test-only sim and manual features into every bench. Exclude
kio from the workspace-hack, as when it was a member.

An arrival read allocated a Vec per walk and consumed a group only to judge
whether it was stale; reuse one buffer and judge by key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Nightly 2026-11-26's paired benchmark regressions are fixed or accepted perf(net): fix the 11-26 Nightly bench regressions in capture fanout and arrival reads Nov 27, 2026
… walks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 27, 2026 11:47
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change excludes kio from workspace-hack dependencies and updates benchmark documentation. In moq-net, arrival polling now uses a reusable buffer, and stale checks pass group keys directly. The updated README reports measurements for the capture and delivery-group benchmarks.

Merge Risk: Minimal · up to a7b46 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a perf fix for the 11-26 Nightly benchmark regressions in capture fanout and arrival reads. The diff matches both parts. The hakari.toml and workspace-hack edits exclu…
Description check Passed The description is closely related to the changeset. It names the regressed benchmarks, the PRs that caused them, and the kio exclusion in .config/hakari.toml. It describes the arrival-buffer and stal…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a perf fix for the 11-26 Nightly benchmark regressions in capture fanout and arrival reads. The diff matches both parts. The hakari.toml and workspace-hack edits exclude kio to stop feature unification, which addresses capture_fanout. The track.rs edits reuse an arrival buffer and judge staleness by key, which addresses the arrival-read regression. The title is specific and uses the conventional commit form.

Full details: Description check

Explanation

The description is closely related to the changeset. It names the regressed benchmarks, the PRs that caused them, and the kio exclusion in .config/hakari.toml. It describes the arrival-buffer and staleness changes in track.rs and the removal of the bench-regressions-1126 document. It also gives validation data for the changes.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd5231e9-782e-481e-8848-ba8fd98f2cc1
Commits

Reviewing files that changed from the base of the PR and between 83e10f0 and a7b4678.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 6

  • .config/hakari.toml
  • nix/Cargo.nix
  • quest/m0/nightly/README.md
  • quest/m0/nightly/bench-regressions-1126.md
  • rs/moq-net/src/model/track.rs
  • rs/workspace-hack/Cargo.toml
Files with no reviewable changes: 3

  • nix/Cargo.nix
  • quest/m0/nightly/bench-regressions-1126.md
  • rs/workspace-hack/Cargo.toml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@kixelated
kixelated added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 6d321ea Nov 27, 2026
6 checks passed
@kixelated
kixelated deleted the quest/m0/nightly/bench-regressions-1126 branch November 27, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant