Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 3.29 KB

README.md

File metadata and controls

59 lines (43 loc) · 3.29 KB

benchmarking

Benchmarking various implementations of readers-writer locks, std::sync::RwLock, parking_lot::RwLock, tokio::sync::RwLock.

cargo criterion --message-format=json > tmp/benchmark.json

We compare several different Rust implementations of readers-writer locks.

LLVM Sanitizer

For Linux targets it is also possible to run the LLVM address sanitizer to detect memory issues in unsafe and C++ code. This requires the nightly version of the rust compiler, which can acquired using rustup toolchain install nightly. To show the symbols for the resulting stacktrace it is also convenient to install llvm-symbolizer, for example using sudo apt install llvm on Ubuntu. Afterwards, the tests can be executed with the address sanitizer enabled using cargo +nightly xtask address-sanitizer. Similarly, we can also the thread sanitizer to detect data races using cargo +nightly xtask thread-sanitizer.

Code Coverage

Code coverage can be automatically generated for the full workspace using a cargo task. The code coverage itself is generated by LLVM with source code instrumentation, which requires the preview tools to be installed rustup component add llvm-tools-preview, and grcov, which can be acquired using cargo install grcov. To execute the code coverage task use cargo xtask coverage. The resulting HTML code coverage report can be found in target/coverage.

Concurrency testing

Using the crate loom it is actually possible to test all possible interleavings defined by the C11 memory standard to show that the shared mutex is data race free. This can be used as follows:

RUSTFLAGS="--cfg loom" cargo test

If a violation is detected the following command can be used to show the exact trace and source code locations of read and write accesses.

LOOM_LOG=trace \
LOOM_LOCATION=1 \
LOOM_CHECKPOINT_INTERVAL=1 \
RUSTFLAGS="--cfg loom" \
cargo test --test <test_name> --release

Related work