CreateVehicle and CPU
#1

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?
Reply
#2

didn't fixed in 0.3e =(
Reply
#3

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.
Reply
#4

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
Reply
#5

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 ++
Reply
#6

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.
Reply
#7

170 ticks in 1 seconds with sleep 5.
Reply
#8

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

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)