Subject RE: [firebird-support] CpuAffinityMask
Author Helen Borrie
At 02:58 AM 15/12/2009, Dunbar, Norman wrote:

>>> Dear All, I would like to ask the CpuAffinityMask setting
>This setting says that "make sure that Firebird ONLY ever runs on this
>CPU. Do not allow the OS to schedule Firebird onto any other CPU in
>order to balance the load."

Not quite. The setting tells Windows which processors to use for Superserver. So it is possible to set it to multiple processor BUT YOU SHOULD NOT DO IT.
The installer default is 1 (use only CPU 0) but there is nothing wrong with setting it to another *single* processor - as long as it is a physical CPU and not a hyperthreaded virtual one.

>The reason being that under windows, swapping CPUs introduces a quite
>sever performance penalty. Especially as normally, the load balancer
>decides to switch Firebird to another CPU almost as soon as it gets to
>the new one!

What it seems to do on Windoze is switch the entire process to another CPU as soon as the load on the initial one approaches 100%.

For Windows Classic or any non-Windows server platform, just ignore this setting.

>> So, if I have quad CPU and I 'd like to use all of them then what
>> should I set the number of CpuAffinityMask ?
>Pick a number between 1 and 4, and run on one core only is best.

No, it's calculated from a bitmask of the CPU numbers, so any number that is not an exponent of 2 will set affinity to multiple CPUs (which we don't want).


CPU0 only = 2^0 = 1 (first CPU) - OK
CPU1 only = 2^1 = 2 (second CPU) - OK
CPU0 and CPU1 = 2^0 + 2^1 = 1 + 2 = 3 [DON'T USE]
CPU2 only = 2^2 = 4 (third CPU) - OK
CPU3 only = 2^3 = 8 (fourth CPU) - OK
CPU0 AND CPU2 = 2^0 + 2^2 = 1 + 4 = 5 [DON'T USE]
CPU1 AND CPU2 = 2^1 + 2^2 = 2 + 4 = 6 [DON'T USE]
CPU1 AND CPU3 = 2^1 + 2^3 = 2 + 8 = 10 [DON'T USE]
...and so on...

[Norman, could you do something about the company message in your email footers, please?]