Linux测试磁盘iops

165 阅读4分钟

测试使用的系统

本次测试使用的系统为debian12

root@debianh61:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

安装fio

apt install fio

运行测试

使用同步的方式测试

编写fio需要用到的配置文件

创建posix.fio文件,使用的同步引擎为ioengine=psync, 内容如下

[global]
thread=1
group_reporting=1
direct=1
verify=0
time_based=1
runtime=10
bs=16k
size=16384
iodepth=64
rw=randwrite
filename=testfs
ioengine=psync


[test]
stonewall
description="variable bs"

运行命令

root@debianh61:~# fio posix.fio
test: (g=0): rw=randwrite, bs=(R) 16.0KiB-16.0KiB, (W) 16.0KiB-16.0KiB, (T) 16.0KiB-16.0KiB, ioengine=psync, iodepth=64
fio-3.33
Starting 1 thread
test: Laying out IO file (1 file / 0MiB)
note: both iodepth >= 1 and synchronous I/O engine are selected, queue depth will be capped at 1
Jobs: 1 (f=1): [w(1)][100.0%][w=104MiB/s][w=6671 IOPS][eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=1143: Sat Oct 19 23:59:51 2024
  Description  : ["variable bs"]
  write: IOPS=6709, BW=105MiB/s (110MB/s)(1048MiB/10001msec); 0 zone resets
    clat (usec): min=139, max=8593, avg=147.21, stdev=46.00
     lat (usec): min=140, max=8594, avg=147.69, stdev=46.02
    clat percentiles (usec):
     |  1.00th=[  141],  5.00th=[  141], 10.00th=[  141], 20.00th=[  143],
     | 30.00th=[  143], 40.00th=[  143], 50.00th=[  143], 60.00th=[  143],
     | 70.00th=[  143], 80.00th=[  145], 90.00th=[  145], 95.00th=[  159],
     | 99.00th=[  237], 99.50th=[  515], 99.90th=[  562], 99.95th=[  578],
     | 99.99th=[  627]
   bw (  KiB/s): min=105056, max=109024, per=100.00%, avg=107494.74, stdev=1396.99, samples=19
   iops        : min= 6566, max= 6814, avg=6718.42, stdev=87.31, samples=19
  lat (usec)   : 250=99.34%, 500=0.10%, 750=0.56%
  lat (msec)   : 2=0.01%, 10=0.01%
  cpu          : usr=2.23%, sys=35.42%, ctx=67103, majf=0, minf=0
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,67102,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=64

Run status group 0 (all jobs):
  WRITE: bw=105MiB/s (110MB/s), 105MiB/s-105MiB/s (110MB/s-110MB/s), io=1048MiB (1099MB), run=10001-10001msec

Disk stats (read/write):
  sdb: ios=0/66421, merge=0/9, ticks=0/9302, in_queue=9311, util=92.32%

使用异步的方式测试

将ioengine值改为io_uring

开始测试

root@debianh61:~# fio posix.fio
test: (g=0): rw=randwrite, bs=(R) 16.0KiB-16.0KiB, (W) 16.0KiB-16.0KiB, (T) 16.0KiB-16.0KiB, ioengine=io_uring, iodepth=64
fio-3.33
Starting 1 thread
test: Laying out IO file (1 file / 0MiB)
Jobs: 1 (f=1): [w(1)][100.0%][w=103MiB/s][w=6623 IOPS][eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=1357: Sun Oct 20 00:31:11 2024
  Description  : ["variable bs"]
  write: IOPS=6535, BW=102MiB/s (107MB/s)(1021MiB/10001msec); 0 zone resets
    slat (nsec): min=1061, max=1276.3k, avg=149509.58, stdev=34344.88
    clat (usec): min=299, max=29470, avg=9640.09, stdev=543.85
     lat (usec): min=337, max=29472, avg=9789.60, stdev=543.81
    clat percentiles (usec):
     |  1.00th=[ 9110],  5.00th=[ 9241], 10.00th=[ 9372], 20.00th=[ 9372],
     | 30.00th=[ 9372], 40.00th=[ 9503], 50.00th=[ 9634], 60.00th=[ 9765],
     | 70.00th=[ 9765], 80.00th=[ 9896], 90.00th=[10028], 95.00th=[10290],
     | 99.00th=[10552], 99.50th=[10814], 99.90th=[11600], 99.95th=[19792],
     | 99.99th=[27657]
   bw (  KiB/s): min=98880, max=106400, per=99.89%, avg=104449.68, stdev=2236.99, samples=19
   iops        : min= 6180, max= 6650, avg=6528.11, stdev=139.81, samples=19
  lat (usec)   : 500=0.01%, 750=0.01%, 1000=0.01%
  lat (msec)   : 2=0.02%, 4=0.04%, 10=85.86%, 20=14.02%, 50=0.05%
  cpu          : usr=4.31%, sys=9.31%, ctx=65302, majf=0, minf=0
  IO depths    : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=99.9%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
     issued rwts: total=0,65361,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=64

Run status group 0 (all jobs):
  WRITE: bw=102MiB/s (107MB/s), 102MiB/s-102MiB/s (107MB/s-107MB/s), io=1021MiB (1071MB), run=10001-10001msec

Disk stats (read/write):
  sdb: ios=0/64690, merge=0/17, ticks=0/19160, in_queue=19162, util=95.27%