[Question] Question about speed/performance for the server?

So as I grow as a developer I am slowly becoming more and more speed/stability conscious and was wondering what kind of things could potentially be worse to use over x or what could hurt performance more than using x?

So for example using a repeat loop for x instead of a while loop or a heartbeat.

I’m not talking about remotes etc just to clarify. Purely just code based, practice question.

Hopefully I wrote this in a way you could understand. I kind of rushed writing this as I have an exam today so do excuse me if you don’t understand…

1 Like

Ping related
For ping I’d say that stop doing movement calculation and velocity based calculations on the server. This is best done on the client. Movement should always be done on the client so the server doesn’t really have to do much replication.

Check these topics for more information:

FPS related
Just stop printing too many things and just common sense. :woman_shrugging:

3 Likes

I already know about this practice however I do respect you throwing it in here. Leave it up for those whom come across this post and may need this. I will also be refreshing my self on this too, Thank you.

If you do then I don’t think that there is anything more to know. You just have to know that keep the recieved data and sent data, accessible by pressing Ctrl+F7, should be kept as low as possible. And the script usage should also be kept at a moderate level.

1 Like

if you wanna make really fast loops then you should add an empty wait() inside of a while loop or just use runservice.heartbeat or renderstepped

obvious note do not leave a loop without a wait() unless you wanna break your own game

just leaving it here since i’m too dumb to think about anything

1 Like

I was talking more of threading so like your while loops and stuff like that which could I suppose in some situations be ‘resource heavy’. Hopefully this clarifys more

wait() is going deprecated. Use task.wait().

It is extremely ineffecient and laggy.

So you’re talking about coroutines? If so I am sure coroutines do not really cause lag. Use as much as you want but obviously within a limit.

2 Likes

of course it is because it fires the thread every single frame

Not just coroutines but just generalization of threading and everything that could do with performance/stability of the server/games. But you are getting the idea.

I know of Parallel lua, Coroutines, etc but more of which is the practices of what is best case per say and what could be better to use instead of whatever else may be viable.

Ohh… parallel lua… Yea I haven’t really gone into that part of luaU so I can’t help here. Sorry.

You can’t really talk about this generally in abstract terms, especially when it comes to parallelization.

Either provide some example situations where you’ve ran into performance issues or noticed unsatisfactory execution time, or try not to get too carried away with early optimisation and write something that does the job.

That’s why it would be more important to focus on maintainable code and scalable game programming practices, so that you can always come back and redesign parts that are running too slow.

But if you want general suggestion for performance - think about what algorithms you use and how well they scale with input(big O notation) and minimise amount of dynamically allocated structures like tables and strings - though you can’t really avoid this in Luau, but try to reserve your tables with table.create instead of having the table reallocated multiple times until it reaches the required capacity.

1 Like

More of the answer I was searching for. Thank you, I will keep this in mind.

The issue with parallelisation is that it is difficult to arrange data between workers so that it’s evenly distributed and has little inter-worker communication/data transfer.

This is why not all algorithms can be parallelised and often you might actually get worse performance than serial algorithm.

So when you are dealing with parallelisation you have to consider the overhead of moving data to and from the worker, moving data between workers and how best to synchronise them so that there aren’t workers sitting idly while others are doing most of the work.

Though in some simpler cases spawning one worker could be pretty useful, say you have a huge array to sort, so you can do it in seperate thread so that it doesn’t interrupt other game processes. Or say you have a custom path finding system and you want to rebuild the navigation graph, so do it in seperate worker and do something else meanwhile.

1 Like