diff options
| author | kruall <[email protected]> | 2025-07-16 18:36:17 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-16 18:36:17 +0300 |
| commit | cc4e4bc50061a0f895017eb392229dbdfb146ded (patch) | |
| tree | 08acfc776e49e5300863db702360d13868c77de2 | |
| parent | bf428cb1b9f2117b20d8ef69255ac6231f1285f2 (diff) | |
Fix race condition in harmonozer stats (#20853)
| -rw-r--r-- | ydb/library/actors/core/harmonizer/harmonizer.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ydb/library/actors/core/harmonizer/harmonizer.cpp b/ydb/library/actors/core/harmonizer/harmonizer.cpp index cf467942b2c..eb9d699f624 100644 --- a/ydb/library/actors/core/harmonizer/harmonizer.cpp +++ b/ydb/library/actors/core/harmonizer/harmonizer.cpp @@ -55,6 +55,8 @@ private: THarmonizerCpuConsumption CpuConsumption; THarmonizerStats Stats; float ProcessingBudget = 0.0; + std::atomic<float> SharedFreeCpu = 0.0; + std::atomic<float> Budget = 0.0; void PullStats(ui64 ts); void PullSharedInfo(); @@ -289,6 +291,8 @@ void THarmonizer::ProcessHoggishState() { void THarmonizer::HarmonizeImpl(ui64 ts) { HARMONIZER_DEBUG_PRINT("HarmonizeImpl", "Iteration", Iteration.fetch_add(1, std::memory_order_relaxed)); Y_UNUSED(ts); + Budget.store(CpuConsumption.Budget, std::memory_order_relaxed); + SharedFreeCpu.store(SharedInfo.FreeCpu, std::memory_order_relaxed); for (size_t poolIdx = 0; poolIdx < Pools.size(); ++poolIdx) { TPoolInfo &pool = *Pools[poolIdx]; @@ -497,8 +501,8 @@ THarmonizerStats THarmonizer::GetStats() const { .MinElapsedCpu = MinElapsedCpu.load(std::memory_order_relaxed), .AvgAwakeningTimeUs = WaitingInfo.AvgAwakeningTimeUs.load(std::memory_order_relaxed), .AvgWakingUpTimeUs = WaitingInfo.AvgWakingUpTimeUs.load(std::memory_order_relaxed), - .Budget = CpuConsumption.Budget, - .SharedFreeCpu = SharedInfo.FreeCpu, + .Budget = Budget.load(std::memory_order_relaxed), + .SharedFreeCpu = SharedFreeCpu.load(std::memory_order_relaxed), }; } |
