From e3a0a61c053bd679de9b06f9e0ea3ab54a6f541a Mon Sep 17 00:00:00 2001 From: Filitov Mikhail Date: Tue, 14 May 2024 14:17:41 +0200 Subject: [PATCH] YQL-17175 added maximum memory limit reached flag (#4480) --- ydb/library/yql/minikql/aligned_page_pool.cpp | 2 +- ydb/library/yql/minikql/aligned_page_pool.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ydb/library/yql/minikql/aligned_page_pool.cpp b/ydb/library/yql/minikql/aligned_page_pool.cpp index 0ff6519f112a..3b489fcbd27b 100644 --- a/ydb/library/yql/minikql/aligned_page_pool.cpp +++ b/ydb/library/yql/minikql/aligned_page_pool.cpp @@ -503,8 +503,8 @@ void TAlignedPagePoolImpl::Free(void* ptr, size_t size) noexcept { template void TAlignedPagePoolImpl::UpdateMemoryYellowZone() { - if (IncreaseMemoryLimitCallback) return; if (Limit == 0) return; + if (IncreaseMemoryLimitCallback && !IsMaximumLimitValueReached) return; ui8 usedMemoryPercent = 100 * GetUsed() / Limit; if (usedMemoryPercent >= EnableMemoryYellowZoneThreshold) { diff --git a/ydb/library/yql/minikql/aligned_page_pool.h b/ydb/library/yql/minikql/aligned_page_pool.h index d7bb5f088008..1921df08857d 100644 --- a/ydb/library/yql/minikql/aligned_page_pool.h +++ b/ydb/library/yql/minikql/aligned_page_pool.h @@ -214,12 +214,8 @@ class TAlignedPagePoolImpl { static void ResetGlobalsUT(); - void EnableMemoryYellowZone() noexcept { - IsMemoryYellowZoneReached = true; - } - - void DisableMemoryYellowZone() noexcept { - IsMemoryYellowZoneReached = false; + void SetMaximumLimitValueReached(bool isReached) noexcept { + IsMaximumLimitValueReached = isReached; } bool IsMemoryYellowZoneEnabled() const noexcept { @@ -277,6 +273,10 @@ class TAlignedPagePoolImpl { // The yellow zone turns on when memory consumption reaches 80% and turns off when consumption drops below 50%. const ui8 EnableMemoryYellowZoneThreshold = 80; const ui8 DisableMemoryYellowZoneThreshold = 50; + + // This flag indicates that value of memory limit reached it's maximum. + // Next TryIncreaseLimit call most likely will return false. + bool IsMaximumLimitValueReached = false; }; using TAlignedPagePool = TAlignedPagePoolImpl<>;