Optimum Kernel For Ns And Ht Cpus

KorenskyKorensky Join Date: 2003-08-11 Member: 19408Members
Hi,

I'm getting a weird problem that manifests when a marine tries to build (performs +use on an unbuilt structure) -- monitoring the CPU usage with top on another terminal I see it spike to 99.9% and the game client just seems to freeze briefly.

I had some problems getting HT to work (kernel/config issues) so I'm not going to point the finger at HLDS/NS yet since nobody else has reported this. I was wondering what kernels other people out there are running for the linux ns servers and what CPU they are running.

I'm using a P4 2.6 w/ HT -- should be more than enough for me to run 16 player NS server with apache etc in the background for serving low usage websites. Currently running kernel 2.4.22 compiled with SMP support.

richardm@debian:/$ uname -a
Linux debian 2.4.22 #1 SMP Thu Sep 18 20:57:57 EST 2003 i686 GNU/Linux
richardm@debian:/$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel® Pentium® 4 CPU 2.60GHz
stepping : 9
cpu MHz : 2593.549
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 5177.34

processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel® Pentium® 4 CPU 2.60GHz
stepping : 9
cpu MHz : 2593.549
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
bogomips : 5177.34

Any suggestions would be appreciated.

Comments

  • prodigyprodigy Join Date: 2002-11-01 Member: 3180Members
    I don't have problems, but i'm running a slightly newer chip than you.

    root@goliath linux # uname -a
    Linux goliath.uhfco.net 2.6.0-test5 #1 SMP Fri Sep 19 00:38:07 PDT 2003 i686 Intel® Pentium® 4 CPU 3.06GHz GenuineIntel GNU/Linux

    root@goliath linux # cat /etc/gentoo-release
    Gentoo Base System version 1.4.2.9

    root@goliath prodigy # cat /proc/cpuinfo
    processor : 0
    vendor_id : GenuineIntel
    cpu family : 15
    model : 2
    model name : Intel® Pentium® 4 CPU 3.06GHz
    stepping : 7
    cpu MHz : 3080.231
    cache size : 512 KB
    physical id : 0
    siblings : 2
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 2
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
    bogomips : 6147.27

    processor : 1
    vendor_id : GenuineIntel
    cpu family : 15
    model : 2
    model name : Intel® Pentium® 4 CPU 3.06GHz
    stepping : 7
    cpu MHz : 3080.231
    cache size : 512 KB
    physical id : 0
    siblings : 2
    fdiv_bug : no
    hlt_bug : no
    f00f_bug : no
    coma_bug : no
    fpu : yes
    fpu_exception : yes
    cpuid level : 2
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
    bogomips : 6147.27

    I'm running HLDS 3.1.1.1d.

    I've compiled my 2.6.0 kernel with HZ=100 which cuts CPU use by about 30% Why? Default HZ is 1000 which means better FPS at the expense of MORE cpu, in thise case 30% more, by dropping HZ you limit your MAX server FPS to 50, but you gain back precious CPU cycles. )

    You should definately give 2.6.0-test? a try, its much faster, way better scheduling, and allows you to bind hlds processes to separate processors, which makes a difference although slight even with HT.

    How do you change your HZ? I don't recommend doing it, unless you are confident you can compile your kernel without fecking your machine.

    Still want to? Edit /usr/src/linux/include/asm-i386/param.h (or where ever you keep your kernel) and change:

    #ifdef __KERNEL__
    # define HZ 1000 /* Internal kernel timer frequency */
    # define USER_HZ 100 /* .. some user interfaces are in "ticks" */
    # define CLOCKS_PER_SEC (USER_HZ) /* like times() */
    #endif

    to this:

    #ifdef __KERNEL__
    # define HZ 100 /* Internal kernel timer frequency */
    # define USER_HZ 100 /* .. some user interfaces are in "ticks" */
    # define CLOCKS_PER_SEC (USER_HZ) /* like times() */
    #endif

    (change the 1000 to 100).

    If you want to use as much FPS as possible, without lagging the CPU, and you find that with HZ100 you have ~20% cpu free, change it to HZ 250 which will use up that extra cpu, and provide you with some more FPS. 500 (newer RH kernels use this value) will give you even better FPS, again at the expense of some CPU.

    My personal experience, you just can't tell the difference over 30 server FPS. If your server is using even the 20-30 FPS range you should be more than happy.

    Your mileage may vary, but I've had excellent success with 2.6.0 kernels and hlds 3.1.1.1d (YES 3.1.1.1 not 3.1.1.0). With 2.6.0 kernels and HLDS 3.1.1.0 I was seeing near 100% cpu use with 20 players. (the kernel was 1000HZ in all fairness). However, this point is moot since you will not be able to run 3.1.1.0 much longer, so move on and give 3.1.1.1d a try, or even steam which has similar performance.

    For me, I run 2, 20 player NS 2.01-RC2 servers with the following plugins:

    linux addons/metamod/dlls/marinebleed_mm_i586.so
    linux addons/metamod/dlls/parasite_armory_mm_i386.so
    linux addons/metamod/dlls/phase_select_mm_i686.so
    linux addons/metamod/dlls/fakefull-pro_mm.so
    linux addons/metamod/dlls/unstuck_mm.so
    linux addons/metamod/dlls/cdnotify_mm_i586.so
    linux addons/metamod/dlls/medarmory_mm_i686.so.106
    linux addons/metamod/dlls/phase_eq_mm_i386.so
    linux addons/metamod/dlls/selfweld_mm_i386.so
    linux addons/metamod/dlls/umbraspawn_mm_i386.so
    linux addons/metamod/dlls/marineredeem_mm_i386.so.101
    linux addons/hla/dlls/myhladmin_mm_i686.so.81
    linux addons/cdeath/cdmod_i586.so.440

    My servers run @ 60% CPU each when full on the highest useage maps. Obviously there are spikes to 100% on map changes.

    Use the following code to bind your processes to separate cpus:

    affinity.c

    /*
    * Simple command-line tool to set affinity
    * Robert Love, 20020311
    */
    #include <stdio.h>
    #include <stdlib.h>
    #include <sched.h>
    #include "affinity.h"

    int main(int argc, char * argv[])
    {
    unsigned long new_mask;
    unsigned long cur_mask;
    unsigned int len = sizeof(new_mask);
    pid_t pid;
    if (argc != 3) {
    printf(" usage: %s <pid> <cpu_mask>\n", argv[0]);
    return -1;
    }
    pid = atol(argv[1]);
    sscanf(argv[2], "%08lx", &new_mask);
    if (sched_getaffinity(pid, len, &cur_mask) < 0) {
    printf("error: could not get pid %d's affinity.\n", pid);
    return -1;
    }
    printf(" pid %d's old affinity: %08lx\n", pid, cur_mask);
    if (sched_setaffinity(pid, len, &new_mask)) {
    printf("error: could not set pid %d's affinity.\n", pid);
    return -1;
    }
    if (sched_getaffinity(pid, len, &cur_mask) < 0) {
    printf("error: could not get pid %d's affinity.\n", pid);
    return -1;
    }
    printf(" pid %d's new affinity: %08lx\n", pid, cur_mask);
    return 0;
    }

    affinity.h

    define _AFFINITY_H
    #include <sched.h>
    #include <unistd.h>
    #include <linux/unistd.h>
    /*
    * provide the proper syscall information if our libc is not yet updated.
    * It is suggested you check your kernel to make sure these are right for
    * your architecture.
    */
    #if defined(__i386__)
    #define __NR_sched_setaffinity241
    #define __NR_sched_getaffinity242
    #endif
    _syscall3(int, sched_setaffinity, pid_t, pid, unsigned int, len,
    unsigned long *, user_mask_ptr)
    _syscall3(int, sched_getaffinity, pid_t, pid, unsigned int, len,
    unsigned long *, user_mask_ptr)

    gcc affinity.c -o affinity

    Then just affinity PID 1 (bind to cpu 0) or affinity PID 2 (bind to cpu 1) or affinity PID 3 (use kernel scheduler to decide which cpu (will fluctuate between the two, and this is the DEFAULT))

    GL.
  • cracker_jackmaccracker_jackmac Join Date: 2002-11-04 Member: 6891Members, Constellation, Reinforced - Shadow
    edited September 2003
    You don't feel you can update to 2.6.0x then i suggest getting 2.4.22aa1 or 2.4.23-x because they backported the O(1) STREAM schedular for the 2.4 kernel along with a TON of VM work. Robert love also has a Variable HZ patch that will let y ou change it via a menu option (also splits up the userspace timing and kernel timing into 2 sections like 2.6 kernels).

    Don't change the default HZ in default 2.4 kernels as the effects won't be realized. This is my suggestion for rented or colo boxes. unless you know howto upgrade to 2.6 properly as you need new module tools. 2.6 re-wrote all the module code so the 2.4 module tools will not work with 2.6



    <b>Here is the link for the patch for all the goodies. <a href='http://kerneltrap.org/node/view/841' target='_blank'>http://kerneltrap.org/node/view/841</a> This patch is great for systems not involved in SSI. I think only 2 other people who read the forums use SSI so this more than likely doesn't include you</b>
  • cracker_jackmaccracker_jackmac Join Date: 2002-11-04 Member: 6891Members, Constellation, Reinforced - Shadow
    <a href='http://ck.kolivas.org/patches/2.4/2.4.22/2.4.22-cck3/patch-2.4.22-cck3.bz2' target='_blank'>http://ck.kolivas.org/patches/2.4/2.4.22/2...2.4.22-cck3.bz2</a>

    A GREAT server patch. makes NS run ultra smooooooth.


    <a href='http://ck.kolivas.org/patches/2.4/2.4.22/2.4.22-ck2/patch-2.4.22-ck2.bz2' target='_blank'>http://ck.kolivas.org/patches/2.4/2.4.22/2...-2.4.22-ck2.bz2</a>
    More for desktops, but has some good additons as well..


    Both for 2.4.22
  • TweakGamesTweakGames Join Date: 2004-06-21 Member: 29440Members
    edited June 2004
    ok so I see how to make it work on one cpu or the other, but there is no way for my dual xeon machines to both work on it? We all know that you need some crazy machine to be able to run a 32 man NS server, but I would really like to, and I think that if I could get both of my xeons to work on it, the goal would b easily reached. I am able to run 26 nicely though, maybe I should just do that whole HZ thing, down to 100 instead of 1000. That might give me maybe 30 people.

    But still, is there any way to make both of the processors work on the NS process? Is there a way to split up the processes somehow into two parts? Just some questions, I know we would all like to see a NO LAG 32 man NS server. <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html//emoticons/smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /><!--endemo-->
  • KorenskyKorensky Join Date: 2003-08-11 Member: 19408Members
    <!--QuoteBegin-TweakGames+Jun 21 2004, 01:52 PM--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>QUOTE</b> (TweakGames @ Jun 21 2004, 01:52 PM)</td></tr><tr><td id='QUOTE'><!--QuoteEBegin--> But still, is there any way to make both of the processors work on the NS process? <!--QuoteEnd--> </td></tr></table><div class='postcolor'> <!--QuoteEEnd-->
    Unfortunately HLDS is not a multi-threaded process, so no <!--emo&:(--><img src='http://www.unknownworlds.com/forums/html//emoticons/sad-fix.gif' border='0' style='vertical-align:middle' alt='sad-fix.gif' /><!--endemo-->
  • SpurtySpurty Join Date: 2002-11-16 Member: 8944Members, Constellation
    Is source multi-threaded or do we have to suffer another 3 - 6 years of Uniprocessor code?

    Can't someone in Valve just look out the window once in their lives and learn multithreading ?

    Damn, there are sooo many optimizations that are simple to talk about but really hard to deliver. If I were making a game worth a couple of million, I'd employ some professional help to get the server side optimized for the user experience.

    Having said all this, playing CS:S feels like swimming in treacle. <!--emo&::marine::--><img src='http://www.unknownworlds.com/forums/html//emoticons/marine.gif' border='0' style='vertical-align:middle' alt='marine.gif' /><!--endemo-->
  • JacksonHeliyamJacksonHeliyam Join Date: 2012-01-07 Member: 139780Members
    thanks for all i will try...
Sign In or Register to comment.