Repository navigation
fix(relay): a connection's task frees its startup state once the session starts - #8943
Conversation
Quest-Claim: e2c3babe2126dc5c
…ion starts The chat workload's relay held 35 KiB more per connection on main than on release. A jemalloc profile put it on moq-relay's per-connection task: the startup future passed by value through Lifecycle's async fns, which keep their arguments for their whole life, so the task held 44.8 KiB and a box beside it 20.4 KiB until the connection closed. Box the startup future before the task is built and build the supervision with combinators; the task is now 1.4 KiB plus a 6.2 KiB supervision, and chat's relay RSS is 7% under release's. The release comparison now reports relay RSS beside CPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
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. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
I reviewed the whole PR at 3185c96: the restructured relay connection task, RSS pairing in the bench comparison, and the quest/report bookkeeping.
- Startup future freed once the session starts.
Connection::runnow boxesSelf::start(...)before building the task, so theBoxdrops whenisolatecompletes and the startup state no longer lives as long as the connection. I traced both paths. Without a shared runtime, start and supervision are each still isolated under the connection span, and a panic still closes the connection withconnection panicked. With a shared runtime, start still runs on the worker and supervision is still spawned on the shared runtime with the same close logging. - Supervision built with combinators.
startreturnsjoin(supervise(..), R::drive(driver)).map(..).boxed()directly, and thenegotiatedlog moves intostart, still under the connection span throughisolate.isolatenow takesPin<Box<F>>withF: ?Sized, so passing an existingBoxFuturedoes not box it a second time. The new'staticbound onSealed::driveholds for every impl: each is anasync fnover a concrete'staticDriver. - RSS in
bench/compare.py.rss_bytesis paired like the host CPU metrics, with the same "unavailable" handling when both sides have no samples.summary.pyalready emits it, and the tests cover both the delta and the case where samples are missing. - Quest and report updates.
.github/release-perf.mdrecords the measurements, andquest/m2/relay-cpu.mdis the new follow-up. Removingquest/m2/relay-memory.mdleaves no dangling links, and the new#relay-memory-2026-11-16and#methodanchors both resolve.
claude-opus-5-5 | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed 3185c96bfd391e062203cdacc0b728494810c366. No blocker for the memory fix. The boxed startup future is gone before the session runs, and both phases retain panic isolation, the connection span, and the existing driver/supervision join. All 19 tests in bench/compare.test.py passed locally; I did not rerun the Rust tests or relay pairing.
I’d narrow the release note: chat RSS consistently improved in this pairing; fanout’s paired range still crosses zero. Keep the CPU-per-frame regression separate from the memory result and retire the earlier blanket claim of lower CPU until the follow-up pairing explains the reversal.
|
Maintainer decision (2026-11-16, /quest-run): merge, and keep follow-up quest/m2/relay-cpu.md in m2 with its decision answered: ✅ the cut waits on it (rejected: moving it to m3; dropping it). (Written by Opus 5.5) |

Finishes quest/m2/relay-memory.md.
Problem
The 2026-11-05 release pairing recorded relay RSS but never reported it: in
chat(2,001 connections) the relay used about 17% more memory onmainthan onrelease. The cut waits on a cause, and on the comparison reporting memory so the next one cannot miss it.Approach
Reproduced on today's
main(6488ce6b87) againstorigin/release(ca3b801a6c):chatRSS +16.1% (+35 KiB per connection), every pair larger. A jemalloc heap profile of both sides, attributed by owner in KiB per connection (main minus release):moq-relay's per-connection tasks)moq_net::model)moq_netprotocol,kio)Connection::runpassed its startup future by value throughLifecycle::start,Lifecycle::runandLifecycle::isolate. An async fn keeps its arguments for its whole life, so the connection's task held 44.8 KiB (startup's largest state, twice) plus a 20.4 KiB box, until the connection closed.runnow boxes the startup future before building the task, so it is freed when the session starts, andstartbuilds the supervision withjoin/mapinstead of an async block that kept a second copy of the session's state. Per-connection futures go from 44.8 + 20.4 + 12.3 KiB to 1.4 + 6.2 KiB (-Zprint-type-sizes).releaselacks (report record moq-dev/moq#8440, one-delivery record moq-dev/moq#5446, demand preferences moq-dev/moq#5670), recorded in.github/release-perf.md. The in-tree QUIC stack saves 38 KiB per connection overnoq.bench/compare.pypairsrss_byteslike CPU;bench/README.mdand the performance audit's Release baseline ask for it under the same accept-or-fix rule.Impact
moq_relay::Connection::runisfn run(self) -> impl Future<Output = ()>instead ofasync fn run(self): same output and auto traits, so callers that.awaitor spawn it are unchanged.negotiatedlog line is emitted whenstartreturns rather than on the supervision's first poll, in the same span.Alternatives
superviseitself, which keeps its 2.3 KiB of arguments twice. It is public (moq --listenuses it) and turning it into a non-async fn would move its setup out of the first poll; 2 KiB per connection did not earn that.Lifecycle(1 KiB, of whichClusteris 792 bytes by value) behind anArc: the task now holds one copy, so it would save under 1 KiB per connection; left as is.Caused by
release's task holds about 27 KiB.Decisions
Taken while unattended, each undoable in review:
.tmp/bench(the session's brief), not a durable directory outside it as the quest suggested; every number is copied into.github/release-perf.mdand here.Requiredlink along with the quest.Follow-ups
chatandfanoutrelay CPU per delivered frame +43% and +35% onmain, every pair slower, the opposite of the 2026-11-05 result. Lead:moq_quic's sent-packetSlotsfrees and reallocates an 8 KiB chunk per packet on a connection that has everything acknowledged (half ofchat's allocation churn). Open decision: whether the cut waits on it (recommended: yes, so it stays in m2) or it moves to m3 for the performance audit.Validation
just bench-relay origin/release quic, five alternating rounds each, onfedora(32 CPUs, 1-minute load 13 to 26 at snapshots). Median relay RSS, release / main:chat427.0 / 495.6 MiB (+16.1%, range +14.1 to +29.4),fanout37.2 / 41.1 (+10.3%),video30.5 / 29.1 (-3.5%)chat427.1 / 392.1 MiB (-7.2%, range -13.4 to -6.8),fanout36.9 / 37.4 (-2.7%),video29.9 / 27.4 (-6.0%)just bench-profile heap chat 8 tokio-workers origin/release, jemalloc retained heap at steady end: release 466 / 471 MiB, main 542 MiB before and 395 MiB after (the table above). Steady-window growth was 7.7 MiB of 568, and teardown returns near the idle heap on both sides: no leak.RUSTC_BOOTSTRAP=1 cargo rustc --release -p moq-relay --lib -- -Zprint-type-sizesbefore and after for the future sizes quoted.just rs test -p moq-relay --all-features(492 passed),just check,python3 bench/compare.test.py.Models
Size: M
Implementer: Claude Code, claude-opus-5-5, high effort (arm B)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 3185c96
Base: origin/main at 13e593c
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1e4ff-2f35-7ff3-8a8f-60186751e297, round 2Score: 10/10,
The incremental change fixes unavailable RSS handling, and code inspection found no new issues.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 3fb409e:
bench/compare.py:24:Allow unavailable RSS when host sampling is absent;bench/compare.py includes rss_bytes in HOST_METRICS and reports it unavailable when all paired samples omit it; bench/compare.test.py covers missing CPU and RSS on both sides.