Repository navigation
test(benchmarks): separate broadcast contract and contention costs - #416
Open
rokadepiyush49-rgb wants to merge 1 commit into
Open
rokadepiyush49-rgb wants to merge 1 commit into
rokadepiyush49-rgb wants to merge 1 commit into
Conversation
Add a Tokio adapter that publishes an Arc per message, a one-reader drain, and a sequential four-subscription drain to the no-backpressure comparison.
This branch has not been deployed
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
Add the controls #402 asks for to the no-backpressure broadcast comparison: a
TokioArcadapter that publishes a freshArc<usize>per message, a one-reader drain, and a drain of four subscriptions on a single thread. Together they separate theArc<T>that shared receives return from contention between receivers.Apple M4 (macOS, Rust 1.94.1), median of ten interleaved runs. Lower is faster.
Arctry-roundtripready-roundtrippublish-4p-drain-1rdrain-1r(new)sequential-drain-4r(new)drain-4rThe single-receiver gap to Tokio is almost entirely the per-message allocation that the shared
Arc<T>contract requires: once Tokio pays for it, the rows are within about 10% and Asyncband leads two of them. Without contention, reading four subscriptions is also close (sequential-drain-4r, 0.84×). The remaining gap is contention: with four receiving threads Asyncband takes 296 ms against 79 ms, because every read advances its cursor under the one channel lock while Tokio's receivers read slots in parallel.This PR changes no library code. Spinning briefly before blocking on the channel lock made
drain-4rabout three times slower (819 ms). Reading ahead into each receiver would reduce lock traffic but would change whatretained_message_countreports and release bounded capacity early, so closing the gap looks like a backlog design decision rather than a local fix.Refs #402.