]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Make HighPriPool funcs const and part of cache interface.
authorMark Nelson <mnelson@redhat.com>
Wed, 7 Mar 2018 19:05:23 +0000 (13:05 -0600)
committerMark Nelson <mnelson@redhat.com>
Mon, 14 May 2018 22:48:52 +0000 (17:48 -0500)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
cache/lru_cache.cc
cache/lru_cache.h
include/rocksdb/cache.h

index adefc6551a53184a6346ca7466dd2151829220ba..52e72b72c610fccbd0aeb9bd4335b76380cf77c3 100644 (file)
@@ -169,7 +169,7 @@ size_t LRUCacheShard::TEST_GetLRUSize() {
   return lru_size;
 }
 
-double LRUCacheShard::GetHighPriPoolRatio() {
+double LRUCacheShard::GetHighPriPoolRatio() const{
   MutexLock l(&mutex_);
   return high_pri_pool_ratio_;
 }
@@ -458,12 +458,12 @@ size_t LRUCacheShard::GetPinnedUsage() const {
   return usage_ - lru_usage_;
 }
 
-size_t LRUCacheShard::GetHighPriPoolCapacity() {
+size_t LRUCacheShard::GetHighPriPoolCapacity() const {
   MutexLock l(&mutex_);
   return high_pri_pool_capacity_;
 }
 
-size_t LRUCacheShard::GetHighPriPoolUsage() {
+size_t LRUCacheShard::GetHighPriPoolUsage() const {
   MutexLock l(&mutex_);
   return high_pri_pool_usage_;
 }
@@ -528,7 +528,7 @@ size_t LRUCache::TEST_GetLRUSize() {
   return lru_size_of_all_shards;
 }
 
-size_t LRUCache::GetHighPriPoolCapacity() {
+size_t LRUCache::GetHighPriPoolCapacity() const {
   size_t size = 0;
   for (int i = 0; i < num_shards_; i++) {
     size += shards_[i].GetHighPriPoolCapacity();
@@ -536,7 +536,7 @@ size_t LRUCache::GetHighPriPoolCapacity() {
   return size;
 }
 
-size_t LRUCache::GetHighPriPoolUsage() {
+size_t LRUCache::GetHighPriPoolUsage() const {
   size_t size = 0;
   for (int i = 0; i < num_shards_; i++) {
     size += shards_[i].GetHighPriPoolUsage();
@@ -544,7 +544,7 @@ size_t LRUCache::GetHighPriPoolUsage() {
   return size;
 }
 
-double LRUCache::GetHighPriPoolRatio() {
+double LRUCache::GetHighPriPoolRatio() const {
   double result = 0.0;
   if (num_shards_ > 0) {
     result = shards_[0].GetHighPriPoolRatio();
index 3ec4ea594d5f6753db4d714fbeb3c86422890cc2..8e51cd83a3ee0ac0ff33dc805b108a7395eb31e4 100644 (file)
@@ -202,12 +202,10 @@ class ALIGN_AS(CACHE_LINE_SIZE) LRUCacheShard : public CacheShard {
   // not threadsafe
   size_t TEST_GetLRUSize();
 
-  // Retrieve pool capacities and usages.  Protected with mutex_.
-  size_t GetHighPriPoolCapacity();
-  size_t GetHighPriPoolUsage();
-
-  // Retrives high pri pool ratio
-  double GetHighPriPoolRatio();
+  // Retrieve pool capacities/usages/ratio.  Protected with mutex_.
+  virtual size_t GetHighPriPoolCapacity() const;
+  virtual size_t GetHighPriPoolUsage() const;
+  virtual double GetHighPriPoolRatio() const;
 
   // Overloading to aligned it to cache line size
   void* operator new(size_t);
@@ -297,15 +295,12 @@ class LRUCache : public ShardedCache {
   virtual size_t GetCharge(Handle* handle) const override;
   virtual uint32_t GetHash(Handle* handle) const override;
   virtual void DisownData() override;
+  virtual size_t GetHighPriPoolCapacity() const;
+  virtual size_t GetHighPriPoolUsage() const;
+  virtual double GetHighPriPoolRatio() const;
 
   // Retrieves number of elements in LRU, for unit test purpose only
   size_t TEST_GetLRUSize();
-  // Retrieves high pri pool ratio
-  size_t GetHighPriPoolCapacity();
-  // Retrieves high pri pool capacty
-  size_t GetHighPriPoolUsage();
-  // Retrieves high pri pool ratio
-  double GetHighPriPoolRatio();
 
  private:
   LRUCacheShard* shards_;
index 86dafe3959fb8df1d5c36d2f64bea2c82465a0e6..43a47052ae3773e16244299d4a5a4fd4a2c347de 100644 (file)
@@ -184,6 +184,12 @@ class Cache {
   // returns the maximum configured capacity of the cache
   virtual size_t GetCapacity() const = 0;
 
+  // returns the capacity of the high priority pool
+  virtual size_t GetHighPriPoolCapacity() const {
+    // default implementation returns 0
+    return 0;
+  }
+
   // returns the memory size for the entries residing in the cache.
   virtual size_t GetUsage() const = 0;
 
@@ -193,6 +199,18 @@ class Cache {
   // returns the memory size for the entries in use by the system
   virtual size_t GetPinnedUsage() const = 0;
 
+  // returns the memory size for the entries in the high priority pool
+  virtual size_t GetHighPriPoolUsage() const {
+    // default implementation returns 0
+    return 0;
+  }
+
+  // returns the ratio of memory usaged by the high priority pool
+  virtual double GetHighPriPoolRatio() const {
+    // default implementation returns 0
+    return 0;
+  }
+
   // Call this on shutdown if you want to speed it up. Cache will disown
   // any underlying data and will not free it on delete. This call will leak
   // memory - call this only if you're shutting down the process.