Expand description
Shared-memory ping-pong transport for the wombatkv puffer daemon.
Two POSIX SHM disruptor rings (req + resp) carry typed rkyv-encoded
messages between an inference engine (client) and a long-running
daemon process holding a wombatkv_node::embed::WombatKVKvStore.
§Design choices (v1)
- Right-sized frames plus client chunking.
AlignedFixedFrame<DATA_BYTES>is sized for low-millisecond KV chunks, whileRemoteKvStoreClientchunks larger engine payloads behind its publicput_kv/get_kvAPI. - Tiered ops. This crate handles control + small-payload ops
(PING,
PUT_SMALL,GET_SMALL, EXISTS, STATS, RESTORE, CLEAR). For payloads larger than the per-frame budget are stored as chunk objects plus a tiny manifest. The daemon remains a simple key/value server. - rkyv codec. Zero-alloc encode (
AlignedVec) on the producer side; on the consumer side messages are decoded into owned types for ergonomics. Switching torecv_leasedfor archived-view access is a one-line change once the larger-payload path lands.
§Frame budget
DATA_BYTES = 4 MiB - 16 so each ring slot fits a multi-MiB
rkyv-encoded payload. With ring depth 16 that’s about 64 MiB per
ring, 128 MiB for the full request+response pair. Acceptable on an
RTX dev host and large enough to avoid tens of thousands of tiny
chunks for real KV blobs.
Re-exports§
pub use arena::arena_path;pub use arena::ArenaError;pub use arena::ArenaReader;pub use arena::ArenaWriter;pub use arena::ARENA_HEADER_BYTES;pub use arena::DEFAULT_ARENA_BYTES;pub use client::ClientOptions;pub use client::RemoteError;pub use client::RemoteGetOutcome;pub use client::RemoteHitTier;pub use client::RemoteKvStoreClient;pub use client::DEFAULT_CALL_TIMEOUT;pub use config::DaemonConfig;pub use lifecycle::cleanup_prefix_segments;pub use lifecycle::ClientHeartbeat;pub use lifecycle::HeartbeatMonitor;pub use lifecycle::ReopenReason;
Modules§
- arena
- Shared mmap arena for the future zero-copy KV transfer.
- client
- Remote KV-store client over the SHM ring transport.
- config
- Centralized daemon configuration.
- constants
- Named magic-number constants for the daemon binary.
- envelope
- RFC 0018 universal wire envelope for daemon TCP + HTTP transports.
- http_
transport - HTTP/1.1 + rkyv transport for the WombatKV daemon.
- lifecycle
- Client lifecycle helpers for SHM prefix recovery.
- op
- Wire op codes. Encoded as
u8(struct fields) to side-step rkyv’s enum derive constraints, we want plain field traversal on the hot path, not match dispatch. - runtime_
tpc - TPC (thread-per-core) runtime scaffolding for the wombatkv daemon.
- status
- Wire status codes (see
opfor design rationale). - tcp_
transport - Length-prefixed rkyv-over-TCP transport for the WombatKV daemon.
Structs§
- Archived
GetKv Blocks Batch Req - An archived
GetKvBlocksBatchReq - Archived
GetKv Blocks Batch Resp - An archived
GetKvBlocksBatchResp - Archived
Lookup Block Prefix Req - An archived
LookupBlockPrefixReq - Archived
Lookup Block Prefix Resp - An archived
LookupBlockPrefixResp - Archived
PutKv Blocks Batch Req - An archived
PutKvBlocksBatchReq - Archived
PutKv Blocks Batch Resp - An archived
PutKvBlocksBatchResp - Archived
Wire Request - An archived
WireRequest - Archived
Wire Response - An archived
WireResponse - GetKv
Blocks Batch Req - Request payload for
op::GET_KV_BLOCKS_BATCH. - GetKv
Blocks Batch ReqResolver - The resolver for an archived
GetKvBlocksBatchReq - GetKv
Blocks Batch Resp - Response payload for
op::GET_KV_BLOCKS_BATCH. - GetKv
Blocks Batch Resp Resolver - The resolver for an archived
GetKvBlocksBatchResp - Lookup
Block Prefix Req - Request payload for
op::LOOKUP_BLOCK_PREFIX. - Lookup
Block Prefix ReqResolver - The resolver for an archived
LookupBlockPrefixReq - Lookup
Block Prefix Resp - Response payload for
op::LOOKUP_BLOCK_PREFIX. - Lookup
Block Prefix Resp Resolver - The resolver for an archived
LookupBlockPrefixResp - PutKv
Blocks Batch Req - Request payload for
op::PUT_KV_BLOCKS_BATCH. - PutKv
Blocks Batch ReqResolver - The resolver for an archived
PutKvBlocksBatchReq - PutKv
Blocks Batch Resp - Response payload for
op::PUT_KV_BLOCKS_BATCH. - PutKv
Blocks Batch Resp Resolver - The resolver for an archived
PutKvBlocksBatchResp - Wire
Request - rkyv-archivable wire request.
- Wire
Request Resolver - The resolver for an archived
WireRequest - Wire
Response - rkyv-archivable wire response.
- Wire
Response Resolver - The resolver for an archived
WireResponse
Enums§
- Wire
Codec Error - Typed error for the daemon’s wire-codec helpers (encode/decode/
validate). Replaces ad-hoc
Result<T, String>in the daemon’s codec surface. NamedWireCodecErrorto avoid shadowingmyelon::codec::CodecError(which we import at the top of this file for the typed-transport surface).
Constants§
- ATTACH_
TIMEOUT - Default attach timeout for SHM segments (matches perf-bench).
- DEFAULT_
RING_ DEPTH - Disruptor ring depth: N in-flight slots.
Total ring footprint per direction = depth ×
FRAME_DATA_BYTES= 1 MiB. - FRAME_
DATA_ BYTES - Per-frame data budget. 4 MiB minus 16-byte header.
- REQ_
CONSUMER_ ID - Consumer id on the request ring (daemon side). Kept tiny because macOS POSIX SHM caps segment names at 31 chars; the consumer cursor segment appends this id to the ring name.
- RESP_
CONSUMER_ ID - Consumer id on the response ring (client side).
Functions§
- decode_
bytes_ batch - Decode an ordered payload batch without copying individual payloads.
- decode_
get_ kv_ blocks_ batch_ req - decode_
get_ kv_ blocks_ batch_ resp - decode_
key_ batch - Decode an ordered key list encoded by
encode_key_batch. - decode_
lookup_ block_ prefix_ req - decode_
lookup_ block_ prefix_ resp - decode_
put_ kv_ blocks_ batch_ req - decode_
put_ kv_ blocks_ batch_ resp - effective_
attach_ timeout - Resolves the effective SHM attach timeout from
WMBT_KV_DAEMON_SHM_ATTACH_TIMEOUT_SECSenv, falling back toATTACH_TIMEOUT. Useful for slow Docker startup ops or CI runners where the daemon takes longer to bring up SHM segments. - encode_
bytes_ batch - Encode ordered payload bytes for a batched GET response.
- encode_
get_ kv_ blocks_ batch_ req - encode_
get_ kv_ blocks_ batch_ resp - encode_
key_ batch - Encode an ordered key list for the daemon batched GET control path.
- encode_
lookup_ block_ prefix_ req - rkyv-encode a
LookupBlockPrefixReqforWireRequest.payload. - encode_
lookup_ block_ prefix_ resp - rkyv-encode a
LookupBlockPrefixRespforWireResponse.payload. - encode_
put_ kv_ blocks_ batch_ req - encode_
put_ kv_ blocks_ batch_ resp - fits_
one_ frame - Returns true when a payload of
lenbytes fits in a single frame (after rkyv envelope overhead, uses a conservative 256-byte budget). - open_
client - Open the client side of the ring pair: req-producer + resp-consumer.
- open_
daemon - Open the daemon side of the ring pair: req-consumer + resp-producer.
- segment_
names - Build the request and response SHM segment names for a daemon prefix.
The format is
wk<prefix>randwk<prefix>s(no underscores) so the names stay short enough that disruptor-mp’s per-ring auxiliary segments (notably<base>_producer_seq) still fit the macOS POSIX-SHM 31-char budget. - validate_
segment_ name_ budget - Validate that the SHM segment names derived from
prefix, including the longest disruptor-mp auxiliary segment (<base>_producer_seq) - will fit the macOS POSIX-SHM 31-char budget. Returns a clear, actionable error so daemon and client both fail loud at startup instead of letting the OS surface a crypticENAMETOOLONG (errno 63)(or worse, aShared segment not foundafter thousands of retries - see RFC 0011 P10 / the 2026-05-18 macOS DST-sweep regression).
Type Aliases§
- ShmFrame
- The frame type backing both rings.