filesystem测试工具之filebench

简介

Filebench 是一款文件系统性能的自动化测试工具,它通过快速模拟真实应用服务器的负载来测试文件系统的性能。它不仅可以仿真文件系统微操作(如 copyfiles, createfiles, randomread, randomwrite ),而且可以仿真复杂的应用程序(如 varmail, fileserver, oltp, dss, webserver, webproxy )。 Filebench 比较适合用来测试文件服务器性能,但同时也是一款负载自动生成工具,也可用于文件系统的性能。

代码

https://github.com/filebench/filebench

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# yum install libtool automake
# libtoolize
# aclocal
# autoheader
# automake --add-missing
# autoconf
# yum install gcc flex bison
# ./configure
# make
# make install
...
----------------------------------------------------------------------

Libraries have been installed in:
/usr/local/lib/filebench
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
...

运行

在目录 /usr/local/share/filebench/workloads/ 下有很多定义好的workload,我们可以拿来使用
配置里面的 $dir 为测试filesystem的目录,若文件后没有run <secs>命令,添加:run <secs>

1
2
3
4
5
6
7
8
9
10
11
# ls /usr/local/share/filebench/workloads/
compflow_demo.f filemicro_rwrite.f fivestreamreaddirect.f openfiles.f singlestreamwrite.f
copyfiles.f filemicro_rwritefsync.f fivestreamread.f randomfileaccess.f tpcso.f
createfiles.f filemicro_seqread.f fivestreamwritedirect.f randomread.f varmail.f
cvar_example.f filemicro_seqwrite.f fivestreamwrite.f randomrw.f videoserver.f
filemicro_create.f filemicro_seqwriterand.f listdirs.f randomwrite.f webproxy.f
filemicro_createfiles.f filemicro_seqwriterandvargam.f makedirs.f ratelimcopyfiles.f webserver.f
filemicro_createrand.f filemicro_seqwriterandvartab.f mongo.f removedirs.f
filemicro_delete.f filemicro_statfile.f netsfs.f singlestreamreaddirect.f
filemicro_rread.f filemicro_writefsync.f networkfs.f singlestreamread.f
filemicro_rwritedsync.f fileserver.f oltp.f singlestreamwritedirect.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# /usr/local/bin/filebench -f /usr/local/share/filebench/workloads/createfiles.f
Filebench Version 1.5-alpha3
0.000: Allocated 173MB of shared memory
0.001: Createfiles Version 3.0 personality successfully loaded
0.001: Populating and pre-allocating filesets
0.031: bigfileset populated: 50000 files, avg. dir. width = 100, avg. dir. depth = 2.3, 0 leafdirs, 781.250MB total size
0.031: Removing bigfileset tree (if exists)
0.033: Pre-allocating directories in bigfileset tree
0.159: Pre-allocating files in bigfileset tree
0.207: Waiting for pre-allocation to finish (in case of a parallel pre-allocation)
0.207: Population and pre-allocation of filesets completed
0.208: Starting 1 filecreate instances
1.210: Running...
17.211: Run took 16 seconds...
17.211: Per-Operation Breakdown
closefile1 49985ops 3124ops/s 0.0mb/s 0.002ms/op [0.001ms - 0.238ms]
writefile1 49985ops 3124ops/s 48.8mb/s 0.020ms/op [0.006ms - 2.307ms]
createfile1 50000ops 3125ops/s 0.0mb/s 4.905ms/op [0.147ms - 1267.256ms]
17.211: IO Summary: 149970 ops 9372.298 ops/s 0/3124 rd/wr 48.8mb/s 1.643ms/op
17.211: Shutting down processes

输出解释:

  1. flowop name - 支持的flowop有很多
  2. 所有threads的ops
  3. 所有threads的ops / run time
  4. 所有threads的READ/WRITE带宽
  5. 所有threads的每个op的平均latency
  6. 测试中op的最小和最大latency

IO Summary:

  1. 149970 ops :所有flowop的总和
  2. 9372.298 ops/s :所有flowop的总和 / run time
  3. 0/3124 rd/wr :所有flowop中READ/WRITE的ops / run time
  4. 48.8mb/s : 所有flowop的IO带宽
  5. 1.643ms/op :所有flowop的每个op的平均latency

参考

https://github.com/filebench/filebench/wiki/Collected-metrics

写workload

我们可以自己写workload文件,语法格式可参考:https://github.com/filebench/filebench/wiki/Workload-model-language

以createfiles.f为例,解释里面的含义:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# cat createfiles.f
...
// 下面是用户变量定义
set $dir=/home/yangguanjun3/mike/tst1
set $nfiles=50000
set $meandirwidth=100
set $meanfilesize=16k
set $iosize=1m
set $nthreads=16

// 设置退出模式,支持[ timeout | alldone | firstdone ]
set mode quit firstdone

// fileset:定义一组测试中用的files
// name=bigfileset:必须指定 - fileset的名称,后面flowop中用到
// path=$dir:必须指定 - 创建测试文件的目录
// size=$meanfilesize:可选,关键字也可以为filesize,默认为1KB - 测试文件的size
// entries=$nfiles:可选,默认位1024 - fileset中的file个数
// dirwidth=$meandirwidth:可选,默认为0 - 每个目录中创建的file个数
define fileset name=bigfileset,path=$dir,size=$meanfilesize,entries=$nfiles,dirwidth=$meandirwidth

// process:定义处理过程
// name=filecreate:必须指定 - 处理过程的名称
// instances=1:可选,默认为1 - 处理过程的进程数
define process name=filecreate,instances=1
{
// thread:process中的一个thread
// name=filecreatethread:必须指定 - 处理线程的名称
// memsize=10m:必须指定 - 线程启动后初始化为0的内存大小,用于read/write flowop
// instances=$nthreads:可选,默认为1 - 创建的线程数
thread name=filecreatethread,memsize=10m,instances=$nthreads
{
// flowop:定义处理流程中的每一步
// createfile/writewholefile/closefile:flowop的关键字,每个代表不同的操作
// name=$name:flowop的名称
// filesetname=bigfileset:指定op操作的fileset
// fd=1:指定file descriptor的值,在应用允许文件被多次open的场景中有用
// iosize=$iosize:指定读写的iosize
flowop createfile name=createfile1,filesetname=bigfileset,fd=1
flowop writewholefile name=writefile1,fd=1,iosize=$iosize
flowop closefile name=closefile1,fd=1
}
}

echo "Createfiles Version 3.0 personality successfully loaded”
// 开始运行filebench测试
// 格式:run [<runtime>],<runtime>不指定的话,默认为60s
run 60
支持原创