EMRY-004: SPSC event ring with drop-and-count backpressure #52

Merged
vxfemboy merged 2 commits from emry-004-ring-buffer into main 2026-06-25 00:59:00 +00:00
vxfemboy commented 2026-06-25 00:44:25 +00:00 (Migrated from github.com)

Closes EMRY-004 (#5). Branched off main (no stacking).

What

crates/emry-core/src/ring.rsEventProducer/EventConsumer wrapping rtrb (lock-free SPSC), DEFAULT_CAPACITY = 65 536.

Backpressure policy (design §3)

Observability never blocks training. On a full ring, push() drops the event, increments a shared atomic counter, and returns RingFull. dropped() is readable from both halves so the UI can surface loss.

Verification

  • ./scripts/pre-commit-rust.sh green: fmt, clippy -D warnings, 26 tests, ring.rs 96% lines
  • Tests: FIFO order, overflow drop+count, shared counter, 10 000-event cross-thread no-deadlock run

Review note

Reviewer flagged Relaxed ordering on the counter. Kept Relaxed (correct for a standalone counter — coherence + finite-time visibility cover the 'observe the count' goal; no happens-before edge needed since it guards no other memory) and documented the rationale inline so it isn't re-flagged.

Closes EMRY-004 (#5). Branched off `main` (no stacking). ## What `crates/emry-core/src/ring.rs` — `EventProducer`/`EventConsumer` wrapping `rtrb` (lock-free SPSC), `DEFAULT_CAPACITY` = 65 536. ## Backpressure policy (design §3) Observability never blocks training. On a full ring, `push()` **drops** the event, increments a shared atomic counter, and returns `RingFull`. `dropped()` is readable from both halves so the UI can surface loss. ## Verification - `./scripts/pre-commit-rust.sh` green: fmt, clippy `-D warnings`, 26 tests, ring.rs 96% lines - Tests: FIFO order, overflow drop+count, shared counter, 10 000-event cross-thread no-deadlock run ## Review note Reviewer flagged `Relaxed` ordering on the counter. Kept `Relaxed` (correct for a standalone counter — coherence + finite-time visibility cover the 'observe the count' goal; no happens-before edge needed since it guards no other memory) and documented the rationale inline so it isn't re-flagged.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
femboy/emry!52
No description provided.