disruptor-mp
disruptor-mp exists for one job: move fixed-size events between OS processes with as little coordination overhead as possible.
It extends the upstream disruptor crate with a cross-process data plane. Producers and consumers in different OS processes coordinate through shared memory or a memory-mapped file using a fixed-size ring buffer and cache-line-padded sequence cursors.
Use this crate directly when you want the raw substrate only. If you need framing, codecs, typed zero-copy, or topology helpers, use myelon instead.
What this crate provides
| Concern | Type | Purpose |
|---|---|---|
| Raw ring (SHM) | SharedProducer<E>, SharedConsumer<E> |
Cross-process publish and consume of fixed-size events over a POSIX shared-memory segment. |
| Raw ring (mmap) | MmapProducer<E>, MmapConsumer<E> |
Same model, backed by a memory-mapped file. |
| Builders | build_shared_single_producer(...), attach_shared_consumer(...) |
Construct producer and consumer endpoints with coordination and discovery. |
| Coordination | CoordinationMode |
Decide when the producer considers peers attached. |
| Liveness | RequiredConsumerLivenessConfig, RequiredConsumerFailureAction |
Turn a stalled required consumer into an observable failure or alert. |
| Naming | portable_shm_segment_name(name) |
Derive a macOS-safe SHM segment name from an arbitrary label. |
| Observability | disruptor_mp::observability::* |
Hot-path counters file plus optional exporter integration. |
E is your event type: Copy + Default + 'static with a stable layout.
What this crate does not try to do:
- variable-length framing
- typed serialization layers
- zero-copy archived reads over serialized bytes
- inference-specific topology helpers
When to choose disruptor-mp vs myelon
| Need | Better entry point |
|---|---|
Fixed-size Copy events over a raw ring buffer |
disruptor-mp |
| Variable-length messages, fragmentation, reassembly | myelon |
| Codec-backed typed messages | myelon |
| Typed zero-copy reads of serialized payloads | myelon |
Quick start
[]
= "0.1.0-alpha.1"
Producer side:
use ;
let segment = portable_shm_segment_name;
let mut producer =
.discover_consumer_with_prefix
.with_coordination
.build_producer
.expect;
producer.publish;
Consumer side, in a different process:
use attach_shared_consumer;
let mut consumer =
.with_consumer_id
.build_consumer
.expect;
while let Some = consumer.try_consume_next_leased
Required-consumer liveness
The base model is strict broadcast: the slowest consumer gates capacity. The optional liveness layer turns a stalled required consumer into a producer-visible timeout or graceful failure.
#
The check is cold-path only. It runs while the producer is blocked on a required consumer, not on the steady-state fast path.
Common entry points
build_shared_single_producer(...)attach_shared_consumer(...)SharedProducer,SharedConsumerMmapProducer,MmapConsumerportable_shm_segment_name(...)CoordinationModeRequiredConsumerLivenessConfig
Platform support
- Linux: officially supported
- macOS: officially supported
- Windows: unsupported
Development
Benchmarks
Performance work lives in the dedicated bench crates:
crates/perf-benchfor the broad internal sweepcrates/competitive-benchfor the external-comparison contract
raw_ring (this crate's substrate) and raw_myelon (the same substrate re-exported through the myelon crate) measure identically across the matrix, confirming the re-export is zero-overhead:
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.