A write buffer is a type of
data buffer that can be used to hold
data being written from the cache to
main memory
Computer data storage is a technology consisting of computer components and recording media that are used to retain digital data. It is a core function and fundamental component of computers.
The central processing unit (CPU) of a computer ...
or to the next cache in the
memory hierarchy
In computer architecture, the memory hierarchy separates computer storage into a hierarchy based on response time. Since response time, complexity, and capacity are related, the levels may also be distinguished by their performance and controlli ...
to improve performance and reduce
latency. It is used in certain
CPU cache architectures like Intel's x86 and AMD64. In multi-core systems, write buffers destroy
sequential consistency
Sequential consistency is a consistency model used in the domain of concurrent computing
Concurrent computing is a form of computing in which several computations are executed '' concurrently''—during overlapping time periods—instead of ...
. Some software disciplines, like
C11's data-race-freedom, are sufficient to regain a sequentially consistent view of memory.
A variation of
write-through caching is called ''buffered write-through''.
Use of a write buffer in this manner frees the cache to service read requests while the write is taking place. It is especially useful for very slow main memory in that subsequent reads are able to proceed without waiting for long main memory latency. When the write buffer is full (i.e. all buffer entries are occupied), subsequent writes still have to wait until slots are freed. Subsequent reads could be served from the write buffer. To further mitigate this stall, one optimization called write buffer merge may be implemented. Write buffer merge
combines writes that have consecutive destination addresses into one buffer entry. Otherwise, they would occupy separate entries which increases the chance of pipeline stall.
A victim buffer is a type of write buffer that stores dirty evicted lines in
write-back caches
[ Write-through caches don't need write the evicted cache lines as they are written to main memory when the cache is written.] so that they get written back to main memory. Besides reducing pipeline stall by not waiting for dirty lines to write back as a simple write buffer does, a victim buffer may also serve as a temporary backup storage when subsequent cache accesses exhibit