From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 17/18] vinyl: set quota timer period to 100 ms Date: Thu, 16 Aug 2018 19:12:11 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: Currently, it's 1 second, which is OK for calculating watermark, but too long for throttling (think of latency of 1 seconds that would be introduced by throttling if such timeout were used). --- src/box/vy_quota.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/box/vy_quota.c b/src/box/vy_quota.c index 43fc645a..471a8bd0 100644 --- a/src/box/vy_quota.c +++ b/src/box/vy_quota.c @@ -43,18 +43,17 @@ #include "histogram.h" #include "trivia/util.h" -enum { - /** - * Time interval between successive updates of - * quota watermark and use rate, in seconds. - */ - VY_QUOTA_UPDATE_INTERVAL = 1, - /** - * Period of time over which the quota use rate - * is averaged, in seconds. - */ - VY_QUOTA_RATE_AVG_PERIOD = 5, -}; +/** + * Time interval between successive updates of quota watermark + * and use rate, in seconds. + */ +static const double VY_QUOTA_UPDATE_INTERVAL = 0.1; + +/** + * Period of time over which the quota use rate is averaged, + * in seconds. + */ +static const double VY_QUOTA_RATE_AVG_PERIOD = 5; /* * Until we dump anything, assume bandwidth to be 10 MB/s, @@ -154,7 +153,7 @@ vy_quota_timer_cb(ev_loop *loop, ev_timer *timer, int events) * Update the quota use rate with the new measurement. */ const double weight = 1 - exp(-VY_QUOTA_UPDATE_INTERVAL / - (double)VY_QUOTA_RATE_AVG_PERIOD); + VY_QUOTA_RATE_AVG_PERIOD); q->use_rate = (1 - weight) * q->use_rate + weight * q->use_curr / VY_QUOTA_UPDATE_INTERVAL; q->use_curr = 0; -- 2.11.0