SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/08/2019, 08:29 PM   #1
Hillo
Big Clucker
 
Join Date: Dec 2012
Posts: 106
Reputation: 2
Default High CPU usage, please help me

Hello everyone.

I have had a weird problem in my server for a long time now, where the CPU usage randomly goes to 100% (sometimes even more) and that's why the server freezes (hangs), that the server shows as online in the SA-MP client but in fact it isn't, or gets closed itself (it does both of them, it changes).

Sometimes the server hangs/gets closed instantly when a player joins, and sometimes it hangs otherwise. It would even hang for example if there are 0 players in the server, and someone joins. Sometimes the server can be up for 30+ hours before it hangs, and sometimes it hangs earlier.

And the CPU usage is always around 2-4% (it doesn't matter that are there 2 or 20 players, the CPU usage is always still around 2-4%), but when the server hangs, it literally goes directly to ~90% and then (while the server is already hanged) it increases to 100% (sometimes even more, like 100.4% or something). Also, the server does not have any lag at all. No warning messages about acks limit or anything else in the server log. And no, I don't have any infinite loops, so don't question me on this. My server version is 0.3.7-R2. I'm using a paid gameserver host (linux).

(Few times my host didn't even show the CPU and RAM usage while the server was hanged, it just showed "%" icon, but no numbers).

Things I have done to try to fix it:
- Updated plugins to the latest version (sscanf, streamer, IRC and whirlpool)
- Removed all code under OnPlayerUpdate (+ I don't use many timers as well, but I use 2 1-second timers)
- Used crashdetect plugin, it didn't show any error messages
- Redefined MAX_PLAYERS (to the amount how many slots I have in the server.cfg, I do have 8 NPCs, I didn't set that amount that how many slots are in the server after the NPCs are added)

None of these helped. What in the world would cause this problem? Bad host (CPU)? Or is it an issue in this SA-MP version itself?

Also, every .rec files are over 2 MB+, so could it be that then?


Thanks in advance.
__________________
-

Last edited by Hillo; 16/08/2019 at 09:23 PM.
Hillo is offline   Reply With Quote
Old 17/08/2019, 07:16 AM   #2
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 662
Reputation: 96
Default Re: High CPU usage, please help me

In "hang" state, send SIGINT to the server process. Hopefully, you will get more details from crashdetect in case of infinite loop.

Next step is to profile it: https://forum.sa-mp.com/showthread.php?t=271129
Calisthenics is offline   Reply With Quote
Old 18/08/2019, 09:14 PM   #3
Hillo
Big Clucker
 
Join Date: Dec 2012
Posts: 106
Reputation: 2
Default Re: High CPU usage, please help me

Quote:
Originally Posted by Calisthenics View Post
In "hang" state, send SIGINT to the server process. Hopefully, you will get more details from crashdetect in case of infinite loop.

Next step is to profile it: https://forum.sa-mp.com/showthread.php?t=271129
I don't understand, how to do it? Also, I don't know how to use that plugin (I tried it before but it didn't give the file with the errors).
__________________
-
Hillo is offline   Reply With Quote
Old 19/08/2019, 01:44 AM   #4
DRIFT_HUNTER
High-roller
 
Join Date: Oct 2009
Posts: 2,073
Reputation: 184
Default Re: High CPU usage, please help me

Try profiler plugin, it should tell you where the problem is when it happens.
__________________
Looking for someone to start drifting server, drop me a pm if you are interested.


Any PM's that include question about any kind of help will be ignored.
Use appropriate boards for that
DRIFT_HUNTER is offline   Reply With Quote
Old 22/08/2019, 11:41 PM   #5
Hillo
Big Clucker
 
Join Date: Dec 2012
Posts: 106
Reputation: 2
Default Re: High CPU usage, please help me

Quote:
Originally Posted by DRIFT_HUNTER View Post
Try profiler plugin, it should tell you where the problem is when it happens.
Read what I said above:
Quote:
Originally Posted by Hillo View Post
I don't know how to use that plugin (I tried it before but it didn't give the file with the errors).
__________________
-
Hillo is offline   Reply With Quote
Old 22/08/2019, 11:48 PM   #6
willttoonn
Gangsta
 
willttoonn's Avatar
 
Join Date: Nov 2011
Location: Brazil
Posts: 876
Reputation: 62
Default Re: High CPU usage, please help me

Try this.
__________________
Sometimes a captain has to make the unpopular call because that's his responsibility
willttoonn is offline   Reply With Quote
Old 23/08/2019, 12:02 AM   #7
Hillo
Big Clucker
 
Join Date: Dec 2012
Posts: 106
Reputation: 2
Default Re: High CPU usage, please help me

Quote:
Originally Posted by willttoonn View Post
Try this.
I already transfered OnPlayerUpdate to (4) timers, and they already have different interval. I save players' data only on OnPlayerDisconnect.

Also, I noticed that the server doesn't crash if no one joins it. And also, I restarted it for a few times and when I joined it after that, so it crashed twice.
__________________
-
Hillo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cpu high usage TheWhiteEarth Server Support 5 16/02/2014 11:43 AM
High CPU Usage CONTROLA Scripting Help 1 23/09/2013 06:34 PM
High CPU usage. The__ Scripting Help 5 03/04/2013 04:15 PM
High CPU Usage jop9888 Scripting Help 0 21/07/2012 07:31 PM
High RAM usage Pooh7 Server Support 7 12/02/2012 08:49 PM


All times are GMT. The time now is 01:04 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.