SRCDS Steam group


Counterstrike Source Server CPU amount
#1
Hi,

I wanted to run some Counterstrike Source Server with a 100 tickrate on my Root server.
The Server is running with CentOS (64Bit), has a AMD X2 5600+ Dualcore CPU and 4GB RAM.

After installing all the stuff and preparing the server.cfg file (adding name, 6 bots, ...), I checked how much of the CPU the process actually uses.
Shock! Sad
It uses about 30%-60% of a X2 5600+!!! Is this normal? I hope not, otherwise I wont be able to host 2 CS:S Servers ...
An strace of the process shows, that it's calling 3 functions like every 10ms. Here is an example:
Code:
time(NULL)                              = 1229409318
gettimeofday({1229409318, 456573}, NULL) = 0
gettimeofday({1229409318, 456653}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 460042}, NULL) = 0
gettimeofday({1229409318, 460106}, NULL) = 0
gettimeofday({1229409318, 460164}, NULL) = 0
gettimeofday({1229409318, 460221}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 463033}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 466046}, NULL) = 0
gettimeofday({1229409318, 466105}, NULL) = 0
gettimeofday({1229409318, 466161}, NULL) = 0
gettimeofday({1229409318, 466217}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 469060}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 472072}, NULL) = 0
gettimeofday({1229409318, 472131}, NULL) = 0
gettimeofday({1229409318, 472188}, NULL) = 0
gettimeofday({1229409318, 472243}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 475087}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 478101}, NULL) = 0
gettimeofday({1229409318, 478159}, NULL) = 0
gettimeofday({1229409318, 478216}, NULL) = 0
gettimeofday({1229409318, 478271}, NULL) = 0
gettimeofday({1229409318, 478327}, NULL) = 0
accept(7, 0xff92f920, [727806191404580880]) = -1 EAGAIN (Resource temporarily unavailable)
gettimeofday({1229409318, 478516}, NULL) = 0
gettimeofday({1229409318, 478572}, NULL) = 0
recvfrom(4, 0xff919250, 96016, 0, 0xff9191e0, 0xff9191dc) = -1 EAGAIN (Resource temporarily unavailable)
gettimeofday({1229409318, 478726}, NULL) = 0
time(NULL)                              = 1229409318
gettimeofday({1229409318, 484901}, NULL) = 0
gettimeofday({1229409318, 484981}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 488169}, NULL) = 0
gettimeofday({1229409318, 488232}, NULL) = 0
gettimeofday({1229409318, 488291}, NULL) = 0
gettimeofday({1229409318, 488353}, NULL) = 0
nanosleep({0, 1000000}, NULL)           = 0
select(1, [0], NULL, NULL, {0, 0})      = 0 (Timeout)
gettimeofday({1229409318, 492165}, NULL) = 0
gettimeofday({1229409318, 492224}, NULL) = 0
gettimeofday({1229409318, 492281}, NULL) = 0
Question: Is this the normal behavior or did I do something wrong?

I just start a server like this (on a screen called css-server)
Code:
./srcds_run -game cstrike -pingboost 0 +map de_dust2 +maxplayers 12 -secure -tickrate 100 -autoupdate +ip 78.XX.88.77 -port 27015 +servercfgfile css-server1.cfg -pidfile css-server1.pid

Any hints, links, rtfms, ... for "how to reduce the CPU amount of SRCDS" appreciated! Cool

Thanks in advance,
Alex

PS: I heard that I should use custom kernels. Problem is, that I'm quite new to the whole UNIX world.
There is also a MySQL Database, Apache with PHP and Teamspeak running on that machine.
Changing the kernel and stuff would hopefully not affect these services? Big Grin
Reply
#2
Actually form looking that looks normal it calls the time of day function quite often and there has been much talk about this in the fact that it creates alot of unecessary processing power being used. I would recommend a kernel compile it helps to slim the bloat down to only the things you need. Plus it reduces boot time as well. Which CentOS are you running?
*Windows lack of output*
You: Hey, I want to run this program!
Windows: Ok.. It crashed... Now what? Give up?
You:...wtf...
*linux output helpful?*
You: ./My_program
Linux:...Failed!...oo kitties!
You:...wtf...
Reply
#3
Hi,

thanks for the quick answer.

Code:
# cat /etc/issue
CentOS release 5.2 (Final)

# uname -r
2.6.18-92.1.18.el5

PS: Kernel compile sounds difficult Smile
Reply
#4
ashiso Wrote:Hi,

thanks for the quick answer.

Code:
# cat /etc/issue
CentOS release 5.2 (Final)

# uname -r
2.6.18-92.1.18.el5

PS: Kernel compile sounds difficult Smile

You can follow the kernel compile guide on http://www.RussThompson.me under the tutorial section.
Game Server Administration Services
Linux & Windows performance specialist.
http://www.viGeek.net
Reply
#5
OK with this tutorial even the stupid me can compile the kernel, thanks for that!
What options should I set via menuconfig or should it just remain how it is?

