]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: create and tear down a radosgw perfcounter
authorSage Weil <sage@newdream.net>
Tue, 11 Oct 2011 21:00:42 +0000 (14:00 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 8 Nov 2011 17:50:29 +0000 (09:50 -0800)
Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_main.cc

index 53ac82892c164c0d721f1e4a842beaea862c0427..19c1bac9b7e707fb3182ddeec2e36c84c8141a91 100644 (file)
@@ -8,12 +8,42 @@
 #include "common/errno.h"
 #include "common/Clock.h"
 #include "common/Formatter.h"
+#include "common/perf_counters.h"
 #include "auth/Crypto.h"
 
 #include <sstream>
 
 #define DOUT_SUBSYS rgw
 
+PerfCounters *perfcounter = NULL;
+
+int rgw_perf_start(CephContext *cct)
+{
+  PerfCountersBuilder plb(cct, cct->_conf->name.to_str(), l_rgw_first, l_rgw_last);
+
+  plb.add_u64_counter(l_rgw_get, "get");
+  plb.add_u64_counter(l_rgw_get_b, "get_b");
+  plb.add_fl_avg(l_rgw_get_lat, "get_lat");
+  plb.add_u64_counter(l_rgw_put, "put");
+  plb.add_u64_counter(l_rgw_put_b, "put_b");
+  plb.add_fl_avg(l_rgw_put_lat, "put_lat");
+
+  plb.add_u64(l_rgw_qlen, "qlen");
+  plb.add_u64(l_rgw_qactive, "qactive");
+
+  perfcounter = plb.create_perf_counters();
+  cct->get_perfcounters_collection()->add(perfcounter);
+  return 0;
+}
+
+void rgw_perf_stop(CephContext *cct)
+{
+  assert(perfcounter);
+  cct->get_perfcounters_collection()->remove(perfcounter);
+  delete perfcounter;
+}
+
+
 using namespace ceph::crypto;
 
 rgw_err::
index 1a73d430370c08d6d33acdf5d4200e384ee604d2..d8f976e7a8c94fd753ede7d34ac09fb999395198 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "common/ceph_crypto.h"
 #include "common/debug.h"
+#include "common/perf_counters.h"
 
 #include "acconfig.h"
 #ifdef FASTCGI_INCLUDE_DIR
@@ -125,6 +126,33 @@ using ceph::crypto::MD5;
 
 typedef void *RGWAccessHandle;
 
+
+/* perf counter */
+
+extern PerfCounters *perfcounter;
+
+extern int rgw_perf_start(CephContext *cct);
+extern void rgw_perf_stop(CephContext *cct);
+
+enum {
+  l_rgw_first = 15000,
+  l_rgw_req,
+
+  l_rgw_get,
+  l_rgw_get_b,
+  l_rgw_get_lat,
+
+  l_rgw_put,
+  l_rgw_put_b,
+  l_rgw_put_lat,
+
+  l_rgw_qlen,
+  l_rgw_qactive,
+
+  l_rgw_last,
+};
+
+
  /* size should be the required string size + 1 */
 extern int gen_rand_base64(char *dest, int size);
 extern int gen_rand_alphanumeric(char *dest, int size);
index 0965600778783ea468a0e96a06aba149eb3a9b61..d72bcfb3179bf5f5f50c03ab4753266b976da40e 100644 (file)
@@ -287,9 +287,15 @@ int main(int argc, const char **argv)
     return EIO;
   }
   
+  int r = rgw_perf_start(g_ceph_context);
+  if (r < 0)
+    return 1;
+
   RGWProcess process(g_ceph_context, g_conf->rgw_thread_pool_size);
   process.run();
 
+  rgw_perf_stop(g_ceph_context);
+
   return 0;
 }