@@ -109,7 +109,6 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> {
109
109
ui64 UserPoolUsage = 0 ; // (usage uS x threads) / sec
110
110
ui64 MemUsage = 0 ;
111
111
ui64 MemLimit = 0 ;
112
- ui64 CpuLimit = 0 ; // PotentialMaxThreadCount of UserPool
113
112
double NodeUsage = 0 ;
114
113
115
114
bool SentDrainNode = false ;
@@ -273,28 +272,28 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> {
273
272
HandlePipeDestroyed (ctx);
274
273
}
275
274
276
- void FillResourceMaximum (NKikimrTabletBase::TMetrics* record) {
277
- record->CopyFrom (ResourceLimit);
278
- if (!record->HasCPU ()) {
279
- if (CpuLimit != 0 ) {
280
- record->SetCPU (CpuLimit);
275
+ void SendStatusOk (const TActorContext &ctx) {
276
+ LOG_DEBUG_S (ctx, NKikimrServices::LOCAL, " TLocalNodeRegistrar SendStatusOk" );
277
+ TAutoPtr<TEvLocal::TEvStatus> eventStatus = new TEvLocal::TEvStatus (TEvLocal::TEvStatus::StatusOk);
278
+ auto & record = eventStatus->Record ;
279
+ record.SetStartTime (StartTime.GetValue ());
280
+ record.MutableResourceMaximum ()->CopyFrom (ResourceLimit);
281
+ if (!record.GetResourceMaximum ().HasCPU ()) {
282
+ TExecutorPoolStats poolStats;
283
+ TVector<TExecutorThreadStats> statsCopy;
284
+ TVector<TExecutorThreadStats> sharedStatsCopy;
285
+ ctx.ExecutorThread .ActorSystem ->GetPoolStats (AppData ()->UserPoolId , poolStats, statsCopy, sharedStatsCopy);
286
+ if (!statsCopy.empty ()) {
287
+ record.MutableResourceMaximum ()->SetCPU (poolStats.CurrentThreadCount * 1000000 );
281
288
}
282
289
}
283
- if (!record-> HasMemory ()) {
290
+ if (!record. GetResourceMaximum (). HasMemory ()) {
284
291
if (MemLimit != 0 ) {
285
- record->SetMemory (MemLimit);
292
+ record. MutableResourceMaximum () ->SetMemory (MemLimit);
286
293
} else {
287
- record->SetMemory (NSystemInfo::TotalMemorySize ());
294
+ record. MutableResourceMaximum () ->SetMemory (NSystemInfo::TotalMemorySize ());
288
295
}
289
296
}
290
- }
291
-
292
- void SendStatusOk (const TActorContext &ctx) {
293
- LOG_DEBUG_S (ctx, NKikimrServices::LOCAL, " TLocalNodeRegistrar SendStatusOk" );
294
- TAutoPtr<TEvLocal::TEvStatus> eventStatus = new TEvLocal::TEvStatus (TEvLocal::TEvStatus::StatusOk);
295
- auto & record = eventStatus->Record ;
296
- record.SetStartTime (StartTime.GetValue ());
297
- FillResourceMaximum (record.MutableResourceMaximum ());
298
297
NTabletPipe::SendData (ctx, HivePipeClient, eventStatus.Release ());
299
298
}
300
299
@@ -588,7 +587,6 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> {
588
587
record.MutableTotalResourceUsage ()->SetMemory (MemUsage);
589
588
}
590
589
record.SetTotalNodeUsage (NodeUsage);
591
- FillResourceMaximum (record.MutableResourceMaximum ());
592
590
NTabletPipe::SendData (ctx, HivePipeClient, event.Release ());
593
591
SendTabletMetricsTime = ctx.Now ();
594
592
} else {
@@ -651,8 +649,7 @@ class TLocalNodeRegistrar : public TActorBootstrapped<TLocalNodeRegistrar> {
651
649
const NKikimrWhiteboard::TSystemStateInfo& info = record.GetSystemStateInfo (0 );
652
650
if (static_cast <ui32>(info.PoolStatsSize ()) > AppData ()->UserPoolId ) {
653
651
const auto & poolStats (info.GetPoolStats (AppData ()->UserPoolId ));
654
- CpuLimit = poolStats.limit () * 1'000'000 ; // microseconds
655
- UserPoolUsage = poolStats.usage () * CpuLimit; // microseconds
652
+ UserPoolUsage = poolStats.usage () * poolStats.threads () * 1000000 ; // uS
656
653
}
657
654
658
655
// Note: we use allocated memory because MemoryUsed(AnonRSS) has lag
0 commit comments