[lld] ad93232 - [lld-macho] Parallelize scanning the symbol tables in export/unexport-ing.

Vy Nguyen via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 12 17:57:45 PST 2021


Author: Vy Nguyen
Date: 2021-11-12T20:57:24-05:00
New Revision: ad932320d89684e23f7952e54bc90c96598db1a3

URL: https://github.com/llvm/llvm-project/commit/ad932320d89684e23f7952e54bc90c96598db1a3
DIFF: https://github.com/llvm/llvm-project/commit/ad932320d89684e23f7952e54bc90c96598db1a3.diff

LOG: [lld-macho] Parallelize scanning the symbol tables in export/unexport-ing.

(Split from D113167)
Benchmarking on one of our large apps which exports a few thousands symbols,
this showed an improvement of ~17%.

x ./LLD_no_parallel.txt
+ ./LLD_with_parallel.txt

    N           Min           Max        Median           Avg        Stddev
x  10         84.01         89.41         88.64        87.693     1.7424061
+  10          71.9         74.29         72.63        72.753    0.77734663
Difference at 95.0% confidence
	-14.94 +/- 1.26763
	-17.0367% +/- 1.44553%
	(Student's t, pooled s = 1.34912)

(wallclock)

Differential Revision: https://reviews.llvm.org/D113820

Added: 
    

Modified: 
    lld/MachO/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 82914c383587..ceaefeda839d 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1462,7 +1462,7 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
     createSyntheticSymbols();
 
     if (!config->exportedSymbols.empty()) {
-      for (Symbol *sym : symtab->getSymbols()) {
+      parallelForEach(symtab->getSymbols(), [](Symbol *sym) {
         if (auto *defined = dyn_cast<Defined>(sym)) {
           StringRef symbolName = defined->getName();
           if (config->exportedSymbols.match(symbolName)) {
@@ -1474,12 +1474,13 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
             defined->privateExtern = true;
           }
         }
-      }
+      });
     } else if (!config->unexportedSymbols.empty()) {
-      for (Symbol *sym : symtab->getSymbols())
+      parallelForEach(symtab->getSymbols(), [](Symbol *sym) {
         if (auto *defined = dyn_cast<Defined>(sym))
           if (config->unexportedSymbols.match(defined->getName()))
             defined->privateExtern = true;
+      });
     }
 
     for (const Arg *arg : args.filtered(OPT_sectcreate)) {


        


More information about the llvm-commits mailing list