]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Throttler: optionally disable use of perfcounters
authorGreg Farnum <greg@inktank.com>
Tue, 7 Jan 2014 17:43:28 +0000 (09:43 -0800)
committerGreg Farnum <greg@inktank.com>
Fri, 31 Jan 2014 23:54:40 +0000 (15:54 -0800)
These can be expensive enough that we want to disable them. We're already
mostly set up for it to be optional, so just plug in a config option and
move a timestamp read under the "if (logger)" guard to set it up!

Signed-off-by: Greg Farnum <greg@inktank.com>
src/common/Throttle.cc
src/common/config_opts.h

index 7c097e2d87c34c28ba70e879470f177a4b3f08d2..a2b96979d832ee22385bb78752eedc89ed6727a7 100644 (file)
@@ -40,22 +40,24 @@ Throttle::Throttle(CephContext *cct, std::string n, int64_t m, bool _use_perf)
   if (!use_perf)
     return;
 
-  PerfCountersBuilder b(cct, string("throttle-") + name, l_throttle_first, l_throttle_last);
-  b.add_u64_counter(l_throttle_val, "val");
-  b.add_u64_counter(l_throttle_max, "max");
-  b.add_u64_counter(l_throttle_get, "get");
-  b.add_u64_counter(l_throttle_get_sum, "get_sum");
-  b.add_u64_counter(l_throttle_get_or_fail_fail, "get_or_fail_fail");
-  b.add_u64_counter(l_throttle_get_or_fail_success, "get_or_fail_success");
-  b.add_u64_counter(l_throttle_take, "take");
-  b.add_u64_counter(l_throttle_take_sum, "take_sum");
-  b.add_u64_counter(l_throttle_put, "put");
-  b.add_u64_counter(l_throttle_put_sum, "put_sum");
-  b.add_time_avg(l_throttle_wait, "wait");
-
-  logger = b.create_perf_counters();
-  cct->get_perfcounters_collection()->add(logger);
-  logger->set(l_throttle_max, max.read());
+  if (cct->_conf->throttler_perf_counter) {
+    PerfCountersBuilder b(cct, string("throttle-") + name, l_throttle_first, l_throttle_last);
+    b.add_u64_counter(l_throttle_val, "val");
+    b.add_u64_counter(l_throttle_max, "max");
+    b.add_u64_counter(l_throttle_get, "get");
+    b.add_u64_counter(l_throttle_get_sum, "get_sum");
+    b.add_u64_counter(l_throttle_get_or_fail_fail, "get_or_fail_fail");
+    b.add_u64_counter(l_throttle_get_or_fail_success, "get_or_fail_success");
+    b.add_u64_counter(l_throttle_take, "take");
+    b.add_u64_counter(l_throttle_take_sum, "take_sum");
+    b.add_u64_counter(l_throttle_put, "put");
+    b.add_u64_counter(l_throttle_put_sum, "put_sum");
+    b.add_time_avg(l_throttle_wait, "wait");
+
+    logger = b.create_perf_counters();
+    cct->get_perfcounters_collection()->add(logger);
+    logger->set(l_throttle_max, max.read());
+  }
 }
 
 Throttle::~Throttle()
@@ -69,8 +71,10 @@ Throttle::~Throttle()
   if (!use_perf)
     return;
 
-  cct->get_perfcounters_collection()->remove(logger);
-  delete logger;
+  if (logger) {
+    cct->get_perfcounters_collection()->remove(logger);
+    delete logger;
+  }
 }
 
 void Throttle::_reset_max(int64_t m)
@@ -93,7 +97,8 @@ bool Throttle::_wait(int64_t c)
     do {
       if (!waited) {
        ldout(cct, 2) << "_wait waiting..." << dendl;
-       start = ceph_clock_now(cct);
+       if (logger)
+         start = ceph_clock_now(cct);
       }
       waited = true;
       cv->Wait(lock);
@@ -101,9 +106,10 @@ bool Throttle::_wait(int64_t c)
 
     if (waited) {
       ldout(cct, 3) << "_wait finished waiting" << dendl;
-      utime_t dur = ceph_clock_now(cct) - start;
-      if (logger)
+      if (logger) {
+       utime_t dur = ceph_clock_now(cct) - start;
         logger->tinc(l_throttle_wait, dur);
+      }
     }
 
     delete cv;
index ae248a36cc229fb103e34320a741e51bdbd5362f..049b60d754ba11740345331a2d38eae683dff222 100644 (file)
@@ -780,6 +780,7 @@ OPTION(rgw_user_quota_sync_wait_time, OPT_INT, 3600 * 24) // min time between tw
 OPTION(rgw_multipart_min_part_size, OPT_INT, 5 * 1024 * 1024) // min size for each part (except for last one) in multipart upload
 
 OPTION(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter
+OPTION(throttler_perf_counter, OPT_BOOL, true) // enable/disable throttler perf counter
 
 // This will be set to true when it is safe to start threads.
 // Once it is true, it will never change.