From fec2b3abf9d9abdc12bfeedaf2b22e8b0cc8c9f4 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 13 Sep 2017 10:45:21 -0400 Subject: [PATCH] mon: elevate priority of many perf counters We can be quite liberal here, because mons are small in number. However, we don't want to expose KV database counters at this database from OSDs, so use the prio_adjust mechanism for that. Signed-off-by: John Spray (cherry picked from commit ac8320f23dd4c00eb80da0d9837c29744e38bd57) --- src/kv/KeyValueDB.h | 10 ++++++++++ src/kv/LevelDBStore.h | 5 +++++ src/kv/RocksDBStore.h | 5 +++++ src/mon/MonitorDBStore.h | 12 ++++++++++++ src/mon/Paxos.cc | 5 +++++ 5 files changed, 37 insertions(+) diff --git a/src/kv/KeyValueDB.h b/src/kv/KeyValueDB.h index 37a78480f1408..818884a1a97ed 100644 --- a/src/kv/KeyValueDB.h +++ b/src/kv/KeyValueDB.h @@ -12,6 +12,7 @@ #include #include "include/encoding.h" #include "common/Formatter.h" +#include "common/perf_counters.h" using std::string; /** @@ -350,6 +351,15 @@ public: virtual void get_statistics(Formatter *f) { return; } + + /** + * Return your perf counters if you have any. Subclasses are not + * required to implement this, and callers must respect a null return + * value. + */ + virtual PerfCounters *get_perf_counters() { + return nullptr; + } protected: /// List of matching prefixes and merge operators std::vector &elems); void get_statistics(Formatter *f) override; + PerfCounters *get_perf_counters() override + { + return logger; + } + struct RocksWBHandler: public rocksdb::WriteBatch::Handler { std::string seen ; int num_seen = 0; diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index 707d635af557a..00e56a9d8fcdb 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -624,6 +624,8 @@ class MonitorDBStore db->init(g_conf->mon_rocksdb_options); else db->init(); + + } int open(ostream &out) { @@ -640,6 +642,16 @@ class MonitorDBStore r = db->open(out); if (r < 0) return r; + + // Monitors are few in number, so the resource cost of exposing + // very detailed stats is low: ramp up the priority of all the + // KV store's perf counters. Do this after open, because backend may + // not have constructed PerfCounters earlier. + if (db->get_perf_counters()) { + db->get_perf_counters()->set_prio_adjust( + PerfCountersBuilder::PRIO_USEFUL - PerfCountersBuilder::PRIO_DEBUGONLY); + } + io_work.start(); is_open = true; return 0; diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 3555d60dba5d7..31d3cfdb51f13 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -86,6 +86,11 @@ void Paxos::init() void Paxos::init_logger() { PerfCountersBuilder pcb(g_ceph_context, "paxos", l_paxos_first, l_paxos_last); + + // Because monitors are so few in number, the resource cost of capturing + // almost all their perf counters at USEFUL is trivial. + pcb.set_prio_default(PerfCountersBuilder::PRIO_USEFUL); + pcb.add_u64_counter(l_paxos_start_leader, "start_leader", "Starts in leader role"); pcb.add_u64_counter(l_paxos_start_peon, "start_peon", "Starts in peon role"); pcb.add_u64_counter(l_paxos_restart, "restart", "Restarts"); -- 2.39.5