Edit:
No, I was wrong: I cannot compile the kernel.
After following the tutorial to "make install" this is what I get:
Code:
# make install
sh /usr/src/linux-2.6.27.9/arch/x86/boot/install.sh 2.6.27.9 arch/x86/boot/bzImage System.map "/boot"
WARNING: Couldn't open directory /lib/modules/2.6.27.9: No such file or directory
FATAL: Could not open /lib/modules/2.6.27.9/modules.dep.temp for writing: No such file or directory
No modules available for kernel "2.6.27.9".
mkinitrd failed
make[1]: *** [install] Error 1
make: *** [install] Error 2
Should I just create the directory "/lib/modules/2.6.27.9" ?

Edit 2:
Stupid me again, I forgot # make modules_install Big Grin
Reply
#6
I'm going to try the kernel stuff posted here:
http://forums.srcds.com/viewtopic/9126

Edit:
OK, I'll have to try this later because it doesn't affect the CPU usage.
The CPU usage after applying the new kernel remains the same. With 6 players on it, 30% - 60%. Sad

Edit 2:
By the way: How is "top" calculating the CPU amount of a process?
I read that SCRDS doesn't support multi threading, so when I start a CS:S server is top calculating the amount taken from one core?
So, when I start a second CS:S server can Linux assign that process to the second core and top calculates the amount for that process for the second core?
Is Linux doing this?
Reply
#7
srcds does not support multiple cores. When using top its only telling you percentage of the core its running on. hyperthreading as its called is supported from the processor itself. you cna get a per core analysis using mpstat and mpstat -P ALL that will give you per core. for a more in depth look try using # sar check its usages it has alot of options. And compiling the kernel does not reduce cpu usage for the game but it does increase performance srcds will always use the same amount of cpu which is why you should improve your server performance.
*Windows lack of output*
You: Hey, I want to run this program!
Windows: Ok.. It crashed... Now what? Give up?
You:...wtf...
*linux output helpful?*
You: ./My_program
Linux:...Failed!...oo kitties!
You:...wtf...
Reply
#8
I just installed sysstat. It'll take a while for sar to gain information.

The part i absolutely don't understand is, that a 100 Tick 10 Slot public server with 10 players on it (me and 9 Bots), takes a CPU amount of 50% - 75% on one core.
(I assigned the process to a core via # taskset -c 1 ./srcds_run ...)
I couldn't find any clue on the net, compiling a newer Kernel didn't change anything.
Is this the normal CPU amount the srcds takes for a CS:S server? I simply can't belief this. How is a gameserver provider even making his money?
I mean come on, 10 slots 100 Tick on a 2,8 GHz Core ...
is this normal, or not?

Ah and # mpstat -P ALL is showing me 3 Cores?
Code:
# mpstat -P ALL
Linux 2.6.27.9 (hostname)     12/18/2008

06:25:54 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
06:25:54 PM  all    4.36    0.04    0.20    0.04    0.02    0.09    0.00   95.24   2154.89
06:25:54 PM    0    2.78    0.02    0.15    0.06    0.00    0.02    0.00   96.97      3.43
06:25:54 PM    1    5.94    0.07    0.25    0.03    0.04    0.16    0.00   93.51      0.15
06:25:54 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00      0.00
Reply
#9
disregard the last core as you can see it shows nothing mine will show the same thing on my core 2 duo. The CPU usage is normal for a 100tick server as you will notice though try increasing the number of available player slots the CPU usage stays the same. Its the 100tick rate that is consuming the cpu plus adding bots which are processor intensive anyway isn't really an accurate measurement. Secondly have you ever even tried running your server with the stock kernel?? I bet you ten bucks that says the tick rate fluctuates alot and doesn't hold at 100tick specially with more than one server. I have a 2.4 duo core running centos 5 64bit and mine would fluctuate badly until I ran the compiled kernel. Like I stated earlier your kernel recompile does not reduce the amount it will take on the processor in fact nothing besides changing hardware will really. I can run 5 servers steady on my box and its only 2.4, 2 of those servers are 100tick. That mpstat is that with your server running???
*Windows lack of output*
You: Hey, I want to run this program!
Windows: Ok.. It crashed... Now what? Give up?
You:...wtf...
*linux output helpful?*
You: ./My_program
Linux:...Failed!...oo kitties!
You:...wtf...
Reply
#10
whilst in top try pressing 1

Smile you'll get multi CPU support

Code:
top - 14:00:47 up  1:21,  5 users,  load average: 0.38, 0.51, 0.75
Tasks: 232 total,   1 running, 229 sleeping,   0 stopped,   2 zombie
Cpu0  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  1.0%us,  0.3%sy,  0.0%ni, 98.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  2.3%us,  2.6%sy,  0.0%ni, 91.5%id,  3.3%wa,  0.0%hi,  0.3%si,  0.0%st
Cpu3  :  1.3%us,  0.0%sy,  0.0%ni, 98.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   2073264k total,  1749020k used,   324244k free,    95568k buffers
Swap:  4128760k total,        0k used,  4128760k free,  1141508k cached
Reply
#11
the cpu% is not really very reliable for source servers. the servers might get laggy way before reaching 100%... also you might experience some effects like running two servers will not result in twice as much cpu load.

if you want to optimize your kernel, you find a howto link in my signature :-) it does not optimize for low cpu load but for a smooth server performance even while running like 2 servers per cpu core.
http://www.fpsmeter.org
http://wiki.fragaholics.de/index.php/EN:Linux_Optimization_Guide (Linux Kernel HOWTO!)
Do not ask technical questions via PM!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)