6.3.9.Setting CPU Affinity

If one runs multiple Virtuoso processes on a physical machine it may be advantageous to bind the processes to a physical CPU. In this way one may be certain that memory allocated for the processes is local to the CPU on which the process runs. This is specially important for servers with more than 2 CPU sockets, as there can be high variability in memory access latency Even with dual-socket Intel servers there caan be performance gains of up to 20% from setting CPU affinity if the workload is well balanced. On the other hand if the workload is not balanced, binding a process to a CPU may lead to less platform utilization than not specifying affinity.

There are two settings in the virtuoso.ini for affinity:

  1. Affinity

    is the overall affinity for threads of the server process and is specified by comma-separated CPU numbers or ranges of numbers.

  2. ListenerAffinity

    is the affinity of the thread handling incoming cluster traffic. In the interest of low latency, it may be advantageous to bind the listener thread to a core of its own, so that it will never be preempted. This can decrease the incidence of blocking on write for other processes since incoming messages will be read at full interface speed all the time.

For example:

...
Affinity = 1-7, 16-23
ListenerAffinity = 0
...

specifies that the process is bound to CPU 0 of a dual socket 16 core 32 thread system.

See numactl -- hardware for the actual numbers of the cores on each CPU. CPU 0, i.e. first thread of first core is here exclusively allocated to network traffic and canbnot be preempted by any other thread running for the server process.