pub struct GroupCommitMaster { /* private fields */ }Expand description
Group-commit implementation for the Master role.
When a transaction arrives it is added to a pending queue. A leader thread
waits for up to interval_ms milliseconds (or until max_count
transactions are queued) before issuing a single fsync. After the fsync the
queued transactions are acknowledged.
§Threshold semantics
buffer_commit() returns false (caller must fsync) every max_count
calls — the count-based threshold. The caller (Txn::commit_with_durability)
treats a false return as a signal to call LogManager::flush_sync(),
which then handles the time-based coalescing via FSyncManager. This
correctly separates concerns: GroupCommit enforces the batch-size policy;
FSyncManager enforces the time-window and leader/waiter coalescing.
Implementations§
Source§impl GroupCommitMaster
impl GroupCommitMaster
Sourcepub fn new(max_count: usize, interval_ms: u64) -> Self
pub fn new(max_count: usize, interval_ms: u64) -> Self
Creates a new GroupCommitMaster.
§Arguments
max_count— maximum batch size.interval_ms— batch window in millisecondsMASTER_GROUP_COMMIT_INTERVAL).
Sourcepub fn interval_ms(&self) -> u64
pub fn interval_ms(&self) -> u64
Returns the batch window in milliseconds.
Sourcepub fn flush_count(&self) -> usize
pub fn flush_count(&self) -> usize
Returns the number of times the count threshold has fired.
Used in tests to verify durability threshold enforcement.
Trait Implementations§
Source§impl Default for GroupCommitMaster
impl Default for GroupCommitMaster
Source§impl GroupCommit for GroupCommitMaster
impl GroupCommit for GroupCommitMaster
Source§fn buffer_commit(&self, _commit_vlsn: i64) -> bool
fn buffer_commit(&self, _commit_vlsn: i64) -> bool
Buffer a commit and enforce the count-based threshold.
Returns false (caller must fsync) on every max_countth call.
Returns true (commit is buffered, skip fsync) otherwise.
Count-threshold path.
The time-window threshold is handled by FSyncManager when the
caller proceeds to LogManager::flush_sync() on a false return.
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
true if group commit is currently enabled.