Skip to main content

Module group_commit

Module group_commit 

Source
Expand description

Group commit with consolidation for WAL frame writes (bd-ncivz.3).

Amortizes fsync overhead across multiple concurrent transactions by batching WAL frame writes into a single I/O + fsync operation.

§Consolidation Protocol

Writers submit sealed frame batches to a consolidation queue. The protocol transitions through three phases:

FILLING ──▶ FLUSHING ──▶ COMPLETE ──▶ FILLING (next epoch)
  • FILLING: Accepting new frame batches from writers.
  • FLUSHING: The flusher (first writer to arrive) writes all accumulated frames to the WAL file via a single consolidated I/O, then fsyncs.
  • COMPLETE: All waiters are notified; committed frames are durable.

The first writer to enter a FILLING phase becomes the flusher. Subsequent writers add their frames and park on a condvar. When the flusher decides to flush (batch full OR max delay exceeded), it writes all accumulated frames, fsyncs once, and wakes all parked writers.

§I/O Optimization

Consolidated writes serialize all frame buffers into a single contiguous write to the WAL file, avoiding per-frame syscall overhead. The single fsync after the batch write makes all frames durable atomically.

§Tuning

  • max_group_size: Maximum frames per group before forced flush (default: 64).
  • max_group_delay: Maximum time to wait for additional writers before flushing (default: 1ms). Bounded to ensure tail latency.

Structs§

ConsolidationMetrics
Atomic counters for group commit consolidation observability.
ConsolidationMetricsSnapshot
Point-in-time snapshot of consolidation metrics.
FrameSubmission
A single WAL frame submitted for consolidated writing.
GroupCommitConfig
Configuration for group commit consolidation.
GroupCommitConsolidator
The group commit consolidator accumulates frame batches from concurrent writers and flushes them to the WAL file in consolidated groups.
PhaseHistogram
PhasePercentiles
Percentile snapshot from a PhaseHistogram.
TransactionConflictSnapshot
WAL conflict horizon captured by a submitting transaction.
TransactionFrameBatch
A batch of frames from a single transaction, submitted atomically.
TransactionFrameBatchContext
Lane-local staging context attached to a transaction batch.
WakeReasonCounters
Tracks why a waiter woke up during epoch wait.
WakeReasonSnapshot
Point-in-time snapshot of wake reasons.

Enums§

ConsolidationPhase
Phase of the consolidation protocol.
SubmitOutcome
Outcome of submitting a transaction batch for consolidated writing.

Statics§

GLOBAL_CONSOLIDATION_METRICS
Global consolidation metrics singleton.

Functions§

commit_phase_timing_enabled
Whether commit phase timing should sample Instant::now().
commit_phase_timing_forced_enabled
Whether commit phase timing has been explicitly enabled by a profiling caller.
detailed_consolidation_metrics_enabled
Whether expensive per-substep consolidation timing is enabled.
set_commit_phase_timing_enabled
Enable or disable WAL commit phase timing for explicit profiling windows.
write_consolidated_frames
Write a consolidated batch of frames to the WAL file.