]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
cache/lru_cache: high pri pool capacity -> size_t
authorMark Nelson <mnelson@redhat.com>
Wed, 18 Apr 2018 18:28:50 +0000 (13:28 -0500)
committerMark Nelson <mnelson@redhat.com>
Tue, 29 May 2018 16:00:45 +0000 (11:00 -0500)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
cache/lru_cache.cc
cache/lru_cache.h

index a7611cac1f33dab57888614ea4a1e18336b68788..28b93800c12a103f241510aeb69936ec0fb8e22c 100644 (file)
@@ -251,7 +251,7 @@ void LRUCacheShard::SetCapacity(size_t capacity) {
   {
     MutexLock l(&mutex_);
     capacity_ = capacity;
-    high_pri_pool_capacity_ = capacity_ * high_pri_pool_ratio_;
+    ResetHighPriPoolCapacity();
     EvictFromLRU(0, &last_reference_list);
   }
   // we free the entries here outside of mutex for
@@ -293,10 +293,15 @@ bool LRUCacheShard::Ref(Cache::Handle* h) {
 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_;
+  ResetHighPriPoolCapacity();
   MaintainPoolSize();
 }
 
+void LRUCacheShard::ResetHighPriPoolCapacity() {
+  high_pri_pool_capacity_ = 
+      static_cast<size_t>(capacity_ * high_pri_pool_ratio_);
+}
+
 bool LRUCacheShard::Release(Cache::Handle* handle, bool force_erase) {
   if (handle == nullptr) {
     return false;
index 60538c5f5783e90c858349a68b91554299cb166c..d926e7d8e261f81fd5e2eac07d2a8d554fe9eb24 100644 (file)
@@ -229,6 +229,9 @@ class ALIGN_AS(CACHE_LINE_SIZE) LRUCacheShard : public CacheShard {
   // holding the mutex_
   void EvictFromLRU(size_t charge, autovector<LRUHandle*>* deleted);
 
+  // Reset the high-pri pool capacity based on the capacity and ratio.
+  void ResetHighPriPoolCapacity();
+
   // Initialized before use.
   size_t capacity_;
 
@@ -243,7 +246,7 @@ class ALIGN_AS(CACHE_LINE_SIZE) LRUCacheShard : public CacheShard {
 
   // High-pri pool size, equals to capacity * high_pri_pool_ratio.
   // Remember the value to avoid recomputing each time.
-  double high_pri_pool_capacity_;
+  size_t high_pri_pool_capacity_;
 
   // Dummy head of LRU list.
   // lru.prev is newest entry, lru.next is oldest entry.