@@ -5,13 +5,18 @@ CURRENT_RESULTS=$1
55OLD_RESULTS=$2
66FILTER_OPS=(" File read" " File stat" " File removal" " Tree removal" " Tree creation" )
77
8- # New function to extract time from time output
9- extract_time () {
10- local time_output=$1
11- local real_time=$( grep -oP ' real\s+\d+m\d+\.\d+s' <<< " $time_output" | awk ' {print $2}' )
12- local minutes=$( echo " $real_time " | grep -oP ' \d+(?=m)' )
13- local seconds=$( echo " $real_time " | grep -oP ' \d+\.\d+(?=s)' | head -1)
14- echo " $minutes * 60 + $seconds " | bc -l
8+ # Function to extract files/s from built-in mdtest output
9+ extract_files_per_sec () {
10+ local mdtest_output=$1
11+ local files_per_sec=$( grep -oP ' Created .*files.*\(\K[0-9]+(\.[0-9]+)?(?= files/s\))' <<< " $mdtest_output" | head -1)
12+ if [[ -z " $files_per_sec " ]]; then
13+ files_per_sec=$( grep -oP ' \(\K[0-9]+(\.[0-9]+)?(?= files/s\))' <<< " $mdtest_output" | head -1)
14+ fi
15+ if [[ -z " $files_per_sec " ]]; then
16+ echo " 0"
17+ else
18+ echo " $files_per_sec "
19+ fi
1520}
1621
1722# Function to extract IOPS from fio output
@@ -30,6 +35,16 @@ extract_iops() {
3035 fi
3136}
3237
38+ extract_bw () {
39+ local fio_output=$1
40+ local bw=$( grep -oP ' BW=\K[^, ]+' <<< " $fio_output" | head -1)
41+ if [[ -z " $bw " ]]; then
42+ echo " N/A"
43+ else
44+ echo " $bw "
45+ fi
46+ }
47+
3348extract_metrics () {
3449 awk ' {
3550 op_description=$1;
@@ -54,6 +69,7 @@ compare_with_tolerance() {
5469 local current=$1
5570 local old=$2
5671 local op_type=$3
72+ local direction=${4:- higher}
5773 tolerance=$( echo " $old * 0.2" | bc -l)
5874 lower_bound=$( echo " $old - $tolerance " | bc -l)
5975 upper_bound=$( echo " $old + $tolerance " | bc -l)
@@ -63,10 +79,20 @@ compare_with_tolerance() {
6379 echo " skip"
6480 elif (( $(echo "$current <= $upper_bound && $current >= $lower_bound " | bc - l) )) ; then
6581 echo " same"
66- elif (( $(echo "$current > $old " | bc - l) )) ; then
67- echo " better"
6882 else
69- echo " worse"
83+ if [[ " $direction " == " lower" ]]; then
84+ if (( $(echo "$current < $old " | bc - l) )) ; then
85+ echo " better"
86+ else
87+ echo " worse"
88+ fi
89+ else
90+ if (( $(echo "$current > $old " | bc - l) )) ; then
91+ echo " better"
92+ else
93+ echo " worse"
94+ fi
95+ fi
7096 fi
7197}
7298
@@ -86,7 +112,7 @@ compare_scenario() {
86112 echo " Command is : mpirun --use-hwthread-cpus --allow-run-as-root -np 4 mdtest -F -w 102400 -I 3000 -z 0"
87113 ;;
88114 " scenario3" )
89- echo " Command is : cmd/mount/mount mdtest -- threads 100 --dirs 3 --depth 5 --files 100 --create "
115+ echo " Command is : ./juicefs mdtest <meta-url> /mdtest_perf -- threads 10 --dirs 3 --depth 3 --files 100"
90116 ;;
91117 " fio_scenario4" )
92118 echo " Command is : fio --name=big-write --directory=/mnt/fio --group_reporting --rw=write --direct=1 --bs=64k --end_fsync=1 --numjobs=8 --nrfiles=1 --size=2G --runtime=120"
@@ -114,15 +140,20 @@ compare_scenario() {
114140
115141 # Handle built-in mdtest scenario (scenario3)
116142 if [[ " $scenario " == " scenario3" ]]; then
117- printf " %-30s %-12s %-12s %-12s %-12s %-12s\n" " Operation" " Current Time " " Old Time " " Diff" " Status" " Variance"
143+ printf " %-30s %-12s %-12s %-12s %-12s %-12s\n" " Operation" " Current files/s " " Old files/s " " Diff" " Status" " Variance"
118144 echo " --------------------------------------------------------------------"
119145
120- current_time =$( extract_time " $( cat " ${current_file} " ) " )
121- old_time =$( extract_time " $( cat " ${old_file} " ) " )
146+ current_files_per_sec =$( extract_files_per_sec " $( cat " ${current_file} " ) " )
147+ old_files_per_sec =$( extract_files_per_sec " $( cat " ${old_file} " ) " )
122148
123- diff=$( echo " $current_time - $old_time " | bc -l)
124- variance=$( echo " scale=2; ($current_time - $old_time )*100/$old_time " | bc -l)
125- comparison=$( compare_with_tolerance $current_time $old_time " builtin_mdtest" )
149+ diff=$( echo " $current_files_per_sec - $old_files_per_sec " | bc -l)
150+ if (( $(echo "$old_files_per_sec == 0 " | bc - l) )) ; then
151+ variance=" N/A"
152+ comparison=" same"
153+ else
154+ variance=$( echo " scale=2; ($current_files_per_sec - $old_files_per_sec )*100/$old_files_per_sec " | bc -l)
155+ comparison=$( compare_with_tolerance $current_files_per_sec $old_files_per_sec " builtin_mdtest" )
156+ fi
126157
127158 case $comparison in
128159 " worse" ) status=" ❌ Worse" ;;
@@ -132,8 +163,13 @@ compare_scenario() {
132163 * ) status=" ⚠️ Unknown" ;;
133164 esac
134165
135- printf " %-30s %-12.2f %-12.2f %-12.2f %-12s %-12s%%\n" \
136- " Built-in mdtest" " $current_time " " $old_time " " $diff " " $status " " $variance "
166+ if [[ " $variance " == " N/A" ]]; then
167+ printf " %-30s %-12.2f %-12.2f %-12.2f %-12s %-12s\n" \
168+ " Built-in mdtest" " $current_files_per_sec " " $old_files_per_sec " " $diff " " $status " " $variance "
169+ else
170+ printf " %-30s %-12.2f %-12.2f %-12.2f %-12s %-12s%%\n" \
171+ " Built-in mdtest" " $current_files_per_sec " " $old_files_per_sec " " $diff " " $status " " $variance "
172+ fi
137173
138174 # Handle fio scenarios
139175 elif [[ " $scenario " =~ ^fio ]]; then
@@ -142,6 +178,8 @@ compare_scenario() {
142178
143179 current_iops=$( extract_iops " $( cat " ${current_file} " ) " )
144180 old_iops=$( extract_iops " $( cat " ${old_file} " ) " )
181+ current_bw=$( extract_bw " $( cat " ${current_file} " ) " )
182+ old_bw=$( extract_bw " $( cat " ${old_file} " ) " )
145183
146184 diff=$( echo " $current_iops - $old_iops " | bc -l)
147185 variance=$( echo " scale=2; ($current_iops - $old_iops )*100/$old_iops " | bc -l)
@@ -157,7 +195,8 @@ compare_scenario() {
157195
158196 printf " %-30s %-12.2f %-12.2f %-12.2f %-12s %-12s%%\n" \
159197 " FIO ${scenario} " " $current_iops " " $old_iops " " $diff " " $status " " $variance "
160-
198+ printf " %-30s %-12s %-12s\n" " Bandwidth" " $current_bw " " $old_bw "
199+
161200 # Handle mdtest scenarios
162201 else
163202 printf " %-30s %-12s %-12s %-12s %-12s %-12s\n" " Operation" " Current Max" " Old Max" " Diff" " Status" " Variance"
@@ -214,13 +253,17 @@ check_regression() {
214253
215254 # Handle built-in mdtest scenario (scenario3)
216255 if [[ " $scenario " == " scenario3" ]]; then
217- current_time=$( extract_time " $( cat " ${current_file} " ) " )
218- old_time=$( extract_time " $( cat " ${old_file} " ) " )
219- comparison=$( compare_with_tolerance $current_time $old_time " builtin_mdtest" )
256+ current_files_per_sec=$( extract_files_per_sec " $( cat " ${current_file} " ) " )
257+ old_files_per_sec=$( extract_files_per_sec " $( cat " ${old_file} " ) " )
258+ if (( $(echo "$old_files_per_sec == 0 " | bc - l) )) ; then
259+ comparison=" same"
260+ else
261+ comparison=$( compare_with_tolerance $current_files_per_sec $old_files_per_sec " builtin_mdtest" )
262+ fi
220263
221264 if [ " $comparison " == " worse" ]; then
222- variance=$( echo " scale=2; ($current_time - $old_time )*100/$old_time " | bc -l)
223- echo " Regression detected in $scenario for built-in mdtest: Current $current_time vs Old $old_time (Variance: ${variance} %)"
265+ variance=$( echo " scale=2; ($current_files_per_sec - $old_files_per_sec )*100/$old_files_per_sec " | bc -l)
266+ echo " Regression detected in $scenario for built-in mdtest (files/s) : Current $current_files_per_sec vs Old $old_files_per_sec (Variance: ${variance} %)"
224267 regression_detected=1
225268 fi
226269
@@ -235,7 +278,7 @@ check_regression() {
235278 echo " Regression detected in $scenario : Current $current_iops IOPS vs Old $old_iops IOPS (Variance: ${variance} %)"
236279 regression_detected=1
237280 fi
238-
281+
239282 # Handle mdtest scenarios
240283 else
241284 while IFS= read -r current_line && IFS= read -r old_line < & 3; do
0 commit comments