Repository navigation
perf(net): fix the 11-26 Nightly bench regressions in capture fanout and arrival reads - #9747
Conversation
Quest-Claim: 49525495ea009dae
…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>
… walks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughThe change excludes Merge Risk:
|
Finishes quest/m0/nightly/bench-regressions-1126.md.
Problem
Nightly 45867457463 (
4fba5df73fagainst420b8dcb0d) flaggedcapture_fanout/*(+14% to +17%) and one lite-07session_delivery_group_cost_cpucell (+11.2%). Both still reproduce onmain(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 hakaristarted unifying its features: the workspace-hack gainedkio = { features = ["manual", "serde", "sim"] }, so every bench and test build compiled kio'ssimpoll accounting (13 more instructions per read). Release builds never had it, since the workspace-hack is a dev-dependency. Fix: list kio underfinal-excludesin.config/hakari.toml, which is how kio was built when it was a workspace member.TrackState::poll_arrivalsbuilt a newVecon every walk, andCursor::write_off_oldestconsumed the oldest held group (anArc<Delivery>) only to judge whether it was stale, then dropped it. Fix: the cursor'sFilterkeeps onearrivedbuffer for the walk, shrunk back to 4 keys after a catch-up, andpoll_stalejudges 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/laggingregression was recorded.Impact
Caused by
cargo hakariunify kio's test-onlysim/manualfeatures into every bench and test build (found by check: Nightly paired benchmarks)Vecper walk and consumed a group only to judge it stale (found by check: Nightly paired benchmarks)Validation
capture_fanoutinstructions per iteration (base420b8dcb0d/main/ this PR), fromperf statat N and 2N iterations of a scratch driver running the bench's own loop: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'sSESSION_ALLOCScounter:420b8dcb0d7cab21e65bmainThe 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,
main285.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 failedmoq-tokiomigrate::a_predecessor_serves_until_its_last_subscription_leavesonce (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, andquest checkare clean.Alternatives
simfrom the workspace-hack by excluding it some other way: hakari has no per-feature exclude. Excluding the package keeps unification for kio's own dependencies.write_off_oldestand the pick share one scan: it would save part of the remaining 2.3%, but it would rework the ordering logic feat(net): an arrival read serves held groups in Group Order, in Rust and JS #9529 just verified against the resume model. Not worth it for this cost.Decisions
.config/hakari.tomlas well, next to the existing pins inCargo.toml,nix/Cargo.nix, and the fanout bench manifests. A stale pin makescargo hakari generatefail 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'ssim. 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 reviewafter 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-e93cfdd0c033Risk file: bb7b1c0de60b
Reviewer: Codex, gpt-6.2-sol, high effort
Session:
01a21cc4-4209-7d60-b8cb-cf1134ce808d, round 2Score: 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:
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`).