summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yt/yt/core/concurrency/throughput_throttler.cpp2
-rw-r--r--yt/yt/core/concurrency/unittests/throughput_throttler_ut.cpp7
2 files changed, 5 insertions, 4 deletions
diff --git a/yt/yt/core/concurrency/throughput_throttler.cpp b/yt/yt/core/concurrency/throughput_throttler.cpp
index 120ada9fcc7..afa15a0154a 100644
--- a/yt/yt/core/concurrency/throughput_throttler.cpp
+++ b/yt/yt/core/concurrency/throughput_throttler.cpp
@@ -315,7 +315,7 @@ private:
{
auto timePassed = current - lastUpdated;
- if (limit > 1) {
+ if (limit * period.SecondsFloat() > 1) {
// Preventing arithmetic overflows by reducing time interval.
timePassed = std::min(period, timePassed);
}
diff --git a/yt/yt/core/concurrency/unittests/throughput_throttler_ut.cpp b/yt/yt/core/concurrency/unittests/throughput_throttler_ut.cpp
index d1056ab9865..e86242a4043 100644
--- a/yt/yt/core/concurrency/unittests/throughput_throttler_ut.cpp
+++ b/yt/yt/core/concurrency/unittests/throughput_throttler_ut.cpp
@@ -75,7 +75,7 @@ TEST(TReconfigurableThroughputThrottlerTest, TestNoOverflow)
.ThrowOnError();
}
-TEST(TReconfigurableThroughputThrottlerTest, FailedTest)
+TEST(TReconfigurableThroughputThrottlerTest, TestFractionalPeriod)
{
auto config = NYT::New<NYT::NConcurrency::TThroughputThrottlerConfig>();
config->Limit = 15;
@@ -84,8 +84,9 @@ TEST(TReconfigurableThroughputThrottlerTest, FailedTest)
auto throttler = CreateReconfigurableThroughputThrottler(config);
for (int i = 0; i < 10; ++i) {
- throttler->Throttle(1).Get().ThrowOnError();
- Sleep(TDuration::Seconds(3));
+ WaitFor(throttler->Throttle(1)
+ .WithTimeout(TDuration::Seconds(5)))
+ .ThrowOnError();
}
}