mirror of
https://github.com/wassname/ray.git
synced 2026-08-12 12:20:11 +08:00
redefined SchedulingClass to avoid including the FunctionDescriptor (#9022)
* redefined SchedulingClass to avoid including the FunctionDescriptor * updated TestSchedulingKeys test in DirectTaskTransportTest
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -17,7 +17,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
namespace ray {
|
||||
typedef std::pair<ResourceSet, ray::FunctionDescriptor> 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<rpc::TaskSpec> {
|
||||
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<ray::SchedulingClassDescriptor> {
|
||||
size_t operator()(ray::SchedulingClassDescriptor const &k) const {
|
||||
size_t seed = std::hash<ray::ResourceSet>()(k.first);
|
||||
seed ^= k.second->Hash();
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
} // namespace ray
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user