CPU detection should consider CPU affinity
(Ref: https://techsupport.isc.org/Ticket/Display.html?id=23847)
A customer has stated that the current method of detecting CPU count via sysctlbyname("hw.ncpu" ...)
does not consider CPU affinity.
A general suggestion around cpuset_getaffinity() was offered:
#include <sys/cpuset.h>
cpuset_t mask;
CPU_ZERO(&mask);
if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1,
sizeof(mask), &mask) != 0)
...error_handling...;
result = CPU_COUNT(&mask);