From ce26dc2a4e75b64a52c799bab3c242414676299e Mon Sep 17 00:00:00 2001 From: Pan Liu Date: Tue, 25 Oct 2016 12:36:28 +0800 Subject: [PATCH] common: make l_finisher_complete_lat more accurate Signed-off-by: Pan Liu --- src/common/Finisher.cc | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/common/Finisher.cc b/src/common/Finisher.cc index 73900ddc20d..2e1567d1640 100644 --- a/src/common/Finisher.cc +++ b/src/common/Finisher.cc @@ -44,12 +44,9 @@ void *Finisher::finisher_thread_entry() finisher_lock.Lock(); ldout(cct, 10) << "finisher_thread start" << dendl; - utime_t start; while (!finisher_stop) { /// Every time we are woken up, we process the queue until it is empty. while (!finisher_queue.empty()) { - if (logger) - start = ceph_clock_now(cct); // To reduce lock contention, we swap out the queue to process. // This way other threads can submit new contexts to complete while we are working. vector ls; @@ -61,23 +58,25 @@ void *Finisher::finisher_thread_entry() ldout(cct, 10) << "finisher_thread doing " << ls << dendl; // Now actually process the contexts. + utime_t start; for (vector::iterator p = ls.begin(); - p != ls.end(); - ++p) { - if (*p) { - (*p)->complete(0); - } else { - // When an item is NULL in the finisher_queue, it means - // we should instead process an item from finisher_queue_rval, - // which has a parameter for complete() other than zero. - // This preserves the order while saving some storage. - assert(!ls_rval.empty()); - Context *c = ls_rval.front().first; - c->complete(ls_rval.front().second); - ls_rval.pop_front(); - } - if (logger) { - logger->dec(l_finisher_queue_len); + p != ls.end(); + ++p) { + start = ceph_clock_now(cct); + if (*p) { + (*p)->complete(0); + } else { + // When an item is NULL in the finisher_queue, it means + // we should instead process an item from finisher_queue_rval, + // which has a parameter for complete() other than zero. + // This preserves the order while saving some storage. + assert(!ls_rval.empty()); + Context *c = ls_rval.front().first; + c->complete(ls_rval.front().second); + ls_rval.pop_front(); + } + if (logger) { + logger->dec(l_finisher_queue_len); logger->tinc(l_finisher_complete_lat, ceph_clock_now(cct) - start); } }