-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove LinkedDeque and replace with LinkedHashMap #6968
Remove LinkedDeque and replace with LinkedHashMap #6968
Conversation
After the recent changes the usage of the LinkedDeque fits quite well with the insertion order semantics of LinkedHashMap, which also allows for constant time additions and removals. Signed-off-by: Andrew Ross <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #6968 +/- ##
============================================
- Coverage 70.66% 70.57% -0.10%
+ Complexity 59231 59071 -160
============================================
Files 4812 4812
Lines 283761 283617 -144
Branches 40917 40909 -8
============================================
- Hits 200519 200153 -366
- Misses 66784 67033 +249
+ Partials 16458 16431 -27
... and 472 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@andrross I like it, the implementation is much simpler now, interestingly enough, the |
|
||
private final RemovalListener<K, V> listener; | ||
|
||
private final Weigher<V> weigher; | ||
|
||
private final StatsCounter<K> statsCounter; | ||
|
||
private volatile ReentrantLock lock; | ||
private final ReentrantLock lock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 we could replace
final ReentrantLock lock = this.lock;
lock.lock();
with just
lock.lock();
now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch! I'm sure there was some previous incarnation of this code where a volatile lock was needed, but it definitely was never necessary here.
Signed-off-by: Andrew Ross <[email protected]>
Gradle Check (Jenkins) Run Completed with:
|
@reta regarding |
Gradle Check (Jenkins) Run Completed with:
|
Gradle Check (Jenkins) Run Completed with:
|
…#6968) * Remove LinkedDeque and replace with LinkedHashMap After the recent changes the usage of the LinkedDeque fits quite well with the insertion order semantics of LinkedHashMap, which also allows for constant time additions and removals. Signed-off-by: Andrew Ross <[email protected]> * Use class member reference now that lock is final Signed-off-by: Andrew Ross <[email protected]> --------- Signed-off-by: Andrew Ross <[email protected]> Signed-off-by: Valentin Mitrofanov <[email protected]>
…#6968) * Remove LinkedDeque and replace with LinkedHashMap After the recent changes the usage of the LinkedDeque fits quite well with the insertion order semantics of LinkedHashMap, which also allows for constant time additions and removals. Signed-off-by: Andrew Ross <[email protected]> * Use class member reference now that lock is final Signed-off-by: Andrew Ross <[email protected]> --------- Signed-off-by: Andrew Ross <[email protected]> (cherry picked from commit 65443ad)
… filecache support in clear indices cache API (#7595) * Remove LinkedDeque and replace with LinkedHashMap (#6968) * Remove LinkedDeque and replace with LinkedHashMap After the recent changes the usage of the LinkedDeque fits quite well with the insertion order semantics of LinkedHashMap, which also allows for constant time additions and removals. Signed-off-by: Andrew Ross <[email protected]> * Use class member reference now that lock is final Signed-off-by: Andrew Ross <[email protected]> --------- Signed-off-by: Andrew Ross <[email protected]> (cherry picked from commit 65443ad) * Add filecache support in clear indices cache API (#7498) Signed-off-by: Kunal Kotwani <[email protected]> (cherry picked from commit a1e42b1) Signed-off-by: Kunal Kotwani <[email protected]> --------- Signed-off-by: Kunal Kotwani <[email protected]> Co-authored-by: Andrew Ross <[email protected]>
Looks like #7595 includes this? @kotwanikunal |
|
After the recent changes the usage of the LinkedDeque fits quite well with the insertion order semantics of LinkedHashMap, which also allows for constant time additions and removals.
Microbenchmark Results
The benchmark results are quite similar. The LinkedHashMap version seems to be slightly faster, but they are close enough there could be other variables in the test runs causing the difference. The benchmarks show there isn't any significant regression.
OS: Ubuntu 20.04.5 LTS
Host: AWS EC2 c6i.8xlarge
Benchmark command:
./gradlew -p benchmarks run --args 'FileCacheBenchmark'
This PR:
Previous implementation:
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.