Skip to content

Commit

Permalink
relax local compute tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
gridnevvvit committed May 3, 2024
1 parent eebd1ab commit cb8cfb3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ydb/core/kqp/executer_actor/kqp_data_executer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2408,7 +2408,7 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da

const bool singlePartitionOptAllowed = !HasOlapTable && !UnknownAffectedShardCount && !HasExternalSources && DatashardTxs.empty() && EvWriteTxs.empty();
const bool useDataQueryPool = !(HasExternalSources && DatashardTxs.empty() && EvWriteTxs.empty());
const bool localComputeTasks = !((HasExternalSources || HasOlapTable || HasDatashardSourceScan) && DatashardTxs.empty());
const bool localComputeTasks = !DatashardTxs.empty();

Planner = CreateKqpPlanner({
.TasksGraph = TasksGraph,
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/kqp/executer_actor/kqp_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ std::unique_ptr<IEventHandle> TKqpPlanner::AssignTasksToNodes() {
return nullptr;
}

if (ResourcesSnapshot.empty()) {
ResourcesSnapshot = std::move(GetKqpResourceManager()->GetClusterResources());
}

if (ResourcesSnapshot.empty() || (ResourcesSnapshot.size() == 1 && ResourcesSnapshot[0].GetNodeId() == ExecuterId.NodeId())) {
// try to run without memory overflow settings
if (LocalRunMemoryEst <= localResources.Memory[NRm::EKqpMemoryPool::ScanQuery] &&
Expand Down Expand Up @@ -402,6 +406,8 @@ std::unique_ptr<IEventHandle> TKqpPlanner::PlanExecution() {

nComputeTasks = ComputeTasks.size();

// explicit requirement to execute task on the same node because it has dependencies
// on datashard tx.
if (LocalComputeTasks) {
bool shareMailbox = (ComputeTasks.size() <= 1);
for (ui64 taskId : ComputeTasks) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/kqp/executer_actor/kqp_planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class TKqpPlanner {
const bool WithSpilling;
const TMaybe<NKikimrKqp::TRlPath> RlPath;
THashSet<ui32> TrackingNodes;
const TVector<NKikimrKqp::TKqpNodeResources> ResourcesSnapshot;
TVector<NKikimrKqp::TKqpNodeResources> ResourcesSnapshot;
NWilson::TSpan& ExecuterSpan;
const NKikimrConfig::TTableServiceConfig::TExecuterRetriesConfig& ExecuterRetriesConfig;
ui64 LocalRunMemoryEst = 0;
Expand Down
17 changes: 17 additions & 0 deletions ydb/core/kqp/rm_service/kqp_rm_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,23 @@ class TKqpResourceManager : public IKqpResourceManager {
FireResourcesPublishing();
}

TVector<NKikimrKqp::TKqpNodeResources> GetClusterResources() const override {
TVector<NKikimrKqp::TKqpNodeResources> resources;
Y_ABORT_UNLESS(PublishResourcesByExchanger);

if (PublishResourcesByExchanger) {
std::shared_ptr<TVector<NKikimrKqp::TKqpNodeResources>> infos;
with_lock (ResourceSnapshotState->Lock) {
infos = ResourceSnapshotState->Snapshot;
}
if (infos != nullptr) {
resources = *infos;
}
}

return resources;
}

void RequestClusterResourcesInfo(TOnResourcesSnapshotCallback&& callback) override {
LOG_AS_D("Schedule Snapshot request");
if (PublishResourcesByExchanger) {
Expand Down
1 change: 1 addition & 0 deletions ydb/core/kqp/rm_service/kqp_rm_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class IKqpResourceManager : private TNonCopyable {

virtual void RequestClusterResourcesInfo(TOnResourcesSnapshotCallback&& callback) = 0;

virtual TVector<NKikimrKqp::TKqpNodeResources> GetClusterResources() const = 0;
virtual TKqpLocalNodeResources GetLocalResources() const = 0;
virtual NKikimrConfig::TTableServiceConfig::TResourceManager GetConfig() = 0;

Expand Down

0 comments on commit cb8cfb3

Please sign in to comment.