马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本文先容磁盘性能测试工具fio在某国产操纵体系(内核4.19,gcc为7.3.0)上的编译和利用。
配景
某项目利用物理机安装某数据库,干系职员提到磁盘性能方面的要求,用fio测试32k的随机读写,性能要到达1万 IOPS。本文即举行此工具测试。
fio是一款强盛的磁盘 I/O 性能测试工具,用于评估存储装备(如硬盘、SSD、NVMe)的 吞吐量(BW)、IOPS(每秒 I/O 操纵数)和耽误(Latency)。它支持多种 I/O 引擎和工作模式,可模仿真实业务场景的压力测试。
告急特点如下:
- 多引擎支持:libaio(Linux 异步 I/O)、io_uring(高性能)、psync(同步)、mmap(内存映射)等。
- 机动设置:可自界说 块巨细(block size)、队列深度(iodepth)、读写比例(rwmixread) 等参数。
- 多线程/多使命:通过 numjobs 模仿并发负载。
- 跨平台:支持 Linux、Windows、macOS。
安装
下载:https://github.com/axboe/fio/releases 。文件:fio-3.39.tar.gz
在线安装依靠库:- sudo yum install libaio libaio-devel -y
复制代码 编译:- ./configure
- make
- sudo make install
复制代码 验证 libaio 支持:- # ./fio --enghelp | grep libaio
- libaio
复制代码 测试
32k随机读写测试下令,利用libaio库,下令如下:- fio --name=randrw_test --ioengine=libaio --iodepth=32 --rw=randrw --rwmixread=50 --bs=32k --direct=1 --size=4G --numjobs=4 --runtime=60 --time_based --group_reporting
复制代码 关键参数分析
- –iodepth=32:设置I/O队列深度为32,这对SSD/NVMe装备很告急
- –numjobs=4:利用4个并行线程/进程来产生负载
- –direct=1:绕过体系缓存,直接I/O
- –size=4G:每个线程测试4GB数据
- –runtime=60:测试运行60秒
测试效果的告急指标如下:从效果看,测试服务器硬盘性能一样寻常般。具体效果如下:- # fio --name=randrw_test --ioengine=libaio --iodepth=32 --rw=randrw --rwmixread=50 --bs=32k --direct=1 --size=4G --numjobs=4 --runtime=60 --time_based --group_reporting
- randrw_test: (g=0): rw=randrw, bs=(R) 32.0KiB-32.0KiB, (W) 32.0KiB-32.0KiB, (T) 32.0KiB-32.0KiB, ioengine=libaio, iodepth=32...fio-3.39Starting 4 processesrandrw_test: Laying out IO file (1 file / 4096MiB)randrw_test: Laying out IO file (1 file / 4096MiB)randrw_test: Laying out IO file (1 file / 4096MiB)randrw_test: Laying out IO file (1 file / 4096MiB)Jobs: 4 (f=4): [m(4)][5.0%][r=18.0MiB/s,w=18.8MiB/s][r=576,w=603 IOPS][eta 00m:5Jobs: 4 (f=4): [m(4)][6.7%][r=17.8MiB/s,w=19.2MiB/s][r=571,w=614 IOPS][eta 00m:5Jobs: 4 (f=4): [m(4)][8.3%][r=17.1MiB/s,w=16.9MiB/s][r=547,w=542 IOPS][eta 00m:5Jobs: 4 。。。(f=4): [m(4)][100.0%][r=6048KiB/s,w=6688KiB/s][r=189,w=209 IOPS][eta 00mJobs: 4 (f=4): [m(4)][9.6%][r=7776KiB/s,w=5760KiB/s][r=243,w=180 IOPS][eta 09m:3Jobs: 2 (f=2): [m(2),_(2)][34.4%][r=1069KiB/s,w=855KiB/s][r=33,w=26 IOPS][eta 01m:58s]randrw_test: (groupid=0, jobs=4): err= 0: pid=1048845: Thu Mar 27 16:53:20 2025 read: IOPS=423, BW=13.2MiB/s
- (13.9MB/s)(821MiB/62024msec) slat (nsec): min=4456, max=96903, avg=14923.19, stdev=5994.18 clat (usec): min=30, max=3032.4k, avg=230270.66, stdev=238818.59 lat (usec): min=37, max=3032.4k, avg=230285.58, stdev=238818.97 clat percentiles (msec): | 1.00th=[ 3], 5.00th=[ 12], 10.00th=[ 26], 20.00th=[ 58], | 30.00th=[ 96], 40.00th=[ 134], 50.00th=[ 169], 60.00th=[ 209], | 70.00th=[ 266], 80.00th=[ 347], 90.00th=[ 498], 95.00th=[ 659], | 99.00th=[ 1150], 99.50th=[ 1469], 99.90th=[ 2106], 99.95th=[ 2165], | 99.99th=[ 2601] bw ( KiB/s): min= 1856, max=46208, per=100.00%, avg=13948.19, stdev=2178.00, samples=481 iops : min= 58, max= 1444, avg=435.88, stdev=68.06, samples=481 write: IOPS=429, BW=13.4MiB/s (14.1MB/s)(832MiB/62024msec); 0 zone resets slat (usec): min=4, max=110, avg=15.08, stdev= 7.04 clat (usec): min=30, max=2336.7k, avg=66911.12, stdev=126808.10 lat (usec): min=37, max=2336.8k, avg=66926.21, stdev=126809.08 clat percentiles (usec): | 1.00th=[ 35], 5.00th=[ 38], 10.00th=[ 40], | 20.00th=[ 42], 30.00th=[ 45], 40.00th=[ 48], | 50.00th=[ 63], 60.00th=[ 41157], 70.00th=[ 79168], | 80.00th=[ 121111], 90.00th=[ 183501], 95.00th=[ 270533], | 99.00th=[ 522191], 99.50th=[ 633340], 99.90th=[1736442], | 99.95th=[1920992], 99.99th=[2231370] bw ( KiB/s): min= 1344, max=48128, per=100.00%, avg=14177.60, stdev=2354.39, samples=480 iops : min= 42, max= 1504, avg=443.05, stdev=73.57, samples=480 lat (usec) : 50=22.30%, 100=4.20%, 250=0.19%, 500=0.13%, 750=0.11% lat (usec) : 1000=0.07% lat (msec) : 2=0.18%, 4=0.49%, 10=1.89%, 20=2.60%, 50=7.73% lat (msec) : 100=13.39%, 250=27.73%, 500=13.43%, 750=3.72%, 1000=1.02% lat (msec) : 2000=0.72%, >=2000=0.11% cpu : usr=0.10%, sys=0.35%, ctx=50323, majf=0, minf=54 IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=99.8%, >=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.1%, 64=0.0%, >=64=0.0% issued rwts: total=26277,26637,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0, window=0, percentile=100.00%, depth=32Run status group 0 (all jobs): READ: bw=13.2MiB/s (13.9MB/s), 13.2MiB/s-13.2MiB/s (13.9MB/s-13.9MB/s), io=821MiB (861MB), run=62024-62024msec WRITE: bw=13.4MiB/s (14.1MB/s), 13.4MiB/s-13.4MiB/s (14.1MB/s-14.1MB/s), io=832MiB (873MB), run=62024-62024msecDisk stats (read/write): dm-0: ios=26277/27963, sectors=1681728/1722759, merge=0/0, ticks=5988971/1844511, in_queue=0, util=98.92%, aggrios=26277/27885, aggsectors=1681728/1722759, aggrmerge=0/78, aggrticks=5991165/1774213, aggrin_queue=7745112, aggrutil=99.33% sda: ios=26277/27885, sectors=1681728/1722759, merge=0/78, ticks=5991165/1774213, in_queue=7745112, util=99.33%
复制代码 别的分析
可以举行以下几种范例的测试:
- 随机读写:–rw=randrw
- 随机读:–rw=randread
- 随机写:–rw=randwrite
别的事项:
- 对于NVMe SSD,可以利用--ioengine=io_uring以得到更好性能。
- 如果体系核数较多,则可以增长线程数numjobs,发挥最大性能。
小结
现在还没有服务器测试,后续找时机再试试。
附
在centos7无法编译信息
fio新版本对GCC有要求,如版本过低,则无法编译,如下:- # ./configure
- Operating system Linux
- CPU x86_64
- Big endian no
- Compiler gcc
- Cross compile no
- Static build no
- Your compiler doesn't support C11 atomics. gcc 4.9/clang 3.6 are the
- minimum versions with it - perhaps your compiler is too old?
- C11 atomics support not found
- Configure failed, check config.log and/or the above output
复制代码 |