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}

Installation

For Python (also installs the kickmsg CLI):

pip install kickmsg

Pre-built wheels are published for CPython 3.10–3.12 on Linux x86_64 / aarch64 (manylinux_2_28) and macOS 11+ (universal2). On any other platform pip will fall back to a source build, which needs the build prerequisites.

For C++ only, see Building or use the Conan recipe in conan/all.

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, msg/s rates (interactive; Ctrl-C to quit)
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 C++ examples
./build/examples/hello_pubsub
./build/examples/hello_zerocopy
./build/examples/hello_broadcast
./build/examples/hello_diagnose
./build/examples/hello_schema
./build/examples/hello_schema_late_publisher
./build/examples/hello_lowlevel

# Run Python examples (after `pip install kickmsg`)
python examples/python/hello_pubsub.py
python examples/python/hello_camera_zerocopy.py    # zero-copy with memoryview
python examples/python/hello_schema.py
python examples/python/cli_playground.py           # long-running, drive the `kickmsg` CLI against it

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.

Troubleshooting

See TROUBLESHOOTING.md for common operational gotchas: stale segments after a crash, the diagnose/repair flow, SHM naming and length limits, permission errors, and platform-specific notes (macOS PSHMNAMLEN, Windows session isolation, Linux /dev/shm sizing).

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

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

kickmsg-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (893.7 kB view details)

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

kickmsg-0.5.0-cp312-abi3-macosx_11_0_arm64.whl (335.7 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

kickmsg-0.5.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (896.9 kB view details)

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

kickmsg-0.5.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (897.0 kB view details)

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

kickmsg-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (336.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kickmsg-0.5.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (896.5 kB view details)

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

kickmsg-0.5.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (896.6 kB view details)

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

kickmsg-0.5.0-cp310-cp310-macosx_11_0_arm64.whl (336.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57458697e546b193dc961daffaf6e2f55761baf99ec179ddf3514cc05b2c8c82
MD5 c16f99706079c47f0fc872b1680a9b88
BLAKE2b-256 91a2ec7661f5f6ebe1651eacc78b288ce4a330f412631e82a29960af3d6dd2e8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 08e823baba7ab016d8b54c697165e2bae0b8cd6bd40e98c868e8fac7675ab1e8
MD5 7e655bbabea0f575faadc57082613b6b
BLAKE2b-256 e5343958116884491521b75de59b5559f2371b5f0d429a903e2fbb12812164b9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4dc4a0fbea73e9e35e4062117108341fee494505839c98528211ee24b19d5356
MD5 728561354259bc6cfaff9bada34ac49d
BLAKE2b-256 4d3102a808ad7f014f6021f1c7d473b9d7948f20f785d1aacc62166331808571

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 03d9db338310542637bd53dd6201a5f98c83a412a3a42fb21db73d335b50c101
MD5 11da274ef03065fac644a3a6ad2b1bf8
BLAKE2b-256 18aa0f4a9b2da9d86e4a741573ba094582f3d47da057ddb4c76f2cee2c5f2695

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 212b023b4495531c492f3e160f6c37df7293600eb297faa547f7a0829acf325b
MD5 14aa18a371cf0a6e8afbdf288a5f78d1
BLAKE2b-256 67501ce08ef987217550a6e5994f624f92c0988c0219fe1108e18de4949dbccd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1466fbef4f0f2445ff77d9617ce3eae348b25aa6fe78a83564695edf7b601624
MD5 d9c09ab0500220873fc19c1ffd7807aa
BLAKE2b-256 b8d134ebd5fe6b5eadc473f9d76e8c4ac54e6c81aab713ff6ac530e19477d87f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 598ad7494d655ddc216406167546ef9c419c97f8bc9b65b9b1171bd91100924f
MD5 fe1798955955794db31c5e332149fa69
BLAKE2b-256 a5c47661433961336f228b1363a95e371daf409a3cc4930eca56e89ad781bdad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2dc96172afe02f77311702a20022b0dd5f9e48174b12fe969bcd4111abd09167
MD5 eb1135d0fc58edbd84979d31886db821
BLAKE2b-256 5075ef45b86918ad9049a532b384ffd6b39bb2467dad2ffe2651588758b8d442

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b2b69b85a504ef2f3dd789b0957daeaafe34f31f1f2a8dbed9d603c5e4511c6
MD5 c0aac01ef8173efdf1e27409fb25d3d1
BLAKE2b-256 092a66016e54b8a4b04125e0235edebba882d57063246f86e85043ebe97e9a18

See more details on using hashes here.

Provenance

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