From b197869b704c26f05b86702e6b7262efd8246d4d Mon Sep 17 00:00:00 2001 From: Misha Shneerson Date: Mon, 25 Jul 2016 22:14:37 -0700 Subject: [PATCH] Fix gcpu regression associated with 1ms tick in HHWheelTimer Summary: We should go back to 10ms granularity. Because regressions - https://www.facebook.com/groups/wfi/permalink/1107102889338325/ Reviewed By: haijunz Differential Revision: D3616784 fbshipit-source-id: dc1d7ff5195ae836df4a334a9ac5c41164c0627b --- folly/io/async/EventBase.h | 2 +- folly/io/async/test/HHWheelTimerTest.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/folly/io/async/EventBase.h b/folly/io/async/EventBase.h index 507e8beb..b2c4883b 100644 --- a/folly/io/async/EventBase.h +++ b/folly/io/async/EventBase.h @@ -496,7 +496,7 @@ class EventBase : private boost::noncopyable, HHWheelTimer& timer() { if (!wheelTimer_) { - wheelTimer_ = HHWheelTimer::newTimer(this, std::chrono::milliseconds(1)); + wheelTimer_ = HHWheelTimer::newTimer(this); } return *wheelTimer_.get(); } diff --git a/folly/io/async/test/HHWheelTimerTest.cpp b/folly/io/async/test/HHWheelTimerTest.cpp index 85ce3e83..026d94bb 100644 --- a/folly/io/async/test/HHWheelTimerTest.cpp +++ b/folly/io/async/test/HHWheelTimerTest.cpp @@ -135,7 +135,7 @@ TEST_F(HHWheelTimerTest, TestSchedulingWithinCallback) { */ TEST_F(HHWheelTimerTest, CancelTimeout) { - HHWheelTimer& t = eventBase.timer(); + StackWheelTimer t(&eventBase, milliseconds(1)); // Create several timeouts that will all fire in 5ms. TestTimeout t5_1(&t, milliseconds(5)); @@ -350,7 +350,7 @@ TEST_F(HHWheelTimerTest, AtMostEveryN) { */ TEST_F(HHWheelTimerTest, SlowLoop) { - HHWheelTimer& t = eventBase.timer(); + StackWheelTimer t(&eventBase, milliseconds(1)); TestTimeout t1; TestTimeout t2; @@ -429,7 +429,7 @@ TEST_F(HHWheelTimerTest, DefaultTimeout) { } TEST_F(HHWheelTimerTest, lambda) { - HHWheelTimer& t = eventBase.timer(); + StackWheelTimer t(&eventBase, milliseconds(1)); size_t count = 0; t.scheduleTimeoutFn([&]{ count++; }, milliseconds(1)); eventBase.loop(); @@ -439,14 +439,14 @@ TEST_F(HHWheelTimerTest, lambda) { // shouldn't crash because we swallow and log the error (you'll have to look // at the console to confirm logging) TEST_F(HHWheelTimerTest, lambdaThrows) { - HHWheelTimer& t = eventBase.timer(); + StackWheelTimer t(&eventBase, milliseconds(1)); t.scheduleTimeoutFn([&]{ throw std::runtime_error("expected"); }, milliseconds(1)); eventBase.loop(); } TEST_F(HHWheelTimerTest, cancelAll) { - HHWheelTimer& t = eventBase.timer(); + StackWheelTimer t(&eventBase, milliseconds(1)); TestTimeout tt; t.scheduleTimeout(&tt, std::chrono::minutes(1)); EXPECT_EQ(1, t.cancelAll()); -- 2.34.1