Skip to content

This project contains scripts and snippets in C++

License

Notifications You must be signed in to change notification settings

pkarneliuk/dlsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2850f26 · Mar 14, 2025

History

30 Commits
Apr 30, 2024
Apr 30, 2024
May 2, 2024
Sep 15, 2023
Mar 14, 2025
Apr 30, 2024
Mar 14, 2025
Mar 14, 2025
Sep 15, 2023
Apr 30, 2024
Mar 15, 2024
May 2, 2024
Apr 30, 2024
May 2, 2024
Mar 14, 2025

Repository files navigation

DLSM

build coverage

Introduction

This project contains scripts and snippets in C++.

Features

  • 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

Disruptor

Yet another implementation of LMAX Disruptor in C++20.

Details

Other known implementations

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
    • Sequencers::
      • SPMC - Single Producer Multiple Consumers pattern
      • MPMC - Multiple Producers Multiple Consumers pattern
    • Ring - adapter for external random-access container(std::array/vector) for ring-access to Events
  • External memory injection(optional) for sequencers, useful for placement in HugePages/SharedMemory
  • Unit and Performance(latency&throughput) tests
  • dlsm::Disruptor::Graph - high-level API

Known defects and limitations

  • 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

Latency & Throughput tests

Results of performance tests are in separate tests/perf/Disruptor.md.

Useful Scripts

./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

Links and References