Is this proper use of parrarel luau?

Hello, i’ve read that parrarel luau can improve performance, especially calculations, and i’ve decided to check it out

I also observerd that if i have server-only or client-only system, i can use many actors in place of modules, + use shared tables and messaging api to return results to controller script, which can use bindable function to return result like a module

Because modules can’t use parrarel luau like script can, i think this is the only way to do it, is there any other way? is this performant?

image

1 Like

It depends on what you are splitting into parallel as to how it would be benefitting performance.

For example, if you had a single CPU core doing all the heavy calculations or terrain generation, this would be very intense on it causing lag so splitting these tasks into separate CPU cores would increase performance.

However, I thought I’d also mention that if you are using task.spawn and coroutines they do not run in parallel but give the illusion of doing so. They just separate threads on the same CPU core but looking at your screenshot I doubt you are doing this.

To use Parallel Lua you have to run scripts under different actors (which you have) and use task.desynchronize to run it parallel. To revert to serial execution, you would use task.synchronize.

To answer your question ‘is this performant?’ and ‘is there another way?’, yes this increases performance due to you running, I’m assuming heavy tasks, into separate CPU cores you are not pressuring one CPU core to do all the work and if you are looking for performance and not just running tasks on the same CPU core in different threads this would be the most beneficial way and is the proper use of parallel.

2 Likes

One more question, because i’m new to parrarel luau, i wanted to ask how to split raycasts over more than 1 actor, while keeping it in module script, there is very little resources on that, and i want to fire hundreds of rays per second, i managed to optimize raycasting itself by doing it only if client is owner of projectile or if projectile is visual but can be seen by other players, still i think parrarel luau may benefit this

1 Like

Don’t worry I am slightly new to parallel as well :sweat_smile:

This is actually a great question and you are right there isn’t much said about raycasting in parallel. Unfortunately I am unsure of how to answer your question as I have never done this before nor have I found many others who have documented or made community resources to about this.

So sorry I can’t help you further. All I can hope is that the information I have provided has helped you out for now.

1 Like

thx, also do you have ideas on how to optimize raycasting? apart of running it on client and validating on server, because i do it already

If you are running the code on the client and validating it on the server, it should be fine and if you have followed the Raycasting Documentation recommendations in your code you should be fine raycast wise.

1 Like

There are no reccomendations in those docs, but still thx for help, have a nice day, bye

1 Like

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