src/third_party/wiredtiger/tools/tsan_playground/readme.md
This is a playground for testing TSAN (Thread Sanitizer) in a controlled environment to better understand its behavior and limitations.
Currently, the main tested limitation is TSAN's ability to detect synchronization through standalone barriers.
The tsan_playground.c file contains a simple example of N threads (4 by default) that read and modify a shared buffer in a defined order. The threads use an abstract lock-free acquire-release API to synchronize their access to the shared resource.
All the headers contain different implementations of the acquire-release API, which are used to test TSAN's behavior with different approaches and implementations.
mkdir -p build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/mongodbtoolchain_stable_clang.cmake -DCMAKE_BUILD_TYPE=TSan ..
cmake --build . -j 16
Every implementation can be tested by running a separate binary.
You can also run the collect_warnings.sh script to see all the warnings for different synchronization implementations.
The tests were performed on both x86 and ARM architectures and on both clang and gcc compilers. However, the mongodbtoolchain v5 gcc compiler does not support TSAN, so GCC was taken from the system (Ubuntu 24.04).
The conclusions made from running the test with different implementations are as follows:
'atomic_thread_fence' is not supported with '-fsanitize=thread'