From af3fa519ac83267fabc53d3799a57dab761de0bc Mon Sep 17 00:00:00 2001 From: Pavlo Kushnir Date: Wed, 28 Oct 2015 17:15:19 -0700 Subject: [PATCH 1/1] Do not set startWork_ in EventBase if time measurement is disabled Summary: startWork_ is used only if enableTimeMeasurement is set. It gives ~0.5% performance win for mcrouter. Reviewed By: yfeldblum Differential Revision: D2590176 fb-gh-sync-id: 07f2189ebdec751cd0d91d191d8f595780d2808a --- folly/io/async/EventBase.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/folly/io/async/EventBase.cpp b/folly/io/async/EventBase.cpp index 2ec1e90d..55691b19 100644 --- a/folly/io/async/EventBase.cpp +++ b/folly/io/async/EventBase.cpp @@ -459,12 +459,14 @@ bool EventBase::bumpHandlingTime() { " (loop) latest " << latestLoopCnt_ << " next " << nextLoopCnt_; if(nothingHandledYet()) { latestLoopCnt_ = nextLoopCnt_; - // set the time - startWork_ = std::chrono::duration_cast( - std::chrono::steady_clock::now().time_since_epoch()).count(); + if (enableTimeMeasurement_) { + // set the time + startWork_ = std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()).count(); - VLOG(11) << "EventBase " << this << " " << __PRETTY_FUNCTION__ << - " (loop) startWork_ " << startWork_; + VLOG(11) << "EventBase " << this << " " << __PRETTY_FUNCTION__ << + " (loop) startWork_ " << startWork_; + } return true; } return false; -- 2.34.1