Cache写机制:Write-through与Write-back
2012-07-09 16:09
525 查看
Writing policies
A Write-Through cache with No-Write Allocation
A Write-Back cache with Write Allocation
When a system writes a datum to cache, it must at some point write that datum to backing store as well. The timing of this write is controlled by what is known as the write policy.
There are two basic writing approaches:
Write-through - Write is done synchronously both to the cache and to the backing store.
Write-back (or Write-behind) - Writing is done only to the cache. A modified cache block is written back to the store, just before it is replaced.
write-through同时更新cache和后端存储
write-back 只写cache。当cache blokc要被替换时,才写到后端存储。
Write-back cache is more complex to implement, since it needs to track which of its locations have been written over, and mark them as dirty for later writing to the backing store. The data in these locations are written back to the backing store only when they are evicted from the cache, an effect referred to as a lazy write. For this reason, a read miss in a write-back cache (which requires a block to be replaced by another) will often require two memory accesses to service: one to write the replaced data from the cache back to the store, and then one to retrieve the needed datum.
Other policies may also trigger data write-back. The client may make many changes to a datum in the cache, and then explicitly notify the cache to write back the datum.
Since on write operations, no actual data are needed back, there are two approaches for situations of write-misses:
Write allocate (aka Fetch on write) - Datum at the missed-write location is loaded to cache, followed by a write-hit operation. In this approach, write misses are similar to read-misses.
No-write allocate (aka Write-no-allocate, Write around) - Datum at the missed-write location is not loaded to cache, and is written directly to the backing store. In this approach, actually only system reads are being cached.
Both write-through and write-back policies can use either of these write-miss policies, but usually they are paired in this way:[2]
A write-back cache uses write allocate, hoping for subsequent writes (or even reads) to the same location, which is now cached.
A write-through cache uses no-write allocate. Here, subsequent writes have no advantage, since they still need to be written directly to the backing store.
Entities other than the cache may change the data in the backing store, in which case the copy in the cache may become out-of-date or stale. Alternatively, when the client updates the data in the cache, copies of those data in other caches will become stale. Communication protocols between the cache managers which keep the data consistent are known as coherency protocols.
A Write-Through cache with No-Write Allocation
A Write-Back cache with Write Allocation
When a system writes a datum to cache, it must at some point write that datum to backing store as well. The timing of this write is controlled by what is known as the write policy.
There are two basic writing approaches:
Write-through - Write is done synchronously both to the cache and to the backing store.
Write-back (or Write-behind) - Writing is done only to the cache. A modified cache block is written back to the store, just before it is replaced.
write-through同时更新cache和后端存储
write-back 只写cache。当cache blokc要被替换时,才写到后端存储。
Write-back cache is more complex to implement, since it needs to track which of its locations have been written over, and mark them as dirty for later writing to the backing store. The data in these locations are written back to the backing store only when they are evicted from the cache, an effect referred to as a lazy write. For this reason, a read miss in a write-back cache (which requires a block to be replaced by another) will often require two memory accesses to service: one to write the replaced data from the cache back to the store, and then one to retrieve the needed datum.
Other policies may also trigger data write-back. The client may make many changes to a datum in the cache, and then explicitly notify the cache to write back the datum.
Since on write operations, no actual data are needed back, there are two approaches for situations of write-misses:
Write allocate (aka Fetch on write) - Datum at the missed-write location is loaded to cache, followed by a write-hit operation. In this approach, write misses are similar to read-misses.
No-write allocate (aka Write-no-allocate, Write around) - Datum at the missed-write location is not loaded to cache, and is written directly to the backing store. In this approach, actually only system reads are being cached.
Both write-through and write-back policies can use either of these write-miss policies, but usually they are paired in this way:[2]
A write-back cache uses write allocate, hoping for subsequent writes (or even reads) to the same location, which is now cached.
A write-through cache uses no-write allocate. Here, subsequent writes have no advantage, since they still need to be written directly to the backing store.
Entities other than the cache may change the data in the backing store, in which case the copy in the cache may become out-of-date or stale. Alternatively, when the client updates the data in the cache, copies of those data in other caches will become stale. Communication protocols between the cache managers which keep the data consistent are known as coherency protocols.
相关文章推荐
- Cache写机制:Write-through与Write-back
- Cache写机制:Write-through与Write-back
- Cache写机制:Write-through与Write-back
- Cache写机制:Write-through与Write-back
- Cache写机制:Write-through与Write-back
- Cache写机制:Write-through与Write-back
- 阵列Cache写机制:Write-through与Write-back区别
- Cache写机制:Write-through与Write-back
- Cache写机制:Write-through与Write-back
- PowerPC——Cache——写机制Write-back和Write-through的区别
- Cache写机制:Write-through与Write-back
- linux pagecache bdi writeback 机制
- cache 相关知识 read/write through/back/allocate
- Cache 的write back和write-through
- cache的两种操作方式(Write-through,Write-back)
- 有關 Cache 的 read/write through/back/allocate
- Cache 中 Write through/Write back 区别
- Cache写策略——write-through与write-back
- The Difference between write through and write back for cache
- Cache写策略 — write-through与 write-back