• 请不要在回答技术问题时复制粘贴 AI 生成的内容
pursuit
V2EX  ›  程序员

[分享] 极致优化 SSD 并行读调度

  •  
  •   pursuit · Sep 25, 2023 · 2240 views
    This topic created in 964 days ago, the information mentioned may be changed or developed.

    SSD 在工作业务场景用得蛮多的,对长尾的控制,硬件上历史有 Streamed SSD 、OpenChannel SSD ,还有最新的 Zoned Namespaces SSD 。不过公司引入硬件周期长,业务上的问题也还是得解决。

    我们从以下几个方面充分优化对 SSD 的使用:

    1. 读写和 SSD 上的闪存单元大小对齐,控制为 4K ;
    2. 充分利用 SSD 的并行能力,用上了 libaio 和 iouring ;(吐槽下 iouring 真是太新了,接口用上耗费了一翻源码追踪的功夫,现在 io cacnel 的接口适配还卡着,没来得及定位)
    3. 并行读的时候,利用上了流水线的思想,充分并行本地的 CPU 和 IO ;(这里吹下 fio 的设计,流水线的思路是从这里启发而来的)

    更完整的优化分享可以详见: https://mp.weixin.qq.com/s/CB4u5AQuRrIq5mRISx9GmQ

    5 replies    2023-09-26 14:29:11 +08:00
    dreamlike
        1
    dreamlike  
       Sep 26, 2023 via Android
    能请问下 io cancel 适配是卡在 io_uring 并不保证 cancel 成功吗?🤔我之前遇到的就是这个问题,在写场景/读场景 若未取消成功即操作已经推入内核执行的情况下 用户操作对应到那块内存就会产生 ub
    ac23
        2
    ac23  
       Sep 26, 2023
    感谢分享!
    pursuit
        3
    pursuit  
    OP
       Sep 26, 2023
    @dreamlike 调用 io_uring_prep_cancel 指定要 cancel 的任务,但是根据观察没有 cancel 成功,其实 libaio 使用同样的 cancel 接口,也没有成功。按照接口语义( https://man7.org/linux/man-pages/man3/io_uring_prep_cancel.3.html )应该是成功才对,还不知道为什么不成功。提交的内存确实得保证不能有竞争,得完整回来操作才不会 ub ,因为异步 io 不知道什么时候就给那块内存写东西了~
    dreamlike
        4
    dreamlike  
       Sep 26, 2023 via Android
    @pursuit The execution state of the request has progressed far enough that cancelation is no longer possible ,不保证吧。。。
    pursuit
        5
    pursuit  
    OP
       Sep 26, 2023
    @dreamlike 这段话是说返回 -EALREADY 的情况下吧,但也有不返回 error 成功的时候
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2986 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 07:54 · PVG 15:54 · LAX 00:54 · JFK 03:54
    ♥ Do have faith in what you're doing.