[Tiered Caching] Performance improvement for TieredCaching #13989
Labels
enhancement
Enhancement or improvement to existing feature or request
Search:Performance
v2.18.0
Issues and PRs related to version 2.18.0
Is your feature request related to a problem? Please describe
The current implementation of TieredCaching.computeIfAbsent() is performing poorly which was discovered while running some performance benchmarks. Before we delve into the root cause, lets me elaborate on the current implementation.
Current implementation:
As of now TieredCaching implementation has onheap and disk tier which are individually thread safe. But we need to ensure that the TieredCache as a whole is thread safe and doesn't allow any key to be cached onto both tiers.
So we implemented a single global read/write lock(link) which ensures that any write operation is performed on TieredCache by only one thread at a time and allows multiple readers to access any cache via read lock.
Performance Issues with currrent approach:
Describe the solution you'd like
To address above performance issues:
1. Firstly we need to move out the query recompute part(during cache miss) outside the write lock in computeIfAbsent
This can be probably achieved by below(reusing Cache.java logic).
Map<Key, CompletableFuture>
. This will temporally hold the queries for short duration.future.get()
.put
call. Rest of the threads will return the value.2. Avoid using a single read/write lock
Possible solutions:
Related component
Search:Performance
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: