zoukankan      html  css  js  c++  java
  • SSD 为什么顺序写比随机写性能更好?

    SSD以Page为单位做读写,以Block为单位做垃圾回收,Page一般有16KB大小,Block一般有几十MB大小,SSD写数据的逻辑是:

    1)将该块数据所在的Page读出

    2)修改该Page中该块数据的内容

    3)找出一个新的空闲Block将2)中的Page写入,并将1)中提到的Page所在的Block中的Page标志为脏

    理解了写原理,也就明白了为什么顺序写比随机写好了。四个字:垃圾回收!写相同数据量的情况下,顺序写制造更少的垃圾Block,所以比随机写有更高的性能。

    这篇文章有详细的描述:

    ... the need for garbage collection affects an SSD’s performance, because any write operation to a “full” disk (one whose initial free space or capacity has been filled at least once) needs to await the availability of new free space created through the garbage collection process. Because garbage collection occurs at the block level, there is also a significant performance difference, depending on whether sequential or random data is involved. Sequential files fill entire blocks, which dramatically simplifies garbage collection. The situation is very different for random data.
    
    As random data is written, often by multiple applications, the pages are written sequentially throughout the blocks of the flash memory.
    The problem is: This new data is replacing old data distributed randomly in other blocks. This causes a potentially large number of small “holes” of invalid pages to become scattered among the pages still containing valid data. During garbage collection of these blocks, all valid data must be moved (i.e. read and re-written) to a different block.
    By contrast, when sequential files are replaced, entire blocks are often invalid, so no data needs to be moved. Sometimes a portion of a sequential file might share a block with another file, but on average only about half of such blocks will need to be moved, making it much faster than garbage collection for randomly-written blocks. ...
    

     原文来源:http://serverfault.com/questions/843628/why-does-sequential-writes-have-better-performance-than-random-writes-in-ssds

    当然,如果每次读写都以Block为单位读写,那么顺序写和随机写的性能相当。

  • 相关阅读:
    如何查看Android SDK源码版本
    迁移 Express 到函数计算
    阿里云安全运营中心:DDoS攻击趁虚而入,通过代理攻击已成常态
    Schedulerx2.0支持应用级别资源管理和任务优先级
    Serverless 解惑——函数计算如何安装字体
    一遇到复杂分析查询就卡顿?MySQL分析实例了解一下
    浅谈企业的数据资产管理
    大咖说备份 | 云,让灾备更简单
    急速上线 Serverless 钉钉机器人“防疫精灵”
    Alibaba Cloud Linux 2 LTS 正式发布,提供更高性能和更多保障
  • 原文地址:https://www.cnblogs.com/cobbliu/p/6692803.html
Copyright © 2011-2022 走看看