Repository navigation
perf(once-cell): avoid locking on uncontended initialization - #412
Merged
orthur2 merged 2 commits intoNov 8, 2026
Merged
Conversation
Kaileshwar16
marked this pull request as draft
November 7, 2026 12:40
Kaileshwar16
marked this pull request as ready for review
November 7, 2026 13:11
tisonkun
approved these changes
Nov 7, 2026
tisonkun
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution! LGTM.
This was referenced Nov 8, 2026
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.
Reduce fresh OnceCell initialization cost by acquiring two of three internal semaphore permits. The spare permit allows uncontended release to avoid locking the wait queue while preserving exclusive initialization and existing cancellation handling.
On Linux, ten alternating benchmark samples reduced median fresh initialization time from 352 ms to 236 ms for six million operations (33%). Already-initialized reads and four-waiter performance remained within measurement noise.
Add regression coverage for publication, cancellation, retry, and waiter progress, plus an already-initialized read benchmark.
Fixes #398.