Skip to content

Commit 203c1cc

Browse files
authored
Improve harmonizer on pulling stats (#5170)
1 parent 82dabad commit 203c1cc

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

ydb/library/actors/core/executor_pool_basic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ namespace NActors {
610610
}
611611
TExecutorThreadCtx& threadCtx = Threads[threadIdx];
612612
TExecutorThreadStats stats;
613-
threadCtx.Thread->GetCurrentStats(stats);
613+
threadCtx.Thread->GetCurrentStatsForHarmonizer(stats);
614614
return {Ts2Us(stats.SafeElapsedTicks), static_cast<double>(stats.CpuUs), stats.NotEnoughCpuExecutions};
615615
}
616616

ydb/library/actors/core/executor_pool_shared.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,19 @@ void TSharedExecutorPool::GetSharedStats(i16 poolId, std::vector<TExecutorThread
149149
}
150150
}
151151

152+
void TSharedExecutorPool::GetSharedStatsForHarmonizer(i16 poolId, std::vector<TExecutorThreadStats>& statsCopy) {
153+
statsCopy.resize(SharedThreadCount + 1);
154+
for (i16 i = 0; i < SharedThreadCount; ++i) {
155+
Threads[i].Thread->GetSharedStatsForHarmonizer(poolId, statsCopy[i + 1]);
156+
}
157+
}
158+
152159
TCpuConsumption TSharedExecutorPool::GetThreadCpuConsumption(i16 poolId, i16 threadIdx) {
153160
if (threadIdx >= SharedThreadCount) {
154161
return {0.0, 0.0};
155162
}
156163
TExecutorThreadStats stats;
157-
Threads[threadIdx].Thread->GetSharedStats(poolId, stats);
164+
Threads[threadIdx].Thread->GetSharedStatsForHarmonizer(poolId, stats);
158165
return {Ts2Us(stats.SafeElapsedTicks), static_cast<double>(stats.CpuUs), stats.NotEnoughCpuExecutions};
159166
}
160167

ydb/library/actors/core/executor_pool_shared.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace NActors {
3737

3838
TSharedExecutorThreadCtx *GetSharedThread(i16 poolId);
3939
void GetSharedStats(i16 pool, std::vector<TExecutorThreadStats>& statsCopy);
40+
void GetSharedStatsForHarmonizer(i16 pool, std::vector<TExecutorThreadStats>& statsCopy);
4041
TCpuConsumption GetThreadCpuConsumption(i16 poolId, i16 threadIdx);
4142
std::vector<TCpuConsumption> GetThreadsCpuConsumption(i16 poolId);
4243

ydb/library/actors/core/executor_thread.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,19 @@ namespace NActors {
811811
statsCopy.Aggregate(SharedStats[poolId]);
812812
}
813813

814+
void TGenericExecutorThread::GetCurrentStatsForHarmonizer(TExecutorThreadStats& statsCopy) {
815+
statsCopy.SafeElapsedTicks = RelaxedLoad(&Ctx.Stats->SafeElapsedTicks);
816+
statsCopy.CpuUs = RelaxedLoad(&Ctx.Stats->CpuUs);
817+
statsCopy.NotEnoughCpuExecutions = RelaxedLoad(&Ctx.Stats->NotEnoughCpuExecutions);
818+
}
819+
820+
void TGenericExecutorThread::GetSharedStatsForHarmonizer(i16 poolId, TExecutorThreadStats &stats) {
821+
stats.SafeElapsedTicks = RelaxedLoad(&SharedStats[poolId].SafeElapsedTicks);
822+
stats.CpuUs = RelaxedLoad(&SharedStats[poolId].CpuUs);
823+
stats.NotEnoughCpuExecutions = RelaxedLoad(&SharedStats[poolId].NotEnoughCpuExecutions);
824+
}
825+
826+
814827
TGenericExecutorThreadCtx::~TGenericExecutorThreadCtx()
815828
{}
816829
}

ydb/library/actors/core/executor_thread.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ namespace NActors {
7171
void GetCurrentStats(TExecutorThreadStats& statsCopy);
7272
void GetSharedStats(i16 poolId, TExecutorThreadStats &stats);
7373

74+
void GetCurrentStatsForHarmonizer(TExecutorThreadStats& statsCopy);
75+
void GetSharedStatsForHarmonizer(i16 poolId, TExecutorThreadStats &stats);
76+
7477
TThreadId GetThreadId() const; // blocks, must be called after Start()
7578
TWorkerId GetWorkerId() const;
7679

ydb/library/actors/core/harmonizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ TCpuConsumption TPoolInfo::PullStats(ui64 ts) {
295295
}
296296
TVector<TExecutorThreadStats> sharedStats;
297297
if (Shared) {
298-
Shared->GetSharedStats(Pool->PoolId, sharedStats);
298+
Shared->GetSharedStatsForHarmonizer(Pool->PoolId, sharedStats);
299299
}
300300

301301
for (ui32 sharedIdx = 0; sharedIdx < SharedInfo.size(); ++sharedIdx) {

0 commit comments

Comments
 (0)