Skip to content
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

[GCS]Add gcs resource scheduler #13072

Merged
merged 32 commits into from
Jan 14, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add part code
  • Loading branch information
灵洵 committed Dec 28, 2020
commit 7dd33b9548971cb0682a0d60ff1859d3cba31bf9
24 changes: 15 additions & 9 deletions src/ray/gcs/gcs_server/gcs_resource_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ void GcsResourceScheduler::StrictSpreadSchedule(

// There are nodes to meet the scheduling requirements.
if (!node_scores.empty() && node_scores.front().second > 0) {
const auto &highest_score_node = node_scores.front().first;
result->push_back(highest_score_node);
candidate_nodes_copy.erase(highest_score_node);
const auto &highest_score_node_id = node_scores.front().first;
result->push_back(highest_score_node_id);
candidate_nodes_copy.erase(highest_score_node_id);
} else {
// There is no node to meet the scheduling requirements.
break;
Expand All @@ -150,16 +150,18 @@ void GcsResourceScheduler::SpreadSchedule(

// There are nodes to meet the scheduling requirements.
if (!node_scores.empty() && node_scores.front().second > 0) {
const auto &highest_score_node = node_scores.front().first;
result->push_back(highest_score_node);
candidate_nodes_copy.erase(highest_score_node);
selected_nodes.insert(highest_score_node);
const auto &highest_score_node_id = node_scores.front().first;
result->push_back(highest_score_node_id);
RAY_CHECK(gcs_resource_manager_.AcquireResources(highest_score_node_id, iter));
candidate_nodes_copy.erase(highest_score_node_id);
selected_nodes.insert(highest_score_node_id);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

// Scheduling from selected nodes.
const auto &node_scores = ScoreNodes(iter, candidate_nodes_copy);
if (!node_scores.empty() && node_scores.front().second > 0) {
const auto &highest_score_node = node_scores.front().first;
result->push_back(highest_score_node);
const auto &highest_score_node_id = node_scores.front().first;
result->push_back(highest_score_node_id);
RAY_CHECK(gcs_resource_manager_.AcquireResources(highest_score_node_id, iter));
} else {
break;
}
Expand All @@ -169,6 +171,10 @@ void GcsResourceScheduler::SpreadSchedule(
if (result->size() != required_resources_list.size()) {
// Unable to meet the resources required for scheduling, scheduling failed.
result->clear();
} else {
// Scheduling succeeded, releasing the resources temporarily deducted from
// `gcs_resource_manager_`.
ReleaseTemporarilyDeductedResources(required_resources_list, *result);
}
}

Expand Down