File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 11
22#pragma once
33
4+ #include < util/system/mem_info.h>
45#include < ydb/library/services/services.pb.h>
56#include < ydb/library/yql/dq/actors/compute/dq_compute_actor.h>
67#include < ydb/library/yql/minikql/mkql_alloc.h>
@@ -55,6 +56,18 @@ namespace NYql::NDq {
5556 }
5657 }
5758
59+ void TrySetIncreaseMemoryLimitCallbackWithRSSControl (NKikimr::NMiniKQL::TScopedAlloc* alloc) {
60+ if (CanAllocateExtraMemory) {
61+ alloc->Ref ().SetIncreaseMemoryLimitCallback ([this , alloc](ui64 limit, ui64 required) {
62+ RequestExtraMemory (required - limit, alloc);
63+ auto currentRSS = NMemInfo::GetMemInfo ().RSS ;
64+ if (currentRSS > 10_GB) {
65+ alloc->SetMaximumLimitValueReached (true );
66+ }
67+ });
68+ }
69+ }
70+
5871 void TryShrinkMemory (NKikimr::NMiniKQL::TScopedAlloc* alloc) {
5972 if (alloc->GetAllocated () - alloc->GetUsed () > MemoryLimits.MinMemFreeSize ) {
6073 alloc->ReleaseFreePages ();
@@ -113,6 +126,7 @@ namespace NYql::NDq {
113126
114127 private:
115128 void RequestExtraMemory (ui64 memory, NKikimr::NMiniKQL::TScopedAlloc* alloc) {
129+ alloc->GetAllocated ();
116130 memory = std::max (AlignMemorySizeToMbBoundary (memory), MemoryLimits.MinMemAllocSize );
117131
118132 if (MemoryLimits.MkqlProgramHardMemoryLimit && MkqlMemoryLimit + memory > MemoryLimits.MkqlProgramHardMemoryLimit ) {
Original file line number Diff line number Diff line change @@ -423,7 +423,11 @@ class TLocalTaskRunnerActor
423423
424424 auto guard = TaskRunner->BindAllocator (MemoryQuota ? TMaybe<ui64>(MemoryQuota->GetMkqlMemoryLimit ()) : Nothing ());
425425 if (MemoryQuota) {
426- MemoryQuota->TrySetIncreaseMemoryLimitCallback (guard.GetMutex ());
426+ if (settings.GetEnableSpilling ()) {
427+ MemoryQuota->TrySetIncreaseMemoryLimitCallbackWithRSSControl (guard.GetMutex ());
428+ } else {
429+ MemoryQuota->TrySetIncreaseMemoryLimitCallback (guard.GetMutex ());
430+ }
427431 }
428432
429433 TaskRunner->Prepare (settings, ev->Get ()->MemoryLimits , *ev->Get ()->ExecCtx );
Original file line number Diff line number Diff line change @@ -213,6 +213,10 @@ class TScopedAlloc {
213213 Release ();
214214 }
215215
216+ void SetMaximumLimitValueReached (bool IsReached) {
217+ MyState_.SetMaximumLimitValueReached (IsReached);
218+ }
219+
216220private:
217221 const bool InitiallyAcquired_;
218222 TAllocState MyState_;
You can’t perform that action at this time.
0 commit comments