当前位置: 首页 > 工具软件 > Filebench > 使用案例 >

filebench负载测试文件系统性能手册

公孙慎之
2023-12-01

一、安装filebench

https://github.com/filebench/filebench/wiki
https://www.cnblogs.com/xuyaowen/p/filebench.html
https://www.pianshen.com/article/6501303418/

二、负载选择

https://github.com/filebench/filebench/wiki/Predefined-personalities

我主要是选择webserver fileserver varmail oltp videoserver五种负载测试

filesever.f

set $dir=/data
set $nfiles=60000
set $meandirwidth=20
set $filesize=cvar(type=cvar-gamma,parameters=mean:136192;gamma:1.5)
#set $filesize=cvar(type=cvar-gamma,parameters=mean:13107200;gamma:1.5)
set $nthreads=50
set $iosize=1m
set $meanappendsize=16k

define fileset name=bigfileset1,path=$dir,size=$filesize,entries=$nfiles,dirwidth=$meandirwidth,prealloc=80

define process name=filereader,instances=1
{
  thread name=filereaderthread,memsize=10m,instances=$nthreads
  {
    flowop createfile name=createfile1,filesetname=bigfileset1,fd=1
    flowop writewholefile name=wrtfile1,srcfd=1,fd=1,iosize=$iosize
	flowop fsync name=fsyncfile2,fd=1
    flowop closefile name=closefile1,fd=1
    flowop openfile name=openfile1,filesetname=bigfileset1,fd=1
    flowop appendfilerand name=appendfilerand1,iosize=$meanappendsize,fd=1
	flowop fsync name=fsyncfile3,fd=1
    flowop closefile name=closefile2,fd=1
    flowop openfile name=openfile2,filesetname=bigfileset1,fd=1
    flowop readwholefile name=readfile1,fd=1,iosize=$iosize
    flowop closefile name=closefile3,fd=1
    flowop deletefile name=deletefile1,filesetname=bigfileset1
	#flowop fsync name=fsyncfile3,fd=2
    flowop statfile name=statfile1,filesetname=bigfileset1
  }
}

echo  "File-server Version 3.0 personality successfully loaded"

run 120

webserver.f

set $dir=/data
set $nfiles=60000
set $meandirwidth=20
set $filesize=cvar(type=cvar-gamma,parameters=mean:16384;gamma:1.5)
set $nthreads=50
set $iosize=1m
set $meanappendsize=16k

define fileset name=bigfileset,path=$dir,size=$filesize,entries=$nfiles,dirwidth=$meandirwidth,prealloc=100,readonly
define fileset name=logfiles,path=$dir,size=$filesize,entries=1,dirwidth=$meandirwidth,prealloc

define process name=filereader,instances=1
{
  thread name=filereaderthread,memsize=10m,instances=$nthreads
  {
    flowop openfile name=openfile1,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile1,fd=1,iosize=$iosize
    flowop closefile name=closefile1,fd=1
    flowop openfile name=openfile2,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile2,fd=1,iosize=$iosize
    flowop closefile name=closefile2,fd=1
    flowop openfile name=openfile3,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile3,fd=1,iosize=$iosize
    flowop closefile name=closefile3,fd=1
    flowop openfile name=openfile4,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile4,fd=1,iosize=$iosize
    flowop closefile name=closefile4,fd=1
    flowop openfile name=openfile5,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile5,fd=1,iosize=$iosize
    flowop closefile name=closefile5,fd=1
    flowop openfile name=openfile6,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile6,fd=1,iosize=$iosize
    flowop closefile name=closefile6,fd=1
    flowop openfile name=openfile7,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile7,fd=1,iosize=$iosize
    flowop closefile name=closefile7,fd=1
    flowop openfile name=openfile8,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile8,fd=1,iosize=$iosize
    flowop closefile name=closefile8,fd=1
    flowop openfile name=openfile9,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile9,fd=1,iosize=$iosize
    flowop closefile name=closefile9,fd=1
    flowop openfile name=openfile10,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile10,fd=1,iosize=$iosize
    flowop closefile name=closefile10,fd=1
    flowop appendfilerand name=appendlog,filesetname=logfiles,iosize=$meanappendsize,fd=2
  }
}

