Home > 工具介绍 > Fio IO性能测试工具介绍

Fio IO性能测试工具介绍

September 25th, 2010

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: Fio IO性能测试工具介绍

官网:http://freshmeat.net/projects/fio/

fio is an I/O tool meant to be used both for benchmark and stress/hardware verification. It has support for 13 different types of I/O engines (sync, mmap, libaio, posixaio, SG v3, splice, null, network, syslet, guasi, solarisaio, and more), I/O priorities (for newer Linux kernels), rate I/O, forked or threaded jobs, and much more. It can work on block devices as well as files. fio accepts job descriptions in a simple-to-understand text format. Several example job files are included. fio displays all sorts of I/O performance information. It supports Linux, FreeBSD, NetBSD, OS X, and OpenSolaris.

Ubuntu下可以用apt-get install fio安装就好。

这个工具最大的特点是使用简单,支持的文件操作非常多, 可以覆盖到我们能见到的文件使用方式:
sync:Basic read(2) or write(2) I/O. fseek(2) is used to position the I/O location.
psync:Basic pread(2) or pwrite(2) I/O.
vsync: Basic readv(2) or writev(2) I/O. Will emulate queuing by coalescing adjacents IOs into a single submission.
libaio: Linux native asynchronous I/O.
posixaio: glibc POSIX asynchronous I/O using aio_read(3) and aio_write(3).
mmap: File is memory mapped with mmap(2) and data copied using memcpy(3).
splice: splice(2) is used to transfer the data and vmsplice(2) to transfer data from user-space to the kernel.
syslet-rw: Use the syslet system calls to make regular read/write asynchronous.
sg:SCSI generic sg v3 I/O.
net : Transfer over the network. filename must be set appropriately to `host/port’ regardless of data direction. If receiving,
only the port argument is used.
netsplice: Like net, but uses splice(2) and vmsplice(2) to map data and send/receive.
guasi The GUASI I/O engine is the Generic Userspace Asynchronous Syscall Interface approach to asycnronous I/O.

还可以控制io depth对于测试磁盘的性能很有帮助,对结果的解读也做的很明白。

典型的使用如下:
fio –filename=/dev/sdc1 –direct=1 –rw=randread –bs=4k –size=60G –numjobs=64 –runtime=10 –group_reporting –name=fileXXX

玩的开心。

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: 工具介绍 Tags: ,
  1. kangbo
    October 10th, 2011 at 09:42 | #1

    霸爷的这篇文章bing上搜索fio+linux竟然排第一位,必须顶一下。

  2. baifan
    January 6th, 2013 at 15:38 | #2

    霸爷,不好意思啊,耽误你点时间,麻烦看看这四组数据
    CMD是 fio -filename=/dev/xvdb -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=4k -size=50G -numjobs=32 -runtime=3600 -group_reporting -name=mytest -ioscheduler=noop

    读写频率为7:3,我让它跑了一个小时,按照那边服务器商的说法是没有任何其他负载了,你看第2组的io比例,和7:3差的很远,就它和别人不一样,这个正常么,还有第3组的iops是不是相当不给力啊?另外我设-direct=0,iops显著提升,但是会周期性的突然急剧下降,这是文件缓存在刷脏页的问题吧?

    打搅请见谅 Orz
    打搅请见谅 Orz

    CentOS 6.3 64位  
    read : io=1146.3MB, bw=333747 B/s, iops=81 , runt=3601413msec
    write: io=501996KB, bw=142733 B/s, iops=34 , runt=3601413msec

    CentOS release 6.2
    read : io=1272.3MB, bw=1526.1KB/s, iops=381 , runt=3600077msec
    write: io=2302.5MB, bw=670614 B/s, iops=163 , runt=3600077msec

    CentOS release 5.6.
    read : io=271732KB, bw=77261 B/s, iops=18 , runt=3601460msec
    write: io=116056KB, bw=32998 B/s, iops=8 , runt=3601460msec

    CentOS release 5.8
    read : io=2155.8MB, bw=627661 B/s, iops=153 , runt=3600278msec
    write: io=950684KB, bw=270395 B/s, iops=66 , runt=3600278msec

    Yu Feng Reply:

    direct=0周期性的突然急剧下降是刷脏页的问题。
    -iodepth 1 这个为什么要这么设置呀?
    -ioscheduler=noop 这个的目的是?

    baifan Reply:

    noop是个能做申请合并的FIFO队列,但是direct=1绕过缓存,它就成为一个单纯的先进先出的队列了,
    我觉得这样更有益于测试磁盘寻道随机性能,如果是CFQ的话,队列私有会影响原始申请的位置。

    iodepth不是每次提交队列的深度么?设置1不让他一次提交多个

    我反正是这么理解的

    Yu Feng Reply:

    iodepth是针对全局的吧

    baifan Reply:

    能透露下TB的服务器 fio测试iops有多少嘛?? 哈哈

    Yu Feng Reply:

    iops通常10w左右吧

    baifan Reply:

    哦 这个东西默认就是1,貌似在libaio上才有讲究

  3. baifan
    January 7th, 2013 at 12:06 | #3

    呃 这次回复的这么快

    Yu Feng Reply:

    前几天休假去了

  4. baifan
    January 7th, 2013 at 12:07 | #4

    iodepth我去查查看

  5. baifan
    January 7th, 2013 at 12:11 | #5

    !- – 10W 好有钱 iodepth我去找找看 硬件懂的少,这次测试只是客串一下,我是写代码的 哈哈

  6. yue
    January 8th, 2013 at 11:19 | #6

    不好意思,问个弱智问题:fio命令中 ,filename到底指的是什么呢?就是指定需要测试的硬盘或分区吗?

    Yu Feng Reply:

    linux下一切都是文件,设备当然也是文件,文件名叫 /dev/xxx

    yue Reply:

    嗯。如果这样直接测试裸设备,会对分区或硬盘上的数据造成影响吧?本人菜鸟,上次直接对
    系统分区做了写测试,结果导致系统崩掉了,不清楚这里面的原理

    Yu Feng Reply:

    搞个分区搞,哪能整个系统盘,文件系统立马乱了。

  7. liu.li
    June 9th, 2013 at 16:17 | #7

    不好意思,问个fio无法实用的问题哈~
    本人使用centos6.3与6.4都试了一下,按照安装步骤,加载libaio与libaio-dev,下载相应fio2.0(官网上的),make,make install。使用fio -o1 test.fio,提示:fopen job file: No such file or directory…..

    也使用fio -filename=/dev/sda -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=4k -size=10G -numjobs=32 -runtime=100 -group_reporting -name=mytest
    提示:fopen job file: No such file or directory

    请问:这是什么原因导致?
    感谢不吝赐教~

    liu.li Reply:

    还有就是使用fio2.0出现这样的问题:
    [root@localhost fio-2.1]# fio –filename=/dev/sda1 –direct=1 –rw=randwrite –bs=4k –size=10G –numjobs=32 –runtime=10 –group_reporting –name=aa
    fio: failed parsing group_reporting=–name=aa

    尝试了去掉group_reporting前边的引用“–”

    [root@localhost fio-2.1]# fio –filename=/dev/sda1 –direct=1 –rw=randwrite –b
    s=4k –size=10G –numjobs=32 –runtime=10 group_reporting –name=aa
    aa: (g=0): rw=randwrite, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=1

    aa: (g=0): rw=randwrite, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=1
    fopen job file: No such file or directory

    Yu Feng Reply:

    最好把操作写在job文件里,一不乱,二容易俺section组织,每次运行不同的section

    Yu Feng Reply:

    fio –debug=all 就知道什么原因了。

    liu.li Reply:

    运行fio -debug=all后出现以下信息,但不明白什么意思,貌似相应的包我也安装了~

    fio: set all debug options
    parse 32147 free options
    time 32147 cycles[0]=2666
    time 32147 cycles[1]=2665
    time 32147 cycles[2]=2666
    time 32147 cycles[3]=2666
    time 32147 cycles[4]=2666
    time 32147 cycles[5]=2666
    time 32147 cycles[6]=2666
    time 32147 cycles[7]=2666
    time 32147 cycles[8]=2666
    time 32147 cycles[9]=2666
    time 32147 cycles[10]=2666
    time 32147 cycles[11]=2666
    time 32147 cycles[12]=2666
    time 32147 cycles[13]=2666
    time 32147 cycles[14]=2666
    time 32147 cycles[15]=2666
    time 32147 cycles[16]=2666
    time 32147 cycles[17]=2666
    time 32147 cycles[18]=2666
    time 32147 cycles[19]=2666
    time 32147 cycles[20]=2666
    time 32147 cycles[21]=2666
    time 32147 cycles[22]=2666
    time 32147 cycles[23]=2666
    time 32147 cycles[24]=2666
    time 32147 cycles[25]=2666
    time 32147 cycles[26]=2666
    time 32147 cycles[27]=2666
    time 32147 cycles[28]=2666
    time 32147 cycles[29]=2666
    time 32147 cycles[30]=2666
    time 32147 cycles[31]=2666
    time 32147 cycles[32]=2666
    time 32147 cycles[33]=2666
    time 32147 cycles[34]=2666
    time 32147 cycles[35]=2666
    time 32147 cycles[36]=2666
    time 32147 cycles[37]=2666
    time 32147 cycles[38]=2666
    time 32147 cycles[39]=2666
    time 32147 cycles[40]=2666
    time 32147 cycles[41]=2666
    time 32147 cycles[42]=2666
    time 32147 cycles[43]=2666
    time 32147 cycles[44]=2666
    time 32147 cycles[45]=2666
    time 32147 cycles[46]=2666
    time 32147 cycles[47]=2666
    time 32147 cycles[48]=2666
    time 32147 cycles[49]=2666
    time 32147 avg: 2667
    time 32147 mean=2666.650000, S=0.035743
    time 32147 inv_cycles_per_usec=6290
    io 32147 ioengine cpuio unregistered
    io 32147 ioengine mmap unregistered
    io 32147 ioengine sync unregistered
    io 32147 ioengine psync unregistered
    io 32147 ioengine vsync unregistered
    io 32147 ioengine null unregistered
    io 32147 ioengine net unregistered
    io 32147 ioengine netsplice unregistered
    io 32147 ioengine libaio unregistered
    io 32147 ioengine posixaio unregistered
    io 32147 ioengine falloc unregistered
    io 32147 ioengine e4defrag unregistered
    io 32147 ioengine splice unregistered
    io 32147 ioengine sg unregistered
    io 32147 ioengine binject unregistered
    profile 32147 unregister profile ‘tiobench’

    liu.li Reply:

    可以了,在job文件里添加了ioengine=mmap。调用的,好像还行,但是关于这些engine,具体代表啥意思,请霸爷给明示啊~感谢~

    Yu Feng Reply:

    ioengine=str
    Defines how the job issues I/O. The following types are defined:
    sync

    Basic read(2) or write(2) I/O. fseek(2) is used to position the I/O location.

    psync

    Basic pread(2) or pwrite(2) I/O.

    vsync

    Basic readv(2) or writev(2) I/O. Will emulate queuing by coalescing adjacents IOs into a single submission.

    libaio

    Linux native asynchronous I/O. This ioengine defines engine specific options.

    posixaio

    POSIX asynchronous I/O using aio_read(3) and aio_write(3).

    solarisaio

    Solaris native asynchronous I/O.

    windowsaio

    Windows native asynchronous I/O.

    mmap

    File is memory mapped with mmap(2) and data copied using memcpy(3).

    splice

    splice(2) is used to transfer the data and vmsplice(2) to transfer data from user-space to the kernel.

    syslet-rw

    Use the syslet system calls to make regular read/write asynchronous.

    sg

    SCSI generic sg v3 I/O. May be either synchronous using the SG_IO ioctl, or if the target is an sg character device, we use read(2) and write(2) for asynchronous I/O.

    null

    Doesn’t transfer any data, just pretends to. Mainly used to exercise fio itself and for debugging and testing purposes.

    net

    Transfer over the network. The protocol to be used can be defined with the protocol parameter. Depending on the protocol, filename, hostname, port, or listen must be specified. This ioengine defines engine specific options.

    netsplice

    Like net, but uses splice(2) and vmsplice(2) to map data and send/receive. This ioengine defines engine specific options.

    cpuio

    Doesn’t transfer any data, but burns CPU cycles according to cpuload and cpucycles parameters.

    guasi

    The GUASI I/O engine is the Generic Userspace Asynchronous Syscall Interface approach to asycnronous I/O.

    See <http://www.xmailserver.org/guasi-lib.html>.

    rdma

    The RDMA I/O engine supports both RDMA memory semantics (RDMA_WRITE/RDMA_READ) and channel semantics (Send/Recv) for the InfiniBand, RoCE and iWARP protocols.

    external

    Loads an external I/O engine object file. Append the engine filename as ‘:enginepath’.

    falloc

    IO engine that does regular linux native fallocate callt to simulate data transfer as fio ioengine

    DDIR_READ does fallocate(,mode = FALLOC_FL_KEEP_SIZE,)
    DIR_WRITE does fallocate(,mode = 0)
    DDIR_TRIM does fallocate(,mode = FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE)

    e4defrag

    IO engine that does regular EXT4_IOC_MOVE_EXT ioctls to simulate defragment activity request to DDIR_WRITE event

  8. shiyanch
    August 22nd, 2013 at 10:58 | #8

    您好,fio的测试结果如何保存到文件呢?查阅文档似乎没有发现..还望指教!

    Yu Feng Reply:

    man fio

    –output=filename
    Write output to filename.

    tina Reply:

    不知现在还能答复么,怎么在测试配置文件里面将测试结果保存到文件呢?

Comments are closed.