[PATCH] D128298: [lld/mac] Parallelize code signature computation
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 12:32:13 PDT 2022
thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added projects: lld-macho, All.
thakis requested review of this revision.
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 858e8b17f7365 <https://reviews.llvm.org/rG858e8b17f73652f9b79a8fd409b1f873c50ecd53>, this change here to use parallelFor is an 18% speedup,
and doing 858e8b17f7365 <https://reviews.llvm.org/rG858e8b17f73652f9b79a8fd409b1f873c50ecd53> 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%.)
https://reviews.llvm.org/D128298
Files:
lld/MachO/SyntheticSections.cpp
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -22,6 +22,7 @@
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LEB128.h"
+#include "llvm/Support/Parallel.h"
#include "llvm/Support/Path.h"
#if defined(__APPLE__)
@@ -1254,11 +1255,11 @@
// NOTE: Changes to this functionality should be repeated in llvm-objcopy's
// MachOWriter::writeSignatureData.
uint8_t *hashes = buf + fileOff + allHeadersSize;
- for (uint64_t i = 0; i < getBlockCount(); ++i) {
+ parallelFor(0, getBlockCount(), [&](size_t i) {
sha256(buf + i * blockSize,
std::min(static_cast<size_t>(fileOff - i * blockSize), blockSize),
hashes + i * hashSize);
- }
+ });
#if defined(__APPLE__)
// This is macOS-specific work-around and makes no sense for any
// other host OS. See https://openradar.appspot.com/FB8914231
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128298.438800.patch
Type: text/x-patch
Size: 1018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220621/ed99f8b2/attachment.bin>
More information about the llvm-commits
mailing list