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

Mla*_*vic 5 linux performance storage cache

该分区位于使用软件 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
Run Code Online (Sandbox Code Playgroud)

因此,对于 300K 块,使用一个线程的随机读取速度为 58 ops/second,大约为 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
Run Code Online (Sandbox Code Playgroud)

有谁知道 Linux 操作系统或硬盘驱动器中的读取/缓存策略使 5 线程随机读取 300K 块比 1 线程读取随机 300K 块快吗?

Tom*_*Tom 2

有什么令人惊讶的?

1个线程意味着命令、等待、读取、循环。其中有一个等待元素——延迟。

多线程消除了这一点,并且通过多个命令的排队使光盘更加优化。使用 3 个线程获得更多 IOPS 一点也不奇怪。