]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
cache/lru_cache: expose usage/capacity for high priority pool.
authorMark Nelson <mnelson@redhat.com>
Tue, 6 Mar 2018 20:50:33 +0000 (14:50 -0600)
committerMark Nelson <mnelson@redhat.com>
Tue, 29 May 2018 15:41:51 +0000 (10:41 -0500)
Signed-off-by: Mark Nelson <mnelson@redhat.com>
cache/lru_cache.cc
cache/lru_cache.h

index a128296f91ec37004ac5a14a132cd16ba81e2caa..7b36038981062da6a25467d0c11684df6da0d7d0 100644 (file)
@@ -449,6 +449,16 @@ size_t LRUCacheShard::GetPinnedUsage() const {
   return usage_ - lru_usage_;
 }
 
+size_t LRUCacheShard::GetHighPriPoolCapacity() {
+  MutexLock l(&mutex_);
+  return high_pri_pool_capacity_;
+}
+
+size_t LRUCacheShard::GetHighPriPoolUsage() {
+  MutexLock l(&mutex_);
+  return high_pri_pool_usage_;
+}
+
 std::string LRUCacheShard::GetPrintableOptions() const {
   const int kBufferSize = 200;
   char buffer[kBufferSize];
@@ -515,6 +525,22 @@ size_t LRUCache::TEST_GetLRUSize() {
   return lru_size_of_all_shards;
 }
 
+size_t LRUCache::GetHighPriPoolCapacity() {
+  size_t size = 0;
+  for (int i = 0; i < num_shards_; i++) {
+    size += shards_[i].GetHighPriPoolCapacity();
+  }
+  return size;
+}
+
+size_t LRUCache::GetHighPriPoolUsage() {
+  size_t size = 0;
+  for (int i = 0; i < num_shards_; i++) {
+    size += shards_[i].GetHighPriPoolUsage();
+  }
+  return size;
+}
+
 double LRUCache::GetHighPriPoolRatio() {
   double result = 0.0;
   if (num_shards_ > 0) {
index f5219ad3586f76f959eca76a02a671df2b7d34a5..bb8c247763dc4d2a465ce3be223ecd9455f0a14d 100644 (file)
@@ -202,11 +202,15 @@ class ALIGN_AS(CACHE_LINE_SIZE) LRUCacheShard : public CacheShard {
 
   void TEST_GetLRUList(LRUHandle** lru, LRUHandle** lru_low_pri);
 
-  //  Retrieves number of elements in LRU, for unit test purpose only
-  //  not threadsafe
+  // Retrieves number of elements in LRU, for unit test purpose only
+  // not threadsafe
   size_t TEST_GetLRUSize();
 
-  //  Retrives high pri pool ratio
+  // Retrieve pool capacities and usages.  Protected with mutex_.
+  size_t GetHighPriPoolCapacity();
+  size_t GetHighPriPoolUsage();
+
+  // Retrives high pri pool ratio
   double GetHighPriPoolRatio();
 
  private:
@@ -289,9 +293,13 @@ class LRUCache : public ShardedCache {
   virtual uint32_t GetHash(Handle* handle) const override;
   virtual void DisownData() override;
 
-  //  Retrieves number of elements in LRU, for unit test purpose only
+  // Retrieves number of elements in LRU, for unit test purpose only
   size_t TEST_GetLRUSize();
-  //  Retrives high pri pool ratio
+  // Retrieves high pri pool ratio
+  size_t GetHighPriPoolCapacity();
+  // Retrieves high pri pool capacty
+  size_t GetHighPriPoolUsage();
+  // Retrieves high pri pool ratio
   double GetHighPriPoolRatio();
 
  private: