Open chrysan opened 2 years ago
BTW, memory usage of region cache could be tracked in case of risk of oom.
Another finding is, cached regions are much more than real live regions:
This use case has many "truncate table". The eviction of cached regions could be enhanced.
We may consider using skiplist as a replacement. Compared to btree, skiplist can have a smaller granularity of locks.
When many regions are cached in memory, searchCachedRegion becomes slower and holds RegionCache global read lock for longer time, and then makes other queries who load new regions wait for write lock. When QPS grows, the mutex contention becomes even worse and query latency grows.
findRegionByKey waits for write lock:
searchCachedRegion holds read lock: