Skip to content

Commit 0baf13e

Browse files
committed
[lld/mac] Parallelize code signature computation
According to ministat, this is a small but measurable speedup (using the repro in PR56121): N Min Max Median Avg Stddev x 10 3.7439518 3.7783802 3.7730219 3.7655502 0.012375226 + 10 3.6149218 3.692198 3.6519327 3.6502951 0.025905601 Difference at 95.0% confidence -0.115255 +/- 0.0190746 -3.06078% +/- 0.506554% (Student's t, pooled s = 0.0203008) (Without 858e8b1, this change here to use parallelFor is an 18% speedup, and doing 858e8b1 on top of this change is just a 2.55% +/- 0.58% win. Doing both results in a total speedup of 20.85% +/- 0.44%.) Differential Revision: https://reviews.llvm.org/D128298
1 parent 6d6268d commit 0baf13e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lld/MachO/SyntheticSections.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "llvm/Support/EndianStream.h"
2323
#include "llvm/Support/FileSystem.h"
2424
#include "llvm/Support/LEB128.h"
25+
#include "llvm/Support/Parallel.h"
2526
#include "llvm/Support/Path.h"
2627

2728
#if defined(__APPLE__)
@@ -1247,11 +1248,11 @@ void CodeSignatureSection::writeHashes(uint8_t *buf) const {
12471248
// NOTE: Changes to this functionality should be repeated in llvm-objcopy's
12481249
// MachOWriter::writeSignatureData.
12491250
uint8_t *hashes = buf + fileOff + allHeadersSize;
1250-
for (uint64_t i = 0; i < getBlockCount(); ++i) {
1251+
parallelFor(0, getBlockCount(), [&](size_t i) {
12511252
sha256(buf + i * blockSize,
12521253
std::min(static_cast<size_t>(fileOff - i * blockSize), blockSize),
12531254
hashes + i * hashSize);
1254-
}
1255+
});
12551256
#if defined(__APPLE__)
12561257
// This is macOS-specific work-around and makes no sense for any
12571258
// other host OS. See https://openradar.appspot.com/FB8914231

0 commit comments

Comments
 (0)