pub struct MvccTransaction {
pub txn_id: u64,
pub snapshot_ts: u64,
pub write_set: HashSet<InlineKey>,
pub read_set: HashSet<InlineKey>,
pub write_bloom: SsiBloomFilter,
pub read_bloom: SsiBloomFilter,
pub state: TxnState,
pub mode: TransactionMode,
}Expand description
Transaction state for MVCC
Fields§
§txn_id: u64Transaction ID
snapshot_ts: u64Snapshot timestamp (reads see commits before this)
write_set: HashSet<InlineKey>Keys written by this transaction - uses SmallVec for inline storage Pre-sized to WRITE_SET_INITIAL_CAPACITY to avoid resize overhead
read_set: HashSet<InlineKey>Keys read by this transaction (for SSI validation) - uses SmallVec for inline storage Pre-sized to READ_SET_INITIAL_CAPACITY to avoid resize overhead
write_bloom: SsiBloomFilterBloom filter for write set - fast SSI pre-filtering
read_bloom: SsiBloomFilterBloom filter for read set - fast SSI pre-filtering
state: TxnStateTransaction state
mode: TransactionModeTransaction mode for SSI optimization (Recommendation 9) ReadOnly/WriteOnly modes skip SSI tracking for 2.6x improvement
Implementations§
Source§impl MvccTransaction
impl MvccTransaction
Sourcepub fn new(txn_id: u64, snapshot_ts: u64) -> Self
pub fn new(txn_id: u64, snapshot_ts: u64) -> Self
Create a new transaction with pre-sized collections
This avoids HashSet resize overhead during the transaction which was causing +11% regression on write_set.insert().
Sourcepub fn read_only(txn_id: u64, snapshot_ts: u64) -> Self
pub fn read_only(txn_id: u64, snapshot_ts: u64) -> Self
Create a read-only transaction (SSI bypass - 2.6x faster)
Read-only transactions skip all SSI tracking:
- No read_set allocation
- No read_bloom allocation
- No commit validation
§Performance
For N=100 reads: 8350ns → 3230ns (2.6× improvement)
Sourcepub fn write_only(txn_id: u64, snapshot_ts: u64) -> Self
pub fn write_only(txn_id: u64, snapshot_ts: u64) -> Self
Create a write-only transaction (partial SSI bypass)
Write-only transactions skip read tracking:
- No read_set tracking
- No read_bloom inserts
- Still needs write_set for commit
Sourcepub fn with_mode(txn_id: u64, snapshot_ts: u64, mode: TransactionMode) -> Self
pub fn with_mode(txn_id: u64, snapshot_ts: u64, mode: TransactionMode) -> Self
Create transaction with specific mode
Sourcepub fn with_capacity(
txn_id: u64,
snapshot_ts: u64,
write_capacity: usize,
read_capacity: usize,
mode: TransactionMode,
) -> Self
pub fn with_capacity( txn_id: u64, snapshot_ts: u64, write_capacity: usize, read_capacity: usize, mode: TransactionMode, ) -> Self
Create with custom capacities for expected workload
Use this when you know the transaction will write many keys to avoid resize overhead entirely.
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Check if this is a read-only transaction
Sourcepub fn is_single_key_write(&self) -> bool
pub fn is_single_key_write(&self) -> bool
Check if this is a single-key write transaction
Trait Implementations§
Source§impl Clone for MvccTransaction
impl Clone for MvccTransaction
Source§fn clone(&self) -> MvccTransaction
fn clone(&self) -> MvccTransaction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MvccTransaction
impl RefUnwindSafe for MvccTransaction
impl Send for MvccTransaction
impl Sync for MvccTransaction
impl Unpin for MvccTransaction
impl UnsafeUnpin for MvccTransaction
impl UnwindSafe for MvccTransaction
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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