aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Threading.cpp
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2020-04-24 15:28:01 -0400
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>2020-04-24 15:28:25 -0400
commit0e13a0331fb90078bf71cc0c4612492a6954a5d0 (patch)
tree9b96f8665fadce4dd425bed64a0bf82099421578 /llvm/lib/Support/Threading.cpp
parent0e2bd49370197dd8bf2c36ee0ce1275f7cfb515b (diff)
downloadllvm-0e13a0331fb90078bf71cc0c4612492a6954a5d0.zip
llvm-0e13a0331fb90078bf71cc0c4612492a6954a5d0.tar.gz
llvm-0e13a0331fb90078bf71cc0c4612492a6954a5d0.tar.bz2
[llvm-cov] Prevent llvm-cov from using too many threads
As reported 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. Differential Revision: https://reviews.llvm.org/D78408
Diffstat (limited to 'llvm/lib/Support/Threading.cpp')
-rw-r--r--llvm/lib/Support/Threading.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index 4bf373d..61f8ee5 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -84,14 +84,15 @@ void llvm::llvm_execute_on_thread_async(
int computeHostNumHardwareThreads();
unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
- if (ThreadsRequested > 0)
- return ThreadsRequested;
-
int MaxThreadCount = UseHyperThreads ? computeHostNumHardwareThreads()
: sys::getHostNumPhysicalCores();
if (MaxThreadCount <= 0)
MaxThreadCount = 1;
- return MaxThreadCount;
+ if (ThreadsRequested == 0)
+ return MaxThreadCount;
+ if (!Limit)
+ return ThreadsRequested;
+ return std::min((unsigned)MaxThreadCount, ThreadsRequested);
}
namespace {