Open yeya24 opened 1 year ago
@yeya24 This seems quite interesting. We could implement ristretto
as another module and introduce a new case to select it as our indexCache
here. That would give us a starting point to compare the performance of the two in-memory caches. I'd love to take this up unless we need to explore other concurrent hashmap/cache options.
@Akhil-2001 hey thanks for the interests.
Actually I already implemented the code to use Ristretto and currently doing tests with it. So I will take this up, sorry about this.
@yeya24 sure, np! Let me know if there are other issues or prospective features which you might need help with.
Is your proposal related to a problem?
Currently, we are mainly using https://github.com/hashicorp/golang-lru
simplelru
library for inmemory cache. It is not thread safe, so we added a lock for the whole cache https://github.com/thanos-io/thanos/blob/main/pkg/store/cache/inmemory.go#L36.This impacts the performance a lot under high concurrency situation as each
get
andset
operation, we need to hold the lock.In the ideally case, we should use a thread safe cache implementation which bucketizes the whole cache into multiple buckets to improve performance under high concurrency.
Describe the solution you'd like
https://github.com/dgraph-io/ristretto might be a good candidate to check.