diff options
author | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2020-04-24 15:28:01 -0400 |
---|---|---|
committer | Alexandre Ganea <alexandre.ganea@ubisoft.com> | 2020-04-24 15:28:25 -0400 |
commit | 0e13a0331fb90078bf71cc0c4612492a6954a5d0 (patch) | |
tree | 9b96f8665fadce4dd425bed64a0bf82099421578 /llvm/tools/llvm-cov/CoverageReport.cpp | |
parent | 0e2bd49370197dd8bf2c36ee0ce1275f7cfb515b (diff) | |
download | llvm-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/tools/llvm-cov/CoverageReport.cpp')
-rw-r--r-- | llvm/tools/llvm-cov/CoverageReport.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/tools/llvm-cov/CoverageReport.cpp b/llvm/tools/llvm-cov/CoverageReport.cpp index 187e2dc..8509710 100644 --- a/llvm/tools/llvm-cov/CoverageReport.cpp +++ b/llvm/tools/llvm-cov/CoverageReport.cpp @@ -352,12 +352,15 @@ std::vector<FileCoverageSummary> CoverageReport::prepareFileReports( ArrayRef<std::string> Files, const CoverageViewOptions &Options, const CoverageFilter &Filters) { unsigned LCP = getRedundantPrefixLen(Files); - auto NumThreads = Options.NumThreads; - // If NumThreads is not specified, auto-detect a good default. - if (NumThreads == 0) - NumThreads = Files.size(); - ThreadPool Pool(heavyweight_hardware_concurrency(NumThreads)); + ThreadPoolStrategy S = hardware_concurrency(Options.NumThreads); + if (Options.NumThreads == 0) { + // If NumThreads is not specified, create one thread for each input, up to + // the number of hardware cores. + S = heavyweight_hardware_concurrency(Files.size()); + S.Limit = true; + } + ThreadPool Pool(S); std::vector<FileCoverageSummary> FileReports; FileReports.reserve(Files.size()); |