Parallel Lua Questions

i’ve read a lotta the documentation on the devhub and I understand how it works, however i want to know the limitations of it. what are the benefits of using parallel lua vs programming in serial? what cases would it be better to have parallel code vs just having things in serial? what can and cannot be done in parallel?

Parallelization is really only good for math and any algorithmically-intense workloads, such as running thousands of raycasts/shapecasts all at once to simulate projectiles in a game, or rendering the Mandelbrot Set by calculating the converging points.

The biggest takeaway with parallelization is that tasks can be done INDEPENDENTLY. What one task does has zero influence on the other; in other words, there is no need for them to run in any specific order. There’s a name for these kinds of workloads, along with some more examples in the article below:

When working with parallelized tasks, you have to keep in mind how data transaction will work. When you distribute the tasks among different threads, you need a way to send and receive them. This can be a bottleneck with parallelization. If it takes more effort to send/receive data than the parallelized task itself, it may not be worth parallelizing and should remain in serial mode. There is also a name for this effect:

Now, in terms of Roblox, the bottleneck comes from RemoteEvents and Actor Messages. Firing events too often is bad (because of how they get scheduled and organized etc) so you should try packing them together into bundles of data.

1 Like

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