diff options
| author | qrort <[email protected]> | 2022-12-02 11:31:25 +0300 |
|---|---|---|
| committer | qrort <[email protected]> | 2022-12-02 11:31:25 +0300 |
| commit | b1f4ffc9c8abff3ba58dc1ec9a9f92d2f0de6806 (patch) | |
| tree | 2a23209faf0fea5586a6d4b9cee60d1b318d29fe /library/cpp/cpulimit/cpu.h | |
| parent | 559174a9144de40d6bb3997ea4073c82289b4974 (diff) | |
remove kikimr/driver DEPENDS
Diffstat (limited to 'library/cpp/cpulimit/cpu.h')
| -rw-r--r-- | library/cpp/cpulimit/cpu.h | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/library/cpp/cpulimit/cpu.h b/library/cpp/cpulimit/cpu.h deleted file mode 100644 index eb5ee9b011e..00000000000 --- a/library/cpp/cpulimit/cpu.h +++ /dev/null @@ -1,59 +0,0 @@ -#pragma once - -#include "cpu.h" - -#include <util/datetime/base.h> -#include <util/system/types.h> -#include <util/thread/factory.h> - -#include <deque> - -namespace NCpuLimit { - class TCpuMeasurer { - struct TProbe { - TDuration Period; - std::atomic<double> Usage; - THolder<IThreadFactory::IThread> MeasurerThread; - std::deque<std::pair<TInstant, TDuration>> Window; - TDuration WindowDuration{}; - TDuration WindowUsage{}; - }; - - public: - explicit TCpuMeasurer(TDuration probePeriod); - ~TCpuMeasurer(); - - double CpuUsageFast() const { - return FastProbe_.Usage.load(); - } - - double CpuUsageSlow() const { - return SlowProbe_.Usage.load(); - } - - private: - void UpdateProbeThread(TProbe& probe); - - std::atomic<bool> Finished_ = false; - - TProbe FastProbe_; - TProbe SlowProbe_; - }; - - class TCpuLimiter { - public: - TCpuLimiter(double slowThreshold, double fastThresholdBegin, double fastThresholdEnd); - - // Only throttle (all requests) when LA is greater than FastThresholdEnd_ - bool ThrottleSoft(double slowUsage, double fastUsage) const; - - // Throttle requests with some probability when LA is greater than - // FastThresholdBegin_ - bool ThrottleHard(double slowUsage, double fastUsage) const; - - private: - double SlowThreshold_; - double FastThresholdBegin_; - double FastThresholdEnd_; - }; -} |
