PDA

View Full Version : Lags



Lonsofore
26th April 2017, 14:15
Hello Killtube. I have a problem and as you guessed, with lags.
This thread isn't like "help me, everything broke". And let me explain why:
1. I tested my connection with cmd and ping - it's ok, stable. But in game it can be higher and unstable. In cmd it's like (for me) 105-115 (it's ok), in game it's like 120-160.
2. This lags depend on players count. With 10 players it's ok, but with 20 we have lags
3. I have enough RAM and CPU. It isn't overloaded more than 70% (by the way, on map restart one of two CPU is 100% - is it ok?)
I don't know, can it tells you something, but I attached here some images of my lagometer.
So, I need some opinions about it - where can I look at to find a solution?

Ni3ls
26th April 2017, 14:38
Is it only at map start? Or also "randomly"?
If it's at map start, check the cvars you are setting. This causes lag. Also loops can be causing lags

IzNoGoD
26th April 2017, 14:46
set your rate higher. Sounds like not enough data per second can be pushed through. Also increase cl_maxpackets.

Lonsofore
26th April 2017, 15:46
Is it only at map start? Or also "randomly"?
If it's at map start, check the cvars you are setting. This causes lag. Also loops can be causing lags
Randomly and not only at map start. I see lags during the whole game, if people count more than 10-15. I'll check my loops. Do you know something about loops "in numbers"?



set your rate higher. Sounds like not enough data per second can be pushed through. Also increase cl_maxpackets.
Rate 25000 and cl_maxpackets 100 for everyone, so the problem isn't here. Or can this problem be here, but on OS-side?

IzNoGoD
26th April 2017, 16:57
Possibly you have nested for loops, or even nested-in-nested for loops (or worse). This means that your execution time might go O(N^3) or higher, meaning that more players add waaaay more cpu time.

Possibly best to upgrade to a vps/server with some beefy single-threaded performance. I can recommend buyvm.net's KVM slices, starting at 3.5 usd/month.

kung foo man
26th April 2017, 17:55
If you suspect some code to be slow, just add some wait 0.05; in there (like, when if (i == 10) wait 0.05;), so the game engine has some time to care about the other events and later just resume the loops.

Or generally, optimize the code. In computer science there is always more than one way to do stuff. To know what to optimize, there first need to be a profiler tho (or some good wild guesses). Probably would be a nice addition to measure time in all kinds of functions to create "fire graphs"... to see where it burns the most.

Random idea I just got: make some function, which measueres the time till "last reset". So before entering performance critical code, the timer is reset. And IN the performance critical code, you can check all the time how much time was spend already, like in every loop body. If the time passed e.g. more than 10 milliseconds (which is quite alot, consider that a frame is only 50ms and there are others threads/coroutines which need to work aswell), then just "drop out" via wait 0.05 and reset the timer.

Ni3ls
26th April 2017, 18:19
Check your console log for infinite loops or other errors. Server might continue with the presents of errors

Lonsofore
27th April 2017, 08:18
Possibly you have nested for loops, or even nested-in-nested for loops (or worse). This means that your execution time might go O(N^3) or higher, meaning that more players add waaaay more cpu time.

Possibly best to upgrade to a vps/server with some beefy single-threaded performance. I can recommend buyvm.net's KVM slices, starting at 3.5 usd/month.
I'll check my loops, maybe you're right here, thank you :)
VPS from US isn't for me anyway. Only Russia, only hardcore...


If you suspect some code to be slow, just add some wait 0.05; in there (like, when if (i == 10) wait 0.05;), so the game engine has some time to care about the other events and later just resume the loops.

Or generally, optimize the code. In computer science there is always more than one way to do stuff. To know what to optimize, there first need to be a profiler tho (or some good wild guesses). Probably would be a nice addition to measure time in all kinds of functions to create "fire graphs"... to see where it burns the most.

Random idea I just got: make some function, which measueres the time till "last reset". So before entering performance critical code, the timer is reset. And IN the performance critical code, you can check all the time how much time was spend already, like in every loop body. If the time passed e.g. more than 10 milliseconds (which is quite alot, consider that a frame is only 50ms and there are others threads/coroutines which need to work aswell), then just "drop out" via wait 0.05 and reset the timer.
Good ideas, I'll try it, thank you :)


Check your console log for infinite loops or other errors. Server might continue with the presents of errors
Too easy

IzNoGoD
27th April 2017, 08:50
[QUOTE=Lonsofore;16225]I'll check my loops, maybe you're right here, thank you :)
VPS from US isn't for me anyway. Only Russia, only hardcore...

They have a luxembourgh location too

Lonsofore
27th April 2017, 19:04
I think, I found the source of the problem. I just changed my hosting again and it's ok now. I don't know, what was wrong, but these awesome Russian hostings... hate them already. That's why I created this (https://killtube.org/showthread.php?2873-cod2install-Install-CoD2-on-your-VDS-much-faster!)...

IzNoGoD
27th April 2017, 21:36
russia? vstoike, vscale, myvps.ru, and for the far-east xhostfire.

Lonsofore
28th April 2017, 03:09
russia? vstoike, vscale, myvps.ru, and for the far-east xhostfire.
Thank you, I'll try it if my new host will disappoint me.