Posted: Tue Aug 10, 2010 5:03 pm Post subject: Feature Request, affinity, priority
Hello,
Just thought I'd throw this out into the mix, not sure if it was said already or not. But having the ability to control the priority and affinity via control panel would be marvelous.
Valve recommends running srcds at above normal priority, and there is quite a difference in performance. It's a bit of a hassle to login to Remote Desktop and set priority's and cpu affinity's. I am a GSP, and I have a quad core system, and a dual core system, and it's absolutely essential that I be able to evenly balance the servers, so that they all don't depend on the first core.
Also if anyone has a quick work around, to make programs start with preset affinity/priorities my ears are open
I highly recommend Priffinity 2 for Affinity and Priority Setting. It can reset the affinity if the server task crashes or restarts, and can differentiate between server tasks (some affinity setting programs will only set the affinity by the program name). I use it on a dual core server (which means setting affinity is quite important and highly recommend it.
Is there something similar for Linux? I would flip out if someone could call a program which is able to change priorities without losing the track of the process when it crashes
We have internal support for process priority on Windows (Linux is not implemented, but can sort of be done using the 'nice' tool) and round-robin CPU core affinity (allocate the process to 1 core only round robin style).
Unfortunately at this time these features are not fully exposed to users, so you would need to manage this yourself.
I wonder if you can write a script that looks for 'srcds.exe' running (for example) and simply have that script apply the priority settings when it notices a new process with that name has started?
Writing it in a .Net console application would be my first choice.
1. Create a script which runs every few minutes via cron and renices/reaffines processes.
2. Wrap the script which starts the game server (in your case srcds_run) with a script which does the renicing/reaffining of the original script.
renice can't search for process names by itself, but you can find the pid in
a number of ways. I suppose the easiest is to use 'pidof'. The script can look
something like this:
Code:
#!/bin/bash
pids=`pidof srcds.x86`
for pid in ${pids}; do renice -5 ${pid}; done
It is untested, but I wouldn't be surprised if it works
Try to run it as root while your servers are running. Use 'top' to verify that their niceness changed after running it. It it does work, simply add it to cron as root. If it doesn't work, let me know what goes wrong and I'll fix it.
Why root? Because in order to renice any process to a higher level (a lower number), you need the correct privileges.
First check which process actually runs. I wrote "srcds.x86" above, which is wrong. It should be srcds_somethingorother. To find out, type 'ps aux | grep srcds'. Then simply substitute whatever the process is called in the script where I wrote srcds.x86. Also, make sure you copied the script exactly, paying particular care to get the ` correct (note: ' and ` are not the same)
Which process reports -10 in the NI-column in top? srcds_something? If so it is already running at a high priority (the number is low because it is not being very nice to the other processes on your host). If that's what you want, then problem solved, no?
The problem is, that the script does not seem to change anything.... A manual "renice -5 PID" works.
EDIT: If you simply type in "pidof srcds_linux" and send it, should there be any output?
EDIT2: Oh, there is xD
EDIT3: Oh god damn.......it works. As you see above, there is a typo "scrds_linux != srcds_linux". Nevermind, it works
EDIT4: Ok, another problem. What do I have to type in, if I have different CoD4 servers running? A simple "pidof "Reign of the Undead 1"" does not work.
Great! I'm assuming that this is the only remaining question?
LukLuk wrote:
EDIT4: Ok, another problem. What do I have to type in, if I have different CoD4 servers running? A simple "pidof "Reign of the Undead 1"" does not work.
The original script iterates over all running srcds_linux processes, so if you want the same niceness for all your COD4-servers, simply replace "srcds_linux" with "cod4_lnxded-bin".
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum