Replace std::sync locks with parking_lot locks #9731
Merged
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.
↪️ Pull Request
Internally we see crashes related to locks, not coming from Rust, but from the system level
pthread
calls. This seems to be mostly related to the resolver, and exhibits itself as a system error 22 - which means a lock operation was called with an "invalid argument".In Rust 1.78 the
RwLock
implementation, where we saw these crashes occurring, was replaced with a native rust implementation. We've upgraded to a build built with Rust 1.78, and now see crashes coming from the Mutex in https://github.com/parcel-bundler/parcel/blob/v2/packages/utils/node-resolver-rs/src/cache.rs#L196. These are of the form:failed to lock mutex: Invalid argument (os error 22)
. This error is not readily reproducible for debugging, and doesn't seem to be reproducible under a stress test of the resolver either.This change replaces the
std::sync
usage of locks with theparking_lot
implementation. The hope is that this makes the errors go away, or manifest themselves in a form that provides better insight into why they are occurring.parking_lot
is also advertised as having better perf, so it's worth trying to see if we see any improvement there too as a side beenfit.🚨 Test instructions
We've tested against our very large application internally. Haven't really seen a performance boost, but no performance regression either.
✔️ PR Todo