perf(mpsc): coalesce unbounded receiver wakeups - #231
Closed
tisonkun wants to merge 2 commits into
Closed
Conversation
tisonkun
marked this pull request as draft
August 28, 2026 14:57
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
A local Apple Silicon comparison used the existing ecosystem benchmark with two seconds per benchmark. Median latency changed as follows:
mainThe eight-producer result is effectively unchanged; contention in the standard-library MPMC queue remains the limiting factor there.
Design Notes
The queue remains the durable source of truth. The receiver follows
register waker -> publish waiting -> recheck queue, while a successful sender followsenqueue -> claim waiting -> wake. The waiting flag uses sequentially consistent operations.If a sender claims the flag, it owns the wake. If it observes the pre-waiting false value, its enqueue precedes the receiver's subsequent queue recheck, so the receiver observes the message instead of sleeping. Clearing the flag after a successful recheck prevents stale notification ownership. Last-sender disconnect uses the same notification path after dropping the standard-library sender.
This keeps the proof local to notification delivery, adds no unsafe code or dependency, and intentionally leaves replacement of the queue backend in #209 out of scope.
Validated with
cargo x test,cargo x check, andcargo x lint.