llvm-project/compiler-rt/lib/tsan/tests/unit
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
..
CMakeLists.txt
tsan_clock_test.cc tsan: optimize sync clock memory consumption 2017-07-14 11:30:06 +00:00
tsan_dense_alloc_test.cc [TSan] Fix signed-compare warning in the unit test 2014-11-03 22:17:39 +00:00
tsan_flags_test.cc [Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across all sanitizers. 2015-08-21 20:49:37 +00:00
tsan_mman_test.cc Follow-up for r277458: Update the tsan_mman_test.cc unit test. 2016-08-02 14:41:03 +00:00
tsan_mutex_test.cc Remove TSAN_DEBUG in favor of SANITIZER_DEBUG. 2015-01-03 04:29:12 +00:00
tsan_mutexset_test.cc
tsan_shadow_test.cc
tsan_stack_test.cc [TSan] Use StackTrace from sanitizer_common where applicable 2014-11-03 22:23:44 +00:00
tsan_sync_test.cc tsan: don't create sync objects on acquire 2016-06-27 11:14:59 +00:00
tsan_unit_test_main.cc [sanitizer] On OS X, verify that interceptors work and abort if not, take 2 2016-03-17 08:37:25 +00:00
tsan_vector_test.cc tsan: remove in_rtl counter 2013-12-24 12:55:56 +00:00