Skip to content

Use std OnceLock to avoid wasted CPU time#637

Merged
jtraglia merged 2 commits intoethereum:mainfrom
DaniPopes:std-oncelock
Mar 9, 2026
Merged

Use std OnceLock to avoid wasted CPU time#637
jtraglia merged 2 commits intoethereum:mainfrom
DaniPopes:std-oncelock

Conversation

@DaniPopes
Copy link
Contributor

once_cell's OnceBox allows races during initialization, and then only one thread gets to set the value. std's OnceLock waits for the first thread to finish computation.

Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

Nice, this is much nicer. Do you need a release with this?

@jtraglia jtraglia merged commit ee6e7ca into ethereum:main Mar 9, 2026
43 checks passed
@DaniPopes DaniPopes deleted the std-oncelock branch March 9, 2026 13:42
@DaniPopes
Copy link
Contributor Author

That would be nice, yes

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