简介
Filebench 是一款文件系统性能的自动化测试工具,它通过快速模拟真实应用服务器的负载来测试文件系统的性能。它不仅可以仿真文件系统微操作(如 copyfiles, createfiles, randomread, randomwrite ),而且可以仿真复杂的应用程序(如 varmail, fileserver, oltp, dss, webserver, webproxy )。 Filebench 比较适合用来测试文件服务器性能,但同时也是一款负载自动生成工具,也可用于文件系统的性能。
代码
https://github.com/filebench/filebench
安装
下载地址:https://sourceforge.net/projects/filebench/
下载并解压 filebench-1.5-alpha3.tar.gz,假设放在/home目录下
安装两个依赖库:apt-get install -y flex bison
cd /home/filebench-1.5-alpha3
./configure
make
make install
安装完成
filebench使用
方法一(不常用)
自己定义测试负载(我没实践)
方法二
直接使用filebench中提供的负载,并修改相应的工作目录,文件大小等信息.
Filebench带有几个预定义的微观和宏工作负载(例如web服务器,文件服务器,邮件服务器),这些工作负载在WML中也有描述。 在源代码树中,工作负载位于workloads/目录中。
不建议直接使用来自workloads/或/ usr / local / share / filebench / workloads /目录的工作负载文件。 主要原因是这些工作负载的大小不正确(例如,按照数据集大小)到特定系统。 例如,webserver工作负载的初始数据集大小仅略大于16MiB,这通常不是您想要测试包含多个千兆字节RAM的系统的大小。
(最好将它提供的改成我们的,不覆盖)故我们将这些提供的workload拷贝一份,并修改其以适应我们的测试:
cp /home/filebench/workloads/webserver.f mywebserver.f
- 接着我们就可以修改mywebserver.f以适应我们的测试了.
-
运行
在目录 /usr/local/share/filebench/workloads/ 下有很多定义好的workload,我们可以拿来使用
配置里面的 $dir 为测试filesystem的目录,若文件后没有run <secs>
命令,添加:run <secs>
- 一般就修改dir, nfiles, filesize, nthreads等主要参数,然后就可以开始测试了,使用命令:
-
filebench -f mywebserver.f
-
输出解释:
flowop name - 支持的flowop有很多(closefile1,readfile1,openfile1等)
所有threads的ops
所有threads的ops / run time
所有threads的READ/WRITE带宽
所有threads的每个op的平均latency
测试中op的最小和最大latency -
IO Summary:
30987315ops :所有flowop的总和
516394.358 ops/s :所有flowop的总和 / run time
172131/0 rd/wr :所有flowop中READ/WRITE的ops / run time
2648mb/s : 所有flowop的IO带宽
0.0ms/op :所有flowop的每个op的平均latency写workload
我们可以自己写workload文件,语法格式可参考:https://github.com/filebench/filebench/wiki/Workload-model-language
以createfiles.f为例,解释里面的含义:
-
# 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
用户也可用WML(workload model language) 编写自定义的.f文件。
参考资料
2.如何安装yacc
-
参照:http://www.cnblogs.com/AgainstTheWind/p/9869790.html