Skip to content
Snippets Groups Projects

[Runtime] use pthread_getaffinity_np to determine default worker count

Merged Florian Fischer requested to merge aj46ezos/emper:improve-default-worker-count into master
  1. Jul 05, 2021
    • Florian Fischer's avatar
      [Runtime] use pthread_getaffinity_np to determine default worker count · 7cb1a828
      Florian Fischer authored
      The value reported by std::thread::hardware_concurrency() can be more
      than the available CPUs to the current process for example if EMPER runs
      in a container or qemu.
      GNU nproc(1) does the right thing and we can take inspiration from them.
      The solution is to use pthread_getaffinity_np which fills a CPU set with
      all CPU a pthread can be scheduled on.
      We use this more precise CPU count if possible.
      7cb1a828
Loading