SA-MP Forums Archive
CPU usage gradually increases as time passes. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CPU usage gradually increases as time passes. (/showthread.php?tid=335098)



CPU usage gradually increases as time passes. - Dairyll - 17.04.2012

Just as the thread title says, the CPU usage gradually increases over time and even faster when people are on. Within 24 hours, I sometimes hit 100% and movements desync so vehicles and people look like they're just sliding from one position to another. I got 6 timers running, 4 of those are in 1000ms and I use MySQL. Any idea how to fix this guys? Thanks in advance!


Re: CPU usage gradually increases as time passes. - ninjahippie - 17.04.2012

What type of server is it ? how much ram does it have to use ?


Re: CPU usage gradually increases as time passes. - Jake187 - 17.04.2012

sometimes it's your host as well so you gotta watch out. I remember serverFFS reading my server of taking up almost 2 duel cores yet once I moved to my very own dedicated server even updating the CPU usage every second I never used more than 5% on a 3.2GHz Duel Core with the same player amount of 250 around. But anyways timers depend like you got 6 timers but are they used a lot? Another thing is one of your plugins could also raise up the CPU usage even mySQL can if not coded right.


Re: CPU usage gradually increases as time passes. - Dairyll - 17.04.2012

I'm hosting a roleplay server on a linux VPS which has nothing in it but SA-MP, MySQL, Apache and the usual stuff. The 4 timers are called every one second, the other 2 are called every 15 minutes+. There's no RAM issue, just CPU usage issue.

I've tried lowering some stuff in the code and the streamers in the server.cfg as well. I've followed some code optimization guides so I'm not really sure what's going on. I have mysql.so, sscanf.so and streamer.so as my plugins.


Re: CPU usage gradually increases as time passes. - Jake187 - 17.04.2012

Quote:
Originally Posted by Dairyll
Посмотреть сообщение
I'm hosting a roleplay server on a linux VPS which has nothing in it but SA-MP, MySQL, Apache and the usual stuff. The 4 timers are called every one second, the other 2 are called every 15 minutes+. There's no RAM issue, just CPU usage issue.
What are these 4 timers doing?


Re: CPU usage gradually increases as time passes. - MP2 - 17.04.2012

Show your OnPlayerUpdate.


Re: CPU usage gradually increases as time passes. - Dairyll - 17.04.2012

They check and set variables, sync time, handle paychecks and other data. I was having problems with them earlier being called at the same time (the timers stopped randomly) so I made them be called on different milliseconds (https://sampforum.blast.hk/showthread.php?tid=334279) and they started working as usual.

Edit:
My OnPlayerUpdate is still the default VX-RP one (http://pastebin.com/gXnMvt27)


Re: CPU usage gradually increases as time passes. - Dairyll - 17.04.2012

What kind of MySQL problem? One of my admins told me something about placing mysql_free_result.

Regarding the timers, they do the same thing at the span of 1000ms. Nothing gets added to their list of tasks unless a new player connects -- that means more variables to process, etc.


Re: CPU usage gradually increases as time passes. - Dairyll - 17.04.2012

Is this (https://sampforum.blast.hk/showthread.php?tid=271129) the performance profiler you're talking about? Thank you for helping so much by the way.


Re: CPU usage gradually increases as time passes. - System64 - 17.04.2012

You have 4 timers and every is 1000ms? Why don't you 'connect' 4 timers in one?
Also, yeah, MySQL takes CPU alot, use threaded queryes and after using mysql_store_result always use mysql_free_result!