SA-MP Forums Archive
CreateVehicle and CPU - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: CreateVehicle and CPU (/showthread.php?tid=334525)



- ][Noname][ - 15.04.2012

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

Код:
#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?


- ][Noname][ - 11.05.2012

didn't fixed in 0.3e =(


Re: CreateVehicle and CPU - MP2 - 11.05.2012

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.


Re: CreateVehicle and CPU - new121 - 11.05.2012

Quote:
Originally Posted by SPAWN_METAL
Посмотреть сообщение
Run this clear script as gamemode and test CPU usage of server

Код:
#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


Re: CreateVehicle and CPU - Kreyg - 11.05.2012

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 ++


Re: CreateVehicle and CPU - leong124 - 12.05.2012

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.


Re: CreateVehicle and CPU - ][Noname][ - 12.05.2012

170 ticks in 1 seconds with sleep 5.


Re: CreateVehicle and CPU - leong124 - 12.05.2012

My main question is that how can you know that the check is done on every tick?


Re: CreateVehicle and CPU - Kalcor - 15.05.2012

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.


Re: CreateVehicle and CPU - SeoToX - 19.05.2012

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