Is parallel luau worth the hastle and risk?

I am asking because of posts like this

Apparently many have had problems with parallel luau and some have even said it has degraded performance, surely there are better more optimized features to utilize such as instance streaming rather than this?

4 Likes

Yes definitely, in the future you’re gonna need to run code on different cores for optimisation and thus parallel lua is definitely recommended to use. The hastle and risk are overshadowed by the performance improvement of using parallel luau

Really the only people i’ve seen use parallel luau are people who are doing crazy things. all games used to run on one core unless I’m mistaken. And they worked completely fine, even big games with big maps. Surely one core is enough?

Instance streaming is a much more powerful feature I’d say that is less of a risk, easier to use, and is actually really significant on performance. But it mostly depends on the size of your map and your game.

2 Likes

Nowadays computers with 16 and 24 cores are being manufactured a lot, so parallel luau makes use of these many cores to split work more evenly, thus improving overall performance

But, unless you’re doing something that is super intensive I don’t see the reason. Unless you have one? I am open to suggestions and really wanna use these optimization features but some of them like this I have no use for them.

IMO, its not really worth changing all your code(especially if it’s already written) to use parallel luau UNLESS it needs the performance, for instance, optimized code that due to it’s nature is slow(like chunk generation in minecraft)
Currently it is super frustrating using parallel luau in general and if your game runs good already then there’s no need

This is what I’m thinking to but many people have told me that parallel luau should be used alot. I’m still not leaning to that side though.

Not every problem can be parallellized.

“Can’t fit round pegs in square holes”

3 Likes

Considering me being a beginner, how would you go by determining which mechanics or functions would need to be multi threaded? A simple example would also help understand its utilization more.

Im really a lag-o-phobe type of person when it comes to performance, so I really would love to start getting insight into what I should really lay my hands over. Much appreciated.

I would say personally read the documentation it helped me understand the whole concept well: Performance Optimization | Documentation - Roblox Creator Hub

1 Like

I know I wasn’t asked the question, but in my case I use parallel lua for things such as projectiles, since I need to he able to simulate a lot of bullets without too much lag from all the raycasting. Another place I use parallel lua is with my AI, since I want to have a lot of NPC’s in my map.

Although, a use case should usually be pretty obvious. Want thousands of simulated projectiles? Use parallel lua. Want 10 npcs? Use serial. Want 200 npcs? Use parallel lua. It usually is applied best where you need something done in mass, and you shouldn’t force it otherwise because it could actually result in worse performance than just staying in serial.

1 Like

That’s pretty much what my current project has on its roadmap. I intend for it to be a horde shooter type of game, which exactly would need what you mentioned.

Since now I understand that parallel luau is what I need, i’m going to research more with what Amritss provided. Thank you for your responses!

(I’ll most definitely be posting or browsing through when I get to parallel luau, definitely going to encounter issues :slight_smile: )

1 Like

Parallel luau is a very powerful feature (again I know you didn’t talk to me either) but you’re right. i think it should really be a last resort in extreme situations like you said with mass.

200 NPCs and thousands of simulated projectiles is honestly very unlikely that someone would need to do that, the only use-case scenario I could really think of parallel luau would be for chunk-loading. I’m pretty sure the docs also showed that on their tutorial for parallel luau.

The documentation actually provides some examples I didn’t think of when it comes to using parallel luau that you can see here, even for basic things such as raycast validations:

1 Like

These are just examples, but either way they are actually not very unlikely. There are a lot of front page games that feature hundreds of NPC’s around the map at once. The same goes for projectiles; shooters such as war games will likely reach a thousand or more projectiles being simulated at once. Parallel lua could make the difference of opening up your game to mobile, and if not apparent alone, open up extra head room for other performance heavy features.

2 Likes

Yes, but usually what happens is he NPCs are automatically destroyed by the server after some time (because the scripter did this). Or the players are usually abundant so they kill most of them, but I see what you mean.

If your script’s purpose requires very frequent modification of Instance’s properties, then I’d recommend sticking to serial since you’ll most likely end up having to constantly synchronize anyways due to them being unable to be written to while in parallel

If your script’s purpose mostly involves calculating (generating chunks is a good example), or needs to do a bunch of verification on data before synchronizing (a killbrick would be a good example, since the FindFirst functions are all able to be used in parallel, thus synchronization only needs to happen if a Humanoid was successfully found in-order to damage it), then parallel is quite useful :slight_smile::+1:

1 Like

Wait really? Even for a simple killbrick? Serial is worse?

-- Server script by the way
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)

So from what it seems and from the documentation and what you mentioned earlier, its about finding the right balance of actors and computations? I probably would have to understand how actors and computations function. So I could really determine what system requires x amount of actors.

But if it really opens up opportunities for more performance heavy duties that way, then it’s definitely worth having to make a game with complex systems running simultaneosly.

Not worse, but if you’re familiar with parallel you can benefit since the Humanoid checks will run in a separate core

1 Like

This is not always true. This most times depends on how you go about setting properties (switching to serial to do serial things)

Lets say you have 100 parts that you want to cframe around every frame. Lets also say for some reason getting the cframe for each part is very taxing, therefore we need to do it in parallel. We know setting properties such as cframe cannot be done in parallel, so we’ll need to be switching between parallel and serial for this to work.

What you could do is loop through every part, switch to parallel, get the cframe, switch to serial, set the cframe. The only problem with this is youre switching between serial and parallel too much.

The smarter way to do this is switch to parallel, loop through every part, get the cframe, store the cframe in a table, after you are done looping switch to serial, loop through every part again and set the cframe of the part using the table.

TL;DR it depends on how you do it

Just because something can be done in parallel does not mean it will increase performance. In this case, I’d assume the performance difference will be negligable, or even worse since synchronizing and desychronizing is pretty taxing.

3 Likes