电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

硬盘Cache写机制 Write-through与Write-back的区别


发布日期:2018/9/29
 

Writethrough Write is done synchronously both to the cache and to the backing store

Writeback (or Writebehind) – Writing is done only to the cache A modified cache block is written back to the store just before it is replaced

Writethrough(直写模式)在数据更新时同时写入缓存Cache和后端存储此模式的优点是操作简单;缺点是因为数据修改需要同时写入存储数据写入速度较慢

Writeback(回写模式)在数据更新时只写入缓存Cache只在数据被替换出缓存时被修改的缓存数据才会被写到后端存储此模式的优点是数据写入速度快因为不需要写存储;缺点是一旦更新后的数据未被写入存储时出现系统掉电的情况数据将无法找回

Writemisses写缺失的处理方式

对于写操作存在写入缓存缺失数据的情况这时有两种处理方式

Write allocate (aka Fetch on write) – Datum at the missedwrite location is loaded to cache followed by a writehit operation In this approach write misses are similar to readmisses

Nowrite allocate (aka Writenoallocate Write around) – Datum at the missedwrite location is not loaded to cache and is written directly to the backing store In this approach actually only system reads are being cached

Write allocate方式将写入位置读入缓存然后采用writehit(缓存命中写入)操作写缺失操作与读缺失操作类似

Nowrite allocate方式并不将写入位置读入缓存而是直接将数据写入存储这种方式下只有读操作会被缓存

无论是Writethrough还是Writeback都可以使用写缺失的两种方式之一只是通常Writeback采用Write allocate方式而Writethrough采用Nowrite allocate方式;因为多次写入同一缓存时Write allocate配合Writeback可以提升性能;而对于Writethrough则没有帮助

处理流程图

Writethrough模式处理流程

A WriteThrough cache with NoWrite Allocation

Writeback模式处理流程

A WriteBack cache with Write Allocation

上一篇:新浪微博企业微博头像尺寸大小为多少呢?

下一篇:如何调整笔记本电池充电最低百分比?