iozone:5个并发线程随机读取300K块比仅使用一个线程执行更多的操作/秒,其根本原因可能是什么?

iozone:5个并发线程随机读取300K块比仅使用一个线程执行更多的操作/秒,其根本原因可能是什么?

该分区采用软件 RAID,处于 RAID1 状态。

    Command line used: iozone -s 190g -r 300k -O -b test_file
    OPS Mode. Output is in operations per second.
                                                            random  random    bkwd   record   stride                                   
          KB  reclen   write rewrite    read    reread    read   write    read  rewrite     read   fwrite frewrite   fread  freread
   199229440     300     240     234      254      253      58     127     100     6539       91      234      234     254      254

因此对于 300K 块,使用一个线程的随机读取速度为 58 操作/秒,约为 17MB/s。

但是当我尝试 5 个线程,每个线程读取 300K 个块时,出乎意料的是,它运行得更快,尽管我期望有更多的随机访问:

    OPS Mode. Output is in operations per second.
    Command line used: iozone -s 80g -r 300k -O -l5 -u 5 -F test_file1 test_file2 test_file3 test_file4 test_file5

    Children see throughput for 5 random readers    =      69.27 ops/sec
    Parent sees throughput for 5 random readers     =      69.27 ops/sec
    Min throughput per process                      =      13.81 ops/sec 
    Max throughput per process                      =      13.89 ops/sec
    Avg throughput per process                      =      13.85 ops/sec

是否有人知道 Linux 操作系统或硬盘中的哪些读取/缓存策略使得 5 个线程读取随机 300K 块比 1 个线程读取随机 300K 块更快?

答案1

有什么好惊奇的呢?

1 个线程表示命令、等待、读取、循环。其中有一个等待元素 - 延迟。

多线程消除了这个问题,并且由于多条命令排队,磁盘可以得到进一步优化。使用 3 个线程可以获得更高的 IOPS,这并不奇怪。

答案2

这是 raid1,因此写入会转到两个磁盘,但读取只需一个磁盘即可,因此线程越多,我期望性能越好。但线程数最好等于 raid 1(或 raid 10 的 raid 1 部分)中的磁盘数。

相关内容