IndexBus Layouts
This page documents the v1 shared-memory layouts used by IndexBus.
Layout Principles
- All exported types use
#[repr(C)]for cross-language compatibility - Layouts are header-versioned for forward compatibility
- Field alignment follows C struct packing rules
- Cache-line awareness for producer/consumer hot fields
Region Layout
A shared-memory region contains:
- Region header — magic, version, lane count, region size
- Lane headers — one per lane, at fixed offsets
- Lane data — entry storage for each lane
Lane Header Fields
Hot fields (write position, read positions) are placed on separate cache lines to minimize false sharing between producer and consumer.
Router Counter Layout
Routers maintain per-output counters for monitoring:
Message Format
indexbus-msg-v1 defines the message envelope:
- Fixed header with message type, length, and sequence number
- Payload follows immediately after the header
- No padding between header and payload unless required by alignment
ABI Compatibility
The layout is part of the IndexBus ABI contract:
repr(C)layouts must not change without a version bump- Generated C headers (
indexbus_v1.h) are the reference for non-Rust consumers - ByteOr's generated header (
byteor_v1.h) includesindexbus_v1.h - Additive changes are preferred; breaking layout changes require explicit versioning