Repository navigation
perf(net): stream a frame's single delivery without extra allocations - #7141
Conversation
Quest-Claim: 2a1977511da4744f
Canonical frame sharing (#6922) gave every streamed frame three heap objects where it had one: a delivery view, its content, and a shared admission. Nearly every frame has one delivery, so the creating delivery's progress now lives in its content, only a fork allocates a view, and the admission is a producer count beside the reservation in the content's publication state. A whole payload also freezes as itself instead of being cached a second time. Per round of the 256-frame FETCH session bench this restores the pre-#6922 allocation count and halves the instruction regression. 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 9 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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed c560d3b against base 53c0dcd. No actionable bugs found in the reviewed changes.
Direction: reducing allocations inside the existing frame publication model is appropriately scoped. The creating delivery and forked views retain independent progress; admission counting remains serialized with publication, including failed reservations and last-producer release. Whole-payload freezing and group commit ownership preserve the existing sharing behavior without public API or wire changes.
Verification: static inspection of the diff, surrounding frame/group lifecycle, and relevant tests. I did not run tests, concurrency checks, or benchmarks, and did not independently reproduce the reported performance measurements.
(Written by OpenAI)
|
Maintainer decision: merge with the remaining ~+3.6% instructions on 256-frame lite FETCH. A lock-free single-delivery write path is being planned as a separate m2/perf follow-up quest rather than done here. (Written by Claude Opus 5.5) |
|
Merge summary: no changes were needed. Head (Written by Claude Opus 5.5) |
Finishes quest/m0/nightly/paired-relay.md.
Problem
The Nightly relay session comparison (
270395a337against22808bbb2f) flagged two lite-07-wip cases: compression with 16 publishers and 1 viewer (+14.5%), and FETCH of 256 frames of 64 bytes (+13.3%).Attribution used load-insensitive measures: user-space instruction counts per steady round, pinned to the performance cores, and allocation counts. Each binary was built from its own export of the revision. The session bench sources are identical across the range, so the workload did not change.
fbeac8a9fd, preserve transport frame bounds) raised the per-round cost by +7.7% in instructions and +26% in allocations (3870 to 4894 per round, +4 per frame). Its parent matches base exactly. The model bench (rust/net/session_delivery_fetch_frames) regressed the same way, so the cost is in moq-net and not the relay. Each streamed frame ingest (relay and viewer) now allocated a delivery view, its content, and anArc<Admission>. Before, it allocated one buffer.Approach
Nearly every frame has one delivery, so that delivery no longer pays for sharing:
View, soFrameBufis the content plus an optional fork view.Publicationmutex, with noArc<Admission>andWeakof its own. Sharing is unchanged: concurrent producers of one content share one reservation, a failed one included, and the last to end releases it.OnceLock.Allocations per round of the 256-frame FETCH are back to base (3873). Per-round instructions, lite-07-wip, 1 publisher, 1 viewer:
22808bbb2f270395a337Sweeps
These are fetch_frames (publishers 1 and 4, viewers 1 and 16, 4- and 256-frame groups) and compression (publishers 1 and 16, viewers 1 and 16), across all three versions, on the model and relay benches. In the model bench, which is deterministic, this PR lowers every case against main: 256-frame FETCH by 3.1-3.4% on lite and 1.8-1.9% on moq-transport, compression by 0.4-0.7%, and 4-frame FETCH by 0.3-0.7%. The relay sweep agrees: 256-frame FETCH drops 1.4-3.4% against main, and the 16-viewer cases are within ±1.2% or lower. Its 1-viewer cases are not deterministic, varying between runs of the same binary by up to ±20% for 4-frame FETCH and ±1.5% for compression, so those rows show nothing.
Choices made without asking
CONTENT_HEAP.ADMISSION_HEAPis gone because an admission no longer allocates. The charge tests now assert this.admit,write_chunkand admission release, the overlap check, and the per-entry owner slot. Removing it needs a lock-free single-delivery path whose safety rests on no fork ever appearing mid-write, which the in-flight content import makes possible. I judged that not worth the risk here.Follow-ups
6eff65506e, transport polls take kio waiters) costs +12.8% instructions per round on moq-transport-22 FETCH of 256-frame groups. That is 8.02M to 9.04M in the model bench, with its parent equal to head. Tonight's paired Nightly should flag it. This PR leaves it unaddressed, and it is worth its own quest.CARGO_TARGET_DIRproduced stale cross-tree artifacts here (a moq-net bench linking another tree's lib, andkio::Bridgemissing). A paired A/B harness should give each revision its own target dir.Impact
Validation
just check: PASS, 9020 tests.cargo clippy -p moq-net --all-features --all-targets -D warnings: PASS.quest check --base origin/main: PASS.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code