Skip to content

Commit e8fc786

Browse files
committed
add alloc yellow zone notification
1 parent 88c1914 commit e8fc786

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

ydb/library/yql/dq/actors/compute/dq_compute_memory_quota.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,29 @@ namespace NYql::NDq {
7373
});
7474
}
7575

76-
bool AllocateQuota(ui64 bytes) {
77-
return MemoryLimits.MemoryQuotaManager->AllocateQuota(bytes);
76+
bool AllocateQuota(ui64 bytes, NKikimr::NMiniKQL::TScopedAlloc* alloc) {
77+
if (!MkqlMemoryLimit) {
78+
return true;
79+
}
80+
bool allocated = MemoryLimits.MemoryQuotaManager->AllocateQuota(bytes);
81+
if (MemoryLimits.MemoryQuotaManager->IsReasonableToUseSpilling()) {
82+
alloc->SetMaximumLimitValueReached(true);
83+
} else {
84+
alloc->SetMaximumLimitValueReached(false);
85+
}
86+
return allocated;
7887
}
7988

80-
void FreeQuota(ui64 bytes) {
89+
void FreeQuota(ui64 bytes, NKikimr::NMiniKQL::TScopedAlloc* alloc) {
90+
if (!MkqlMemoryLimit) {
91+
return;
92+
}
8193
MemoryLimits.MemoryQuotaManager->FreeQuota(bytes);
94+
if (MemoryLimits.MemoryQuotaManager->IsReasonableToUseSpilling()) {
95+
alloc->SetMaximumLimitValueReached(true);
96+
} else {
97+
alloc->SetMaximumLimitValueReached(false);
98+
}
8299
}
83100

84101
void TryShrinkMemory(NKikimr::NMiniKQL::TScopedAlloc* alloc) {

ydb/library/yql/dq/actors/compute/dq_sync_compute_actor_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ class TDqSyncComputeActorBase: public TDqComputeActorBase<TDerived, TComputeActo
236236
if (this->Task.GetEnableSpilling()) {
237237
TaskRunner->SetSpillerFactory(std::make_shared<TDqSpillerFactory>(execCtx.GetTxId(), NActors::TActivationContext::ActorSystem(), execCtx.GetWakeupCallback(), execCtx.GetErrorCallback()));
238238
TaskRunner->SetMemoryUsageReporter(std::make_shared<NKikimr::NMiniKQL::TMemoryUsageReporter>(
239-
[this](ui64 bytes){ return this->MemoryQuota->AllocateQuota(bytes); },
240-
[this](ui64 bytes){ this->MemoryQuota->FreeQuota(bytes); }
239+
[this, alloc](ui64 bytes){ return this->MemoryQuota->AllocateQuota(bytes, alloc); },
240+
[this, alloc](ui64 bytes){ this->MemoryQuota->FreeQuota(bytes, alloc); }
241241
));
242242
}
243243

yql/essentials/minikql/computation/mkql_memory_usage_reporter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class TMemoryUsageReporter {
3939
// Cerr << "[MISHA][DESTR]: " << "Total: " << BytesAllocated_ << Endl;
4040
if (BytesAllocated_) {
4141
// WHY??
42-
Cerr << std::format("[MISHA] Bytes not freed: {}\n", BytesAllocated_);
4342
ReportFreeCallback_(BytesAllocated_);
4443
}
44+
Cerr << std::format("[MISHA] Bytes not freed: {}\n", BytesAllocated_);
4545
// Y_ENSURE(BytesAllocated_ == 0, "Memory leak");
4646
}
4747

0 commit comments

Comments
 (0)