]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Make KeyValueStore support "ceph osd perf" command 1899/head
authorHaomai Wang <haomaiwang@gmail.com>
Sat, 31 May 2014 08:09:45 +0000 (16:09 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Sat, 31 May 2014 09:31:14 +0000 (17:31 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/os/KeyValueStore.cc
src/os/KeyValueStore.h

index d1642edf0ade9593da2cc312769b130768675ae3..2dca21b1e956037ba385a9d94f3ec993d76cc296 100644 (file)
@@ -521,7 +521,7 @@ KeyValueStore::KeyValueStore(const std::string &base,
   current_op_seq_fn = sss.str();
 
   // initialize perf_logger
-  PerfCountersBuilder plb(g_ceph_context, internal_name, l_os_commit_lat, l_os_last);
+  PerfCountersBuilder plb(g_ceph_context, internal_name, l_os_commit_len, l_os_last);
 
   plb.add_u64(l_os_oq_max_ops, "op_queue_max_ops");
   plb.add_u64(l_os_oq_ops, "op_queue_ops");
@@ -529,6 +529,7 @@ KeyValueStore::KeyValueStore(const std::string &base,
   plb.add_u64(l_os_oq_max_bytes, "op_queue_max_bytes");
   plb.add_u64(l_os_oq_bytes, "op_queue_bytes");
   plb.add_u64_counter(l_os_bytes, "bytes");
+  plb.add_time_avg(l_os_commit_lat, "commit_latency");
   plb.add_time_avg(l_os_apply_lat, "apply_latency");
   plb.add_time_avg(l_os_queue_lat, "queue_transaction_latency_avg");
 
@@ -1095,6 +1096,7 @@ void KeyValueStore::_finish_op(OpSequencer *osr)
 
   utime_t lat = ceph_clock_now(g_ceph_context);
   lat -= o->start;
+  perf_logger->tinc(l_os_commit_lat, lat);
   perf_logger->tinc(l_os_apply_lat, lat);
 
   if (o->onreadable_sync) {
index 8dfd395c0deb84e26fa25214163b3adca20acdf8..02574596954a77bcba5bb300310dd10651058fbc 100644 (file)
@@ -147,9 +147,31 @@ class StripObjectMap: public GenericObjectMap {
 class KeyValueStore : public ObjectStore,
                       public md_config_obs_t {
  public:
+  struct KVPerfTracker {
+    PerfCounters::avg_tracker<uint64_t> os_commit_latency;
+    PerfCounters::avg_tracker<uint64_t> os_apply_latency;
+
+    objectstore_perf_stat_t get_cur_stats() const {
+      objectstore_perf_stat_t ret;
+      ret.filestore_commit_latency = os_commit_latency.avg();
+      ret.filestore_apply_latency = os_apply_latency.avg();
+      return ret;
+    }
+
+    void update_from_perfcounters(PerfCounters &logger) {
+      os_commit_latency.consume_next(
+        logger.get_tavg_ms(
+          l_os_commit_lat));
+      os_apply_latency.consume_next(
+        logger.get_tavg_ms(
+          l_os_apply_lat));
+    }
+
+  } perf_tracker;
+
   objectstore_perf_stat_t get_cur_stats() {
-    objectstore_perf_stat_t ret;
-    return ret;
+    perf_tracker.update_from_perfcounters(*perf_logger);
+    return perf_tracker.get_cur_stats();
   }
 
   static const uint32_t target_version = 1;