]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: make pri cache perf counters optional
authorMykola Golub <mgolub@suse.com>
Sun, 19 May 2019 10:09:22 +0000 (11:09 +0100)
committerMykola Golub <mgolub@suse.com>
Tue, 11 Jun 2019 06:59:04 +0000 (07:59 +0100)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/common/PriorityCache.cc
src/common/PriorityCache.h
src/os/bluestore/BlueStore.cc

index 202d7ddedd9b4005089192d1be5d7d0036cbcf7b..bb4366b6cc61e9cccaa396d986d2805589658eff 100644 (file)
@@ -148,13 +148,18 @@ namespace PriorityCache
     logger->set(MallocStats::M_CACHE_BYTES, new_size);
   }
 
-  void Manager::insert(const std::string& name, std::shared_ptr<PriCache> c)
+  void Manager::insert(const std::string& name, std::shared_ptr<PriCache> c,
+                       bool enable_perf_counters)
   {
     ceph_assert(!caches.count(name));
     ceph_assert(!indexes.count(name));
 
     caches.emplace(name, c);
 
+    if (!enable_perf_counters) {
+      return;
+    }
+
     // TODO: If we ever assign more than
     // PERF_COUNTER_MAX_BOUND - PERF_COUNTER_LOWER_BOUND perf counters for
     // priority caching we could run out of slots.  Recycle them some day?
@@ -282,25 +287,29 @@ namespace PriorityCache
       balance_priority(&mem_avail, pri);
 
       // Update the per-priority perf counters
-      for (auto it = caches.begin(); it != caches.end(); it++) {
+      for (auto &l : loggers) {
+        auto it = caches.find(l.first);
+        ceph_assert(it != caches.end());
+
         auto bytes = it->second->get_cache_bytes(pri);
-        auto l = loggers.find(it->first);
-        l->second->set(indexes[it->first][pri], bytes);
+        l.second->set(indexes[it->first][pri], bytes);
       }
     }
     // assert if we assigned more memory than is available.
     ceph_assert(mem_avail >= 0);
 
-    for (auto it = caches.begin(); it != caches.end(); it++) {
+    for (auto &l : loggers) {
+      auto it = caches.find(l.first);
+      ceph_assert(it != caches.end());
+
       // Commit the new cache size
       int64_t committed = it->second->commit_cache_size(tuned_mem);
 
       // Update the perf counters
       int64_t alloc = it->second->get_cache_bytes();
 
-      auto l = loggers.find(it->first);
-      l->second->set(indexes[it->first][Extra::E_RESERVED], committed - alloc);
-      l->second->set(indexes[it->first][Extra::E_COMMITTED], committed);
+      l.second->set(indexes[it->first][Extra::E_RESERVED], committed - alloc);
+      l.second->set(indexes[it->first][Extra::E_COMMITTED], committed);
     }
   }
 
index f0984d273f0fa4f3124721821b251c5dc1545b4d..6ac607022414838d32587836fce5bdf3b3129976 100644 (file)
@@ -134,7 +134,8 @@ namespace PriorityCache {
     uint64_t get_tuned_mem() const {
       return tuned_mem;
     }
-    void insert(const std::string& name, const std::shared_ptr<PriCache> c);
+    void insert(const std::string& name, const std::shared_ptr<PriCache> c,
+                bool enable_perf_counters);
     void erase(const std::string& name);
     void clear();
     void tune_memory();
index 9045c068dcb511d2ca21ac1d053cae00dad42526..3edde9520280039b6177d9711e059a4a61e52007 100644 (file)
@@ -3667,9 +3667,9 @@ void *BlueStore::MempoolThread::entry()
   if (store->cache_autotune && binned_kv_cache != nullptr) {
     pcm = std::make_shared<PriorityCache::Manager>(
         store->cct, min, max, target, true);
-    pcm->insert("kv", binned_kv_cache);
-    pcm->insert("meta", meta_cache);
-    pcm->insert("data", data_cache);
+    pcm->insert("kv", binned_kv_cache, true);
+    pcm->insert("meta", meta_cache, true);
+    pcm->insert("data", data_cache, true);
   }
 
   utime_t next_balance = ceph_clock_now();