Speed up actor creation task submission by generating IDs with uuid. (#1744)

* Speed up actor creation task submission by generating IDs deterministically.

* Revert "Speed up actor creation task submission by generating IDs deterministically."

This reverts commit 175d9587302664916ce9db4071185485da8da041.

* Don't generate actor IDs deterministically yet.

* Factor out ID generation method.
This commit is contained in:
Robert Nishihara
2018-03-19 19:32:46 -07:00
committed by Philipp Moritz
parent d78de0d41f
commit f88a2544bf
2 changed files with 10 additions and 12 deletions
+3 -11
View File
@@ -12,18 +12,10 @@ import ray.cloudpickle as pickle
import ray.local_scheduler
import ray.signature as signature
import ray.worker
from ray.utils import (FunctionProperties, random_string, is_cython,
from ray.utils import (FunctionProperties, _random_string, is_cython,
push_error_to_driver)
def random_actor_id():
return ray.local_scheduler.ObjectID(random_string())
def random_actor_class_id():
return random_string()
def compute_actor_handle_id(actor_handle_id, num_forks):
"""Deterministically comopute an actor handle ID.
@@ -750,7 +742,7 @@ def actor_handle_from_class(Class, class_id, actor_creation_resources,
raise Exception("Actors cannot be created before ray.init() "
"has been called.")
actor_id = random_actor_id()
actor_id = ray.local_scheduler.ObjectID(_random_string())
# The ID for this instance of ActorHandle. These should be unique
# across instances with the same _ray_actor_id.
actor_handle_id = ray.local_scheduler.ObjectID(
@@ -930,7 +922,7 @@ def make_actor(cls, resources, checkpoint_interval, actor_method_cpus):
Class.__module__ = cls.__module__
Class.__name__ = cls.__name__
class_id = random_actor_class_id()
class_id = _random_string()
return actor_handle_from_class(Class, class_id, resources,
checkpoint_interval, actor_method_cpus)
+7 -1
View File
@@ -4,9 +4,11 @@ from __future__ import print_function
import binascii
import collections
import hashlib
import numpy as np
import os
import sys
import uuid
import ray.local_scheduler
@@ -15,7 +17,11 @@ DRIVER_ID_LENGTH = 20
def _random_string():
return np.random.bytes(20)
id_hash = hashlib.sha1()
id_hash.update(uuid.uuid4().bytes)
id_bytes = id_hash.digest()
assert len(id_bytes) == 20
return id_bytes
def format_error_message(exception_message, task_exception=False):