[PATCH] D12554: tsan: speed up race deduplication

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 06:37:55 PDT 2015


dvyukov created this revision.
dvyukov added a reviewer: kcc.
dvyukov added subscribers: eugenis, samsonov, glider, llvm-commits.

Race deduplication code proved to be a performance bottleneck in the past if suppressions/annotations are used, or just some races left unaddressed. And we still get user complaints about this:
https://groups.google.com/forum/#!topic/thread-sanitizer/hB0WyiTI4e4
ReportRace already has several layers of caching for racy pcs/addresses to make deduplication faster. However, ReportRace still takes a global mutex (ThreadRegistry and ReportMutex) during deduplication and also calls mmap/munmap (which take process-wide semaphore in kernel), this makes deduplication non-scalable.

This patch moves race deduplication outside of global mutexes and also removes all mmap/munmap calls.
As the result, race_stress.cc with 100 threads and 10000 iterations become 30x faster:

before:
real	0m21.673s
user	0m5.932s
sys	0m34.885s

after:
real	0m0.720s
user	0m23.646s
sys	0m1.254s





http://reviews.llvm.org/D12554

Files:
  lib/lsan/lsan_common.cc
  lib/sanitizer_common/sanitizer_suppressions.cc
  lib/sanitizer_common/sanitizer_suppressions.h
  lib/tsan/rtl/tsan_interceptors.cc
  lib/tsan/rtl/tsan_interface_ann.cc
  lib/tsan/rtl/tsan_mman.cc
  lib/tsan/rtl/tsan_mutex.cc
  lib/tsan/rtl/tsan_mutex.h
  lib/tsan/rtl/tsan_rtl.cc
  lib/tsan/rtl/tsan_rtl.h
  lib/tsan/rtl/tsan_rtl_report.cc
  lib/tsan/rtl/tsan_stat.cc
  lib/tsan/rtl/tsan_stat.h
  lib/tsan/rtl/tsan_suppressions.cc
  test/tsan/race_stress.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12554.33802.patch
Type: text/x-patch
Size: 23814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150902/00af588a/attachment.bin>


More information about the llvm-commits mailing list