mirror of
https://github.com/wassname/ray.git
synced 2026-07-06 01:59:56 +08:00
Reduce actor submission python overhead (#5949)
This commit is contained in:
+16
-15
@@ -16,7 +16,7 @@ import ray.ray_constants as ray_constants
|
||||
import ray._raylet
|
||||
import ray.signature as signature
|
||||
import ray.worker
|
||||
from ray import ActorID, ActorClassID, profiling
|
||||
from ray import ActorID, ActorClassID
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -468,6 +468,12 @@ class ActorHandle(object):
|
||||
self._ray_class_name = class_name
|
||||
self._ray_actor_method_cpus = actor_method_cpus
|
||||
self._ray_session_and_job = session_and_job
|
||||
self._ray_function_descriptor_lists = {
|
||||
method_name: FunctionDescriptor(
|
||||
self._ray_module_name, method_name,
|
||||
self._ray_class_name).get_function_descriptor_list()
|
||||
for method_name in self._ray_method_signatures.keys()
|
||||
}
|
||||
|
||||
def _actor_method_call(self,
|
||||
method_name,
|
||||
@@ -500,20 +506,15 @@ class ActorHandle(object):
|
||||
kwargs = kwargs or {}
|
||||
|
||||
list_args = signature.flatten_args(function_signature, args, kwargs)
|
||||
function_descriptor = FunctionDescriptor(
|
||||
self._ray_module_name, method_name, self._ray_class_name)
|
||||
with profiling.profile("submit_task"):
|
||||
if worker.mode == ray.LOCAL_MODE:
|
||||
function = getattr(worker.actors[self._actor_id], method_name)
|
||||
object_ids = worker.local_mode_manager.execute(
|
||||
function, function_descriptor, args, kwargs,
|
||||
num_return_vals)
|
||||
else:
|
||||
object_ids = worker.core_worker.submit_actor_task(
|
||||
self._ray_actor_id,
|
||||
function_descriptor.get_function_descriptor_list(),
|
||||
list_args, num_return_vals,
|
||||
{"CPU": self._ray_actor_method_cpus})
|
||||
if worker.mode == ray.LOCAL_MODE:
|
||||
function = getattr(worker.actors[self._actor_id], method_name)
|
||||
object_ids = worker.local_mode_manager.execute(
|
||||
function, method_name, args, kwargs, num_return_vals)
|
||||
else:
|
||||
object_ids = worker.core_worker.submit_actor_task(
|
||||
self._ray_actor_id,
|
||||
self._ray_function_descriptor_lists[method_name], list_args,
|
||||
num_return_vals, {"CPU": self._ray_actor_method_cpus})
|
||||
|
||||
if len(object_ids) == 1:
|
||||
object_ids = object_ids[0]
|
||||
|
||||
Reference in New Issue
Block a user