Skip to content

Commit

Permalink
adaptive concurrency: Reset sample timer after minRTT calculation (en…
Browse files Browse the repository at this point in the history
…voyproxy#8524)

This fixes a bug where the concurrency limit calculations were not
occurring anymore after the minRTT window closed. It was expected that
the minRTT update would set the sample timer again.

Signed-off-by: Tony Allen <[email protected]>
  • Loading branch information
tonya11en authored and mattklein123 committed Oct 9, 2019
1 parent 00b3aa2 commit 7348e44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void GradientController::updateMinRTT() {

min_rtt_calc_timer_->enableTimer(
applyJitter(config_.minRTTCalcInterval(), config_.jitterPercent()));
sample_reset_timer_->enableTimer(config_.sampleRTTCalcInterval());
}

std::chrono::milliseconds GradientController::applyJitter(std::chrono::milliseconds interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ TEST_F(GradientControllerTest, TimerAccuracyTest) {

// Verify the configuration affects the timers that are kicked off.
NiceMock<Event::MockDispatcher> fake_dispatcher;
auto sample_timer = new NiceMock<Event::MockTimer>;
auto rtt_timer = new NiceMock<Event::MockTimer>;
auto sample_timer = new Event::MockTimer();
auto rtt_timer = new Event::MockTimer();

// Expect the sample timer to trigger start immediately upon controller creation.
EXPECT_CALL(fake_dispatcher, createTimer_(_))
Expand All @@ -488,6 +488,8 @@ TEST_F(GradientControllerTest, TimerAccuracyTest) {
// random value > 10% of the interval.
EXPECT_CALL(random_, random()).WillOnce(Return(15000));
EXPECT_CALL(*rtt_timer, enableTimer(std::chrono::milliseconds(105000), _));
// Verify the sample timer is reset after the minRTT calculation occurs.
EXPECT_CALL(*sample_timer, enableTimer(std::chrono::milliseconds(123), _));
for (int i = 0; i < 6; ++i) {
tryForward(controller, true);
controller->recordLatencySample(std::chrono::milliseconds(5));
Expand All @@ -511,8 +513,8 @@ TEST_F(GradientControllerTest, TimerAccuracyTestNoJitter) {

// Verify the configuration affects the timers that are kicked off.
NiceMock<Event::MockDispatcher> fake_dispatcher;
auto sample_timer = new NiceMock<Event::MockTimer>;
auto rtt_timer = new NiceMock<Event::MockTimer>;
auto sample_timer = new Event::MockTimer;
auto rtt_timer = new Event::MockTimer;

// Expect the sample timer to trigger start immediately upon controller creation.
EXPECT_CALL(fake_dispatcher, createTimer_(_))
Expand All @@ -525,6 +527,8 @@ TEST_F(GradientControllerTest, TimerAccuracyTestNoJitter) {

// Set the minRTT- this will trigger the timer for the next minRTT calculation.
EXPECT_CALL(*rtt_timer, enableTimer(std::chrono::milliseconds(45000), _));
// Verify the sample timer is reset after the minRTT calculation occurs.
EXPECT_CALL(*sample_timer, enableTimer(std::chrono::milliseconds(123), _));
for (int i = 0; i < 6; ++i) {
tryForward(controller, true);
controller->recordLatencySample(std::chrono::milliseconds(5));
Expand Down

0 comments on commit 7348e44

Please sign in to comment.