mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 01:00:10 +08:00
Introduce concept of resources required for placing a task. (#2837)
* Introduce concept of resources required for placement. * Add placement resources to task spec * Update java worker * Update taskinfo.java
This commit is contained in:
committed by
Alexey Tumanov
parent
01bb073569
commit
faa31ae018
+12
-1
@@ -373,6 +373,15 @@ class ActorClass(object):
|
||||
self._num_cpus, self._num_gpus, self._resources, num_cpus,
|
||||
num_gpus, resources)
|
||||
|
||||
# If the actor methods require CPU resources, then set the required
|
||||
# placement resources. If actor_placement_resources is empty, then
|
||||
# the required placement resources will be the same as resources.
|
||||
actor_placement_resources = {}
|
||||
assert self._actor_method_cpus in [0, 1]
|
||||
if self._actor_method_cpus == 1:
|
||||
actor_placement_resources = resources.copy()
|
||||
actor_placement_resources["CPU"] += 1
|
||||
|
||||
creation_args = [self._class_id]
|
||||
function_id = compute_actor_creation_function_id(self._class_id)
|
||||
[actor_cursor] = worker.submit_task(
|
||||
@@ -380,7 +389,8 @@ class ActorClass(object):
|
||||
creation_args,
|
||||
actor_creation_id=actor_id,
|
||||
num_return_vals=1,
|
||||
resources=resources)
|
||||
resources=resources,
|
||||
placement_resources=actor_placement_resources)
|
||||
|
||||
# We initialize the actor counter at 1 to account for the actor
|
||||
# creation task.
|
||||
@@ -566,6 +576,7 @@ class ActorHandle(object):
|
||||
# We add one for the dummy return ID.
|
||||
num_return_vals=num_return_vals + 1,
|
||||
resources={"CPU": self._ray_actor_method_cpus},
|
||||
placement_resources={},
|
||||
driver_id=self._ray_actor_driver_id)
|
||||
# Update the actor counter and cursor to reflect the most recent
|
||||
# invocation.
|
||||
|
||||
+10
-2
@@ -550,6 +550,7 @@ class Worker(object):
|
||||
execution_dependencies=None,
|
||||
num_return_vals=None,
|
||||
resources=None,
|
||||
placement_resources=None,
|
||||
driver_id=None):
|
||||
"""Submit a remote task to the scheduler.
|
||||
|
||||
@@ -575,6 +576,9 @@ class Worker(object):
|
||||
num_return_vals: The number of return values this function should
|
||||
have.
|
||||
resources: The resource requirements for this task.
|
||||
placement_resources: The resources required for placing the task.
|
||||
If this is not provided or if it is an empty dictionary, then
|
||||
the placement resources will be equal to resources.
|
||||
driver_id: The ID of the relevant driver. This is almost always the
|
||||
driver ID of the driver that is currently running. However, in
|
||||
the exceptional case that an actor task is being dispatched to
|
||||
@@ -628,6 +632,9 @@ class Worker(object):
|
||||
raise ValueError(
|
||||
"Resource quantities must all be whole numbers.")
|
||||
|
||||
if placement_resources is None:
|
||||
placement_resources = {}
|
||||
|
||||
with self.state_lock:
|
||||
# Increment the worker's task index to track how many tasks
|
||||
# have been submitted by the current task so far.
|
||||
@@ -640,7 +647,8 @@ class Worker(object):
|
||||
num_return_vals, self.current_task_id, task_index,
|
||||
actor_creation_id, actor_creation_dummy_object_id, actor_id,
|
||||
actor_handle_id, actor_counter, is_actor_checkpoint_method,
|
||||
execution_dependencies, resources, self.use_raylet)
|
||||
execution_dependencies, resources, placement_resources,
|
||||
self.use_raylet)
|
||||
self.local_scheduler_client.submit(task)
|
||||
|
||||
return task.returns()
|
||||
@@ -2138,7 +2146,7 @@ def connect(info,
|
||||
worker.current_task_id, worker.task_index,
|
||||
ray.ObjectID(NIL_ACTOR_ID), ray.ObjectID(NIL_ACTOR_ID),
|
||||
ray.ObjectID(NIL_ACTOR_ID), ray.ObjectID(NIL_ACTOR_ID),
|
||||
nil_actor_counter, False, [], {"CPU": 0}, worker.use_raylet)
|
||||
nil_actor_counter, False, [], {"CPU": 0}, {}, worker.use_raylet)
|
||||
|
||||
# Add the driver task to the task table.
|
||||
if not worker.use_raylet:
|
||||
|
||||
Reference in New Issue
Block a user