@@ -13,13 +13,15 @@ struct TMemoryQuotaManager : public NYql::NDq::TGuaranteeQuotaManager {
13
13
, std::shared_ptr<IKqpNodeState> state
14
14
, ui64 txId
15
15
, ui64 taskId
16
- , ui64 limit)
16
+ , ui64 limit
17
+ , ui64 reasonableSpillingTreshold)
17
18
: NYql::NDq::TGuaranteeQuotaManager(limit, limit)
18
19
, ResourceManager(std::move(resourceManager))
19
20
, MemoryPool(memoryPool)
20
21
, State(std::move(state))
21
22
, TxId(txId)
22
23
, TaskId(taskId)
24
+ , ReasonableSpillingTreshold(reasonableSpillingTreshold)
23
25
{
24
26
}
25
27
@@ -42,6 +44,8 @@ struct TMemoryQuotaManager : public NYql::NDq::TGuaranteeQuotaManager {
42
44
return false ;
43
45
}
44
46
47
+ TotalQueryAllocationsSize = result.TotalAllocatedQueryMemory ;
48
+
45
49
return true ;
46
50
}
47
51
@@ -51,6 +55,10 @@ struct TMemoryQuotaManager : public NYql::NDq::TGuaranteeQuotaManager {
51
55
);
52
56
}
53
57
58
+ bool IsReasonableToUseSpilling () const override {
59
+ return TotalQueryAllocationsSize >= ReasonableSpillingTreshold;
60
+ }
61
+
54
62
void TerminateHandler (bool success, const NYql::TIssues& issues) {
55
63
AFL_DEBUG (NKikimrServices::KQP_COMPUTE)
56
64
(" problem" , " finish_compute_actor" )
@@ -64,6 +72,8 @@ struct TMemoryQuotaManager : public NYql::NDq::TGuaranteeQuotaManager {
64
72
ui64 TxId;
65
73
ui64 TaskId;
66
74
bool Success = true ;
75
+ ui64 TotalQueryAllocationsSize = 0 ;
76
+ ui64 ReasonableSpillingTreshold = 0 ;
67
77
};
68
78
69
79
class TKqpCaFactory : public IKqpNodeComputeActorFactory {
@@ -123,7 +133,8 @@ class TKqpCaFactory : public IKqpNodeComputeActorFactory {
123
133
std::move (state),
124
134
txId,
125
135
dqTask->GetId (),
126
- limit);
136
+ limit,
137
+ Config.GetReasonableSpillingTreshold ());
127
138
128
139
auto runtimeSettings = settings;
129
140
NYql::NDq::IMemoryQuotaManager::TWeakPtr memoryQuotaManager = memoryLimits.MemoryQuotaManager ;
0 commit comments