As requested here: https://reviews.llvm.org/D75153#1987272
Before, each instance of llvm-cov was creating one thread per hardware core, which wasn't needed probably because the number of inputs were small. This was probably causing a thread rlimit issue on large core count systems.
After this patch, the previous behavior is restored (to what was before rG8404aeb5):
- If --num-threads is not specified, we create one thread per input, up to num.cores.
- When specified, --num-threads indicates any number of threads, with no upper limit.
Petr, could you please confirm that this patch fixes the issue?
Note that sys::getHostNumPhysicalCores can return -1 in some cases (on some OS/arch). In such cases we will return 1 if ThreadsRequested == 0.
I still think that if the user asks for more threads than the CPU supports, we should respect that. For one thing, not every task can fully leverage 100% of the computing power of a core.