llvm-project/compiler-rt/lib/tsan/rtl
Dmitry Vyukov 9f2c6207d5 tsan: optimize sync clock memory consumption
This change implements 2 optimizations of sync clocks that reduce memory consumption:

Use previously unused first level block space to store clock elements.
Currently a clock for 100 threads consumes 3 512-byte blocks:

2 64-bit second level blocks to store clock elements
+1 32-bit first level block to store indices to second level blocks
Only 8 bytes of the first level block are actually used.
With this change such clock consumes only 2 blocks.

Share similar clocks differing only by a single clock entry for the current thread.
When a thread does several release operations on fresh sync objects without intervening
acquire operations in between (e.g. initialization of several fields in ctor),
the resulting clocks differ only by a single entry for the current thread.
This change reuses a single clock for such release operations. The current thread time
(which is different for different clocks) is stored in dirty entries.

We are experiencing issues with a large program that eats all 64M clock blocks
(32GB of non-flushable memory) and crashes with dense allocator overflow.
Max number of threads in the program is ~170 which is currently quite unfortunate
(consume 4 blocks per clock). Currently it crashes after consuming 60+ GB of memory.
The first optimization brings clock block consumption down to ~40M and
allows the program to work. The second optimization further reduces block consumption
to "modest" 16M blocks (~8GB of RAM) and reduces overall RAM consumption to ~30GB.

Measurements on another real world C++ RPC benchmark show RSS reduction
from 3.491G to 3.186G and a modest speedup of ~5%.

Go parallel client/server HTTP benchmark:
https://github.com/golang/benchmarks/blob/master/http/http.go
shows RSS reduction from 320MB to 240MB and a few percent speedup.

Reviewed in https://reviews.llvm.org/D35323

