Skip to content

Conversation

@Chain-Fox
Copy link

@Chain-Fox Chain-Fox commented May 5, 2025

Fix #4502

The fix is to use OnceLock Once and atomic variables (for older Rust versions) to replace the original two atomic variables.
OnceLock guarantees the hash can only be initialized once.
This reduces the race condition and provides a slightly better performance.

I also add a test to it to ensure the result before and after patch is consistent.

@Chain-Fox Chain-Fox force-pushed the fix-race-condition2 branch 2 times, most recently from 441c36c to 841f8e1 Compare May 5, 2025 07:39
@Chain-Fox Chain-Fox force-pushed the fix-race-condition2 branch from 841f8e1 to cbac5f7 Compare May 5, 2025 07:53
@Chain-Fox Chain-Fox changed the title Replace atomic operations with OnceLock in backend/util Replace atomic operations with Once in backend/util May 6, 2025
@guybedford
Copy link
Contributor

Automated PRs are not appreciated.

@guybedford guybedford closed this Aug 8, 2025
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.

Race Condition and Performance Regression in wasm-bindgen util.rs

2 participants