aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozhikhov <akozhikhov@yandex-team.com>2023-08-15 16:05:27 +0300
committerakozhikhov <akozhikhov@yandex-team.com>2023-08-15 17:15:04 +0300
commit7811ca5fe828e3c080c0d928e6ce1cf7d21d7749 (patch)
tree67efb469bdd2d087fe850c30fabbc235feb392dc
parentcf1d3c2a0f4ec54b688bb5fb98ec52f5dbc45103 (diff)
downloadydb-7811ca5fe828e3c080c0d928e6ce1cf7d21d7749.tar.gz
Fix quota metric in fair throttler
-rw-r--r--yt/yt/core/concurrency/fair_throttler.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/yt/yt/core/concurrency/fair_throttler.cpp b/yt/yt/core/concurrency/fair_throttler.cpp
index 545701d137..a3b1d67578 100644
--- a/yt/yt/core/concurrency/fair_throttler.cpp
+++ b/yt/yt/core/concurrency/fair_throttler.cpp
@@ -275,9 +275,10 @@ DEFINE_REFCOUNTED_TYPE(TBucketThrottleRequest)
struct TLeakyCounter
{
- TLeakyCounter(int windowSize)
+ TLeakyCounter(int windowSize, NProfiling::TGauge quotaGauge)
: Value(std::make_shared<std::atomic<i64>>(0))
, Window(windowSize)
+ , QuotaGauge_(std::move(quotaGauge))
{ }
std::shared_ptr<std::atomic<i64>> Value;
@@ -285,6 +286,8 @@ struct TLeakyCounter
std::vector<i64> Window;
int WindowPosition = 0;
+ NProfiling::TGauge QuotaGauge_;
+
i64 Increment(i64 delta)
{
return Increment(delta, delta);
@@ -309,6 +312,8 @@ struct TLeakyCounter
}
*Value += delta;
+ QuotaGauge_.Update(Value->load());
+
return std::max<i64>(currentValue - maxValue, 0);
}
};
@@ -317,8 +322,8 @@ struct TLeakyCounter
struct TSharedBucket final
{
- TSharedBucket(int windowSize)
- : Limit(windowSize)
+ TSharedBucket(int windowSize, const NProfiling::TProfiler& profiler)
+ : Limit(windowSize, profiler.Gauge("/shared_quota"))
{ }
TLeakyCounter Limit;
@@ -341,17 +346,13 @@ public:
, SharedBucket_(sharedBucket)
, Value_(profiler.Counter("/value"))
, WaitTime_(profiler.Timer("/wait_time"))
- , Quota_(config->BucketAccumulationTicks)
+ , Quota_(config->BucketAccumulationTicks, profiler.Gauge("/quota"))
, DistributionPeriod_(config->DistributionPeriod)
{
profiler.AddFuncGauge("/queue_size", MakeStrong(this), [this] {
return GetQueueTotalAmount();
});
- profiler.AddFuncGauge("/quota", MakeStrong(this), [this] {
- return Quota_.Value->load();
- });
-
profiler.AddFuncGauge("/throttled", MakeStrong(this), [this] {
return IsOverdraft();
});
@@ -589,7 +590,7 @@ TFairThrottler::TFairThrottler(
NProfiling::TProfiler profiler)
: Logger(std::move(logger))
, Profiler_(std::move(profiler))
- , SharedBucket_(New<TSharedBucket>(config->GlobalAccumulationTicks))
+ , SharedBucket_(New<TSharedBucket>(config->GlobalAccumulationTicks, Profiler_))
, Config_(std::move(config))
{
if (Config_->IPCPath) {
@@ -609,10 +610,6 @@ TFairThrottler::TFairThrottler(
ScheduleLimitUpdate(TInstant::Now());
- Profiler_.AddFuncGauge("/shared_quota", MakeStrong(this), [this] {
- return SharedBucket_->Limit.Value->load();
- });
-
Profiler_.AddFuncGauge("/total_limit", MakeStrong(this), [this] {
auto guard = Guard(Lock_);
return Config_->TotalLimit;