echo  "Web-server Version 3.1 personality successfully loaded"

run 120

vermail.f

set $dir=/data
set $nfiles=60000
set $meandirwidth=1000000
set $filesize=cvar(type=cvar-gamma,parameters=mean:16384;gamma:1.5)
set $nthreads=16
set $iosize=1m
set $meanappendsize=16k

define fileset name=bigfileset,path=$dir,size=$filesize,entries=$nfiles,dirwidth=$meandirwidth,prealloc=80

define process name=filereader,instances=1
{
  thread name=filereaderthread,memsize=10m,instances=$nthreads
  {
    flowop deletefile name=deletefile1,filesetname=bigfileset
    flowop createfile name=createfile2,filesetname=bigfileset,fd=1
    flowop appendfilerand name=appendfilerand2,iosize=$meanappendsize,fd=1
    flowop fsync name=fsyncfile2,fd=1
    flowop closefile name=closefile2,fd=1
    flowop openfile name=openfile3,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile3,fd=1,iosize=$iosize
    flowop appendfilerand name=appendfilerand3,iosize=$meanappendsize,fd=1
    flowop fsync name=fsyncfile3,fd=1
    flowop closefile name=closefile3,fd=1
    flowop openfile name=openfile4,filesetname=bigfileset,fd=1
    flowop readwholefile name=readfile4,fd=1,iosize=$iosize
    flowop closefile name=closefile4,fd=1
  }
}

echo  "Varmail Version 3.0 personality successfully loaded"

run 120

oltp.f

#nfiles2000 = 20G
set $dir=/data
set $eventrate=0
set $runtime=30
set $iosize=2k
set $nshadows=200
set $ndbwriters=10
set $usermode=200000
set $filesize=10m
set $memperthread=1m
set $workingset=0
set $cached=0
set $logfilesize=10m
set $nfiles=1000 
set $nlogfiles=1
set $directio=0

eventgen rate = $eventrate

# Define a datafile and logfile
define fileset name=datafiles,path=$dir,size=$filesize,dirgamma=0,entries=$nfiles,dirwidth=1024,prealloc=100,reuse
define fileset name=logfile,path=$dir,size=$logfilesize,dirgamma=0,entries=$nlogfiles,dirwidth=1024,prealloc=100,reuse

define process name=lgwr,instances=1
{
  thread name=lgwr,memsize=$memperthread,useism
  {
    flowop aiowrite name=lg-write,filesetname=logfile,
        iosize=256k,random,directio=$directio,dsync
    flowop aiowait name=lg-aiowait
    flowop semblock name=lg-block,value=3200,highwater=1000
  }
}

# Define database writer processes
define process name=dbwr,instances=$ndbwriters
{
  thread name=dbwr,memsize=$memperthread,useism
  {
    flowop aiowrite name=dbwrite-a,filesetname=datafiles,
        iosize=$iosize,workingset=$workingset,random,iters=100,opennext,directio=$directio,dsync
    flowop hog name=dbwr-hog,value=10000
    flowop semblock name=dbwr-block,value=1000,highwater=2000
    flowop aiowait name=dbwr-aiowait
  }
}

define process name=shadow,instances=$nshadows
{
  thread name=shadow,memsize=$memperthread,useism
  {
    flowop read name=shadowread,filesetname=datafiles,
      iosize=$iosize,workingset=$workingset,random,opennext,directio=$directio
    flowop hog name=shadowhog,value=$usermode
    flowop sempost name=shadow-post-lg,value=1,target=lg-block,blocking
    flowop sempost name=shadow-post-dbwr,value=1,target=dbwr-block,blocking
    flowop eventlimit name=random-rate
  }
}

