[lld] 3aae04c - [ELF] Parallelize MergeNoTailSection::writeTo

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 17 23:30:48 PST 2021


Author: Fangrui Song
Date: 2021-12-17T23:30:42-08:00
New Revision: 3aae04c744b03eb3eec7376f9d34fa3e42f8d108

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

LOG: [ELF] Parallelize MergeNoTailSection::writeTo

With this patch, writing .debug_str is significantly for a program with
1.5G .debug_str:

* .debug_info 1.22s
* .debug_str 2.57s decreases to 0.66

Added: 
    

Modified: 
    lld/ELF/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 4e4c4c019ffd5..884798e1e6abf 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -3256,8 +3256,8 @@ void MergeTailSection::finalizeContents() {
 }
 
 void MergeNoTailSection::writeTo(uint8_t *buf) {
-  for (size_t i = 0; i < numShards; ++i)
-    shards[i].write(buf + shardOffsets[i]);
+  parallelForEachN(0, numShards,
+                   [&](size_t i) { shards[i].write(buf + shardOffsets[i]); });
 }
 
 // This function is very hot (i.e. it can take several seconds to finish)


        


More information about the llvm-commits mailing list