How does write combining interact with redo logging patterns?
In the world of database performance, the Redo Log is the ultimate "write-heavy" structure. Every transaction generates change vectors that must be streamed to disk as fast as possible. To optimize this, modern CPUs use a hardware mechanism called Write Combining (WC).
When WC and Redo logging patterns align, performance is effortless. When they clash, you get a "stall-and-flush" cycle that can choke your commit throughput.
Normally, the CPU treats memory writes with strict "Coherency" rules. If you write 8 bytes, the CPU tries to manage that 8-byte chunk through the cache hierarchy.
Write Combining is a "bulk-shipping" optimization. It identifies a series of small, sequential writes and, instead of sending them to the cache one by one, it gathers them in a Write Combining Buffer (usually 64 bytes, matching a cache line). Once the buffer is full, the CPU sends the entire 64-byte block in a single "burst" transaction across the bus.
Redo logging is the "perfect customer" for Write Combining because of its access pattern:
Sequentiality: Redo entries are appended one after another in a contiguous buffer.
Write-Only Nature: The Log Writer (LGWR) rarely reads the data it just wrote; it simply "blasts" it toward the storage controller or Persistent Memory (PMEM).
The Benefit: By using Write Combining, the CPU avoids the overhead of "Reading for Ownership" (RFO). It doesn't ask the other cores if they have the cache line; it simply overwrites the destination with the combined 64-byte burst. This significantly reduces Interconnect traffic.
The efficiency of Write Combining depends on filling that 64-byte buffer. This is where database "Commit" patterns can cause issues.
If a database performs a COMMIT for a very small transaction (e.g., changing one flag), the Log Writer must immediately flush the redo log to disk to satisfy ACID requirements.
The Collision: If the Log Writer has only written 16 bytes into the 64-byte WC buffer, the COMMIT forces a Memory Barrier.
The Penalty: The barrier forces a Partial Flush. The hardware is forced to ship an incomplete 64-byte line. This wastes bus bandwidth and adds "stall cycles" as the CPU waits for an acknowledgment of a tiny, inefficient transfer.
The interaction between WC and redo logging is even more critical in modern hardware architectures:
Persistent Memory (PMEM): When using PMEM for redo logs, DBAs often use Non-Temporal Stores (instructions like MOVNTI). These instructions explicitly use Write Combining to bypass the CPU caches. This is the fastest way to write redo, but it makes the "Partial Flush" penalty even more severe.
RoCE (RDMA over Converged Ethernet): In RAC environments, Cache Fusion and Redo shipping often use RDMA. Write Combining allows the CPU to prep data for the NIC in "bursts," reducing the number of PCIe transactions required to move log buffers across the wire.
| Log Pattern | WC Efficiency | Throughput Impact |
| Large Batch Loads | High | Full 64-byte bursts; minimal CPU overhead. |
| High-Frequency Tiny Commits | Low | Frequent partial flushes; high "System" CPU time. |
| Padded Log Headers | Optimal | Ensures metadata updates align with 64-byte boundaries. |
To make the most of Write Combining for your redo logs:
Encourage Group Commits: By grouping multiple small transactions into a single log write, you ensure the Write Combining buffers are full before they are flushed.
Align Log Buffers: Ensure your database log buffers are aligned on 64-byte boundaries. If a log write starts at byte 63, every single write will "straddle" two WC buffers, doubling the work the hardware has to do.
Monitor "Bus Utilization": If you see high bus contention despite low IOPS, it’s a sign that your Redo logging is triggering too many inefficient, partial write-combining flushes.