-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize the implementation of
Intern::default
.
The implementation of `Intern::default` used to return `Self::new(T::default())`, which caused performance issues in workloads that call this method often. First, `ArcIntern::new()` performs heap allocation even if the value already exists in the interner. Second, `default()` always hits the same shard in the `dashmap` inside `internment` causing contention given a large enough number of threads (in my experiments it gets pretty severe with 16 threads running on 16 CPU cores). Note that we cannot rely on the DDlog compiler optimization that statically evaluates function calls with constant arguments, as `Intern::default()` is typically called from Rust, not DDlog, e.g., when deserializing fields with `serde(default)` annotations. The new implementation uses thread-local cache to make sure that we call `Self::new(T::default())` at most once per type per thread. Signed-off-by: Leonid Ryzhyk <[email protected]>
- Loading branch information
Showing
4 changed files
with
55 additions
and
3 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