Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve harmonizer on pulling stats #5170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/library/actors/core/executor_pool_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ namespace NActors {
}
TExecutorThreadCtx& threadCtx = Threads[threadIdx];
TExecutorThreadStats stats;
threadCtx.Thread->GetCurrentStats(stats);
threadCtx.Thread->GetCurrentStatsForHarmonizer(stats);
return {Ts2Us(stats.SafeElapsedTicks), static_cast<double>(stats.CpuUs), stats.NotEnoughCpuExecutions};
}

Expand Down
9 changes: 8 additions & 1 deletion ydb/library/actors/core/executor_pool_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,19 @@ void TSharedExecutorPool::GetSharedStats(i16 poolId, std::vector<TExecutorThread
}
}

void TSharedExecutorPool::GetSharedStatsForHarmonizer(i16 poolId, std::vector<TExecutorThreadStats>& statsCopy) {
statsCopy.resize(SharedThreadCount + 1);
for (i16 i = 0; i < SharedThreadCount; ++i) {
Threads[i].Thread->GetSharedStatsForHarmonizer(poolId, statsCopy[i + 1]);
}
}

TCpuConsumption TSharedExecutorPool::GetThreadCpuConsumption(i16 poolId, i16 threadIdx) {
if (threadIdx >= SharedThreadCount) {
return {0.0, 0.0};
}
TExecutorThreadStats stats;
Threads[threadIdx].Thread->GetSharedStats(poolId, stats);
Threads[threadIdx].Thread->GetSharedStatsForHarmonizer(poolId, stats);
return {Ts2Us(stats.SafeElapsedTicks), static_cast<double>(stats.CpuUs), stats.NotEnoughCpuExecutions};
}

Expand Down
1 change: 1 addition & 0 deletions ydb/library/actors/core/executor_pool_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace NActors {

TSharedExecutorThreadCtx *GetSharedThread(i16 poolId);
void GetSharedStats(i16 pool, std::vector<TExecutorThreadStats>& statsCopy);
void GetSharedStatsForHarmonizer(i16 pool, std::vector<TExecutorThreadStats>& statsCopy);
TCpuConsumption GetThreadCpuConsumption(i16 poolId, i16 threadIdx);
std::vector<TCpuConsumption> GetThreadsCpuConsumption(i16 poolId);

Expand Down
13 changes: 13 additions & 0 deletions ydb/library/actors/core/executor_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,19 @@ namespace NActors {
statsCopy.Aggregate(SharedStats[poolId]);
}

void TGenericExecutorThread::GetCurrentStatsForHarmonizer(TExecutorThreadStats& statsCopy) {
statsCopy.SafeElapsedTicks = RelaxedLoad(&Ctx.Stats->SafeElapsedTicks);
statsCopy.CpuUs = RelaxedLoad(&Ctx.Stats->CpuUs);
statsCopy.NotEnoughCpuExecutions = RelaxedLoad(&Ctx.Stats->NotEnoughCpuExecutions);
}

void TGenericExecutorThread::GetSharedStatsForHarmonizer(i16 poolId, TExecutorThreadStats &stats) {
stats.SafeElapsedTicks = RelaxedLoad(&SharedStats[poolId].SafeElapsedTicks);
stats.CpuUs = RelaxedLoad(&SharedStats[poolId].CpuUs);
stats.NotEnoughCpuExecutions = RelaxedLoad(&SharedStats[poolId].NotEnoughCpuExecutions);
}


TGenericExecutorThreadCtx::~TGenericExecutorThreadCtx()
{}
}
3 changes: 3 additions & 0 deletions ydb/library/actors/core/executor_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ namespace NActors {
void GetCurrentStats(TExecutorThreadStats& statsCopy);
void GetSharedStats(i16 poolId, TExecutorThreadStats &stats);

void GetCurrentStatsForHarmonizer(TExecutorThreadStats& statsCopy);
void GetSharedStatsForHarmonizer(i16 poolId, TExecutorThreadStats &stats);

TThreadId GetThreadId() const; // blocks, must be called after Start()
TWorkerId GetWorkerId() const;

Expand Down
2 changes: 1 addition & 1 deletion ydb/library/actors/core/harmonizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ TCpuConsumption TPoolInfo::PullStats(ui64 ts) {
}
TVector<TExecutorThreadStats> sharedStats;
if (Shared) {
Shared->GetSharedStats(Pool->PoolId, sharedStats);
Shared->GetSharedStatsForHarmonizer(Pool->PoolId, sharedStats);
}

for (ui32 sharedIdx = 0; sharedIdx < SharedInfo.size(); ++sharedIdx) {
Expand Down
Loading