From: Mykola Golub Date: Sun, 19 May 2019 10:09:22 +0000 (+0100) Subject: common: make pri cache perf counters optional X-Git-Tag: v15.1.0~2445^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=03085f7e4648542a137f49d6720c72a5e7046bfa;p=ceph.git common: make pri cache perf counters optional Signed-off-by: Mykola Golub --- diff --git a/src/common/PriorityCache.cc b/src/common/PriorityCache.cc index 202d7ddedd9b..bb4366b6cc61 100644 --- a/src/common/PriorityCache.cc +++ b/src/common/PriorityCache.cc @@ -148,13 +148,18 @@ namespace PriorityCache logger->set(MallocStats::M_CACHE_BYTES, new_size); } - void Manager::insert(const std::string& name, std::shared_ptr c) + void Manager::insert(const std::string& name, std::shared_ptr 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); } } diff --git a/src/common/PriorityCache.h b/src/common/PriorityCache.h index f0984d273f0f..6ac607022414 100644 --- a/src/common/PriorityCache.h +++ b/src/common/PriorityCache.h @@ -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 c); + void insert(const std::string& name, const std::shared_ptr c, + bool enable_perf_counters); void erase(const std::string& name); void clear(); void tune_memory(); diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 9045c068dcb5..3edde9520280 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3667,9 +3667,9 @@ void *BlueStore::MempoolThread::entry() if (store->cache_autotune && binned_kv_cache != nullptr) { pcm = std::make_shared( 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();