perf(broadcast): reclaim the backlog in proportion to messages, not receivers - #309
Draft
ariesdevil wants to merge 1 commit into
Draft
perf(broadcast): reclaim the backlog in proportion to messages, not receivers#309ariesdevil wants to merge 1 commit into
ariesdevil wants to merge 1 commit into
Conversation
ariesdevil
force-pushed
the
dev_ariesdevil
branch
from
September 13, 2026 16:24
0fe793b to
3cfc80f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up optimizations to #253.
receive/remove_receiverupdate two counters and reclaim pops the zero-count prefix instead of scanning every cursor under the channel lock.WakerBatchstores up to 32 wakers inline (MaybeUninit) before spilling to a single heap allocation, and the broadcast, watch, and barrier publish paths fill it in place through the newWakerSet::drain_into, avoiding both the per-publication allocation and moving the 552-byte batch between frames.Trade-off: retained slots grow from 8 to 16 bytes.
Benchmarks
Median of 100 samples, back-to-back A/B runs of
broadcast::mpmcon the same host (baseline = #253 merge commit):drain_with_receiverspeak 256, live 1drain_with_receiverspeak 256, live 32try_send_and_drain_fanout32 receiversdrain_with_receiverspeak 32, live 1deliver_to_receiver_batch8deliver_to_receiver_batch32try_send_and_try_recv(single receiver)drain_with_receiverspeak 1/8, small live setsThe peak-256-live-1 case shows dropped receivers no longer cost anything: reclaim touches only the slots being released, never the subscription arena.