[PATCH] [Core] Update references in parallel

Davide Italiano davide at freebsd.org
Mon Mar 16 22:14:33 PDT 2015


Hi ruiu, shankar.easwaran, rafael,

Profiling shows a fair amount of time spent in updateReferences. 
Flamegraphs; https://people.freebsd.org/~davide/llvm/lld.svg
The following patch make updateReference() working in parallel.

Some numbers, linking clang with lld on FreeBSD 11.
This patch shaves 15 seconds making lld 18% faster for this workload.

# Unpatched

real    1m23.951s user    2m43.226s   sys     0m17.333s
real    1m25.684s user    2m45.534s   sys     0m16.882s
real    1m22.960s user    2m40.704s   sys      0m16.323s
real    1m24.512s user    2m44.209s   sys     0m17.052s
real    1m24.591s user    2m43.689s   sys     0m17.472s

# Patched

real    1m12.069s user    2m58.951s   sys     0m17.113s
real    1m8.631s   user    3m4.934s     sys     0m17.344s
real    1m11.175s user    3m1.927s     sys     0m16.072s
real    1m11.530s user    3m3.798s     sys     0m15.587s
real    1m8.922s   user    3m3.654s     sys     0m16.541s

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8372

Files:
  lib/Core/Resolver.cpp

Index: lib/Core/Resolver.cpp
===================================================================
--- lib/Core/Resolver.cpp
+++ lib/Core/Resolver.cpp
@@ -341,7 +341,8 @@
 // to the new defined atom
 void Resolver::updateReferences() {
   ScopedTask task(getDefaultDomain(), "updateReferences");
-  for (const Atom *atom : _atoms) {
+  parallel_for_each(_atoms.begin(), _atoms.end(),
+      [&](const Atom *atom) {
     if (const DefinedAtom *defAtom = dyn_cast<DefinedAtom>(atom)) {
       for (const Reference *ref : *defAtom) {
         // A reference of type kindAssociate should't be updated.
@@ -358,7 +359,7 @@
         const_cast<Reference *>(ref)->setTarget(newTarget);
       }
     }
-  }
+  });
 }
 
 // For dead code stripping, recursively mark atoms "live"

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8372.22070.patch
Type: text/x-patch
Size: 769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150317/b86be740/attachment.bin>


More information about the llvm-commits mailing list