Actor dummy object garbage collection (#3593)

* Convert UniqueID::nil() to a constructor

* Cleanup actor handle pickling code

* Add new actor handles to the task spec

* Pass in new actor handles

* Add new handles to the actor registration

* Regression test for actor handle forking and GC

* lint and doc

* Handle pickled actor handles in the backend and some refactoring

* Add regression test for dummy object GC and pickled actor handles

* Check for duplicate actor tasks on submission

* Regression test for forking twice, fix failed named actor leak

* Fix bug for forking twice

* lint

* Revert "Fix bug for forking twice"

This reverts commit 3da85e59d401e53606c2e37ffbebcc8653ff27ac.

* Add new actor handles when task is assigned, not finished

* Remove comment

* remove UniqueID()

* Updates

* update

* fix

* fix java

* fixes

* fix
This commit is contained in:
Stephanie Wang
2019-01-09 10:37:11 -08:00
committed by GitHub
parent 3027dde303
commit 04f31db54d
16 changed files with 382 additions and 127 deletions
+81 -2
View File
@@ -1854,8 +1854,87 @@ def test_fork_consistency(setup_queue_actor):
# Fork num_iters times.
num_forks = 10
num_items_per_fork = 100
ray.get(
[fork.remote(queue, i, num_items_per_fork) for i in range(num_forks)])
# Submit some tasks on new actor handles.
forks = [
fork.remote(queue, i, num_items_per_fork) for i in range(num_forks)
]
# Submit some more tasks on the original actor handle.
for item in range(num_items_per_fork):
local_fork = queue.enqueue.remote(num_forks, item)
forks.append(local_fork)
# Wait for tasks from all handles to complete.
ray.get(forks)
# Check that all tasks from all handles have completed.
items = ray.get(queue.read.remote())
for i in range(num_forks + 1):
filtered_items = [item[1] for item in items if item[0] == i]
assert filtered_items == list(range(num_items_per_fork))
def test_pickled_handle_consistency(setup_queue_actor):
queue = setup_queue_actor
@ray.remote
def fork(pickled_queue, key, num_items):
queue = ray.worker.pickle.loads(pickled_queue)
x = None
for item in range(num_items):
x = queue.enqueue.remote(key, item)
return ray.get(x)
# Fork num_iters times.
num_forks = 10
num_items_per_fork = 100
# Submit some tasks on the pickled actor handle.
new_queue = ray.worker.pickle.dumps(queue)
forks = [
fork.remote(new_queue, i, num_items_per_fork) for i in range(num_forks)
]
# Submit some more tasks on the original actor handle.
for item in range(num_items_per_fork):
local_fork = queue.enqueue.remote(num_forks, item)
forks.append(local_fork)
# Wait for tasks from all handles to complete.
ray.get(forks)
# Check that all tasks from all handles have completed.
items = ray.get(queue.read.remote())
for i in range(num_forks + 1):
filtered_items = [item[1] for item in items if item[0] == i]
assert filtered_items == list(range(num_items_per_fork))
def test_nested_fork(setup_queue_actor):
queue = setup_queue_actor
@ray.remote
def fork(queue, key, num_items):
x = None
for item in range(num_items):
x = queue.enqueue.remote(key, item)
return ray.get(x)
@ray.remote
def nested_fork(queue, key, num_items):
# Pass the actor into a nested task.
ray.get(fork.remote(queue, key + 1, num_items))
x = None
for item in range(num_items):
x = queue.enqueue.remote(key, item)
return ray.get(x)
# Fork num_iters times.
num_forks = 10
num_items_per_fork = 100
# Submit some tasks on new actor handles.
forks = [
nested_fork.remote(queue, i, num_items_per_fork)
for i in range(0, num_forks, 2)
]
ray.get(forks)
# Check that all tasks from all handles have completed.
items = ray.get(queue.read.remote())
for i in range(num_forks):
filtered_items = [item[1] for item in items if item[0] == i]