[PATCH 08/11] vinyl: set quota timer period to 100 ms
Vladimir Davydov
vdavydov.dev at gmail.com
Thu Sep 20 12:34:13 MSK 2018
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 5f8c0618..def05aa2 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,
@@ -106,7 +105,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
More information about the Tarantool-patches
mailing list