Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions ydb/core/kqp/compute_actor/kqp_compute_actor_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ struct TMemoryQuotaManager : public NYql::NDq::TGuaranteeQuotaManager {
, std::shared_ptr<IKqpNodeState> state
, TIntrusivePtr<NRm::TTxState> tx
, TIntrusivePtr<NRm::TTaskState> task
, ui64 limit
, ui64 reasonableSpillingTreshold)
, ui64 limit)
: NYql::NDq::TGuaranteeQuotaManager(limit, limit)
, ResourceManager(std::move(resourceManager))
, MemoryPool(memoryPool)
, State(std::move(state))
, Tx(std::move(tx))
, Task(std::move(task))
, ReasonableSpillingTreshold(reasonableSpillingTreshold)
{
}

Expand Down Expand Up @@ -57,7 +55,7 @@ struct TMemoryQuotaManager : public NYql::NDq::TGuaranteeQuotaManager {
}

bool IsReasonableToUseSpilling() const override {
return Tx->GetExtraMemoryAllocatedSize() >= ReasonableSpillingTreshold;
return Task->IsReasonableToStartSpilling();
}

TString MemoryConsumptionDetails() const override {
Expand Down Expand Up @@ -88,7 +86,6 @@ class TKqpCaFactory : public IKqpNodeComputeActorFactory {
std::atomic<ui64> MkqlLightProgramMemoryLimit = 0;
std::atomic<ui64> MkqlHeavyProgramMemoryLimit = 0;
std::atomic<ui64> MinChannelBufferSize = 0;
std::atomic<ui64> ReasonableSpillingTreshold = 0;

public:
TKqpCaFactory(const NKikimrConfig::TTableServiceConfig::TResourceManager& config,
Expand All @@ -107,7 +104,6 @@ class TKqpCaFactory : public IKqpNodeComputeActorFactory {
MkqlLightProgramMemoryLimit.store(config.GetMkqlLightProgramMemoryLimit());
MkqlHeavyProgramMemoryLimit.store(config.GetMkqlHeavyProgramMemoryLimit());
MinChannelBufferSize.store(config.GetMinChannelBufferSize());
ReasonableSpillingTreshold.store(config.GetReasonableSpillingTreshold());
}

TActorStartResult CreateKqpComputeActor(TCreateArgs&& args) override {
Expand Down Expand Up @@ -158,8 +154,7 @@ class TKqpCaFactory : public IKqpNodeComputeActorFactory {
std::move(args.State),
std::move(args.TxInfo),
std::move(task),
limit,
ReasonableSpillingTreshold.load());
limit);

auto runtimeSettings = args.RuntimeSettings;
runtimeSettings.ExtraMemoryAllocationPool = args.MemoryPool;
Expand Down
1 change: 1 addition & 0 deletions ydb/core/kqp/compute_actor/kqp_compute_actor_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct IKqpNodeComputeActorFactory {
const TInstant& Deadline;
const bool ShareMailbox;
const TMaybe<NYql::NDqProto::TRlPath>& RlPath;

TComputeStagesWithScan* ComputesByStages = nullptr;
std::shared_ptr<IKqpNodeState> State = nullptr;
TComputeActorSchedulingOptions SchedulingOptions = {};
Expand Down
6 changes: 4 additions & 2 deletions ydb/core/kqp/executer_actor/kqp_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ std::unique_ptr<TEvKqpNode::TEvStartKqpTasksRequest> TKqpPlanner::SerializeReque
}

request.SetSchedulerGroup(UserRequestContext->PoolId);
request.SetMemoryPoolPercent(UserRequestContext->PoolConfig->QueryMemoryLimitPercentPerNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В этом месте может быть UserRequestContext->PoolConfig = std::nullopt, лучше добавить на это проверку


return result;
}
Expand Down Expand Up @@ -351,7 +352,8 @@ TString TKqpPlanner::ExecuteDataComputeTask(ui64 taskId, ui32 computeTasksSize)
NYql::NDq::TComputeRuntimeSettings settings;
if (!TxInfo) {
TxInfo = MakeIntrusive<NRm::TTxState>(
TxId, TInstant::Now(), ResourceManager_->GetCounters());
TxId, TInstant::Now(), ResourceManager_->GetCounters(),
UserRequestContext->PoolId, UserRequestContext->PoolConfig->QueryMemoryLimitPercentPerNode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут тоже стоит проверить UserRequestContext->PoolConfig = std::nullopt

}

auto startResult = CaFactory_->CreateKqpComputeActor({
Expand All @@ -370,7 +372,7 @@ TString TKqpPlanner::ExecuteDataComputeTask(ui64 taskId, ui32 computeTasksSize)
.StatsMode = GetDqStatsMode(StatsMode),
.Deadline = Deadline,
.ShareMailbox = (computeTasksSize <= 1),
.RlPath = Nothing()
.RlPath = Nothing(),
});

if (const auto* rmResult = std::get_if<NRm::TKqpRMAllocateResult>(&startResult)) {
Expand Down
5 changes: 3 additions & 2 deletions ydb/core/kqp/node_service/kqp_node_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ class TKqpNodeService : public TActorBootstrapped<TKqpNodeService> {
}

TIntrusivePtr<NRm::TTxState> txInfo = MakeIntrusive<NRm::TTxState>(
txId, TInstant::Now(), ResourceManager_->GetCounters());
txId, TInstant::Now(), ResourceManager_->GetCounters(),
msg.GetSchedulerGroup(), msg.GetMemoryPoolPercent());

const ui32 tasksCount = msg.GetTasks().size();
for (auto& dqTask: *msg.MutableTasks()) {
Expand Down Expand Up @@ -246,7 +247,7 @@ class TKqpNodeService : public TActorBootstrapped<TKqpNodeService> {
.RlPath = rlPath,
.ComputesByStages = &computesByStage,
.State = State_,
.SchedulingOptions = std::move(schedulingOptions)
.SchedulingOptions = std::move(schedulingOptions),
});

if (const auto* rmResult = std::get_if<NRm::TKqpRMAllocateResult>(&result)) {
Expand Down
Loading