From: Mark Nelson Date: Mon, 12 Mar 2018 12:17:20 +0000 (-0500) Subject: include/rocksdb/cache.h: expose setHighPriPoolRatio X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=947cd86558ca819918c626f247ba76080da0f138;p=rocksdb.git include/rocksdb/cache.h: expose setHighPriPoolRatio Signed-off-by: Mark Nelson --- diff --git a/cache/lru_cache.cc b/cache/lru_cache.cc index 44763c31..a7611cac 100644 --- a/cache/lru_cache.cc +++ b/cache/lru_cache.cc @@ -290,7 +290,7 @@ bool LRUCacheShard::Ref(Cache::Handle* h) { return true; } -void LRUCacheShard::SetHighPriorityPoolRatio(double high_pri_pool_ratio) { +void LRUCacheShard::SetHighPriPoolRatio(double high_pri_pool_ratio) { MutexLock l(&mutex_); high_pri_pool_ratio_ = high_pri_pool_ratio; high_pri_pool_capacity_ = capacity_ * high_pri_pool_ratio_; @@ -549,6 +549,12 @@ double LRUCache::GetHighPriPoolRatio() const { return result; } +void LRUCache::SetHighPriPoolRatio(double high_pri_pool_ratio) { + for (int i = 0; i < num_shards_; i++) { + shards_[i].SetHighPriPoolRatio(high_pri_pool_ratio); + } +} + std::shared_ptr NewLRUCache(const LRUCacheOptions& cache_opts) { return NewLRUCache(cache_opts.capacity, cache_opts.num_shard_bits, cache_opts.strict_capacity_limit, diff --git a/cache/lru_cache.h b/cache/lru_cache.h index 9c41f490..60538c5f 100644 --- a/cache/lru_cache.h +++ b/cache/lru_cache.h @@ -172,7 +172,7 @@ class ALIGN_AS(CACHE_LINE_SIZE) LRUCacheShard : public CacheShard { virtual void SetStrictCapacityLimit(bool strict_capacity_limit) override; // Set percentage of capacity reserved for high-pri cache entries. - void SetHighPriorityPoolRatio(double high_pri_pool_ratio); + void SetHighPriPoolRatio(double high_pri_pool_ratio); // Like Cache methods, but with an extra "hash" parameter. virtual Status Insert(const Slice& key, uint32_t hash, void* value, @@ -293,7 +293,7 @@ class LRUCache : public ShardedCache { virtual size_t GetHighPriPoolCapacity() const; virtual size_t GetHighPriPoolUsage() const; virtual double GetHighPriPoolRatio() const; - + virtual void SetHighPriPoolRatio(double high_pri_pool_ratio); // Retrieves number of elements in LRU, for unit test purpose only size_t TEST_GetLRUSize(); diff --git a/include/rocksdb/cache.h b/include/rocksdb/cache.h index ad82cdbc..66df9c91 100644 --- a/include/rocksdb/cache.h +++ b/include/rocksdb/cache.h @@ -186,6 +186,11 @@ class Cache { // capacity. virtual void SetStrictCapacityLimit(bool strict_capacity_limit) = 0; + // Set the high priority pool ratio + virtual void SetHighPriPoolRatio(double high_pri_pool_ratio) { + // default implementation is noop + } + // Get the flag whether to return error on insertion when cache reaches its // full capacity. virtual bool HasStrictCapacityLimit() const = 0;