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();

CLI (kickmsg)

Installing the Python wheel puts a kickmsg command on $PATH that inspects running channels via a shared participant registry (one per namespace, backed by a SHM region at /{namespace}_registry). Works identically on Linux, macOS, and Windows — no /dev/shm filesystem walk required.

kickmsg list                        # topic-centric enumeration
kickmsg list -o name,pub,sub,stall  # ps-style column selection
kickmsg info  <shm>                 # static header metadata
kickmsg stats <shm>                 # runtime counters (write_pos / dropped / lost)
kickmsg watch <shm>                 # top-like live view with msg/s rates
kickmsg diagnose <shm>              # wraps SharedRegion::diagnose()
kickmsg repair   <shm> [--locked]   # run repair primitives
kickmsg schema <shm>                # focused schema descriptor view
kickmsg schema-diff <a> <b>         # field-by-field schema comparison

All subcommands accept --json for scripting.

Programmatic use (GUIs, exporters)

The same data the CLI renders is available as typed dataclasses through kickmsg.diagnostics, so a GUI can consume it without shelling out:

from kickmsg import diagnostics as diag

for topic in diag.list_topics(namespace="kickmsg"):
    print(topic.shm_name, len(topic.producers), len(topic.consumers))

stats = diag.stats("/kickmsg_telemetry")
for ring in stats.rings:
    if ring.state == "live":
        print(ring.write_pos, ring.dropped_count, ring.lost_count)

# Live updates (generator — caller drives the loop)
for frame in diag.watch("/kickmsg_telemetry", interval=1.0):
    gui.update(frame.stats, frame.rates_msg_per_sec)

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.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (856.6 kB view details)

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

kickmsg-0.2.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (854.4 kB view details)

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

kickmsg-0.2.0-cp312-abi3-macosx_11_0_arm64.whl (320.4 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

kickmsg-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (859.1 kB view details)

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

kickmsg-0.2.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (857.8 kB view details)

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

kickmsg-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (321.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kickmsg-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (858.9 kB view details)

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

kickmsg-0.2.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (857.3 kB view details)

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

kickmsg-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (321.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f1635395ed59d8e5ed031b3c2c77b42fe7ac89c0d2afb3f03d1f95b03fb9ac2
MD5 4e98b3c8f987c5caaf848d500bbe5082
BLAKE2b-256 7d9c614b22921572b6b7303672d8d623bf9954081b82f07dbab0563f0b4618bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 93a7bc2cbe2529646d3c6c08e38d57e398843c2ab8639cf7d46c0b1d79ea9b04
MD5 83e5652d058b57a59a9d24a8853a6d6a
BLAKE2b-256 0887186aca0a4e326be56a3f1803373bb3f8acc780e421b3cfd6f5a4faef443d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 47d4c47140e83b071a7ac153c3319abaa8f12d48232d3d8894859add5172b660
MD5 d88fb08f6ae54e256d52a4511c000b0e
BLAKE2b-256 2242f5ebaf75aeb33163bb4e2e49763e1e97526edf99666f21284b603ef85995

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e11d7f676f39c83007045b63c526658f5e1b501a89f72d382cd172339883045e
MD5 ac39fc9738218a5c9a25c73c5b81cd2e
BLAKE2b-256 f3b6eebd7641a569f3fb51a0b618794640ff3e096efc25e7392effe6053da520

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3214fbd3bb507ae345bfb87668d4f01282ea1d0c331913c3a38fe5e45018f8d0
MD5 2fc6539f868a1aaf0742caf42b23e280
BLAKE2b-256 b06640e5d35ceda3983b2ea92c86b85e203b775e41915e5e105c83104fba6a19

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8fcffa476d80eb315241cbdc1d6e79eafcc7291415f430d19861ac339f0b9d77
MD5 4c0aa56c2e5a45a8178daa046a3e9598
BLAKE2b-256 baf476b43452a55c25d3fe0f6c13435d02a00dd879a07749fe4dff13667c1bd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2ddb2926a340daf490adf37419bf1b91cd55a6213099610fcda67be2345f4531
MD5 44a7ff70ea2f639cb0e203ec3bca3444
BLAKE2b-256 bc489fb1f718f2bb6c5c0402d691aa1bbb9376749735688a24e0c9ae003dcfb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b5365f21177025211d37583bcf933efcb6b25adb8e00595f0e370f352ff7d365
MD5 09dd949a7c283f13949cee5ecf662de4
BLAKE2b-256 94315ed637076efc7039094b99ad024ddfd35f44398b55f2515839fe48d1ec40

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kickmsg-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3581a0dbae32f271903242a2b9971a2919b2a935d80f34f9786ff97cd5a1558b
MD5 aba38b821fb7c25642c107a1e6a0ff2b
BLAKE2b-256 edf7ca92a5316d643d56c274b9078ea14d4db4fe4ebfc06f6e8edbbc6aa7dc00

See more details on using hashes here.

Provenance

The following attestation bundles were made for kickmsg-0.2.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