Skip to content

Commit 2671d97

Browse files
committed
Refactor harmonizer, add tests and fix harmonizer logic (ydb-platform#9454)
1 parent 6b13911 commit 2671d97

File tree

10 files changed

+629
-167
lines changed

10 files changed

+629
-167
lines changed

ydb/library/actors/core/executor_pool.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ namespace NActors {
1515
class ISchedulerCookie;
1616

1717
struct TCpuConsumption {
18-
double ConsumedUs = 0;
19-
double BookedUs = 0;
18+
double ElapsedUs = 0;
19+
double CpuUs = 0;
2020
ui64 NotEnoughCpuExecutions = 0;
2121

2222
void Add(const TCpuConsumption& other) {
23-
ConsumedUs += other.ConsumedUs;
24-
BookedUs += other.BookedUs;
23+
ElapsedUs += other.ElapsedUs;
24+
CpuUs += other.CpuUs;
2525
NotEnoughCpuExecutions += other.NotEnoughCpuExecutions;
2626
}
2727
};

ydb/library/actors/core/executor_pool_basic.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ namespace NActors {
408408
poolStats.DecreasingThreadsByHoggishState = stats.DecreasingThreadsByHoggishState;
409409
poolStats.DecreasingThreadsByExchange = stats.DecreasingThreadsByExchange;
410410
poolStats.PotentialMaxThreadCount = stats.PotentialMaxThreadCount;
411-
poolStats.MaxConsumedCpuUs = stats.MaxConsumedCpu;
412-
poolStats.MinConsumedCpuUs = stats.MinConsumedCpu;
413-
poolStats.MaxBookedCpuUs = stats.MaxBookedCpu;
414-
poolStats.MinBookedCpuUs = stats.MinBookedCpu;
411+
poolStats.MaxElapsedCpuUs = stats.MaxElapsedCpu;
412+
poolStats.MinElapsedCpuUs = stats.MinElapsedCpu;
413+
poolStats.MaxCpuUs = stats.MaxCpu;
414+
poolStats.MinCpuUs = stats.MinCpu;
415415
}
416416

417417
statsCopy.resize(MaxFullThreadCount + 1);
@@ -430,7 +430,7 @@ namespace NActors {
430430
void TBasicExecutorPool::GetExecutorPoolState(TExecutorPoolState &poolState) const {
431431
if (Harmonizer) {
432432
TPoolHarmonizerStats stats = Harmonizer->GetPoolStats(PoolId);
433-
poolState.UsedCpu = stats.AvgConsumedCpu;
433+
poolState.UsedCpu = stats.AvgElapsedCpu;
434434
poolState.PossibleMaxLimit = stats.PotentialMaxThreadCount;
435435
} else {
436436
poolState.PossibleMaxLimit = poolState.MaxLimit;

ydb/library/actors/core/executor_pool_io.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ namespace NActors {
140140

141141
void TIOExecutorPool::GetCurrentStats(TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const {
142142
poolStats.CurrentThreadCount = PoolThreads;
143-
poolStats.DefaultThreadCount = PoolThreads;
143+
poolStats.DefaultThreadCount = 0;
144144
poolStats.MaxThreadCount = PoolThreads;
145145
poolStats.PotentialMaxThreadCount = PoolThreads;
146146
statsCopy.resize(PoolThreads + 1);
@@ -156,7 +156,7 @@ namespace NActors {
156156
void TIOExecutorPool::GetExecutorPoolState(TExecutorPoolState &poolState) const {
157157
if (Harmonizer) {
158158
TPoolHarmonizerStats stats = Harmonizer->GetPoolStats(PoolId);
159-
poolState.UsedCpu = stats.AvgConsumedCpu;
159+
poolState.UsedCpu = stats.AvgElapsedCpu;
160160
}
161161
poolState.CurrentLimit = PoolThreads;
162162
poolState.MaxLimit = PoolThreads;

ydb/library/actors/core/harmonizer.cpp

Lines changed: 213 additions & 121 deletions
Large diffs are not rendered by default.

ydb/library/actors/core/harmonizer.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,29 @@ namespace NActors {
1717
ui64 DecreasingThreadsByStarvedState = 0;
1818
ui64 DecreasingThreadsByHoggishState = 0;
1919
ui64 DecreasingThreadsByExchange = 0;
20-
float MaxConsumedCpu = 0.0;
21-
float MinConsumedCpu = 0.0;
22-
float AvgConsumedCpu = 0.0;
23-
float MaxBookedCpu = 0.0;
24-
float MinBookedCpu = 0.0;
20+
float MaxElapsedCpu = 0.0;
21+
float MinElapsedCpu = 0.0;
22+
float AvgElapsedCpu = 0.0;
23+
float MaxCpu = 0.0;
24+
float MinCpu = 0.0;
2525
i16 PotentialMaxThreadCount = 0;
2626
bool IsNeedy = false;
2727
bool IsStarved = false;
2828
bool IsHoggish = false;
29+
30+
TString ToString() const;
2931
};
3032

3133
struct THarmonizerStats {
32-
i64 MaxConsumedCpu = 0.0;
33-
i64 MinConsumedCpu = 0.0;
34-
i64 MaxBookedCpu = 0.0;
35-
i64 MinBookedCpu = 0.0;
34+
i64 MaxElapsedCpu = 0.0;
35+
i64 MinElapsedCpu = 0.0;
36+
i64 MaxCpu = 0.0;
37+
i64 MinCpu = 0.0;
3638

3739
double AvgAwakeningTimeUs = 0;
3840
double AvgWakingUpTimeUs = 0;
41+
42+
TString ToString() const;
3943
};
4044

4145
// Pool cpu harmonizer

ydb/library/actors/core/mon_stats.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ namespace NActors {
6363
ui64 DecreasingThreadsByStarvedState = 0;
6464
ui64 DecreasingThreadsByHoggishState = 0;
6565
ui64 DecreasingThreadsByExchange = 0;
66-
i64 MaxConsumedCpuUs = 0;
67-
i64 MinConsumedCpuUs = 0;
68-
i64 MaxBookedCpuUs = 0;
69-
i64 MinBookedCpuUs = 0;
66+
i64 MaxElapsedCpuUs = 0;
67+
i64 MinElapsedCpuUs = 0;
68+
i64 MaxCpuUs = 0;
69+
i64 MinCpuUs = 0;
7070
double SpinningTimeUs = 0;
7171
double SpinThresholdUs = 0;
7272
i16 WrongWakenedThreadCount = 0;

ydb/library/actors/core/probes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@
174174
NAMES("poolId", "pool", "threacCount", "minThreadCount", "maxThreadCount", "defaultThreadCount")) \
175175
PROBE(HarmonizeCheckPool, GROUPS("Harmonizer"), \
176176
TYPES(ui32, TString, double, double, double, double, ui32, ui32, bool, bool, bool), \
177-
NAMES("poolId", "pool", "booked", "consumed", "lastSecondBooked", "lastSecondConsumed", "threadCount", "maxThreadCount", \
177+
NAMES("poolId", "pool", "cpu", "elapsed", "lastSecondCpu", "lastSecondElapsed", "threadCount", "maxThreadCount", \
178178
"isStarved", "isNeedy", "isHoggish")) \
179179
PROBE(HarmonizeCheckPoolByThread, GROUPS("Harmonizer"), \
180180
TYPES(ui32, TString, i16, double, double, double, double), \
181-
NAMES("poolId", "pool", "threadIdx", "booked", "consumed", "lastSecondBooked", "lastSecondConsumed")) \
181+
NAMES("poolId", "pool", "threadIdx", "cpu", "elapsed", "lastSecondCpu", "lastSecondElapsed")) \
182182
PROBE(WakingUpConsumption, GROUPS("Harmonizer"), \
183183
TYPES(double, double, double, double, double), \
184184
NAMES("avgWakingUpUs", "realAvgWakingUpUs", "avgAwakeningUs", "realAvgAwakeningUs", "total")) \

0 commit comments

Comments
 (0)