September 28, 2021
https://issues.dlang.org/show_bug.cgi?id=22340

          Issue ID: 22340
           Summary: totalCPUs may not return accurate number of CPUs
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody@puremagic.com
          Reporter: razvan.nitu1305@gmail.com

Taken from Ruby source code [1]:

"man page says CPU_ALLOC takes number of cpus. But it is not accurate explanation. sched_getaffinity() returns EINVAL if cpuset bitmap is smaller than kernel internal bitmap. That said, sched_getaffinity() can fail when a kernel have sparse bitmap even if cpuset bitmap is larger than number of cpus."

[1] https://github.com/ruby/ruby/commit/7d9e04de496915dd9e4544ee18b1a0026dc79242#diff-52a01c201f25446fa66b7489e2c0d573468fdbffad4557fd5f7003936a834229R923

--