[PATCH] D147493: [ELF] Cap parallel::strategy to 16 cores when --threads= is unspecified

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 18:27:10 PDT 2023


MaskRay updated this revision to Diff 512637.
MaskRay retitled this revision from "[ELF] Cap parallel::strategy to 8 cores when --threads= is unspecified" to "[ELF] Cap parallel::strategy to 16 cores when --threads= is unspecified".
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added subscribers: kristof.beyls, krytarowski.
Herald added a reviewer: ctetreau.

8 => 16
update description


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147493/new/

https://reviews.llvm.org/D147493

Files:
  lld/ELF/Driver.cpp


Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1416,8 +1416,12 @@
     config->mllvmOpts.emplace_back(arg->getValue());
   }
 
+  config->threadCount = parallel::strategy.compute_thread_count();
+
   // --threads= takes a positive integer and provides the default value for
-  // --thinlto-jobs=.
+  // --thinlto-jobs=. If unspecified, cap the number of threads since
+  // overhead outweighs optimization for used parallel algorithms for the
+  // non-LTO parts.
   if (auto *arg = args.getLastArg(OPT_threads)) {
     StringRef v(arg->getValue());
     unsigned threads = 0;
@@ -1426,10 +1430,12 @@
             arg->getValue() + "'");
     parallel::strategy = hardware_concurrency(threads);
     config->thinLTOJobs = v;
+  } else if (config->threadCount > 16) {
+    log("set maximum concurrency to 16, specify --threads= to change");
+    parallel::strategy = hardware_concurrency(16);
   }
   if (auto *arg = args.getLastArg(OPT_thinlto_jobs_eq))
     config->thinLTOJobs = arg->getValue();
-  config->threadCount = parallel::strategy.compute_thread_count();
 
   if (config->ltoPartitions == 0)
     error("--lto-partitions: number of threads must be > 0");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147493.512637.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230412/b4bdf0c0/attachment.bin>


More information about the llvm-commits mailing list