cache write-allocate policy

本文介绍了三种主要的缓存写策略:Write-through、Write-around 和 Write-back,详细探讨了各自的优缺点及其适用场景。Write-through 确保数据更新的安全性,Write-around 减少了缓存的负载,而 Write-back 则提供了最佳的性能。

Write-through, write-around and write-back cache

There are three main caching techniques that can be deployed, each with their own pros and cons.

  • Write-through cache directs write I/O ontocache and through to underlying permanent storage before confirming I/O completion to the host. This ensures data updates are safely stored on, for example, a shared storage array, but has the disadvantage that I/O still experiences latency based on writing to that storage. Write-through cache is good for applications that write and then re-read data frequently as data is stored in cache and results in low read latency. 同时写cache和主存。
  • Write-around cache is a similar technique to write-through cache, but write I/O is written directly to permanent storage, by passing the cache. This can reduce the cache being flooded with write I/O that will not subsequently be re-read, but has the disadvantage is that a read request for recently written data will create a “cache miss” and have to be read from slower bulk storage and experience higher latency. 只写内存,绕过cache。
  • Write-back cache is where write I/O is directed to cache and completion is immediately confirmed to the host. This results in low latency and high throughput for write-intensive 集中写 applications, but there is data availability exposure risk because the only copy of the written data is in cache. As we will discuss later, suppliers have added resiliency with products that duplicate writes. Users need to consider whether write-back cache solutions offer enough protection as data is exposed until it is staged to external storage. Write-back cache is the best performing solution for mixed workloads as both read and write I/O have similar response time levels.

----- 在有cache的单机系统中,通常有两种写策略:write through 和 write back

两种写策略都是针对写命中(write hit)情况而言的:

--------- write through是既写cache也写main memory

--------- write back是只写cache,并使用dirty标志位记录cache的修改,直到被修改的cache 块被替换时,才把修改的内容写回main memory

那么在写失效(write miss)时,即所要写的地址不在cache中,该怎么办呢?

一种办法就是把要写的内容直接写回main memory,这种办法叫做no write allocate policy

另一种办法就是把要写的地址所在的块先从main memory调入cache中,然后写cache,这种办法叫做write allocate policy

在有cache的多处理器系统中仍然会有写失效(write miss)的情况,而且no write allocate policy和write allocate policy也仍然都可以使用。需要讨论的只是在出现write miss这种情况后,snooping cache该如何处理的问题。假设执行写操作的是P1,监听的是P2的cache,那么无论P1执行写操作时是write hit还是write miss,P2的cache(即snooping cache)都会检查P1所写的地址是否在P2的cache中,假如执行的是write invalid策略,那么snooping cache或者把相应的块置为invalid,或者什么都不做(因为它没有相应的块),肯定不会把其它处理器所要写的块调入自己的cache中(因为没有任何意义)。




评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值