Difference between one and multiple group(s) of actors?

Should I create one group of actors that will contain all calculating methods needed for all libraries

Example


OR


Should i create a separate group of actors for each library?

Example



Is there any difference in performance at all?

1 Like

There is a difference, yes.

Actors are like the container for work, when you run things in parallel the actors work is distributed evenly in a process called granularization, so the more actors you have, the more you benefit from performance.

There’s a few caveats to this however, such as the overhead of each actor eventually working against you. You can read more about the best practices here, where visuals are also provided. (https://create.roblox.com/docs/scripting/multithreading#best-practices).

From what you’re describing however, I wouldn’t set my code up like how you have it. It’s better to understand and use actor pools, as they’re the analogue we have in Roblox to thread pools in other programming languages.

Your library as a whole should just be one module that you access as you normally would and then have your library use actor pools to distribute the actual work that needs assistance via parallel execution, communicating via the Actor messaging API back to your library. You can read about that here (Parallel Luau [Version 2 Release])

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.