@@ -424,7 +424,7 @@ Y_FORCE_INLINE bool IsStarved(double consumed, double booked) {
424
424
}
425
425
426
426
Y_FORCE_INLINE bool IsHoggish (double booked, double currentThreadCount) {
427
- return booked < currentThreadCount - 1 ;
427
+ return booked < currentThreadCount - 0.5 ;
428
428
}
429
429
430
430
void THarmonizer::HarmonizeImpl (ui64 ts) {
@@ -435,7 +435,7 @@ void THarmonizer::HarmonizeImpl(ui64 ts) {
435
435
i64 beingStopped = 0 ;
436
436
double total = 0 ;
437
437
TStackVec<size_t , 8 > needyPools;
438
- TStackVec<size_t , 8 > hoggishPools;
438
+ TStackVec<std::pair< size_t , double > , 8 > hoggishPools;
439
439
TStackVec<bool , 8 > isNeedyByPool;
440
440
441
441
size_t sumOfAdditionalThreads = 0 ;
@@ -577,7 +577,7 @@ void THarmonizer::HarmonizeImpl(ui64 ts) {
577
577
bool isHoggish = IsHoggish (poolBooked, currentThreadCount)
578
578
|| IsHoggish (lastSecondPoolBooked, currentThreadCount);
579
579
if (isHoggish) {
580
- hoggishPools.push_back (poolIdx);
580
+ hoggishPools.push_back ({ poolIdx, std::max (poolBooked - currentThreadCount, lastSecondPoolBooked - currentThreadCount)} );
581
581
}
582
582
booked += poolBooked;
583
583
consumed += poolConsumed;
@@ -714,18 +714,19 @@ void THarmonizer::HarmonizeImpl(ui64 ts) {
714
714
}
715
715
}
716
716
717
- for (size_t hoggishPoolIdx : hoggishPools) {
717
+ for (auto &[ hoggishPoolIdx, freeCpu] : hoggishPools) {
718
718
TPoolInfo &pool = *Pools[hoggishPoolIdx];
719
719
i64 threadCount = pool.GetFullThreadCount ();
720
720
if (hasBorrowedSharedThread[hoggishPoolIdx]) {
721
721
Shared->ReturnBorrowedHalfThread (hoggishPoolIdx);
722
+ freeCpu -= 0.5 ;
722
723
continue ;
723
724
}
724
725
if (pool.BasicPool && pool.LocalQueueSize > NFeatures::TLocalQueuesFeatureFlags::MIN_LOCAL_QUEUE_SIZE) {
725
726
pool.LocalQueueSize = std::min<ui16>(NFeatures::TLocalQueuesFeatureFlags::MIN_LOCAL_QUEUE_SIZE, pool.LocalQueueSize / 2 );
726
727
pool.BasicPool ->SetLocalQueueSize (pool.LocalQueueSize );
727
728
}
728
- if (threadCount > pool.MinFullThreadCount ) {
729
+ if (threadCount > pool.MinFullThreadCount && freeCpu >= 1 ) {
729
730
AtomicIncrement (pool.DecreasingThreadsByHoggishState );
730
731
LWPROBE (HarmonizeOperation, hoggishPoolIdx, pool.Pool ->GetName (), " decrease by hoggish" , threadCount - 1 , pool.DefaultFullThreadCount , pool.MaxFullThreadCount );
731
732
pool.SetFullThreadCount (threadCount - 1 );
0 commit comments