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

To prove kickmsg works on your own hardware -- the validation ladder from a quick ctest gate to a multi-hour contention soak with a single VERDICT: ALL CLEAN -- see tests/README.md.

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

Security

Shared-memory objects are created with mode 0600 (owner-only) on Linux and macOS, so channel payloads are not readable by other users on a multi-user host. To share channels across users, set the KICKMSG_SHM_MODE environment variable to an octal mode (e.g. KICKMSG_SHM_MODE=0666) in every process that creates regions — openers are unaffected. The value is parsed once per process; an invalid value falls back to 0600 with a warning on stderr.

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, 12 h continuous stress: 2660 passes, 0 failures, 0 reorders) via scripts/validate.sh and tests/endurance.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.6.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (960.6 kB view details)

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

kickmsg-0.6.1-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (958.2 kB view details)

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

kickmsg-0.6.1-cp312-abi3-macosx_11_0_arm64.whl (354.7 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

kickmsg-0.6.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (963.4 kB view details)

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

kickmsg-0.6.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (961.6 kB view details)

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

kickmsg-0.6.1-cp311-cp311-macosx_11_0_arm64.whl (355.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kickmsg-0.6.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (963.3 kB view details)

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

kickmsg-0.6.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (961.4 kB view details)

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

kickmsg-0.6.1-cp310-cp310-macosx_11_0_arm64.whl (355.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4737e3e818f81afb6dfdd5be35c9c8888fc8eddbe9f7f34864eaa0b90a1a92e0
MD5 b99176d3ef43c17436af931480d43437
BLAKE2b-256 5b92daf67916f3a81e084110175de2c8bda19a657ef88c4f69edbebf97c805f6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8ce4e9826432c35bbc41063aa5d2c6543d5fb5a426cfd080571fc399821da701
MD5 30964946581b89e87df5af8c4d808a18
BLAKE2b-256 5589b2f0ec0075a9c8d3ed4e405a39cdc3b17e0d6d338cd97f0060099e61def6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f801f2414095b3675258387abf8f76e5b3a443f7d752e6b2ca045603a0661e04
MD5 35a640b9f0ab751d055e6d491188005d
BLAKE2b-256 119f218ec6c845cb51f6ba345d98d89d11b712a7e1f20af5dec6a98d338d725a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2583e71e1588dfbd4473ffac03ea0d5fc4ecfd8c0d7574e62f9163fbc5d31364
MD5 1563f476d60aadd376f6f399c82e117b
BLAKE2b-256 57641cfabb96bf9edac68cc2a51b8c3ad762bccdf241ca6ad1677788cfe04e26

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bfc5cf055b98764f516e8c43951c5ce28c31e5e8e82b9b483057f28b4bb03099
MD5 7723c2305c93f2afa463d8ea702f7757
BLAKE2b-256 850b895b8ae76a125a295d8d250df3aa6e7f07cc9a60f5c1d3bdf52861525196

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5965e5a7fea2bdf94bd6e7de41aa0e1270545cf146fb4d1cb462532b82a3c9a3
MD5 6e98306318a7397db5c8ccccc907b6fe
BLAKE2b-256 c2b953e37ca4a887dae17f50fbf0585ae99582524026ab1e126021999d8a79f8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e130afc06e3555ddaf3c7bd1d75b19aa276bf3d844517cc8fa03af50ca62acbb
MD5 7359c95311d6e968802eb9204deeaef5
BLAKE2b-256 85cc4d657944e987e45e3f1ae7bc25a29b455a0fc2ebbd5b31e92f2ce311d3d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c10a733e081c7f2f6e25e54ade38de3bcf528e35ce3ddbec9378d09b4e723966
MD5 c21797c3ac0165b907fddea66e22eacc
BLAKE2b-256 9383617e72572b63f65a9f2dcc6b08a0bde3a57e5624b8c492f35e239f1c9dd2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for kickmsg-0.6.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c53e799355ce2bfa9b7d47df699c0476449b0826d3233d8e5784b9ff930441f
MD5 c2fffbe7991e12549470fddff96e5bb8
BLAKE2b-256 0a7635cf8f67cc792317555e5f95fffe29377c5a5241a40db5f4c18951ac5534

See more details on using hashes here.

Provenance

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