-
Notifications
You must be signed in to change notification settings - Fork 27.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(next-custom-transforms): Replace non-
Sync
Rc<DashMap<_, _>>
…
…usage with `Rc<RefCell<FxHashMap<_, _>>>` (#75534) This is a follow-up to #75007 `DashMap` is needed for situations where you have many threads (or tokio tasks) modifying the same data at the same time. It introduces a lot of memory and CPU overhead to create individually lockable `RwLock` shards. This type of data structure implements `Sync`, indicating that it can be shared between threads. `Rc` is not `Sync` (`Arc` is `Sync`), so wrapping `DashMap` in `Rc` doesn't make a lot of sense: You're paying a pretty high overhead for the ability to share data between threads, and wrapping it in something that does not support sharing data between threads. This visitor code is entirely single-threaded, so just use `Rc<RefCell<FxHashMap>>` instead. `RefCell` is a very cheap single-threaded version of a `Mutex`. `FxHashMap` is just a `HashMap` with the faster `FxHash` algorithm used.
- Loading branch information
Showing
4 changed files
with
25 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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