Many actors writing to one object

I would like to have a basic object which all actor classes can write and read. What is best way to do that?

Probably the easiest way here is to just create a new Actor that the other actors will communicate with.

Yeah using actor for global variables is the way to go right now (Ray Design Patterns - Google Docs). Note that plasma store objects are “immutable”, so you are not able to write to the object.

Is this the fastest most-realtime method of communication between actors?

Can you elaborate your question a little bit? I don’t think I understood!

Lets say you wanted to have several Ray actors running forever collecting data, and writing the data to a globally available pandas DataFrame which all actors can see and modify

ah I understand that part. What do you mean by fastest most-realtime method of communication between actors? Are you asking me if using an actor for the global object is the fastest way to achieve it?

Yes @sangcho. The fastest way Actors can collaborate to build a pandas data-frame that all Actors can access in real-time

Hmm if your goal is to modify one shared object among many actors, probably yes in Ray. It is typically not an easy task to modify shared object among many processes since it requires a global lock. If you’d like further optimization you can consider partitioning your data into multiple actors with the expense of get performance (since you need to reduce partitions).

ray.get( self.globalActor.get_df.remote() )
returns a new data frame every time it is called.
How can I leverage the “zero-copy” stuff to ensure high speed connection to GlobalActor which has the shared data frame ?

If you use this approach, you shouldn’t return the whole dataframe from the actor, but it should return partial data (by adding methods).

How can I leverage the “zero-copy” stuff to ensure high speed connection to GlobalActor which has the shared data frame ?

This is not trivial with the current Ray support because zero-copy is used for ray objects, and ray objects are immutable. If you’d like to do this, you need to make this object mutable (which is technically possible, but not recommended by us. I remember there’s a flag you can tweak), and then should have a global lock among actors (and it will only work in a single node). You can probably implement a naive global lock using actors as well. [ray] How to write into numpy arrays in shared memory with Ray? · Issue #6507 · ray-project/ray · GitHub Note that this is not a recommended solution because it can behave wieldy.

Thank You @sangcho !