Having a hard time understanding Parallel Lua and Actors

Multi-threading seems like it would bring massive improvements to performance, but I’m struggling to understand how it could be implemented in practice. Is it only for repetitive tasks such as loops within a single script? Doesn’t Roblox’s engine use multi-threading under the hood by default for rendering, physics, etc? What does it mean for a thread to be unsychronized (I assume they’re not the same as asynchronous threads)? Are there any resources on how Actors should be properly used? I assume a lot of developers could have these questions, so any help would be greatly appreciated!

Yea everyone at first struggled with understanding parallel Lua because there’s literally no good resource out there on how to use them. To their defense, parallel Lua is a beta feature and shouldn’t be used extensively.

  1. As far as I know, parallel Lua is really only good for repetitive tasks like you said, such as running millions of mathematical calculations. Due to the supposed thread safety that comes into consideration with multithreading, many of the vital functions have been restricted which prevents you from doing much with parallel Lua.
  2. I don’t know much about the internals of roblox so not sure about physics simulation and rendering being multithreaded
  3. Normally, code is ran in succession where it executes a snippet, moves onto the next one, and so on. But when a thread becomes unsynchronized, it basically moves out of that queue and runs independently. This is why multi-threading can be unsafe (hence the limitations with using roblox environment functions in parallel Lua) because you don’t exactly know when that code is being ran, and most importantly if that code is going to be ran concurrently (For example, 2 scripts trying to change the property of an instance; they will attempt to override each other) which causes big problems.
  4. CloneTrooper1019 has an open-source project where he utilized parallel Lua for procedural terrain generation. You can check it out here and view its internals to see how it works.

Hopefully this helps you understand how to use parallel Lua.

2 Likes

https://developer.roblox.com/en-us/api-reference/class/Actor

That’s probably the worst documented page in the entire API reference, lol, but I guess that’s to be expected since it’s a beta feature.

https://developer.roblox.com/en-us/api-reference/property/PartOperation/RenderFidelity