]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: OpTracker age histogram calculation is not correct 5065/head
authorZhiqiang Wang <zhiqiang.wang@intel.com>
Thu, 10 Sep 2015 02:15:24 +0000 (10:15 +0800)
committerZhiqiang Wang <zhiqiang.wang@intel.com>
Thu, 10 Sep 2015 03:08:54 +0000 (11:08 +0800)
While the TrackedOps in each sharded list are ordered, there are no
order among different shared lists. Looping the sharded list one by one
won't be able to get the right histogram. Instead, we can increment the
bin count for each of the TrackedOp. Btw, for those TrackedOp whose age
is >= 2^30 ms, they are now been put in the respective number of bits
bin, instead of been put in a single bin.

Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
src/common/TrackedOp.cc

index f759894fb04809c9aed78bd965ec30a84ab5cf53..b5857d20e8a7f8b0985102c28eff4b377440ad4d 100644 (file)
@@ -242,12 +242,8 @@ bool OpTracker::check_ops_in_flight(std::vector<string> &warning_vector)
 void OpTracker::get_age_ms_histogram(pow2_hist_t *h)
 {
   h->clear();
-
   utime_t now = ceph_clock_now(NULL);
-  unsigned bin = 30;
-  uint32_t lb = 1 << (bin-1);  // lower bound for this bin
-  int count = 0;
-  
+
   for (uint32_t iter = 0; iter < num_optracker_shards; iter++) {
     ShardedTrackingData* sdata = sharded_in_flight_list[iter];
     assert(NULL != sdata);
@@ -257,21 +253,9 @@ void OpTracker::get_age_ms_histogram(pow2_hist_t *h)
                                                                !i.end(); ++i) {
       utime_t age = now - (*i)->get_initiated();
       uint32_t ms = (long)(age * 1000.0);
-      if (ms >= lb) {
-        count++;
-        continue;
-      }
-      if (count)
-        h->set_bin(bin, count);
-      while (lb > ms) {
-        bin--;
-        lb >>= 1;
-      }
-      count = 1;
+      h->add(ms);
     }
   }
-  if (count)
-    h->set_bin(bin, count);
 }
 
 void OpTracker::mark_event(TrackedOp *op, const string &dest, utime_t time)