Skip to content

Actor handle GC is problematic. #3472

@raulchen

Description

@raulchen

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): all
  • Ray installed from (source or binary): source
  • Ray version: latest master
  • Python version: all
  • Exact command to reproduce: n/a

Describe the problem

Currently, when the original actor handle is garbage collected by Python interpreter, a __ray_terminate__ message will be sent to also terminate the actor, see

def __del__(self):
.

This mechanism is problematic, because

  1. If there're forked handles, the actor shouldn't be terminated.
  2. __del__ is unreliable and not recommended to use, see https://stackoverflow.com/questions/1481488/what-is-the-del-method-how-to-call-it.

The first point is a critical problem and is hard to handle automatically. Even if we count the number of forked handles, and only terminate the actor when all handles are GC'ed. It's still problematic if users serialize a handle and deserialize it after a long time. Ray doesn't know when an actor is not needed any more. Only the user knows.

Thus, I'm in favor of letting the users manually GC an actor with actor.__ray_terminate__.remote(), when they don't need the actor any more. To prevent the actor from wasting resource forever, there's already the mechanism that we'll clean up all workers when a driver exits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions