Remix.run Logo
▲ thornjm an hour ago

Im familiar with the actor pattern but completely naive to their implementation. I’m having trouble imagining a few things and might be way off the mark. A few questions that might help others resolve my confusion:

1. Are there as many processes as there are cores on the CPU?

2. Is there a single message queue shared across cores?

3. Presumably two networking actors or two filesystem actors could be processing different messages on different cores and hardware resources can still be contested?

▲RossBencina 23 minutes ago | parent | next [-]

I'm only familiar with implementing run-to-completion actors. If a message is sent to an actor, the actor's behavior needs to run to process the message. You could have a message queue per thread (physical or logical core), or a message queue per actor, with a separate scheduler to decide when each actor should get a chance to run. There are obvious performance benefits to keeping communication local to a core, so hierarchical architecture where there are core-local actor networks and cross-core networks can make sense.

As to your final question, actors processing messages is a computation, i/o of any kind would involve sending messages to other lower-level i/o actors that multiplex or coordinate access to individual hardware resources.

▲monocasa 41 minutes ago | parent | prev [-]

1) Typically the number of actors and hardware threads are disconnected and it uses some MxN scheduler. There's a lot of related techniques here, green threads, user threads, coroutines, fibers, etc. Though the implementation under discussion here only uses one hardware thread, and looks a lot like the single threaded models like how node wraps libuv.

2) It can be thought of as at least one message queue per actor.

3) Yep.