[all-commits] [llvm/llvm-project] 51aa61: [hwasan] Fix lock contention on thread creation.
Evgenii Stepanov via All-commits
all-commits at lists.llvm.org
Wed Apr 14 17:14:18 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 51aa61e74bdb394d89217350ddcb0fd04a21e32f
https://github.com/llvm/llvm-project/commit/51aa61e74bdb394d89217350ddcb0fd04a21e32f
Author: Evgenii Stepanov <eugenis at google.com>
Date: 2021-04-14 (Wed, 14 Apr 2021)
Changed paths:
M compiler-rt/lib/hwasan/hwasan_thread_list.h
Log Message:
-----------
[hwasan] Fix lock contention on thread creation.
Do not hold the free/live thread list lock longer than necessary.
This change speeds up the following benchmark 10x.
constexpr int kTopThreads = 50;
constexpr int kChildThreads = 20;
constexpr int kChildIterations = 8;
void Thread() {
for (int i = 0; i < kChildIterations; ++i) {
std::vector<std::thread> threads;
for (int i = 0; i < kChildThreads; ++i)
threads.emplace_back([](){});
for (auto& t : threads)
t.join();
}
}
int main() {
std::vector<std::thread> threads;
for (int i = 0; i < kTopThreads; ++i)
threads.emplace_back(Thread);
for (auto& t : threads)
t.join();
}
Differential Revision: https://reviews.llvm.org/D100348
More information about the All-commits
mailing list