Repository navigation
bench: measure how fanout cost scales with subscriber count - #31
Merged
Merged
Conversation
Users could not tell what this crate buys them, because nothing measured the property it is built around. Delivering one message to N consumers is O(N) work somewhere; the useful question is where it lands and whether the producer pays it. benches/fanout_scaling.rs measures the same logical work across four shapes: publish once, then have all N consumers observe it. Single-threaded and in-cache, so it isolates protocol overhead rather than scheduling. Time in nanoseconds at N = 1, 2, 4, 8, 16, 32, and the marginal cost of one more consumer: photon 3.9 5.9 8.5 14.9 25.9 50.2 1.5 ns shared-ring broadcast 47.7 65.5 99.2 167.3 306.9 579.6 17.2 ns point-to-point (x N) 22.3 44.3 87.8 176.5 351.3 701.9 21.9 ns point-to-point alt (x N) 27.4 53.9 108.7 217.6 428.4 859.3 26.8 ns The marginal column is the result. A subscriber here costs roughly one cursor read and one stamp check because subscribers share no state, so the producer's work does not grow with the audience. Published with the caveats that make it honest: the numbers are single-threaded and in-cache, so they do not predict cross-core fanout latency; and a point-to-point queue is not broadcast, so its row shows what broadcast costs on a queue that does not do broadcast rather than a race it lost. Those libraries solve the different and equally real problem of exactly one receiver owning each message, and the tables say so.
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.
Users could not tell what this crate buys them, because nothing measured the property it is built around.
Delivering one message to N consumers is O(N) work somewhere. The useful question is where it lands, and whether the producer pays it.
benches/fanout_scaling.rsmeasures the same logical work across four shapes — publish once, then have all N consumers observe it — single-threaded and in-cache, isolating protocol overhead from scheduling.The marginal column is the result: a subscriber costs roughly one cursor read and one stamp check, because subscribers share no state, so the producer's work does not grow with the audience.
Published with the caveats that make it honest. The numbers are single-threaded and in-cache, so they measure protocol overhead and do not predict cross-core fanout latency. And a point-to-point queue is not broadcast — fanning out means the producer sends once per consumer, so that row shows what broadcast costs on a queue that doesn't do broadcast, not a race those libraries lost. They solve the different and equally real problem of exactly one receiver owning each message, and both tables say so.
Reproducible with
cargo bench --bench fanout_scaling.Verified: 219 tests, clippy clean, rustdoc clean, HTML tag balance checked.