Skip to content

Commit cb69700

Browse files
authored
Merge pull request #386 from bengland2/pbench-fio-cache-drop
Pbench fio cache drop
2 parents 7729d1e + 7e98d63 commit cb69700

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -x
2+
# drop-cache.sh - an example of a pbench-fio cache-dropping script
3+
# here is an example cache dropping script for Ceph cluster
4+
# it assumes that there is a ceph-ansible inventory file in /root/ansible-hosts
5+
# containing a [osds] host group and a list of Ceph OSD hosts underneath
6+
# the script must be set to be executable using a command like
7+
# chmod 755 drop-cache.sh
8+
9+
ansible -m shell -f 12 -i /root/ansible-hosts -a "sync ; echo 3 > /proc/sys/vm/drop_caches" osds

agent/bench-scripts/pbench-fio

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ runtime=""
5151
ramptime=""
5252
iodepth=""
5353
ioengine=""
54+
pre_iteration_script=""
5455
job_mode="concurrent" # serial or concurrent
5556
file_size=""
5657
direct="" # don't cache IO's by default
@@ -121,6 +122,9 @@ function fio_usage() {
121122
printf "\t\tnumber of jobs to run, if not given then fio default of numjobs=1 will be used\n"
122123
printf -- "\t--job-file=<path>\n"
123124
printf "\t\tprovide the path of a fio job config file, (default is $job_file)\n"
125+
printf -- "\t--pre-iteration-script=str\n"
126+
printf -- "\t\tuse executable script/program to prepare the system for test iteration\n"
127+
printf -- "\t\texample: --pre-iteration-script=\$HOME/drop-cache.sh\n"
124128
printf -- "\t--samples=<int>\n"
125129
printf "\t\tnumber of samples to use per test iteration (default is $nr_samples)\n"
126130
printf -- "\t--max-stddev=<int>\n"
@@ -133,7 +137,7 @@ function fio_usage() {
133137
}
134138

135139
function fio_process_options() {
136-
opts=$(getopt -q -o jic:t:b:s:d:r: --longoptions "help,max-stddev:,max-failures:,samples:,direct:,sync:,install,clients:,client-file:,iodepth:,ioengine:,config:,jobs-per-dev:,job-mode:,rate-iops:,ramptime:,runtime:,test-types:,block-sizes:,file-size:,targets:,tool-group:,postprocess-only:,run-dir:,directory:,numjobs:,job-file:" -n "getopt.sh" -- "$@");
140+
opts=$(getopt -q -o jic:t:b:s:d:r: --longoptions "help,max-stddev:,max-failures:,samples:,direct:,sync:,install,clients:,client-file:,iodepth:,ioengine:,config:,jobs-per-dev:,job-mode:,rate-iops:,ramptime:,runtime:,test-types:,block-sizes:,file-size:,targets:,tool-group:,postprocess-only:,run-dir:,directory:,numjobs:,job-file:,pre-iteration-script:," -n "getopt.sh" -- "$@");
137141
if [ $? -ne 0 ]; then
138142
printf "\t${benchmark}: you specified an invalid option\n\n"
139143
fio_usage
@@ -330,6 +334,18 @@ function fio_process_options() {
330334
if [ -n "$1" ]; then
331335
job_file="$1"
332336
shift;
337+
338+
fi
339+
;;
340+
--pre-iteration-script)
341+
shift;
342+
if [ -n "$1" ]; then
343+
pre_iteration_script="$1"
344+
if [ ! -x $pre_iteration_script ]; then
345+
printf "ERROR: $pre_iteration_script must be executable\n"
346+
exit 1
347+
fi
348+
shift;
333349
fi
334350
;;
335351
--)
@@ -513,6 +529,16 @@ function fio_run_job() {
513529
else
514530
mkdir -p $benchmark_results_dir/clients/localhost
515531
fi
532+
533+
# certain test preparation steps such as cache dropping
534+
# can be a bit hard on the system, give it a few
535+
# seconds before actually starting test
536+
# by putting this before pbench-start-tools,
537+
538+
if [ -n "$pre_iteration_script" ] ; then
539+
printf "running pre-iteration-script command: $pre_iteration_script\n"
540+
eval "$pre_iteration_script"
541+
fi
516542
pbench-start-tools --group=$tool_group --iteration=$iteration --dir=$benchmark_results_dir
517543
local client_opts=""
518544

0 commit comments

Comments
 (0)