Remove LinkedDeque and replace with LinkedHashMap#6968
Remove LinkedDeque and replace with LinkedHashMap#6968andrross merged 2 commits intoopensearch-project:mainfrom
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 <andrross@amazon.com>
Gradle Check (Jenkins) Run Completed with:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@andrross I like it, the implementation is much simpler now, interestingly enough, the |
| private final StatsCounter<K> statsCounter; | ||
|
|
||
| private volatile ReentrantLock lock; | ||
| private final ReentrantLock lock; |
There was a problem hiding this comment.
👍 we could replace
final ReentrantLock lock = this.lock;
lock.lock();
with just
lock.lock();
now
There was a problem hiding this comment.
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 <andrross@amazon.com>
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 <andrross@amazon.com> * Use class member reference now that lock is final Signed-off-by: Andrew Ross <andrross@amazon.com> --------- Signed-off-by: Andrew Ross <andrross@amazon.com> Signed-off-by: Valentin Mitrofanov <mitrofmep@gmail.com>
…#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 <andrross@amazon.com> * Use class member reference now that lock is final Signed-off-by: Andrew Ross <andrross@amazon.com> --------- Signed-off-by: Andrew Ross <andrross@amazon.com> (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 <andrross@amazon.com> * Use class member reference now that lock is final Signed-off-by: Andrew Ross <andrross@amazon.com> --------- Signed-off-by: Andrew Ross <andrross@amazon.com> (cherry picked from commit 65443ad) * Add filecache support in clear indices cache API (#7498) Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> (cherry picked from commit a1e42b1) Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> --------- Signed-off-by: Kunal Kotwani <kkotwani@amazon.com> Co-authored-by: Andrew Ross <andrross@amazon.com>
|
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.