From 567dd1e92adbacb7edb46203a4fdf96faf98c12e Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Thu, 10 Sep 2015 10:15:24 +0800 Subject: [PATCH] common: OpTracker age histogram calculation is not correct 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 --- src/common/TrackedOp.cc | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index f759894fb0480..b5857d20e8a7f 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -242,12 +242,8 @@ bool OpTracker::check_ops_in_flight(std::vector &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) -- 2.39.5