[all-commits] [llvm/llvm-project] 111d8f: tsan: remove quadratic behavior in pthread_join
Dmitry Vyukov via All-commits
all-commits at lists.llvm.org
Wed Nov 17 19:42:01 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 111d8f785b3a2a163411cef00327248d35571612
https://github.com/llvm/llvm-project/commit/111d8f785b3a2a163411cef00327248d35571612
Author: Dmitry Vyukov <dvyukov at google.com>
Date: 2021-11-17 (Wed, 17 Nov 2021)
Changed paths:
M compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cpp
M compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h
M compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
Log Message:
-----------
tsan: remove quadratic behavior in pthread_join
pthread_join needs to map pthread_t of the joined thread to our Tid.
Currently we do this with linear search over all threads.
This has quadratic complexity and becomes much worse with the new
tsan runtime, which memorizes all threads that ever existed.
To resolve this add a hash map of live threads only (that are still
associated with pthread_t) and use it for the mapping.
With the new tsan runtime some programs spent 1/3 of time in this mapping.
After this change the mapping disappears from profiles.
Depends on D113996.
Reviewed By: vitalybuka, melver
Differential Revision: https://reviews.llvm.org/D113997
More information about the All-commits
mailing list