pub struct GroupCommitManager { /* private fields */ }Expand description
Manages batched transaction commits for improved throughput.
Multiple concurrent transactions queue their commits, and a “leader” thread performs the actual WAL sync for the entire batch. This amortizes the cost of fsync across many transactions.
§Algorithm
- Transaction calls
commit(lsn)after writing to WAL - If no leader is active, this thread becomes the leader
- Leader waits up to
max_waitor untilmax_batch_sizereached - Leader performs WAL sync
- Leader notifies all pending commits of completion
- Non-leader threads wait on condvar until notified
§Thread Safety
This struct is designed for concurrent access from multiple threads.
Implementations§
Source§impl GroupCommitManager
impl GroupCommitManager
Sourcepub fn new(config: GroupCommitConfig, wal: Arc<Mutex<Wal>>) -> Self
pub fn new(config: GroupCommitConfig, wal: Arc<Mutex<Wal>>) -> Self
Creates a new group commit manager.
Sourcepub fn batch_count(&self) -> u64
pub fn batch_count(&self) -> u64
Returns the number of batch syncs performed.
Sourcepub fn commit_count(&self) -> u64
pub fn commit_count(&self) -> u64
Returns the total number of commits processed.
Sourcepub fn avg_batch_size(&self) -> f64
pub fn avg_batch_size(&self) -> f64
Returns the average commits per batch.
Auto Trait Implementations§
impl !Freeze for GroupCommitManager
impl RefUnwindSafe for GroupCommitManager
impl Send for GroupCommitManager
impl Sync for GroupCommitManager
impl Unpin for GroupCommitManager
impl UnwindSafe for GroupCommitManager
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
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