SA-MP Forums Archive
High CPU usage on dedicated - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: High CPU usage on dedicated (/showthread.php?tid=544830)



High CPU usage on dedicated - DeitY - 04.11.2014

Hi there! The following problem is :

My server has every day online atleast 200 players, but on 150 players CPu goes very high and server starts lagging.

I know that its problem due to gamemode, so any experienced member could assist me, about how could i reduce cpu usage, what uses too much resources and stuff?

Because i know a servers with 500 players online and their cpu usage is 30-40%~, altough i on 150 players has 60-70% ..

BTW edit: We use same dedicated, so its not problem to dedciated server.


Re: High CPU usage on dedicated - Pravin - 04.11.2014

You should optimize your script, by creating a stock for certain common or general things which you use often.


Re: High CPU usage on dedicated - DeitY - 04.11.2014

I've created stock for almost everything, i don't know if that could make some problem.

I'm more wondered about onplayerupdate, and timers could make problem?


Re: High CPU usage on dedicated - Pravin - 04.11.2014

YES! Dont use OnPlayerUpdate at all. That's the reason for heavy lags. Trust me, i've experienced about OnPlayerUpdate. And try to have less timers, more timers = more lag. And try not to use stock for silly things.


Re: High CPU usage on dedicated - Infinity001 - 04.11.2014

Buy a bigger CPU.


Re: High CPU usage on dedicated - Runn3R - 04.11.2014

If you're using plugins on the host like crashdetect or nativechecker don't. Erase them they use CPU.


Re: High CPU usage on dedicated - nickdodd25 - 04.11.2014

Could give the Performance profiler plugin a try. https://sampforum.blast.hk/showthread.php?tid=271129
That should show the most heavily used functions and callbacks and should show the issue.

Quote:
Originally Posted by Pravin
View Post
YES! Dont use OnPlayerUpdate at all. That's the reason for heavy lags. Trust me, i've experienced about OnPlayerUpdate. And try to have less timers, more timers = more lag. And try not to use stock for silly things.
I wouldn't say don't use OnPlayerUpdate but definitely watch what you do using it.

And as for more timers = more lag that personally is kinda silly. Same concept as OnPlayerUpdate, if you have crappy unoptimised code running under a timer it will obviously slow things down. From personal experience i can say spreading things out to multiple timers can lighten the load and help with sync if done right.


Re: High CPU usage on dedicated - DiDok - 04.11.2014

Optimize your loops, they rape CPU more than any timer, also don't try making loop inside loop unless you REALLY must do it


Re: High CPU usage on dedicated - Tamer - 04.11.2014

Limit your OnPlayerUpdate usage if you wish to use less CPU, https://sampforum.blast.hk/showthread.php?tid=220089

Go to the end of the first post and read "How To Use OPU In An AC"

Only if you think checking 30 times in second is a lot though, if you really need it, then don't limit it.


Re: High CPU usage on dedicated - DeitY - 04.11.2014

Thank you so much, i will test this performance profiler, and i will check this "How to use OPU in an AC"