Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of rigid LRU eviction, perform sampled LRU eviction. Sampled LRU eviction takes K random keys and picks the one with the lowest update timestamp. This way, even though the evicted element is not always the oldest in the whole cache, removes the necessity of maintaining a queue and reduces the contention caused by locking the queue. The K parameter is configurable, but the best performing value so far was 16 and it's used as the default one. The already existing `concurrent_{read,scan}_write` benchmarks are not sufficient for benchmarking the eviction and evaluating what kind of eviction policy performs the best, because they don't fill up the cache, so eviction never happens. To address that, add a new benchmark group which measures time spent on concurrent writes and reads on a full cache (where each write causes eviction). To reduce the noise coming from other parts of accounts-db, use only the cache in that benchmark. The result of that benchmark with the old rigid LRU evction mechamism, for 128 read and write threads, is: ``` cache_eviction/cache_eviction/128 time: [20.737 s 20.936 s 21.138 s] ``` With sampled LRU eviction (K=16), it improves to: ``` cache_eviction/cache_eviction_k_16/128 time: [7.6609 s 7.7177 s 7.7847 s] ```
- Loading branch information