Skip to content

Commit

Permalink
Added method to enable memory yellow zone by force
Browse files Browse the repository at this point in the history
  • Loading branch information
lll-phill-lll committed Jul 18, 2024
1 parent 6302faa commit 6597a5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ydb/library/yql/minikql/aligned_page_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ void TAlignedPagePoolImpl<T>::Free(void* ptr, size_t size) noexcept {
template<typename T>
void TAlignedPagePoolImpl<T>::UpdateMemoryYellowZone() {
if (Limit == 0) return;
if (IsMemoryYellowZoneForcefullyChanged) return;
if (IncreaseMemoryLimitCallback && !IsMaximumLimitValueReached) return;

ui8 usedMemoryPercent = 100 * GetUsed() / Limit;
Expand Down
9 changes: 9 additions & 0 deletions ydb/library/yql/minikql/aligned_page_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ class TAlignedPagePoolImpl {
return IsMemoryYellowZoneReached;
}

void ForcefullySetMemoryYellowZone(bool isEnabled) noexcept {
IsMemoryYellowZoneReached = isEnabled;
IsMemoryYellowZoneForcefullyChanged = true;
}

protected:
void* Alloc(size_t size);
void Free(void* ptr, size_t size) noexcept;
Expand Down Expand Up @@ -268,6 +273,10 @@ class TAlignedPagePoolImpl {

// Indicates when memory limit is almost reached.
bool IsMemoryYellowZoneReached = false;
// Indicates that memory yellow zone was enabled or disabled forcefully.
// If the value of this variable is true, then the limits specified below will not be applied and
// changing the value can only be done manually.
bool IsMemoryYellowZoneForcefullyChanged = false;
// This theshold is used to determine is memory limit is almost reached.
// If TIncreaseMemoryLimitCallback is set this thresholds should be ignored.
// The yellow zone turns on when memory consumption reaches 80% and turns off when consumption drops below 50%.
Expand Down

0 comments on commit 6597a5d

Please sign in to comment.