Repository navigation
perf(event): avoid locking manual-reset state reads and ready waits - #356
Open
Kaileshwar16 wants to merge 1 commit into
Open
Kaileshwar16 wants to merge 1 commit into
Kaileshwar16 wants to merge 1 commit into
Conversation
tisonkun
reviewed
Oct 10, 2026
Member
There was a problem hiding this comment.
We don't set a similar document for other benchmarks.
Typically, I'd prefer to make the benchmark suite self-described, or you may put necessary comments inline.
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
Let
ManualResetEvent::is_set,try_wait, and already-set waits complete without takingthe waiter mutex. Keep the public API and existing waiter storage, with tests covering
registration races, rapid set/reset, cancellation, reentrant callbacks, and memory
publication.
Local benchmarks show single-thread state reads improving from 13.09 to 1.04 ns and
already-set waits from 15.03 to 5.83 ns. Replacing a pending waker costs about 28% more
because cloning outside the lock requires another lock acquisition. The benchmark report
includes methodology and tradeoffs.
Design Notes
State transitions and waiter registration remain serialized by the same mutex. Atomic
reads use Acquire and set publishes with Release. Released waiters retain their commitment
after reset.
Validation: all 597 tests passed, along with Clippy, formatting, documentation, event-
feature checks, and benchmark runs.
Related to #252; references #315. Waiter-storage replacement remains a separate
experiment.