From 311c55132ca206208c2a0a7f4609a4a1573ce6e1 Mon Sep 17 00:00:00 2001 From: Gabriele Oliaro Date: Fri, 19 Jun 2020 16:12:48 -0400 Subject: [PATCH] redefined SchedulingClass to avoid including the FunctionDescriptor (#9022) * redefined SchedulingClass to avoid including the FunctionDescriptor * updated TestSchedulingKeys test in DirectTaskTransportTest --- src/ray/common/task/task_spec.cc | 2 +- src/ray/common/task/task_spec.h | 16 ++-------------- .../test/direct_task_transport_test.cc | 6 +++--- src/ray/raylet/node_manager.cc | 2 +- src/ray/raylet/scheduling_queue.cc | 3 +-- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/ray/common/task/task_spec.cc b/src/ray/common/task/task_spec.cc index 603c82a30..1e65be738 100644 --- a/src/ray/common/task/task_spec.cc +++ b/src/ray/common/task/task_spec.cc @@ -47,7 +47,7 @@ void TaskSpecification::ComputeResources() { // the actor tasks need not be scheduled. // Map the scheduling class descriptor to an integer for performance. - auto sched_cls = std::make_pair(GetRequiredResources(), FunctionDescriptor()); + auto sched_cls = GetRequiredResources(); absl::MutexLock lock(&mutex_); auto it = sched_cls_to_id_.find(sched_cls); if (it == sched_cls_to_id_.end()) { diff --git a/src/ray/common/task/task_spec.h b/src/ray/common/task/task_spec.h index 0fd91578a..02273e513 100644 --- a/src/ray/common/task/task_spec.h +++ b/src/ray/common/task/task_spec.h @@ -17,7 +17,7 @@ extern "C" { } namespace ray { -typedef std::pair SchedulingClassDescriptor; +typedef ResourceSet SchedulingClassDescriptor; typedef int SchedulingClass; /// Wrapper class of protobuf `TaskSpec`, see `common.proto` for details. @@ -194,16 +194,4 @@ class TaskSpecification : public MessageWrapper { static int next_sched_id_ GUARDED_BY(mutex_); }; -} // namespace ray - -/// We must define the hash since it's not auto-defined for vectors. -namespace std { -template <> -struct hash { - size_t operator()(ray::SchedulingClassDescriptor const &k) const { - size_t seed = std::hash()(k.first); - seed ^= k.second->Hash(); - return seed; - } -}; -} // namespace std +} // namespace ray \ No newline at end of file diff --git a/src/ray/core_worker/test/direct_task_transport_test.cc b/src/ray/core_worker/test/direct_task_transport_test.cc index 39adda61f..3e5e6c7ab 100644 --- a/src/ray/core_worker/test/direct_task_transport_test.cc +++ b/src/ray/core_worker/test/direct_task_transport_test.cc @@ -836,11 +836,11 @@ TEST(DirectTaskTransportTest, TestSchedulingKeys) { BuildTaskSpec(resources1, descriptor1), BuildTaskSpec(resources2, descriptor1)); - // Tasks with different function descriptors should request different worker leases. + // Tasks with different function descriptors do not request different worker leases. RAY_LOG(INFO) << "Test different descriptors"; TestSchedulingKey(store, BuildTaskSpec(resources1, descriptor1), - BuildTaskSpec(resources1, descriptor1), - BuildTaskSpec(resources1, descriptor2)); + BuildTaskSpec(resources1, descriptor2), + BuildTaskSpec(resources2, descriptor1)); ObjectID direct1 = ObjectID::FromRandom(); ObjectID direct2 = ObjectID::FromRandom(); diff --git a/src/ray/raylet/node_manager.cc b/src/ray/raylet/node_manager.cc index db16a062d..522e34425 100644 --- a/src/ray/raylet/node_manager.cc +++ b/src/ray/raylet/node_manager.cc @@ -940,7 +940,7 @@ void NodeManager::DispatchTasks( // Approximate fair round robin between classes. for (const auto &it : fair_order) { const auto &task_resources = - TaskSpecification::GetSchedulingClassDescriptor(it->first).first; + TaskSpecification::GetSchedulingClassDescriptor(it->first); // FIFO order within each class. for (const auto &task_id : it->second) { const auto &task = local_queues_.GetTaskOfState(task_id, TaskState::READY); diff --git a/src/ray/raylet/scheduling_queue.cc b/src/ray/raylet/scheduling_queue.cc index 9471a2481..934f92a93 100644 --- a/src/ray/raylet/scheduling_queue.cc +++ b/src/ray/raylet/scheduling_queue.cc @@ -461,8 +461,7 @@ std::string SchedulingQueue::DebugString() const { for (const auto &pair : num_running_tasks_) { result << "\n- "; auto desc = TaskSpecification::GetSchedulingClassDescriptor(pair.first); - result << desc.second->ToString(); - result << desc.first.ToString(); + result << desc.ToString(); result << ": " << pair.second; total += pair.second; }