echo "OLTP Version 3.0  personality successfully loaded"

run 120

videoserver.f

#filesize=100m SSD=14G

set $dir=/data
set $eventrate=96
set $filesize=100m
set $nthreads=48
set $numactivevids=32
set $numpassivevids=194
set $reuseit=false
set $readiosize=256k
set $writeiosize=1m

set $passvidsname=passivevids
set $actvidsname=activevids

set $repintval=10

eventgen rate=$eventrate

define fileset name=$actvidsname,path=$dir,size=$filesize,entries=$numactivevids,dirwidth=4,prealloc,paralloc,reuse=$reuseit
define fileset name=$passvidsname,path=$dir,size=$filesize,entries=$numpassivevids,dirwidth=20,prealloc=50,paralloc,reuse=$reuseit

define process name=vidwriter,instances=1
{
  thread name=vidwriter,memsize=10m,instances=1
  {
    flowop deletefile name=vidremover,filesetname=$passvidsname
    flowop createfile name=wrtopen,filesetname=$passvidsname,fd=1
    flowop writewholefile name=newvid,iosize=$writeiosize,fd=1,srcfd=1
    flowop closefile name=wrtclose, fd=1
    flowop delay name=replaceinterval, value=$repintval
  }
}

define process name=vidreaders,instances=1
{
  thread name=vidreaders,memsize=10m,instances=$nthreads
  {
    flowop read name=vidreader,filesetname=$actvidsname,iosize=$readiosize
    flowop bwlimit name=serverlimit, target=vidreader
  }
}

echo  "Video Server Version 3.0 personality successfully loaded"

run 120

三、运行脚本

1.运行前执行

echo 0 > /sys/fs/f2fs/sda1/min_fsync_blocks
echo 0 > /proc/sys/kernel/randomize_va_space

2.刷缓存脚本

#!/bin/bash
while true
do
echo "drop_caches"
sudo echo 3 > /proc/sys/vm/drop_caches
sleep 1
sudo sync
sleep 1
done

3.自动化执行脚本

umount /mnt/ssd
mkfs.f2fs -f /dev/sda1
mount -t f2fs /dev/sda1 /mnt/ssd
echo 0 > /sys/fs/f2fs/sda1/min_fsync_blocks
cat /sys/fs/f2fs/sda1/min_fsync_blocks
echo 0 > /proc/sys/kernel/randomize_va_space
cat /proc/sys/kernel/randomize_va_space
echo start | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
echo 3 > /proc/sys/vm/drop_caches
filebench -f 1-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 3 > /proc/sys/vm/drop_caches
filebench -f 2-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 3 > /proc/sys/vm/drop_caches
filebench -f 3-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 30% | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
echo 3 > /proc/sys/vm/drop_caches
filebench -f 4-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 40% | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
echo 3 > /proc/sys/vm/drop_caches
filebench -f 5-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 50% | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
cat /proc/fs/f2fs/sda1/segment_bits >> 50_segment_bits.txt
cat /proc/fs/f2fs/sda1/segment_info >> 50_segment_info.txt
echo 3 > /proc/sys/vm/drop_caches
filebench -f 6-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 60% | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
echo 3 > /proc/sys/vm/drop_caches
filebench -f 7-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 70% | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
echo 3 > /proc/sys/vm/drop_caches
filebench -f 8-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 80% | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
echo 3 > /proc/sys/vm/drop_caches
filebench -f 9-fileserver.f | tee -a myfileserver.txt
sleep 5m
sync
echo 90% | tee -a myfileserver.txt
cat /proc/diskstats | tee -a myfileserver.txt
cat /sys/kernel/debug/f2fs/status | tee -a myfileserver.txt
cat /proc/fs/f2fs/sda1/segment_bits >> 90_segment_bits.txt
cat /proc/fs/f2fs/sda1/segment_info >> 90_segment_info.txt

 类似资料: