Skip to main content

Lock-free shared-memory messaging library for inter-process communication.

Project description

Kickmsg

Lock-free shared-memory messaging library for inter-process communication.

Kickmsg provides MPMC publish/subscribe over shared memory with zero-copy receive, per-subscriber ring isolation, and crash resilience — all without locks or kernel-mediated synchronization on the hot path.

Features

  • Lock-free: all data paths use atomic CAS (Treiber stack, MPSC rings)
  • Zero-copy receive: SampleView pins slots via refcount, avoiding memcpy for large payloads
  • Per-subscriber isolation: a slow subscriber only overflows its own ring — fast subscribers are unaffected
  • Crash resilient: publisher crashes never deadlock the channel; bounded slot leaks are recoverable via GC
  • Topic-centric naming: subscribers connect by topic name, not publisher identity
  • C++17, no external dependencies beyond POSIX / Win32

Channel Patterns

Pattern API SHM name
PubSub (1-to-N) advertise / subscribe /{prefix}_{topic}
Broadcast (N-to-N) join_broadcast /{prefix}_broadcast_{channel}
Mailbox (N-to-1) create_mailbox / open_mailbox /{prefix}_{owner}_mbx_{tag}

Quick Start

#include <kickmsg/Publisher.h>
#include <kickmsg/Subscriber.h>

// Create a channel
kickmsg::channel::Config cfg;
cfg.max_subscribers   = 4;
cfg.sub_ring_capacity = 64;
cfg.pool_size         = 256;
cfg.max_payload_size  = 4096;

auto region = kickmsg::SharedRegion::create(
    "/my_topic", kickmsg::channel::PubSub, cfg);

// Subscribe, then publish
kickmsg::Subscriber sub(region);
kickmsg::Publisher  pub(region);

uint32_t value = 42;
pub.send(&value, sizeof(value));

auto sample = sub.try_receive();
// sample->data(), sample->len(), sample->ring_pos()

Node API (topic-centric)

#include <kickmsg/Node.h>

kickmsg::Node pub_node("sensor", "myapp");
auto pub = pub_node.advertise("imu");

// Any node can subscribe by topic name alone
kickmsg::Node sub_node("logger", "myapp");
auto sub = sub_node.subscribe("imu");

Zero-copy receive

auto view = sub.try_receive_view();
// view->data() points directly into shared memory
// slot is pinned until view is destroyed

Blocking receive

auto sample = sub.receive(100ms);
// blocks via futex until data arrives or timeout

Optional payload schema descriptor

// Bake a schema descriptor into the region at creation.
kickmsg::SchemaInfo info{};
info.identity = my_identity_hash();   // user-defined bytes
info.layout   = my_layout_hash();     // user-defined bytes
std::snprintf(info.name, sizeof(info.name), "my/Pose");
info.version  = 2;

kickmsg::channel::Config cfg;
cfg.schema = info;
auto region = kickmsg::SharedRegion::create("/pose_topic", kickmsg::channel::PubSub, cfg);

// Any process can read it back and decide what to do on mismatch.
auto schema = region.schema();
if (schema and schema->version != 2) { /* user-defined policy */ }

The library stores the descriptor in the header but never interprets it — users choose how to compute identity/layout fingerprints and how to react to mismatches.

Health diagnostics and crash recovery

// Periodic health check (read-only, safe under live traffic)
auto report = region.diagnose();
// report.locked_entries, report.retired_rings,
// report.draining_rings, report.live_rings

// Repair poisoned entries (safe under live traffic)
region.repair_locked_entries();

// Reset retired rings (after confirming crashed publisher is gone)
region.reset_retired_rings();

// Reclaim leaked slots (requires full quiescence)
region.reclaim_orphaned_slots();

Building

Prerequisites

  • C++17 compiler (GCC 10+, Clang 12+, MSVC 2019+)
  • CMake 3.15+
  • Conan 2.x (for test/benchmark dependencies)

Build

# Install dependencies
pip install conan
conan install conanfile.py -of=build --build=missing -o unit_tests=True

# Configure and build
cmake -S . -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_PREFIX_PATH=build \
    -DBUILD_UNIT_TESTS=ON \
    -DBUILD_EXAMPLES=ON
cmake --build build

# Run tests
./build/kickmsg_unit
./build/kickmsg_stress_test
./build/kickmsg_crash_test

# Run examples
./build/examples/hello_pubsub
./build/examples/hello_zerocopy
./build/examples/hello_broadcast
./build/examples/hello_diagnose

As a subdirectory

add_subdirectory(kickmsg)
target_link_libraries(my_app PRIVATE kickmsg)

CMake Options

Option Default Description
BUILD_UNIT_TESTS OFF Build unit and stress tests
BUILD_EXAMPLES OFF Build example programs
BUILD_BENCHMARKS OFF Build benchmarks (requires Google Benchmark)
ENABLE_TSAN OFF Enable ThreadSanitizer

Platform Support

Platform SharedMemory Futex
Linux shm_open / mmap SYS_futex
macOS shm_open / mmap __ulock_wait / __ulock_wake
Windows CreateFileMapping / MapViewOfFile WaitOnAddress / WakeByAddressAll

Actively validated on Linux x86-64, Linux ARM64 (Raspberry Pi 4B, 12 h continuous stress), and Darwin ARM64 (Apple Silicon) via scripts/validate.sh.

Architecture

See ARCHITECTURE.md for the full design: shared-memory layout, concurrency model, publish/subscribe flows, crash resilience, garbage collection, and ABA safety analysis.

License

CeCILL-C

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kickmsg-0.1.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (473.7 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

kickmsg-0.1.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (468.0 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

kickmsg-0.1.0-cp312-abi3-macosx_11_0_arm64.whl (178.8 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

kickmsg-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (476.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

kickmsg-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (470.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

kickmsg-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (180.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kickmsg-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (476.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

kickmsg-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (470.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

kickmsg-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (180.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file kickmsg-0.1.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 459e053ac77008a8273712c1859512d0f768640aae1db2983f261031904e9415
MD5 9a109e6d09ed7c697fb5323676fd561f
BLAKE2b-256 c4bec42946f564b0815b2f474015c6422b1cabdbc3485f446d5515b80e881227

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5e95726f699d0a21c36027b4d412001ee9c7b52e4aefafd36b9bf4eaa0680394
MD5 3461450a41b8c4f676fd7e05af2c64b9
BLAKE2b-256 f9d607a3f204565e2e47c4fc919d2dd1d03daae4f6374042a554a113be3fa128

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd8d9d74dce3675a338747b4ff9420ed3897032047c50f4bc5bc0c8b31f8dc92
MD5 302a9c10aa5540fa0c75fca184c44c59
BLAKE2b-256 4522d0527c34c8b0ee8c5c406c33e994ef1150797cf8dea50acab7f132e8d43c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fbec76f1292cf8ebc5cad16d7d9971187f65d0f73d10caee3d224eddbaef4b5a
MD5 f7f91d7fbaa3a3ecc56ee997052a52e0
BLAKE2b-256 6a12504cb234139aa61141a816227b5fb7a00e363000295d76c61a9e69517b8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 26ddfbb302918785c5f2b139866af2f67f612f024652b7ff10faa7736b68b4ae
MD5 24e50b7c010d6b3eb3646ec79422f381
BLAKE2b-256 850f2d973e332fdedfa212ef9d911e90c680eff33cf27b9ce233d9c36462413c

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac7f764330c022bb8bc52c99b48de6f3fbff1ec2c31660fa5d01c4f37be650ee
MD5 f6c81234898f033d9f49d783699f0c18
BLAKE2b-256 633c638a74569d4809d14e71cd02bb2de7954a70df34ac67812397cc08d90822

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c34c126488127601430ddc7c6b3f0f4c992479a62890d26333c62d47df3da901
MD5 e6867a472a7155c1cd6b7ded03f6ae31
BLAKE2b-256 9539ea5070453b47fd87c65ee1c539cba14a185cc2b68d026fc45c7e5cab312e

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bece0be09c8d247fac8fceb39fd08b44b2f52045de84d3b0e9a8d0a6ccc85c51
MD5 690a581fede95fa0600a9f0e621fa54d
BLAKE2b-256 2bedf0ae36a910900aa1836be7c1f471dc593514b63eda40e593c8d3e6d992b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kickmsg-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kickmsg-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e90b6a37589b67aaf825c4d74a3174a1c71b0e3ad5fc3f4f9c533740f4996564
MD5 5e4a922b7937eb77c001181efef1d412
BLAKE2b-256 5923913df2a00d8b1e7fdc91f27a07a94639ace5855d20761f7d0bc013126e28

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: ci.yml on leducp/kickmsg

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page