Skip to content

perf(event): avoid locking manual-reset state reads and ready waits - #356

Open
Kaileshwar16 wants to merge 1 commit into
apache:mainfrom
Kaileshwar16:perf/252-manual-reset-event
Open

Kaileshwar16 wants to merge 1 commit into
apache:mainfrom
Kaileshwar16:perf/252-manual-reset-event

Conversation

@Kaileshwar16

Copy link
Copy Markdown

Summary

Let ManualResetEvent::is_set, try_wait, and already-set waits complete without taking
the 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants