]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: apply a threshold to perf counter prios
authorJohn Spray <john.spray@redhat.com>
Mon, 31 Jul 2017 13:24:09 +0000 (09:24 -0400)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Nov 2017 23:03:22 +0000 (23:03 +0000)
...so that we can control the level of load
we're putting on ceph-mgr with perf counters.  Don't collect
anything below PRIO_USEFUL by default.

Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit bdc775fdd8acdad5c58ff3065a21396f80ce5db4)

src/common/options.cc
src/messages/MMgrConfigure.h
src/mgr/DaemonServer.cc
src/mgr/MgrClient.cc
src/mgr/MgrClient.h

index 3ae2e0777a0a478dde87c7de0a5a9eb7832dd71e..14d81e9ef1e295c2af917905166a6ef6b3fd5658 100644 (file)
@@ -11,6 +11,9 @@
 #include <boost/lexical_cast.hpp>
 #include <boost/regex.hpp>
 
+// Definitions for enums
+#include "common/perf_counters.h"
+
 
 void Option::dump_value(const char *field_name,
     const Option::value_t &v, Formatter *f) const
@@ -4042,6 +4045,14 @@ std::vector<Option> get_global_options() {
     .set_default(0)
     .set_description(""),
 
+  Option("mgr_stats_threshold", Option::TYPE_INT, Option::LEVEL_ADVANCED)
+  .set_default((int64_t)PerfCountersBuilder::PRIO_USEFUL)
+  .set_description("Lowest perfcounter priority collected by mgr")
+  .set_long_description("Daemons only set perf counter data to the manager "
+    "daemon if the counter has a priority higher than this.")
+  .set_min_max((int64_t)PerfCountersBuilder::PRIO_DEBUGONLY,
+               (int64_t)PerfCountersBuilder::PRIO_CRITICAL),
+
     Option("journal_zero_on_create", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
     .set_default(false)
     .set_description(""),
index 27c7cbca4913eb18f56754242bb90bde37755549..10d990807cba70e2ff85987264af5bb49312d2bd 100644 (file)
  */
 class MMgrConfigure : public Message
 {
-  static const int HEAD_VERSION = 1;
+  static const int HEAD_VERSION = 2;
   static const int COMPAT_VERSION = 1;
 
 public:
   uint32_t stats_period;
+  
+  // Default 0 means if unspecified will include all stats
+  uint32_t stats_threshold = 0;
 
   void decode_payload() override
   {
     bufferlist::iterator p = payload.begin();
     ::decode(stats_period, p);
+    if (header.version >= 2) {
+      ::decode(stats_threshold, p);
+    }
   }
 
   void encode_payload(uint64_t features) override {
     ::encode(stats_period, payload);
+    ::encode(stats_threshold, payload);
   }
 
   const char *get_type_name() const override { return "mgrconfigure"; }
   void print(ostream& out) const override {
-    out << get_type_name() << "()";
+    out << get_type_name() << "(period=" << stats_period
+                           << ", threshold=" << stats_threshold << ")";
   }
 
   MMgrConfigure()
index d8d5bc39be554db2e6fd3415cbc5ae15ddc99ef4..74c43d7ac6467eac7c8abe85ce72417c129a0c09 100644 (file)
@@ -317,6 +317,7 @@ bool DaemonServer::handle_open(MMgrOpen *m)
 
   auto configure = new MMgrConfigure();
   configure->stats_period = g_conf->mgr_stats_period;
+  configure->stats_threshold = g_conf->get_val<int64_t>("mgr_stats_threshold");
   m->get_connection()->send_message(configure);
 
   DaemonStatePtr daemon;
index 849590ba93c7974c5e8630504c0b80ead62917de..401edf1b0f1f890ded7a98c3bdee885727f530f5 100644 (file)
@@ -227,9 +227,15 @@ void MgrClient::send_report()
   pcc->with_counters([this, report](
         const PerfCountersCollection::CounterMap &by_path)
   {
+    auto include_counter = [this](
+        const PerfCounters::perf_counter_data_any_d &ctr)
+    {
+      return ctr.prio >= (int)stats_threshold;
+    };
+
     ENCODE_START(1, 1, report->packed);
     for (auto p = session->declared.begin(); p != session->declared.end(); ) {
-      if (by_path.count(*p) == 0) {
+      if (by_path.count(*p) == 0 || !include_counter(*(by_path.at(*p)))) {
        report->undeclare_types.push_back(*p);
        ldout(cct,20) << __func__ << " undeclare " << *p << dendl;
        p = session->declared.erase(p);
@@ -241,8 +247,12 @@ void MgrClient::send_report()
       auto& path = i.first;
       auto& data = *(i.second);
 
+      if (!include_counter(data)) {
+        continue;
+      }
+
       if (session->declared.count(path) == 0) {
-       ldout(cct,20) << __func__ << " declare " << path << dendl;
+       ldout(cct,20) << " declare " << path << dendl;
        PerfCounterType type;
        type.path = path;
        if (data.description) {
@@ -264,8 +274,11 @@ void MgrClient::send_report()
     }
     ENCODE_FINISH(report->packed);
 
-    ldout(cct, 20) << by_path.size() << " counters, of which "
-                  << report->declare_types.size() << " new" << dendl;
+    ldout(cct, 20) << "sending " << session->declared.size() << " counters ("
+                      "of possible " << by_path.size() << "), "
+                  << report->declare_types.size() << " new, "
+                   << report->undeclare_types.size() << " removed"
+                   << dendl;
   });
 
   ldout(cct, 20) << "encoded " << report->packed.length() << " bytes" << dendl;
@@ -313,6 +326,11 @@ bool MgrClient::handle_mgr_configure(MMgrConfigure *m)
 
   ldout(cct, 4) << "stats_period=" << m->stats_period << dendl;
 
+  if (stats_threshold != m->stats_threshold) {
+    ldout(cct, 4) << "updated stats threshold: " << m->stats_threshold << dendl;
+    stats_threshold = m->stats_threshold;
+  }
+
   bool starting = (stats_period == 0) && (m->stats_period != 0);
   stats_period = m->stats_period;
   if (starting) {
index 09fe831b3948364988c6c15a8d678eded1e2cf7e..08ff24c23849428219570c0446a88813f927b8a2 100644 (file)
@@ -59,6 +59,7 @@ protected:
   Mutex lock = {"MgrClient::lock"};
 
   uint32_t stats_period = 0;
+  uint32_t stats_threshold = 0;
   SafeTimer timer;
 
   CommandTable<MgrCommand> command_table;