pub struct RedbBackend { /* private fields */ }Expand description
redb-backed durable state. Atomicity comes from redb’s single-writer write
transaction: each op’s read-modify-write is applied inside one (ADR 000004). redb is
fully synchronous; ADR 000011’s async-aware seam is this KvBackend impl — callers
never see the store or the batching behind it.
Writes amortize begin/commit (and fsync when durable) across concurrent callers — the
classical group-commit idea (DeWitt et al., SIGMOD’84: share durable I/O across a
commit group) — shaped as flat combining (Hendler et al., SPAA’10): a caller queues
its op, then competes for the combiner lock; the winner drains up to MAX_BATCH_OPS
queued ops and applies them inside ONE write transaction. redb serializes writers
globally (begin_write blocks), so per-op transactions would serialize every filter
and route on N× the begin/commit cost; combining keeps the single writer but pays
that cost once per batch. The batch is self-clocking — no timer, no resident thread:
an uncontended caller drains only its own op and runs it inline (zero thread handoff),
while contended callers batch what accumulated while the previous combiner held the lock.
Implementations§
Trait Implementations§
Source§impl KvBackend for RedbBackend
impl KvBackend for RedbBackend
fn get(&self, key: &[u8]) -> Option<Vec<u8>>
fn set(&self, key: &[u8], value: Vec<u8>)
fn delete(&self, key: &[u8])
Source§fn increment(&self, key: &[u8], delta: i64) -> i64
fn increment(&self, key: &[u8], delta: i64) -> i64
delta is signed.Source§fn try_acquire(
&self,
key: &[u8],
cost: u64,
spec: Bucket,
now_ms: u64,
) -> Acquire
fn try_acquire( &self, key: &[u8], cost: u64, spec: Bucket, now_ms: u64, ) -> Acquire
now_ms request-clock snapshot. The
refill + counting stay host-native (ADR 000005) — they never cross the WASM
boundary; the filter only decided to consult the limiter.Auto Trait Implementations§
impl !Freeze for RedbBackend
impl !RefUnwindSafe for RedbBackend
impl !UnwindSafe for RedbBackend
impl Send for RedbBackend
impl Sync for RedbBackend
impl Unpin for RedbBackend
impl UnsafeUnpin for RedbBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more