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
Show file tree
Hide file tree
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 27, 2020
commit b07f369fad09324d73836ee5ba12c3d883db5494
39 changes: 28 additions & 11 deletions src/ray/gcs/gcs_server/gcs_resource_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,39 @@ std::vector<NodeID> GcsResourceScheduler::Schedule(
const auto &cluster_resources = gcs_resource_manager_.GetClusterResources();

// Filter candidate nodes.
absl::flat_hash_set<NodeID> candidate_nodes = Filter(cluster_resources, node_filter_func);
absl::flat_hash_set<NodeID> candidate_nodes =
FilterCandidateNodes(cluster_resources, node_filter_func);
if (candidate_nodes.size() < required_resources.size()) {
return {};
}

// TODO(ffbin): Filter required resources.
// First schedule scarce resources (such as GPU) and large capacity resources to improve
// the scheduling success rate.
const auto &to_schedule_resources = SortRequiredResources(required_resources);

// Scorer.
// std::vector<NodeScore> node_score_list;
// for (const auto &iter : cluster_resources) {
// double node_score = node_scorer_->MakeGrade(required_resources, iter->second);
// node_score_list.emplace_back(NodeScore(iter->first, node_score));
// }
// Score and rank nodes.
switch (policy.type_) {
case SPREAD:
break;
case STRICT_SPREAD:
break;
case PACK:
break;
case STRICT_PACK:
break;
default:
break;
}

for (const auto &resource : to_schedule_resources) {

}

// TODO(ffbin): Rank.
std::vector<NodeID> result;
return result;
}

absl::flat_hash_set<NodeID> GcsResourceScheduler::Filter(
absl::flat_hash_set<NodeID> GcsResourceScheduler::FilterCandidateNodes(
const absl::flat_hash_map<NodeID, ResourceSet> &cluster_resources,
std::function<bool(const NodeID &)> node_filter_func) {
absl::flat_hash_set<NodeID> result;
Expand All @@ -84,7 +97,11 @@ absl::flat_hash_set<NodeID> GcsResourceScheduler::Filter(
}
return result;
}
//////////////////////////////////// End of GcsResourceScheduler ////////////////////////////////

std::vector<ResourceSet> GcsResourceScheduler::SortRequiredResources(
const std::vector<ResourceSet> &required_resources) {}

/////////////////////////////// End of GcsResourceScheduler ///////////////////////////

} // namespace gcs
} // namespace ray
15 changes: 10 additions & 5 deletions src/ray/gcs/gcs_server/gcs_resource_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,23 @@ class LeastResourceScorer : public NodeScorer {
class GcsResourceScheduler {
public:
GcsResourceScheduler(GcsResourceManager &gcs_resource_manager)
: gcs_resource_manager_(gcs_resource_manager), node_scorer_(new LeastResourceScorer()) {}
: gcs_resource_manager_(gcs_resource_manager),
node_scorer_(new LeastResourceScorer()) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

if NodeScorer is Pluggable, I think we should add a ray config here?

Copy link
Contributor Author

@ffbin ffbin Jan 5, 2021

Choose a reason for hiding this comment

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

Good idea, but there is only one implementation at the moment, so i prefer to add configuration after having other implementations, thx.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'll want more dynamic configuration than ray config for this potentially right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, i find it is hard to choose a specific scorer type with ray config.


virtual ~GcsResourceScheduler() = default;

std::vector<NodeID> Schedule(
std::vector<ResourceSet> required_resources, SchedulingPolicy policy,
const std::function<bool(const NodeID &)> &node_filter_func);
const std::vector<ResourceSet> &required_resources, SchedulingPolicy policy,
const std::function<bool(const NodeID &)> &node_filter_func,
const std::function<std::vector<NodeID>(const std::vector<NodeScore> &)> &node_rank_func);

private:
absl::flat_hash_set<NodeID> Filter(
absl::flat_hash_set<NodeID> FilterCandidateNodes(
const absl::flat_hash_map<NodeID, ResourceSet> &cluster_resources,
std::function<bool(const NodeID &)> node_filter_func);
const std::function<bool(const NodeID &)> &node_filter_func);

std::vector<ResourceSet> SortRequiredResources(
const std::vector<ResourceSet> &required_resources);

/// Reference of GcsResourceManager.
GcsResourceManager &gcs_resource_manager_;
Expand Down