pub struct MvccManager { /* private fields */ }Expand description
MVCC Manager with SSI support
Uses DashMap for lock-free per-transaction access. Implements Serializable Snapshot Isolation (SSI) with dangerous structure detection for rw-antidependency cycles.
Implementations§
Source§impl MvccManager
impl MvccManager
pub fn new() -> Self
Sourcepub fn begin(&self, txn_id: u64) -> MvccTransaction
pub fn begin(&self, txn_id: u64) -> MvccTransaction
Begin a new transaction with snapshot isolation
Uses pre-sized HashSets to avoid resize overhead (+11% regression fix)
Sourcepub fn begin_read_only(&self, txn_id: u64) -> MvccTransaction
pub fn begin_read_only(&self, txn_id: u64) -> MvccTransaction
Begin a read-only transaction (SSI bypass - 2.6x faster)
Read-only transactions skip all SSI tracking, reducing per-read overhead from ~82ns to ~32ns.
§Safety
Caller must ensure no writes are performed. Attempting to write in a read-only transaction will still succeed but won’t be tracked for SSI validation.
Sourcepub fn begin_write_only(&self, txn_id: u64) -> MvccTransaction
pub fn begin_write_only(&self, txn_id: u64) -> MvccTransaction
Begin a write-only transaction (partial SSI bypass)
Write-only transactions skip read tracking, reducing overhead for insert-heavy workloads.
Sourcepub fn begin_with_mode(
&self,
txn_id: u64,
mode: TransactionMode,
) -> MvccTransaction
pub fn begin_with_mode( &self, txn_id: u64, mode: TransactionMode, ) -> MvccTransaction
Begin a transaction with specific mode
This is the core transaction creation method that all other begin_* methods delegate to.
Sourcepub fn get(&self, txn_id: u64) -> Option<MvccTransaction>
pub fn get(&self, txn_id: u64) -> Option<MvccTransaction>
Get transaction if active (clones - use get_snapshot_ts for hot path)
Sourcepub fn get_snapshot_ts(&self, txn_id: u64) -> Option<u64>
pub fn get_snapshot_ts(&self, txn_id: u64) -> Option<u64>
Fast path: get just the snapshot timestamp without cloning This is the hot path for reads - avoids cloning bloom filters
Sourcepub fn record_read(&self, txn_id: u64, key: &[u8])
pub fn record_read(&self, txn_id: u64, key: &[u8])
Record a read (for SSI) - uses inline key storage + bloom filter
§SSI Bypass (Recommendation 9)
For ReadOnly mode transactions, this is a no-op (instant return). For WriteOnly mode transactions, this is a no-op. Only ReadWrite mode transactions track reads for SSI.
This reduces per-read overhead from ~50ns to ~0ns for read-only txns.
Sourcepub fn record_write(&self, txn_id: u64, key: &[u8])
pub fn record_write(&self, txn_id: u64, key: &[u8])
Record a write - uses inline key storage + bloom filter
Note: Even ReadOnly transactions can record writes (mode is a hint). The mode only affects SSI tracking, not write capability.
Sourcepub fn alloc_commit_ts(&self) -> u64
pub fn alloc_commit_ts(&self) -> u64
Allocate commit timestamp
Sourcepub fn commit(&self, txn_id: u64) -> Option<(u64, HashSet<InlineKey>)>
pub fn commit(&self, txn_id: u64) -> Option<(u64, HashSet<InlineKey>)>
Commit transaction with SSI validation Returns (commit_ts, write_set) so the memtable can be updated efficiently Returns None if SSI validation fails (dangerous structure detected)
§SSI Bypass (Recommendation 9)
For ReadOnly mode: Skip validation entirely (~10ns commit) For WriteOnly mode: Skip read-based validation (~30ns commit) For ReadWrite mode: Full validation (~50ns commit)
Sourcepub fn min_active_snapshot(&self) -> u64
pub fn min_active_snapshot(&self) -> u64
Get minimum active snapshot timestamp
Sourcepub fn active_transaction_count(&self) -> usize
pub fn active_transaction_count(&self) -> usize
Get count of active transactions
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MvccManager
impl !RefUnwindSafe for MvccManager
impl Send for MvccManager
impl Sync for MvccManager
impl Unpin for MvccManager
impl UnsafeUnpin for MvccManager
impl UnwindSafe for MvccManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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