]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: elevate priority of many perf counters
authorJohn Spray <john.spray@redhat.com>
Wed, 13 Sep 2017 14:45:21 +0000 (10:45 -0400)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Nov 2017 23:03:25 +0000 (23:03 +0000)
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 <john.spray@redhat.com>
(cherry picked from commit ac8320f23dd4c00eb80da0d9837c29744e38bd57)

src/kv/KeyValueDB.h
src/kv/LevelDBStore.h
src/kv/RocksDBStore.h
src/mon/MonitorDBStore.h
src/mon/Paxos.cc

index 37a78480f140814a26ccdb72d59521828bf9ed43..818884a1a97edbf5dd6c11ab9978776903d0e934 100644 (file)
@@ -12,6 +12,7 @@
 #include <boost/scoped_ptr.hpp>
 #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<std::pair<std::string,
index be344ff18e6836a6719314162d0d583b3c5b97e6..5a3ced9e4c9b9d565f435274c668b70d2d11e118 100644 (file)
@@ -184,6 +184,11 @@ public:
 
   void close() override;
 
+  PerfCounters *get_perf_counters() override
+  {
+    return logger;
+  }
+
   class LevelDBTransactionImpl : public KeyValueDB::TransactionImpl {
   public:
     leveldb::WriteBatch bat;
index 6a7c0e37772b275cbb90a9ff50c501bd23ee2867..44c99e1b2e9d59b6ec8aaeb48735e09afaace8d3 100644 (file)
@@ -158,6 +158,11 @@ public:
   void split_stats(const std::string &s, char delim, std::vector<std::string> &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;
index 707d635af557a01a91c4a5f694797e9d9f7dd017..00e56a9d8fcdb8654e40132ff339611047d8e291 100644 (file)
@@ -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;
index 3555d60dba5d728e45330f19ade22cef21b9ab78..31d3cfdb51f13b42993d48685fd40369413386fb 100644 (file)
@@ -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");