This project contains scripts and snippets in C++.
- Build in Docker containers(Fedora, Ubuntu) or in current environment
- Build by GCC and Clang C++ compilers
- Build 3rd-party libraries by Conan
- Build C++ code coverage HTML report by LCOV with lines/functions/branches metrics
- Build with Thread/Address/UndefinedBehavior Sanitizer
- Integration with clang-format and clang-tidy
- Integration with Doxygen
Yet another implementation of LMAX Disruptor in C++20
.
Details
- Original LMAX Disruptor in
Java
- Abc-Arbitrage/Disruptor-cpp
- lewissbaker/disruptorplus
- Vallest/Disruptor-CPP
- jeremyko/disruptorCpp-IPC
Features of dlsm::Disruptor
- Template-based implementation with different components for customization:
- Barriers::
- PointerBarrier - minimal container for dependencies of a sequence
- AtomicsBarrier -
std::atomic
pointers to dependencies - OffsetsBarrier -
std::atomic
offsets to dependencies for placing in shared memory
- Waits::
- SpinsStrategy - busy-wait based on exponential
__x86_64__
_mm_pause()
intrinsic - YieldStrategy - busy-wait based on
std::this_thread::yield()
- BlockStrategy - blocking strategy based on
std::std::condition_variable_any
- ShareStrategy - blocking strategy based on
pthreads
for placing in shared memory
- SpinsStrategy - busy-wait based on exponential
- Sequencers::
SPMC
- Single Producer Multiple Consumers patternMPMC
- Multiple Producers Multiple Consumers pattern
- Ring - adapter for external random-access container(
std::array/vector
) for ring-access to Events
- Barriers::
- External memory injection(optional) for sequencers, useful for placement in HugePages/SharedMemory
- Unit and Performance(latency&throughput) tests
- dlsm::Disruptor::Graph - high-level API
- Implementation of lock-free operations in not portable to
Weak Memory Model
platforms(ARM, PowerPC) Claim-Timeout
/Consume-Timeout
operations are not implemented in Sequencers(Publishers and Consumers)SPSC
- Single Producer Single Consumer pattern is not implemented- dlsm::Disruptor::Graph has high overhead caused by indirections and virtual calls
- dlsm::Disruptor::Graph is incomplete and unstable
Results of performance tests are in separate tests/perf/Disruptor.md.
./scripts/format.sh # Apply .clang-format rules on hpp/cpp files
./scripts/build.sh # Perform all types of builds in current environment
./scripts/conan/build.sh Debug g++ coverage # Build Debug by g++ with code coverage
./scripts/conan/build.sh Release clang++ tsan # Build Release by clang++ with ThreadSanitizer
./scripts/docker/run.sh Ubuntu # Start Ubuntu.Dockerfile container in interactive mode
./scripts/docker/run.sh Fedora ./scripts/build.sh # Perform all types of builds in Docker container
./scripts/docker/run.sh Fedora cat /etc/os-release # Perform command in Fedora.Dockerfile container
./scripts/docker/run.sh Ubuntu ./scripts/conan/build.sh Release g++ tsan ./build-ubuntu-tsan
./scripts/docker/run.sh Ubuntu ./scripts/conan/build.sh RelWithDebInfo g++ common ./build