[compiler-rt] 437b760 - [NFC][lsan] Use LowLevelAllocator to allocate ThreadContext
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 17 20:05:37 PDT 2023
Author: Vitaly Buka
Date: 2023-04-17T20:05:26-07:00
New Revision: 437b7602e4a998220871de78afcb020b9c14a661
URL: https://github.com/llvm/llvm-project/commit/437b7602e4a998220871de78afcb020b9c14a661
DIFF: https://github.com/llvm/llvm-project/commit/437b7602e4a998220871de78afcb020b9c14a661.diff
LOG: [NFC][lsan] Use LowLevelAllocator to allocate ThreadContext
This is more RAM and CPU efficient than allocating entire page per
context, and this approach is used by other sanitizers already.
With the patch "create_thread_loop2.cpp.tmp 5000" is 30% faster.
Added:
Modified:
compiler-rt/lib/lsan/lsan_thread.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/lsan/lsan_thread.cpp b/compiler-rt/lib/lsan/lsan_thread.cpp
index f1075afe9ef6..9da42f32e06b 100644
--- a/compiler-rt/lib/lsan/lsan_thread.cpp
+++ b/compiler-rt/lib/lsan/lsan_thread.cpp
@@ -25,9 +25,12 @@ namespace __lsan {
static ThreadRegistry *thread_registry;
+static Mutex mu_for_thread_context;
+static LowLevelAllocator allocator_for_thread_context;
+
static ThreadContextBase *CreateThreadContext(u32 tid) {
- void *mem = MmapOrDie(sizeof(ThreadContext), "ThreadContext");
- return new (mem) ThreadContext(tid);
+ Lock lock(&mu_for_thread_context);
+ return new (allocator_for_thread_context) ThreadContext(tid);
}
void InitializeThreadRegistry() {
More information about the llvm-commits
mailing list