Having Excessive CPU Usage
#1

I am having problems with excessive CPU usage in my gamemode script. It only started crashing just recently. I cannot pinpoint when it started or what I've added that may have caused it because I've added so many things here and there. Its only gotten worse over time and I don't know what to do.

Any insight that you have would be great, I would like to know what kinds of things would cause these CPU usage spikes so suddenly I normally have a 2-4% CPU usage and now the average is around 40%.

I am using Volt-Host and have already consulted them about this, it seems it has nothing to do with their servers, only my script.

Additionally: It gets worse the more players that are online.
Quote:

Restarted (Excessive CPU Usage - 94.1%)

Restarted (Excessive CPU Usage - 97.2%)

Restarted (Excessive CPU Usage - 91.1%)

Restarted (Excessive CPU Usage - 91.6%)

Restarted (Excessive CPU Usage - 86.8%)

Restarted (Excessive CPU Usage - 97.6%)

Restarted (Excessive CPU Usage - 84.8%)

Restarted (Excessive CPU Usage - 84.1%)

Restarted (Excessive CPU Usage - 81.1%)

Restarted (Excessive CPU Usage - 103.4%)

Restarted (Excessive CPU Usage - 83.3%)

Restarted (Excessive CPU Usage - 91.5%)

Restarted (Excessive CPU Usage - 102.5%)

Restarted (Excessive CPU Usage - 83.5%)

Restarted (Excessive CPU Usage - 83.4%)

Reply
#2

OPTIMISE.

If I was Volt I wouldn't want you on my servers.
Reply
#3

Did you even read my whole post? I always keep my code neat and efficient but I must have added something recently that made it happen all the sudden.
Reply
#4

Quote:
Originally Posted by vvhy
Посмотреть сообщение
Did you even read my whole post? I always keep my code neat and efficient but I must have added something recently that made it happen all the sudden.
There is different definitions of efficient. Anyway, comment out sections and recompile and see if it fixes it, if not move on and comment some other block of code and repeat the process.
Reply
#5

Another thing I should add is that it only happens and gets worse when I have a lot of players on (25-40) and when I have 0 players on it runs below 2% CPU usage. Thats the reason why its so hard to test and diagnose. Thanks anyway.
Reply
#6

Whats your MAX_PLAYERS define? Is based on current server slots?
Reply
#7

such behavior is mostly caused by algorithms working iterative - take f.ex a proxdetector, used to check if a player is able to /wave, /infect him, /piss etc, so the CPU goes up rapidly.
the same situation is for mission checkpoints, checked in a timer. take 100 mission locations, with 20 players, checked 1 time "only" per second == 2000 distance calculations, for nothing.

for your script, "optimize" means the algorithms. think about how many cycles the script needs for 1 information, like getting the closest player (to anopther player or a checkpoint or gangzone).
if you got too many of those loops, its clear why its acting odd.

concluding that its using 2% CPU @ <5 players, but >90% @ ~20 players, i can predict that its value will double to 200% with 1/2 more players (i.e. 20 changes to 30, but uses double CPU).
have a look at the JIT plugin, it speeds things up a bit, the CPU usage will be 40% @ 20 players, and raise up to 80% @ 30 players, @ 35 players it will reset again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)