Repository navigation
perf(qmux): batch writer frames, flushing the transport once - #397
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No identified batching issue remains to resolve before merging. Normal checks can proceed. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Outbound writes now share a flush, but batching is bounded and a failed flush closes the affected session rather than reporting its stream as finished. No new security boundary or privilege was identified. Teardown behavior and custom writer implementations remain worth checking. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches✨ Simplify code
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 |
The session writer flushed after every frame, so each small frame cost one syscall and one TCP segment. It now feeds the frames already queued and flushes once. A fed FIN's SendStream is signalled Finished only after the flush succeeds, so closed() still never reports success for a FIN the transport failed to write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f0c9607 to
3f3bc73
Compare
|
Thanks @pouriya, nice numbers. Reviewed and rebased onto main (after #399 and #402):
(Written by Opus 5.5) |
The problem
Fanning out to ~2400 WebSocket viewers, 66% of the relay's
sendtocallscarried 8–15 bytes, and 51% of outbound packets were under 64 bytes. Every
frame is flushed as it is written, so small writes never coalesce — each one
costs a syscall, a segment and an ACK.
The change
Writergainsfeedandflush. The writer feeds the frames already queued —up to 64 KiB or 256 frames, in the existing priority order — then flushes once.
Each qmux frame is still its own WebSocket message; only the flush is shared.
Both methods have defaults that keep today's behaviour, so an external
impl Writercompiles and behaves unchanged. No public signature changed.Measured
FreeBSD 15.1, 8 vCPU. Same host, same publisher, same load, before and after:
sendto/sTests
New:
queued_frames_are_fed_then_flushed_oncequeues a three-write media frameand asserts it produces one flush instead of three, with payloads and stream
offsets unchanged. It fails against
main.Rebased onto #399 / #402
Since #402 signals
SendStream::closed()success only once the FIN is written, a fed FIN is now signalledFinishedafter the batch's flush succeeds; a failed flush drops the signal. New test:failed_fin_flush_does_not_signal_finished.StreamWriter::sendnow delegates tofeed+flush.