From c5f3170a8294ef305d8293a89687ced09cc49d82 Mon Sep 17 00:00:00 2001 From: serxa Date: Mon, 18 Sep 2023 18:12:55 +0000 Subject: [PATCH] update actual amount of tokens in bucket --- src/IO/Resource/ThrottlerConstraint.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/IO/Resource/ThrottlerConstraint.h b/src/IO/Resource/ThrottlerConstraint.h index 763cd25cf9c..3418306109e 100644 --- a/src/IO/Resource/ThrottlerConstraint.h +++ b/src/IO/Resource/ThrottlerConstraint.h @@ -125,7 +125,9 @@ public: double getTokens() const { - return tokens; + auto now = event_queue->now(); + double elapsed = std::chrono::nanoseconds(now - last_update).count() / 1e9; + return std::min(tokens + max_speed * elapsed, max_burst); } std::chrono::nanoseconds getThrottlingDuration() const