pthread_setname_np does linear search over all thread descriptors
to map pthread_t to the thread descriptor. This has O(N^2) complexity
and becomes much worse in the new tsan runtime that keeps all ever
existed threads in the thread registry.
Replace linear search with direct access if pthread_setname_np
is called for the current thread (a very common case).
Details
Details
- Reviewers
vitalybuka melver - Commits
- rG64b45399e5c5: tsan: speed up pthread_setname_np
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp | ||
---|---|---|
2137 | This part looks unrelated |
Comment Actions
The new test is failing on our Arch64 bots:
https://lab.llvm.org/buildbot/#/builders/179/builds/1761
That one is a stage 2 failure but same thing happens on other 1 stage bots and in local builds.
Actual output:
starting transient threads... starting persistent threads... ThreadSanitizer: CHECK failed: tsan_rtl.cpp:327 "((addr + size)) <= ((TraceMemEnd()))" (0xf06200e03010, 0xf06200000000) (tid=2492946) #0 __tsan::CheckUnwind() /home/david.spickett/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:357 (bench_threads.cpp.tmp+0x4a1b84) #1 __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) /home/david.spickett/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_termination.cpp:86 (bench_threads.cpp.tmp+0x430cc4) #2 __tsan::MapThreadTrace(unsigned long, unsigned long, char const*) /home/david.spickett/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:327 (bench_threads.cpp.tmp+0x4a1b00) #3 __tsan::CreateThreadContext(unsigned int) /home/david.spickett/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:82 (bench_threads.cpp.tmp+0x4a10c4) #4 __sanitizer::ThreadRegistry::CreateThread(unsigned long, bool, unsigned int, void*) /home/david.spickett/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cpp:144 (bench_threads.cpp.tmp+0x42ea9c) #5 __tsan::ThreadCreate(__tsan::ThreadState*, unsigned long, unsigned long, bool) /home/david.spickett/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp:122 (bench_threads.cpp.tmp+0x4bb000) #6 pthread_create /home/david.spickett/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1042 (bench_threads.cpp.tmp+0x4496bc) #7 bench() /home/david.spickett/llvm-project/compiler-rt/test/tsan/bench_threads.cpp:38 (bench_threads.cpp.tmp+0x4c307c) #8 main /home/david.spickett/llvm-project/compiler-rt/test/tsan/bench.h:23 (bench_threads.cpp.tmp+0x4c2e20) #9 __libc_start_main ??:? (libc.so.6+0x2408c) #10 _start ??:? (bench_threads.cpp.tmp+0x41ebc0)
This part looks unrelated