SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Bug Reports

Reply
 
Thread Tools Display Modes
Old 15/04/2012, 04:48 AM   #1
SPAWN_METAL
Huge Clucker
 
Join Date: Dec 2010
Posts: 263
Reputation: 31
Default

Run this clear script as gamemode and test CPU usage of server

Code:
#include <a_samp>

main(){}

public OnGameModeInit()
{
    for(new i=0;i<2000;i++) CreateVehicle(411,random(6000)-3000,random(6000)-3000,random(6000)-3000,0,0,0,1);
}
If you run it on win system CPU will be 0%
If you run it on linux system CPU will be 5%-9%.
If you set respawn delay to 0 on linux CPU will be 0%-1%.

If I set in server.cfg sleep = 100 (mean 10 proccess tick's in second) CPU = 0%-1%
If I set in server.cfg sleep = 1 (up to 1000 proccess tick's) CPU = ~20%

It's check for vehicle's respawn delay every proccess tick => ~170 ticks for every vehicles in second with standart sleep 5 => 170 * 2000 = 340000 checks only for vehicles in 1 second?

Why there is vehicle's check every proccess tick? May be need check every 100 ms or 200 ms or 400ms? And why on win there is no CPU usage from vehicles?

Last edited by SPAWN_METAL; 12/05/2012 at 09:44 AM.
SPAWN_METAL is offline   Reply With Quote
Old 11/05/2012, 08:30 PM   #2
SPAWN_METAL
Huge Clucker
 
Join Date: Dec 2010
Posts: 263
Reputation: 31
Default

didn't fixed in 0.3e =(
SPAWN_METAL is offline   Reply With Quote
Old 11/05/2012, 08:33 PM   #3
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,316
Reputation: 909
Default Re: CreateVehicle and CPU

So what you're saying is the server is checking EVERY vehicle's respawn time, every single 'tick'? Surely it should only be checked once a second..? If that is the case it should be changed.
__________________
>> Click here to see my releases.

Please do not PM me requesting help. Here you have a forum with 11,000+ active users - why are you limiting your help to one person?
MP2 is offline   Reply With Quote
Old 11/05/2012, 10:47 PM   #4
new121
Huge Clucker
 
Join Date: Feb 2012
Posts: 364
Reputation: 21
Default Re: CreateVehicle and CPU

Quote:
Originally Posted by SPAWN_METAL View Post
Run this clear script as gamemode and test CPU usage of server

Code:
#include <a_samp>

main(){}

public OnGameModeInit()
{
    for(new i=0;i<2000;i++) CreateVehicle(411,random(6000)-3000,random(6000)-3000,random(6000)-3000,0,0,0,1);
}
If you run it on win system CPU will be 0%
If you run it on linux system CPU will be 5%-9%.
If you set respawn delay to 0 on linux CPU will be 0%-1%.

If I set in server.cfg sleep = 100 (mean 10 proccess tick's in second) CPU = 0%-1%
If I set in server.cfg sleep = 1 (up to 1000 proccess tick's) CPU = ~20%

It's check for vehicle's respawn delay every proccess tick = ~170 for every vehicles in second with standart sleep 5 => 170 * 2000 = 340000 checks only for vehicles?

Why there is vehicle checking every procces tick? May be need every 100 ms or 200 ms or 400ms? And why on win there is no CPU usage from vehicles?
Thanks for this thread you managed to reduce our CPU by about half
__________________
http://skilladept.com

Team Speak IP: 176.31.241.180

Server IP: 176.31.241.180:1337

From scratch role play script with an active player base please check us out!
new121 is offline   Reply With Quote
Old 11/05/2012, 10:49 PM   #5
Kreyg
Little Clucker
 
Join Date: Jan 2012
Posts: 41
Reputation: 5
Default Re: CreateVehicle and CPU

We were having a bit of a CPU load issue with our server. This helped A LOT. Thank you so much for sharing this info! rep ++
Kreyg is offline   Reply With Quote
Old 12/05/2012, 09:33 AM   #6
leong124
High-roller
 
leong124's Avatar
 
Join Date: Jun 2008
Location: Hong Kong, China
Posts: 1,738
Reputation: 134
Default Re: CreateVehicle and CPU

Actually I'm not sure how can you deduce the data of 170 checks per tick. The sleep setting in server.cfg can't prove that it is affected by CreateVehicle(respawn settings). The smaller sleep time means the CPU will spend more time on the server, instead of other (background) programs, so that it will consume more of the CPU time and it shows higher CPU usage. Correct me if I'm wrong.
__________________
[KDT_MS]hk_shade

Sorry for my bad English and my weakness in expressing myself.
leong124 is offline   Reply With Quote
Old 12/05/2012, 09:42 AM   #7
SPAWN_METAL
Huge Clucker
 
Join Date: Dec 2010
Posts: 263
Reputation: 31
Default Re: CreateVehicle and CPU

170 ticks in 1 seconds with sleep 5.
SPAWN_METAL is offline   Reply With Quote
Old 12/05/2012, 11:55 AM   #8
leong124
High-roller
 
leong124's Avatar
 
Join Date: Jun 2008
Location: Hong Kong, China
Posts: 1,738
Reputation: 134
Default Re: CreateVehicle and CPU

My main question is that how can you know that the check is done on every tick?
__________________
[KDT_MS]hk_shade

Sorry for my bad English and my weakness in expressing myself.
leong124 is offline   Reply With Quote
Old 15/05/2012, 06:53 AM   #9
Kalcor
SA-MP Developer
 
Join Date: Apr 2005
Posts: 619
Reputation: 1924
Default Re: CreateVehicle and CPU

You definitely don't want to use sleep 100. That would mean everyone would have a minimum of 100 ping.

The SA-MP server might use slightly more CPU on linux. There are several reasons for this, but the biggest factor is that most current linux kernels have high-res timer kernel module loaded, which means thread sleep cycles are very accurate.

A server host that ran SA-MP on linux and was concerned about CPU could unload the high-res timers module in the kernel.

More CPU and lower pings mean higher performance and less lag.
Kalcor is offline   Reply With Quote
Old 19/05/2012, 01:00 PM   #10
SeoToX
Little Clucker
 
Join Date: Oct 2011
Posts: 29
Reputation: 0
Default Re: CreateVehicle and CPU

Very useful information! I changed our vehicles respawn delay from 600000 to 0, and the cpu usage reduced by 40-50% (8% to 3-5%)

+rep
SeoToX 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
[FilterScript] [Help] CreateVehicle. Mister. M Filterscripts 3 13/04/2011 02:31 PM
CreateVehicle ? park4bmx Help Archive 2 23/02/2011 12:16 PM
CreateVehicle could lag? Osviux Help Archive 3 27/12/2010 07:38 PM
CreateVehicle barneystinson Help Archive 8 20/11/2010 07:09 PM
Need help on CreateVehicle DragonBlaster50 Help Archive 7 27/07/2010 09:39 AM


All times are GMT. The time now is 01:06 AM.


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