forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement full synchronization for
SkyKeyInterner
to ensure that it…
… fulfills the contract of `Interner` - no duplicate instances possible. Prior to this change, there was the possibility of a race condition leading to a thread missing the canonical instance in both the weak interner and the global pool because another thread was simultaneously transferring it. It turns out that weak interning under the synchronization provided by `ConcurrentHashMap#computeIfAbsent` is reasonably efficient. Benchmarks show that `-DBAZEL_USE_POOLED_SKY_KEY_INTERNER=1` with this change performs on-par with the current state (special `SkyKey` interning disabled). My brief explanation for this is: * In the common case where a node is already present in the graph, interning is performing lock-free lookups on `ConcurrentHashMap`, which is much faster than the archaic `MapMakerInternalMap` that backs Guava's interner. * The optimization in this change to only call `removeWeak` when a node is newly created helps avoid a lot of unnecessary interaction with the Guava interner. PiperOrigin-RevId: 512666596 Change-Id: I67c28a7bfab6d49e65b2aba59ec9d19074ea493d
- Loading branch information
1 parent
b76ba30
commit 7793f7b
Showing
5 changed files
with
71 additions
and
58 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
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