What is write-combining buffer?
In the world of high-performance computing and graphics, the Write-Combining Buffer (WC Buffer) is the CPU's way of turning small, inefficient "drips" of data into a single, powerful "stream."
If your CPU tried to send every single byte to your graphics card or network card as soon as it was ready, the system would grind to a halt due to bus overhead. The Write-Combining Buffer acts as a staging area to prevent this.
Modern system buses (like PCIe) are designed for bulk transport.
The Analogy: Imagine you need to move 64 boxes to a warehouse. You could drive back and forth 64 times with one box in your car (inefficient), or you could wait until you have a full truckload.
The CPU Reality: Without write-combining, every time a program writes a single byte to "uncacheable" memory (like a video frame buffer), the CPU has to initiate a full bus transaction. This creates massive latency and "stalls" the execution pipeline.
Write-Combining is a specific Memory Typing (MTRR or PAT) that tells the CPU: "Don't worry about keeping this data in the L1 cache, and don't worry about immediate consistency. Just wait until you have a full 'cache line' worth of data."
Aggregation: The CPU gathers multiple small writes into a set of internal buffers (usually 64 bytes each, matching the size of a cache line).
Delaying: Instead of sending data to the RAM or PCIe device immediately, it waits until the buffer is full.
Bursting: Once full, the CPU "bursts" the entire 64-byte block across the bus in a single, high-speed transaction.
You won't typically see Write-Combining used for standard application RAM (which uses "Write-Back" caching), but it is critical for:
Video & GPU Workloads: When an OCI GPU instance (like an H100) is rendering a frame, the CPU uses write-combining to push pixel data to the GPU’s VRAM.
High-Speed Networking: Some specialized network drivers use write-combining to "build" packet headers in a buffer before blasting them to the NIC.
Non-Volatile Memory (PMEM): As we discussed in previous sections, write-combining can be used to optimize how data is committed to persistent memory regions.
The "price" of this speed is that Write-Combining breaks Strong Ordering.
The Risk: Because the CPU is holding onto data to fill a buffer, "Write A" might stay in the buffer while "Write B" (sent later) is pushed out first because it happened to fill a different buffer.
For programmers, this means you must use Memory Fences (like sfence in x86) to "flush" the buffers manually if you need to ensure that the data has actually reached the hardware in a specific order.
| Feature | Write-Back (Standard RAM) | Write-Combining (I/O Devices) |
| Caching | Data stays in L1/L2/L3 cache. | Bypasses standard caches. |
| Persistence | Fast, but complex to "flush" to disk. | Optimized for streaming to hardware. |
| Bus Use | Occasional (on cache eviction). | Highly Efficient (always full bursts). |
| Best For | General application logic. | Frame buffers, NICs, and GPUs. |
"Write-combining is the 'shipping container' of the CPU world. By refusing to move data until the container is full, it ensures that your high-speed PCIe devices are fed with massive bursts of data rather than being choked by a million tiny requests."