llvm-svn: 308018
2017-07-14 11:30:06 +00:00
..
tsan.syms.extra tsan: add new mutex annotations 2017-03-26 15:27:04 +00:00
tsan_clock.cc tsan: optimize sync clock memory consumption 2017-07-14 11:30:06 +00:00
tsan_clock.h tsan: optimize sync clock memory consumption 2017-07-14 11:30:06 +00:00
tsan_debugging.cc [sanitizer] Introduce tid_t as a typedef for OS-provided thread IDs 2017-04-17 18:17:38 +00:00
tsan_defs.h tsan: optimize sync clock memory consumption 2017-07-14 11:30:06 +00:00
tsan_dense_alloc.h tsan: give debug names to dense allocators 2017-07-12 12:34:12 +00:00
tsan_external.cc [tsan] Detect races on modifying accesses in Swift code 2017-05-03 16:51:01 +00:00
tsan_fd.cc
tsan_fd.h
tsan_flags.cc tsan: add new mutex annotations 2017-03-26 15:27:04 +00:00
tsan_flags.h tsan: add new mutex annotations 2017-03-26 15:27:04 +00:00
tsan_flags.inc [tsan] Enable ignore_noninstrumented_modules=1 on Darwin by default 2017-01-24 21:37:50 +00:00
tsan_ignoreset.cc
tsan_ignoreset.h
tsan_interceptors.cc [tsan] Add comments for the bool argument of ThreadIgnoreBegin/ThreadIgnoreSyncBegin, NFC. 2017-07-10 15:37:13 +00:00
tsan_interceptors.h [tsan] Ignore memory accesses for libignored modules for "external" races 2017-04-21 17:18:14 +00:00
tsan_interceptors_mac.cc On Darwin, start building the TSan dylib for the iOS simulator. 2017-07-12 17:30:54 +00:00
tsan_interface.cc tsan: Introducing a function to flush the shadow memory from third-party libraries 2017-01-07 11:27:33 +00:00
tsan_interface.h [tsan] Detect races on modifying accesses in Swift code 2017-05-03 16:51:01 +00:00
tsan_interface_ann.cc [tsan] Add comments for the bool argument of ThreadIgnoreBegin/ThreadIgnoreSyncBegin, NFC. 2017-07-10 15:37:13 +00:00
tsan_interface_ann.h
tsan_interface_atomic.cc tsan: don't create sync objects on acquire-load 2017-07-12 12:28:23 +00:00
tsan_interface_inl.h [tsan] Expose __tsan_ignore_thread_begin and __tsan_ignore_thread_end in TSan interface 2016-11-11 22:43:12 +00:00
tsan_interface_java.cc tsan: add new mutex annotations 2017-03-26 15:27:04 +00:00
tsan_interface_java.h tsan: allow Java VM iterate over allocated objects 2016-12-14 18:20:18 +00:00
tsan_libdispatch_mac.cc [tsan] Only Acquire/Release GCD queues if they're not NULL 2017-03-26 20:59:23 +00:00
tsan_malloc_mac.cc [tsan] Switch to InternalAlloc everywhere __libc_malloc is currently used 2016-06-06 18:18:47 +00:00
tsan_md5.cc
tsan_mman.cc tsan: prepare clock for future changes 2017-07-12 12:45:20 +00:00
tsan_mman.h tsan: fix a crash 2016-05-06 19:35:22 +00:00
tsan_mutex.cc tsan: fix a crash 2016-05-06 19:35:22 +00:00
tsan_mutex.h tsan: fix a crash 2016-05-06 19:35:22 +00:00
tsan_mutexset.cc
tsan_mutexset.h tsan: always define SANITIZER_GO 2016-10-28 20:14:18 +00:00
tsan_new_delete.cc [Sanitizers] Operator new() interceptors always die on allocation error 2017-06-28 21:58:57 +00:00
tsan_platform.h [tsan] Add a mapping for Darwin/AArch64 2017-07-10 15:35:04 +00:00
tsan_platform_linux.cc Fix sanitizer build against latest glibc 2017-07-13 21:59:01 +00:00
tsan_platform_mac.cc Fix-up for r307540. 2017-07-10 15:52:30 +00:00
tsan_platform_posix.cc Refactor MemoryMappingLayout::Next to use a single struct instead of output parameters. NFC. 2017-07-11 18:54:00 +00:00
tsan_platform_windows.cc [tsan] Implement WriteMemoryProfile for Darwin 2016-10-31 20:17:13 +00:00
tsan_ppc_regs.h [PPC64, TSAN] Provide setjmp interceptor support for PPC64 2015-12-08 22:14:34 +00:00
tsan_preinit.cc Init tsan with .preinit_array section 2016-05-26 17:05:36 +00:00
tsan_report.cc tsan: fix pedantic warnings 2017-06-13 07:09:56 +00:00
tsan_report.h [tsan] Detect races on modifying accesses in Swift code 2017-05-03 16:51:01 +00:00
tsan_rtl.cc tsan: give debug names to dense allocators 2017-07-12 12:34:12 +00:00
tsan_rtl.h [sanitizer] Change SizeClassAllocator32 to accept just one template 2017-05-15 14:47:19 +00:00
tsan_rtl_aarch64.S Fix a build failure due to r307541 (tsan_rtl_aarch64.S:54: Error: unknown pseudo-op: `.'). 2017-07-10 15:58:22 +00:00
tsan_rtl_amd64.S [tsan] Port setjmp/longjmp assembly to Darwin/AArch64 2017-07-10 15:28:16 +00:00
tsan_rtl_mips64.S [TSan][MIPS] Implements setjmp assembly for MIPS64 2016-08-16 05:06:56 +00:00
tsan_rtl_mutex.cc tsan: prepare clock for future changes 2017-07-12 12:45:20 +00:00
tsan_rtl_ppc64.S Avoid extended mnemonic 'mfvrsave' in assembly code 2015-12-09 15:18:30 +00:00
tsan_rtl_proc.cc tsan: always define SANITIZER_GO 2016-10-28 20:14:18 +00:00
tsan_rtl_report.cc tsan: s/-1/kInvalidTid/ 2017-07-12 12:36:44 +00:00
tsan_rtl_thread.cc tsan: prepare clock for future changes 2017-07-12 12:45:20 +00:00
tsan_stack_trace.cc
tsan_stack_trace.h
tsan_stat.cc tsan: remove some clock-related stats 2017-07-12 12:54:38 +00:00
tsan_stat.h tsan: remove some clock-related stats 2017-07-12 12:54:38 +00:00
tsan_suppressions.cc [tsan] Provide API for libraries for race detection on custom objects 2017-02-02 13:17:05 +00:00
tsan_suppressions.h
tsan_symbolize.cc [TSan] Try harder to avoid compiler-generated memcpy calls. 2015-12-10 19:24:27 +00:00
tsan_symbolize.h
tsan_sync.cc tsan: give debug names to dense allocators 2017-07-12 12:34:12 +00:00
tsan_sync.h tsan: fix reading of mutex flags 2017-06-13 09:37:51 +00:00
tsan_trace.h tsan: always define SANITIZER_GO 2016-10-28 20:14:18 +00:00
tsan_update_shadow_word_inl.h
tsan_vector.h