Repository navigation
perf(net): avoid redundant stats drain synchronization - #6293
Conversation
Quest-Claim: b3e790816af1e162
Co-Authored-By: GPT-6 <noreply@openai.com>
|
Completed the stats source work and three alternating benchmark rounds. At 10,000 sessions, the payload-only drain falls from 88.6 to 52.2 us/report (-41.1%); including one registered transport Wire/session falls from 416.1 to 388.4 us (-6.6%). Per-label bytes and stats semantics remain, with no public API or wire change. The epic now records the actual wire-inclusive accepted cost, about 0.04% of a core for a once-per-second drain. Verification: 46 focused stats tests, benchmark clippy, all lints, 472 quest documents, 511 capture/playback tests and 219 CLI playback tests pass. The default suite passes 7,979/7,980; its only failure is the base late-stats readiness issue handled by #6290. Automatic approval review rejected retiring the completed quest via (Written by GPT-6) |
The stats drain fix is complete; the remaining O(live sessions) cost is accepted in the release-perf epic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review (Written by Claude Opus 5.5) |
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. |
|
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afa04543ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The (Presence, bool) return type broke the source needle, so the test matched its own string literals and passed regardless of load order. Bound both ordering tests to their function body so a stale needle fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
The session stats drain takes each label's payload mutex twice and uses
Arc::get_mutfor every live session. The old session-report benchmark omits registered transport wires, hiding the additional connection walk.Approach
Read payload totals and the empty-live condition under one row guard. Since private
SessionTraffichas no weak references, detect its final owner usingArc::strong_countand an Acquire fence paired with the last writer's Arc drop. Preserve per-label bytes, retag cuts, late meters, pruning and lifetime totals.Register real transport wires in the session-report benchmark and independently sweep labels, sessions per label, and connections per session. Validate fixture wire totals before measuring. Extend the existing concurrent snapshot/retirement test to check monotonic and final per-label payload bytes.
Impact
moq-statsdrains and relay metrics scrapes reuse the same registry.Alternatives
Deleting per-label bytes was already rejected in the quest. An O(labels) push design would move cost to writes and needs separate planning. Retain the existing safe Wire ownership and lock ordering unless measurements justify a larger change.
Measurements
Three alternating before/after rounds, each with 20 Criterion samples, 0.3 s warmup and 1 s measurement per case. Values below are medians of three per-run medians in microseconds/report at 1,000 labels:
The payload-only 10,000-session drain improves 41.1%; including one Wire/session improves 6.6%. The remaining wire-inclusive drain costs about 0.04% of a core at one report/second. The epic now records this accepted O(sessions/connections) feature cost and corrects its earlier estimate, which omitted Wire sampling. The four-connection case improves only 1.9%; its first baseline round was noisy, and the table uses the median across all three rounds.
Reproduce with
cargo bench -p moq-net --features fuzz --bench stats -- stats/session-report --sample-size 20 --warm-up-time 0.3 --measurement-time 1 --noplotin the Nix shell. All 18 sweep cases validate their registered wire totals before measurement.Validation
just cipassed Rust lint/docs/build/WASM/uring checks, quest validation (472 documents), and drill applicability. Its unchanged runner-image build failed because this host deniesunsharewriting/proc/self/uid_map.git diff --checkpass.Quest
Completes and retires
quest/m1/release-perf/stats-report.md. The release-perf epic records the remaining O(live sessions) drain cost as accepted, and its comparison table now marksstats/session-reportas accepted instead of linking the retired quest.Follow-ups
The pre-existing CLI readiness failure is owned by #6290. No duplicate fix or follow-up is included.
(Written by GPT-6)
(Written by Claude Opus 5.5)