SA-MP Forums Archive
Profiler, CPU at 7-13% on 8 cores. - 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: Profiler, CPU at 7-13% on 8 cores. (/showthread.php?tid=487509)



Profiler, CPU at 7-13% on 8 cores. - Kyle - 13.01.2014

KingJ is saying my CPU is high, I've checked and it is averaging 8%, but maxing 13% sometimes. When I said that was low, KingJ told me it was for 8 cores on a whole, even though I'm unsure how it can be calculated like that as SA-MP only uses 1 core.

I've ran a profiler and got the results, could anyone look through and inform me?

Results at http://www.copsandrobbersrpg.com/samp.htm

Not advertising, but no where else to upload to.

Regards


Re: Profiler, CPU at 7-13% on 8 cores. - maddinat0r - 13.01.2014

Maybe you are using a plugin which uses multi-threading? What plugins (and their version numbers) are you using?


Re: Profiler, CPU at 7-13% on 8 cores. - Kyle - 13.01.2014

crashdetect profiler mysql GeoIP_Plugin gvar MerRandom MapAndreas regex RouteConnectorPlugin sscanf streamer irc

Sorry, can't name all the versions, there is so many!


AW: Profiler, CPU at 7-13% on 8 cores. - Mellnik - 13.01.2014

Could you post your update_zones function? Do you call it with a timer, if yes whats its interval?


Re: Profiler, CPU at 7-13% on 8 cores. - Yashas - 13.01.2014

Whats this "normal unknown@fcf08492 6564461 8.15% 175.4 0.0 47.7 6.48% 314.1 0.0 1828.7"

The CPU eater function?

update_zones eating too much of the CPU cycles.

You need to optimize your update_zones code.Is it in a loop or OnPlayerUpdate or somewhere?Show your code.


Re: Profiler, CPU at 7-13% on 8 cores. - Kyle - 13.01.2014

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Whats this "normal unknown@fcf08492 6564461 8.15% 175.4 0.0 47.7 6.48% 314.1 0.0 1828.7"

The CPU eater function?
I've no clue.

As for update zones, it is a loop for all the players then another loop within the loop looping through all the zones, around 400-600 zones. 500 for example * 50 slots = 25k per second! :/


Re: Profiler, CPU at 7-13% on 8 cores. - KingJ - 13.01.2014

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
I've checked and it is averaging 8%, but maxing 13% sometimes. When I said that was low, KingJ told me it was for 8 cores on a whole, even though I'm unsure how it can be calculated like that as SA-MP only uses 1 core.
CPU usage is calculated based on all available cores, so if you have a single process using all 8 cores, then that process is effectively using 100% of the available CPU capacity.

For the most part, the SA-MP server is single threaded, it does perform operations on a few threads but most of the processing, script processing especially, is only performed on a single thread.

Now, a single threaded application can only use at most one core. So if you're fully utilising 1 core of an 8 core server, the CPU usage will be reported as 1/8 = 0.125, or 13% when rounded up.

Hope that helps explain why 13% CPU usage is considered high.


Re: Profiler, CPU at 7-13% on 8 cores. - maddinat0r - 13.01.2014

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Whats this "normal unknown@fcf08492 6564461 8.15% 175.4 0.0 47.7 6.48% 314.1 0.0 1828.7"

The CPU eater function?
Probably. The function name seems unknown, this could happen if the profiler plugin profiled a function in a filterscript not compiled with debug symbols. But the problem is, that ALL 8 cores seemed to be used by the SA:MP server. This could only cause a plugin.

EDIT:
Just realized I understood things wrong (2nd time today :/ ). Then your problem is likely the 'update_zones' callback or the 'IsPlayerInZone' function. Try optimizing them.


Re: Profiler, CPU at 7-13% on 8 cores. - Yashas - 13.01.2014

Show your update_zones code.
25k per second, thats too much for the CPU.
If I am not wrong what your update_zone does is checks the players zone and displays a message showing where is he?

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
Probably. The function name seems unknown, this could happen if the profiler plugin profiled a function in a filterscript not compiled with debug symbols. But the problem is, that ALL 8 cores seemed to be used by the SA:MP server. This could only cause a plugin.
But the fact is the profile shows that update_zones is taking lots of CPU.So lets try to optimize that poor code first then lets see.Though these plugins are multi-threading.


Re: Profiler, CPU at 7-13% on 8 cores. - Kyle - 13.01.2014

Quote:
Originally Posted by KingJ
Посмотреть сообщение
CPU usage is calculated based on all available cores, so if you have a single process using all 8 cores, then that process is effectively using 100% of the available CPU capacity.

For the most part, the SA-MP server is single threaded, it does perform operations on a few threads but most of the processing, script processing especially, is only performed on a single thread.

Now, a single threaded application can only use at most one core. So if you're fully utilising 1 core of an 8 core server, the CPU usage will be reported as 1/8 = 0.125, or 13% when rounded up.

Hope that helps explain why 13% CPU usage is considered high.
The issue looks to be a infinitive loop as diagnosed by Blacklite and D0. I'm looking into my loops now, regards.

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
Probably. The function name seems unknown, this could happen if the profiler plugin profiled a function in a filterscript not compiled with debug symbols. But the problem is, that ALL 8 cores seemed to be used by the SA:MP server. This could only cause a plugin.
I've no FS's included. Just plugins.

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Show your update_zones code.
25k per second, thats too much for the CPU.
If I am not wrong what your update_zone does is checks the players zone and displays a message showing where is he?

But the fact is the profile shows that update_zones is taking lots of CPU.So lets try to optimize that poor code first then lets see.Though these plugins are multi-threading.
Better to paste it into PAWN from pastebin: http://pastebin.com/JsSE88EL