Skip to content

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

Merged
vxfemboy merged 2 commits into
mainfrom
emry-004-ring-buffer
Jun 25, 2026
Merged

vxfemboy merged 2 commits into
mainfrom
emry-004-ring-buffer

Conversation

@vxfemboy

Copy link
Copy Markdown
Member

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.

vxfemboy added 2 commits June 24, 2026 20:42
Wrap rtrb in EventProducer/EventConsumer (DEFAULT_CAPACITY 65_536). push()
never blocks: on a full ring it drops the event, increments a shared dropped
counter, and returns RingFull. dropped() readable from both halves for the UI.
Tests: FIFO order, overflow drop+count, shared counter, 10k cross-thread.
@vxfemboy
vxfemboy merged commit 6fb4359 into main Jun 25, 2026
3 checks passed
@vxfemboy vxfemboy mentioned this pull request Jun 25, 2026
5 tasks
@vxfemboy
vxfemboy deleted the emry-004-ring-buffer branch July 2, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant