Search code examples
multicoreg-wanhypervisor

Gwan - Why gwan determine only 1 core?


I am currently testing the gwan web server, I have a question about the default settings for the gwan worker, and the CPU Core detection.

Running gwan on a Xen server (which contains a 4-core Xeon CPU), the gwan.log file reports that only got a single core was detected:

'./gwan -w 4' used to override 1 x 1-Core CPU(s)
[Wed May 22 06:54:29 2013 GMT]   using   1 workers 0[01]0
[Wed May 22 06:54:29 2013 GMT]   among   2 threads 0[11]1
[Wed May 22 06:54:29 2013 GMT]   (can't use more threads than CPU Cores)

[Wed May 22 06:54:29 2013 GMT] CPU: 1x Intel(R) Xeon(R) CPU E5506 @ 2.13GHz
[Wed May 22 06:54:29 2013 GMT]  0 id: 0     0
[Wed May 22 06:54:29 2013 GMT]  1 id: 1     1
[Wed May 22 06:54:29 2013 GMT]  2 id: 2     2
[Wed May 22 06:54:29 2013 GMT]  3 id: 3     3
[Wed May 22 06:54:29 2013 GMT] CPU(s):1, Core(s)/CPU:1, Thread(s)/Core:2

Any idea?

Thanks!!


Solution

  • the gwan.log file reports that I only got a single core:

    Xen, like many other hypervisors, is breaking the CPUID instruction and the /proc/cpuinfo Linux kernel structures (both of which are used by G-WAN to detect CPU Cores).

    As you have seen, this is a real problem for multithreaded applications designed to scale on multicore.

    './gwan -w 4' used to override 1 x 1-Core CPU(s)

    To avoid stupid manual overrides wasting memory and impacting performance, G-WAN checks that the user-supplied thread count is not greater than the actual CPU Core count.

    This is why you have the warning: "(can't use more threads than CPU Cores)".

    To bypass this protection and warning, you can use the -g ("God") mode:

    ./gwan -g -w 4
    

    This command line switch is documented in the G-WAN executable help:

    ./gwan -h
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Usage: gwan [-b -d -g -k -r -t -v -w] [argument]
    (grouped options '-bd' are ignored, use '-b -d')
    
      -b: use the TCP_DEFER_ACCEPT TCP option
          (this is disabling the DoS shield!)
    
      -d: daemon mode (uses an 'angel' process)
          -d:group:user dumps 'root' privileges
    
      -g: do not limit worker threads to Cores
          (using more threads than physical Cores
           will lower speed and waste resources)
    
      -k: (gracefully) kill local gwan processes
          using the pid files of the gwan folder
    
      -r: run the specified C script (and exit)
          for general-purpose code, not servlets
    
      -t: store client requests in 'trace' file
          (may be useful to debug/trace attacks)
    
      -v: return version number and build date
    
      -w: define the number of worker threads.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Available network interfaces (2):
    127.0.0.1 192.168.0.11