pub struct ArenaMvccMemTable { /* private fields */ }Expand description
Arena-backed MVCC MemTable with optimized key storage
This version uses ArenaKeyHandle instead of Vec<u8> for keys,
reducing per-write allocations from 3 to 1:
- Before: 3 × Vec
clones per write (dirty_list, ordered_index, data) - After: 1 × ArenaKeyHandle creation, 3 × O(1) copies (16 bytes each)
§Performance
Expected improvement: 20-30% throughput increase on write-heavy workloads by reducing:
- Heap allocations: 3 → 1 per write
- Bytes copied: 3L → L + 48 bytes (where L = key length)
Implementations§
Source§impl ArenaMvccMemTable
impl ArenaMvccMemTable
pub fn new() -> Self
pub fn with_ordered_index(enable_ordered_index: bool) -> Self
Sourcepub fn write(
&self,
key: &[u8],
value: Option<Vec<u8>>,
txn_id: u64,
) -> Result<()>
pub fn write( &self, key: &[u8], value: Option<Vec<u8>>, txn_id: u64, ) -> Result<()>
Write a key-value pair using arena key handle
Only creates ONE ArenaKeyHandle, then copies it (16 bytes) to each location.
This is much cheaper than cloning Vec
Sourcepub fn write_batch(
&self,
writes: &[(&[u8], Option<Vec<u8>>)],
txn_id: u64,
) -> Result<()>
pub fn write_batch( &self, writes: &[(&[u8], Option<Vec<u8>>)], txn_id: u64, ) -> Result<()>
Write batch using arena key handles
Sourcepub fn read(
&self,
key: &[u8],
snapshot_ts: u64,
current_txn_id: Option<u64>,
) -> Option<Vec<u8>>
pub fn read( &self, key: &[u8], snapshot_ts: u64, current_txn_id: Option<u64>, ) -> Option<Vec<u8>>
Read at snapshot timestamp
Sourcepub fn commit(
&self,
txn_id: u64,
commit_ts: u64,
write_set: &HashSet<InlineKey>,
)
pub fn commit( &self, txn_id: u64, commit_ts: u64, write_set: &HashSet<InlineKey>, )
Commit transaction
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ArenaMvccMemTable
impl !RefUnwindSafe for ArenaMvccMemTable
impl !UnwindSafe for ArenaMvccMemTable
impl Send for ArenaMvccMemTable
impl Sync for ArenaMvccMemTable
impl Unpin for ArenaMvccMemTable
impl UnsafeUnpin for ArenaMvccMemTable
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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