filebench


一、安裝(版本包見附件)參考網址:https://blog.csdn.net/microsoft2014/article/details/60145433
sudo tar -zxf filebench-1.5-alpha3.tar.gz -C /usr/local
yum install gcc
yum install flex bison
解壓后需要安裝gcc、lex和yacc(linux下是用flex和bison來分別代替lex和yacc的),因為后續安裝需要,不然會出問題。
cd /usr/local/filebench-1.5-alpha3
./configure
make
sudo make install

安裝完測試:
$cd /usr/local/share/filebench/workloads
$filebench -f webserver.f //for example:webserver.f
二、執行(參考網址:https://blog.csdn.net/u012317833/article/details/36676955)(https://blog.csdn.net/for_tech/article/details/75271066)
交互式:Interactively
user@host$ sudo su
[sudo] password for user:
root@host# echo 0 > /proc/sys/kernel/randomize_va_space
root@host# go_filebench
Filebench Version 1.4.9
12102: 0.000: Allocated 170MB of shared memory
filebench>

Now, one can load and run individual workload personalities with full control over their parameters. The following example demonstrates how to run fileserver workload personality:
注意如果沒有go_filebench命令,可以將附件的go_filebench移到/usr/local/bin目錄

root@user# go_filebench
Filebench Version 1.4.9
12324: 0.000: Allocated 170MB of shared memory
filebench> load fileserver
12462: 2.869: FileServer Version 2.2 personality successfully loaded
12462: 2.869: Usage: set $dir=<dir>
12462: 2.869: set $meanfilesize=<size> defaults to 131072
12462: 2.869: set $nfiles=<value> defaults to 10000
12462: 2.869: set $nthreads=<value> defaults to 50
12462: 2.869: set $meanappendsize=<value> defaults to 16384
12462: 2.869: set $iosize=<size> defaults to 1048576
12462: 2.869: set $meandirwidth=<size> defaults to 20
12462: 2.869: (sets mean dir width and dir depth is calculated as log (width, nfiles)
12462: 2.869: run runtime (e.g. run 60)
filebench> set $dir=/mnt
filebench> run 60
12462: 4.909: Creating/pre-allocating files and filesets
12462: 4.918: Fileset bigfileset: 10000 files, avg dir width = 20, avg dir depth = 3.1, 1240.757MB
12462: 5.280: Removed any existing fileset bigfileset in 1 seconds
12462: 5.280: making tree for filset /tmp/bigfileset
12462: 5.290: Creating fileset bigfileset...
12462: 6.080: Preallocated 7979 of 10000 of fileset bigfileset in 1 seconds
12462: 6.080: waiting for fileset pre-allocation to finish
12466: 6.080: Starting 1 filereader instances
12467: 6.081: Starting 50 filereaderthread threads
12462: 7.137: Running...
12462: 67.142: Run took 60 seconds...
12462: 67.145: Per-Operation Breakdown

statfile1 128311ops 2138ops/s 0.0mb/s 0.0ms/op 2320us/op-cpu [0ms - 0ms]
deletefile1 128316ops 2138ops/s 0.0mb/s 0.2ms/op 2535us/op-cpu [0ms - 458ms]
closefile3 128323ops 2139ops/s 0.0mb/s 0.0ms/op 2328us/op-cpu [0ms - 0ms]
readfile1 128327ops 2139ops/s 283.8mb/s 0.1ms/op 2460us/op-cpu [0ms - 267ms]
openfile2 128329ops 2139ops/s 0.0mb/s 0.0ms/op 2332us/op-cpu [0ms - 2ms]
closefile2 128332ops 2139ops/s 0.0mb/s 0.0ms/op 2332us/op-cpu [0ms - 0ms]
appendfilerand1 128337ops 2139ops/s 16.6mb/s 0.1ms/op 2377us/op-cpu [0ms - 559ms]
openfile1 128343ops 2139ops/s 0.0mb/s 0.0ms/op 2353us/op-cpu [0ms - 2ms]
closefile1 128349ops 2139ops/s 0.0mb/s 0.0ms/op 2317us/op-cpu [0ms - 1ms]
wrtfile1 128352ops 2139ops/s 265.2mb/s 0.1ms/op 2601us/op-cpu [0ms - 268ms]
createfile1 128358ops 2139ops/s 0.0mb/s 0.1ms/op 2396us/op-cpu [0ms - 267ms]
12462: 67.145: IO Summary: 1411677 ops, 23526 ops/s, (2139/4278 r/w), 565mb/s, 393us cpu/op, 0.2ms latency
12462: 67.145: Shutting down processes

As you can see, we first loaded fileserver personality using load command. Filebench located corresponding.f in the directory with pre-defined workloads. After that tunables of the workload personality can be set. We change
the benchmark directory to /mnt where the file system we want to benchmark is presumably mounted. To start workload for 60 seconds we execute run 60 command. In response, Filebench first created a file system tree with the properties
defined in the personality file and then spanned all required processes and threads. After 60 seconds of the run the statistics is printed and Filebench exits.

非交互式:Non-interactively(/usr/local/share/filebench/workloads目錄下有各種模型,都可以使用)
If you wish to run Filebench in non-interactive mode, you can use -f option. However, you need to add 'run <time>' to the end of the workload personality file. I prefer to create a copy of original workload file for that:
root@host# cp /usr/local/share/filebench/workloads/fileserver.f /tmp/fileserver-noninteractive.f
root@host# vim /tmp/fileserver-noninteractive.f (add 'run 60' to the end of this file)
root@host# filebench -f /tmp/fileserver-noninteractive.f

After that you will see traditional Filebench output.


文檔提到的2個注意點:
1. filebench默認開啟地址空間randomization (后面有解釋,什么是address space randomization)。如果測試多進程的負載,為了穩定操作可以選擇關閉該選項。方法是:echo 0 > /proc/sys/kernel/randomize_va_space
2. 如果想增加filebench的共享內存,有2個方法
   a. 用root用戶執行。(su)
   b. echo 268435456 > /proc/sys/kernel/randomize_va_space (增加到256MB)
運行
你可以選擇導入別人已經定制好的負載類型( 如fileserver)。也可以自己使用workload model language定制特定的負載。下面介紹的是文檔演示的導入已經定制好的fileserver負載(模擬)。
1. 進入filebench
2. load fileserver (filebench導入對應的~.f文件,代碼自帶,也可以從這個地址下載http://sourceforge.net/apps/mediawiki/filebench/index.php?title=Pre-defined_personalities)
3. set $dir=/mnt (測試mnt目錄)
4. run 60 (運行60秒,運行完畢后打印統計信息)
非交互式運行

執行一條命令即可完成測試,無需要像前面一步一步的設置各個參數。注意在配置文件的末尾添加 'run <time>'
三、輸出解釋
輸出解釋:
flowop name - 支持的flowop有很多
所有threads的ops
所有threads的ops / run time
所有threads的READ/WRITE帶寬
所有threads的每個op的平均latency
測試中op的最小和最大latency

IO Summary:
149970 ops :所有flowop的總和
9372.298 ops/s :所有flowop的總和 / run time
0/3124 rd/wr :所有flowop中READ/WRITE的ops / run time
48.8mb/s : 所有flowop的IO帶寬
1.643ms/op :所有flowop的每個op的平均latency
四、寫workload
我們可以自己寫workload文件,語法格式可參考:https://github.com/filebench/filebench/wiki/Workload-model-language
# 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
---------------------
作者:for_tech
來源:CSDN
原文:https://blog.csdn.net/for_tech/article/details/75271066?utm_source=copy
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM