-
Notifications
You must be signed in to change notification settings - Fork 695
YQ supported override nodes placement #19787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
GrigoriyPA
wants to merge
5
commits into
ydb-platform:main
from
GrigoriyPA:YQ-4319-support-override-nodes-placement
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1023,6 +1023,27 @@ class TKqpExecuterBase : public TActor<TDerived> { | |
} | ||
} | ||
|
||
std::function<ui32(ui32 taskIdx)> GetStageNodesHint(const NKqpProto::TKqpPhyStage& stage, const TVector<NKikimrKqp::TKqpNodeResources>& resourceSnapshot) { | ||
const auto& nodesHint = stage.GetTasksNodes(); | ||
if (nodesHint.empty()) { | ||
return nullptr; | ||
} | ||
|
||
std::unordered_set<ui32> availableNodes; | ||
availableNodes.reserve(resourceSnapshot.size()); | ||
for (const auto& nodeResource : resourceSnapshot) { | ||
availableNodes.emplace(nodeResource.GetNodeId()); | ||
} | ||
|
||
for (const auto nodeId : nodesHint) { | ||
YQL_ENSURE(availableNodes.contains(nodeId), "Invalid node id " << nodeId << " in stage override, available nodes: " << JoinSeq(", ", availableNodes)); | ||
GrigoriyPA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return [nodesHint](ui32 taskIdx) { | ||
return nodesHint[taskIdx % nodesHint.size()]; | ||
}; | ||
} | ||
|
||
void BuildReadTasksFromSource(TStageInfo& stageInfo, const TVector<NKikimrKqp::TKqpNodeResources>& resourceSnapshot, ui32 scheduledTaskCount) { | ||
const auto& stage = stageInfo.Meta.GetStage(stageInfo.Id); | ||
|
||
|
@@ -1056,12 +1077,18 @@ class TKqpExecuterBase : public TActor<TDerived> { | |
structuredToken = NYql::CreateStructuredTokenParser(externalSource.GetAuthInfo()).ToBuilder().ReplaceReferences(SecureParams).ToJson(); | ||
} | ||
|
||
ui64 selfNodeIdx = 0; | ||
for (size_t i = 0; i < resourceSnapshot.size(); ++i) { | ||
if (resourceSnapshot[i].GetNodeId() == SelfId().NodeId()) { | ||
selfNodeIdx = i; | ||
break; | ||
auto nodesPlanner = GetStageNodesHint(stage, resourceSnapshot); | ||
if (!nodesPlanner && !resourceSnapshot.empty()) { | ||
ui64 selfNodeIdx = 0; | ||
for (size_t i = 0; i < resourceSnapshot.size(); ++i) { | ||
if (resourceSnapshot[i].GetNodeId() == SelfId().NodeId()) { | ||
selfNodeIdx = i; | ||
break; | ||
} | ||
} | ||
nodesPlanner = [&resourceSnapshot, selfNodeIdx](ui32 taskIdx) { | ||
return resourceSnapshot[(selfNodeIdx + taskIdx) % resourceSnapshot.size()].GetNodeId(); | ||
}; | ||
} | ||
|
||
TVector<ui64> tasksIds; | ||
|
@@ -1082,10 +1109,10 @@ class TKqpExecuterBase : public TActor<TDerived> { | |
} | ||
FillSecureParamsFromStage(task.Meta.SecureParams, stage); | ||
|
||
if (resourceSnapshot.empty()) { | ||
if (!nodesPlanner) { | ||
task.Meta.Type = TTaskMeta::TTaskType::Compute; | ||
} else { | ||
task.Meta.NodeId = resourceSnapshot[(selfNodeIdx + i) % resourceSnapshot.size()].GetNodeId(); | ||
task.Meta.NodeId = nodesPlanner(i); | ||
task.Meta.Type = TTaskMeta::TTaskType::Scan; | ||
} | ||
|
||
|
@@ -1413,7 +1440,7 @@ class TKqpExecuterBase : public TActor<TDerived> { | |
} | ||
} | ||
|
||
void BuildComputeTasks(TStageInfo& stageInfo, const ui32 nodesCount) { | ||
void BuildComputeTasks(TStageInfo& stageInfo, const ui32 nodesCount, const TVector<NKikimrKqp::TKqpNodeResources>& resourceSnapshot) { | ||
auto& stage = stageInfo.Meta.GetStage(stageInfo.Id); | ||
|
||
ui32 partitionsCount = 1; | ||
|
@@ -1478,9 +1505,15 @@ class TKqpExecuterBase : public TActor<TDerived> { | |
} | ||
} | ||
|
||
auto nodesPlanner = GetStageNodesHint(stage, resourceSnapshot); | ||
for (ui32 i = 0; i < partitionsCount; ++i) { | ||
auto& task = TasksGraph.AddTask(stageInfo); | ||
task.Meta.Type = TTaskMeta::TTaskType::Compute; | ||
if (!nodesPlanner) { | ||
task.Meta.Type = TTaskMeta::TTaskType::Compute; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. что тут происходит, зачем это? |
||
} else { | ||
task.Meta.NodeId = nodesPlanner(i); | ||
task.Meta.Type = TTaskMeta::TTaskType::Scan; | ||
} | ||
task.Meta.ExecuterId = SelfId(); | ||
FillSecureParamsFromStage(task.Meta.SecureParams, stage); | ||
BuildSinks(stage, stageInfo, task); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем аж std::function ? можно проще?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я предлагаю подумать и отказаться от этой идеи как таковой, а решать задачу в какой то другой парадигме. например если задача резделения нагрузки то запрещать использовать какие-то ноды.
назначать сотни тасок по нодам не имеет примерно никакого юзкейса