From e714acc0ef37031b9a5a522703f2832f139c22e0 Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Wed, 25 Mar 2009 20:53:36 +0100 Subject: [PATCH] reduce the number of processes forked One of the big cpu time consumers when running xfsqa on UML is forking of new processes. when looping lots of times, using 'expr' to calculate the loop counter increment means we fork at least once every loop. using shell builtins means that we don't fork and many tests run substantially faster. Some tests are even runnable with this modification. e.g. 110 went from taking 4500s to run down to 9s with the loop iterators changed to avoid forking. Signed-off-by: Dave Chinner Signed-off-by: Christoph Hellwig --- 007 | 2 +- 028 | 2 +- 031 | 2 +- 047 | 2 +- 053 | 4 ++-- 064 | 8 ++++---- 065 | 8 ++++---- 068 | 6 +++--- 071 | 2 +- 089 | 2 +- 109 | 8 ++++---- 110 | 6 +++--- 111 | 2 +- 113 | 2 +- 114 | 4 ++-- 117 | 2 +- 119 | 2 +- 136 | 14 +++++++------- 137 | 4 ++-- 138 | 4 ++-- 139 | 4 ++-- 140 | 4 ++-- 149 | 2 +- 165 | 8 ++++---- 179 | 4 ++-- 180 | 4 ++-- 182 | 4 ++-- common.attr | 6 +++--- common.dump | 12 ++++++------ common.rc | 10 +++++----- 30 files changed, 72 insertions(+), 72 deletions(-) diff --git a/007 b/007 index e8c66101..290f7162 100755 --- a/007 +++ b/007 @@ -50,7 +50,7 @@ num_filenames=100 i=1 while [ $i -le $num_filenames ]; do echo "nametest.$i" >>$sourcefile - i=`expr $i + 1` + let i=$i+1 done mkdir $testdir/$seq diff --git a/028 b/028 index 1b679f23..2c353fa3 100755 --- a/028 +++ b/028 @@ -44,7 +44,7 @@ while [ $i -lt 5 ]; do fi rm $dump_file sleep 2 - i=`expr $i + 1` + let i=$i+1 done echo "middate = $middate" >>$seq.full diff --git a/031 b/031 index 779cf27c..7ddd8427 100755 --- a/031 +++ b/031 @@ -71,7 +71,7 @@ EOF while [ $count -lt $total ] do - count=`expr $count + 1` + let count=$count+1 cat >>$tmp.proto <>$seq.full diff --git a/053 b/053 index f260e1a1..dbd2d5d6 100755 --- a/053 +++ b/053 @@ -54,7 +54,7 @@ for acl in $acls do _do "touch $test.$i" _do "chacl $acl $test.$i" - i=`expr $i + 1` + let i=$i+1 done list_acls() @@ -63,7 +63,7 @@ list_acls() for acl in $acls do chacl -l $test.$i | _acl_filter_id | sed -e "s!$SCRATCH_MNT!\$SCRATCH_MNT!" - i=`expr $i + 1` + let i=$i+1 done } diff --git a/064 b/064 index 27ee1dad..5a7d4b4b 100755 --- a/064 +++ b/064 @@ -58,7 +58,7 @@ while [ $i -le 9 ]; do date >>$seq.full find $SCRATCH_MNT -exec $here/src/lstat64 {} \; | sed 's/(00.*)//' >$tmp.dates.$i if [ $i -gt 0 ]; then - level_1=`expr $i - 1` + let level_1=$i-1 diff -c $tmp.dates.$level_1 $tmp.dates.$i >>$seq.full else cat $tmp.dates.$i >>$seq.full @@ -66,7 +66,7 @@ while [ $i -le 9 ]; do dump_file=$tmp.df.level$i _do_dump_file -l $i - i=`expr $i + 1` + let i=$i+1 done echo "Listing of what files we start with:" @@ -79,7 +79,7 @@ while [ $i -le 9 ]; do echo "restoring from df.level$i" dump_file=$tmp.df.level$i _do_restore_toc - i=`expr $i + 1` + let i=$i+1 done echo "Do the cumulative restores" @@ -91,7 +91,7 @@ while [ $i -le 9 ]; do _do_restore_file_cum -l $i echo "ls -l restore_dir" ls -lR $restore_dir | _ls_size_filter | _check_quota_file - i=`expr $i + 1` + let i=$i+1 done # success, all done diff --git a/065 b/065 index b193f28e..4252b110 100755 --- a/065 +++ b/065 @@ -146,7 +146,7 @@ while [ $i -le $num_dumps ]; do dump_file=$tmp.df.level$i _do_dump_file -l $i - i=`expr $i + 1` + let i=$i+1 done echo "Look at what files are contained in the inc. dump" @@ -156,7 +156,7 @@ while [ $i -le $num_dumps ]; do echo "restoring from df.level$i" dump_file=$tmp.df.level$i _do_restore_toc - i=`expr $i + 1` + let i=$i+1 done echo "Do the cumulative restores" @@ -168,7 +168,7 @@ while [ $i -le $num_dumps ]; do _do_restore_file_cum -l $i echo "list restore_dir" _list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i - i=`expr $i + 1` + let i=$i+1 done echo "" @@ -178,7 +178,7 @@ while [ $i -le $num_dumps ]; do echo "Comparing ls of FS with restored FS at level $i" diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g" echo "" - i=`expr $i + 1` + let i=$i+1 done diff --git a/068 b/068 index eb8b9362..af060ae0 100755 --- a/068 +++ b/068 @@ -75,7 +75,7 @@ touch $tmp.running } & i=0 -ITERATIONS=`expr $ITERATIONS - 1` +let ITERATIONS=$ITERATIONS-1 echo | tee -a $seq.full while [ $i -le $ITERATIONS ] @@ -94,7 +94,7 @@ do sleep 2 echo | tee -a $seq.full - i=`expr $i + 1` + let i=$i+1 done # stop fsstress iterations @@ -105,4 +105,4 @@ wait _check_scratch_fs -exit 1 \ No newline at end of file +exit 1 diff --git a/071 b/071 index 5e621bab..4e958041 100755 --- a/071 +++ b/071 @@ -137,7 +137,7 @@ do echo === Iterating, `expr $upperbound - $count` remains echo echo - count=`expr $count + 1` + let count=$count+1 done # success, all done diff --git a/089 b/089 index db7525b5..9f77c05e 100755 --- a/089 +++ b/089 @@ -30,7 +30,7 @@ addentries() while [ $count -gt 0 ]; do touch `printf $pattern $count` - count=`expr $count - 1` + let count=$count-1 done } diff --git a/109 b/109 index 913ceea7..845f1f2c 100755 --- a/109 +++ b/109 @@ -38,7 +38,7 @@ populate() while [ $i -le $files -a "X$faststart" = "X" ]; do file=$SCRATCH_MNT/f$i xfs_io -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null - i=`expr $i + 1` + let i=$i+1 done # remove every second file, freeing up lots of space @@ -46,7 +46,7 @@ populate() i=1 while [ $i -le $files -a "X$faststart" = "X" ]; do rm $SCRATCH_MNT/f$i - i=`expr $i + 2` + let i=$i+2 done echo "flushing changes via umount/mount." @@ -67,10 +67,10 @@ allocate() xfs_io -f -c 'pwrite -b 64k 0 16m' $file \ >/dev/null 2>&1 rm $file - j=`expr $j + 1` + let j=$j+1 done } & - i=`expr $i + 1` + let i=$i+1 done wait diff --git a/110 b/110 index c578d358..85b313c7 100755 --- a/110 +++ b/110 @@ -52,8 +52,8 @@ E=10030600 while [ $I -le $E ] do echo > $SCRATCH_MNT/test/${STR1}${STR2}${STR3}${I} - I=`expr $I + 1` - [ `expr $I % 1000` -eq 0 ] && echo "Created $I/$E" + let I=$I+1 + [ $[$I % 1000] -eq 0 ] && echo "Created $I/$E" done sync @@ -63,7 +63,7 @@ E=10030599 while [ $I -le $E ] do rm $SCRATCH_MNT/test/${STR1}${STR2}${STR3}${I} & - I=`expr $I + 1` + let I=$I+1 done _check_scratch_fs diff --git a/111 b/111 index 46f1395f..060c0bc5 100755 --- a/111 +++ b/111 @@ -39,7 +39,7 @@ I=0 while [ $I -lt 1000 ] do cp src/itrash.c $SCRATCH_MNT/${I} - I=`expr $I + 1` + let I=$I+1 done umount $SCRATCH_DEV diff --git a/113 b/113 index 9c435cf2..49c8cee6 100755 --- a/113 +++ b/113 @@ -41,7 +41,7 @@ _do_test() [ $__proc -gt 1 ] && _param="-t $__proc $_param" while [ $__proc -gt 1 ]; do _files="$_files $testdir/aiostress.$$.$_n.$__proc" - __proc=`expr $__proc - 1` + let __proc=$__proc-1 done rm -f $_files diff --git a/114 b/114 index 5f7c23db..af8608c7 100755 --- a/114 +++ b/114 @@ -135,8 +135,8 @@ _test_hardlink() paths="$d/l1 $d/l2 $d/l3 $d2/l4 $d2/l5 $d2/l6" i=0 for x in $paths; do - i=`expr $i + 1` - j=`expr $i % 2` + let i=$i+1 + let j=$i%2 if [ $j -eq 0 ]; then echo "rm'ing $x" rm $x diff --git a/117 b/117 index 5fee4164..7cb91d18 100755 --- a/117 +++ b/117 @@ -71,7 +71,7 @@ while [ $i -lt $ITERATIONS ]; do -s $seed \ -S -p 1 -n 1000 >>$seq.full 2>&1 - i=`expr $i + 1` + let i=$i+1 done cd / diff --git a/119 b/119 index 8d234952..055928c0 100755 --- a/119 +++ b/119 @@ -54,7 +54,7 @@ while [ $i -lt $max ]; do xfs_freeze -f $SCRATCH_MNT xfs_freeze -u $SCRATCH_MNT echo -n . - i=`expr $i + 1` + let i=$i+1 done echo "done" diff --git a/136 b/136 index 0978ac90..c3e010c8 100755 --- a/136 +++ b/136 @@ -61,7 +61,7 @@ add_eas() i=$start while [ $i -le $end ]; do attr -s name.$i -V value $file >/dev/null - i=`expr $i + 1` + let i=$i+1 done } @@ -73,7 +73,7 @@ rm_eas() i=$start while [ $i -le $end ]; do attr -r name.$i $file >/dev/null - i=`expr $i + 1` + let i=$i+1 done } @@ -171,7 +171,7 @@ _test_add_extents() while [ $j -le 30 ]; do do_extents $j _print_inode - j=`expr $j + 2` + let j=$j+2 done #scale down @@ -179,7 +179,7 @@ _test_add_extents() while [ $j -ge 1 ]; do do_extents $j _print_inode - j=`expr $j - 2` + let j=$j-2 done #build up @@ -187,7 +187,7 @@ _test_add_extents() while [ $j -le 30 ]; do do_extents $j _print_inode - j=`expr $j + 2` + let j=$j+2 done } @@ -211,7 +211,7 @@ _test_extents_eas() _print_inode _print_inode_u > $tmp.u1 for j in `seq 1 $EAs_inc $EAs_max`; do - k=`expr $j + $EAs_inc - 1` + let k=$k+$EAs_inc-1 add_eas $j $k done # should have same extents @@ -256,7 +256,7 @@ _test_eas_extents() EAs_inc=5 for j in `seq 1 $EAs_inc $EAs_max`; do - k=`expr $j + $EAs_inc - 1` + let k=$k+$EAs_inc-1 add_eas $j $k echo "--- EAs: $j ---" diff --git a/137 b/137 index 4dbf8474..f27a248f 100755 --- a/137 +++ b/137 @@ -47,7 +47,7 @@ do echo error creating/writing file $file exit fi - i=`expr $i + 1` + let i=$i+1 done # give the system a chance to write something out @@ -90,7 +90,7 @@ do rm -f $file fi fi - i=`expr $i + 1` + let i=$i+1 done status=0 diff --git a/138 b/138 index 7cf90202..bf36e3da 100755 --- a/138 +++ b/138 @@ -53,7 +53,7 @@ do echo error truncating file $file exit fi - i=`expr $i + 1` + let i=$i+1 done # give the system a chance to write something out @@ -96,7 +96,7 @@ do rm -f $file fi fi - i=`expr $i + 1` + let i=$i+1 done status=0 diff --git a/139 b/139 index 48052799..5fd2a643 100755 --- a/139 +++ b/139 @@ -53,7 +53,7 @@ do echo error truncating file $file exit fi - i=`expr $i + 1` + let i=$i+1 done # give the system a chance to write something out @@ -96,7 +96,7 @@ do rm -f $file fi fi - i=`expr $i + 1` + let i=$i+1 done status=0 diff --git a/140 b/140 index 797efc4e..e5d63a61 100755 --- a/140 +++ b/140 @@ -53,7 +53,7 @@ do echo error truncating file $file exit fi - i=`expr $i + 1` + let i=$i+1 done # give the system a chance to write something out @@ -93,7 +93,7 @@ do rm -f $file fi fi - i=`expr $i + 1` + let i=$i+1 done status=0 diff --git a/149 b/149 index 0e9d9748..8fea8afa 100755 --- a/149 +++ b/149 @@ -74,7 +74,7 @@ EOF while [ $count -lt $total ] do - count=`expr $count + 1` + let count=$count+1 cat >>$tmp.proto < $file if [ $size -gt 0 ]; then dd if=/dev/zero of=$file bs=1024 count=$size fi - f=`expr $f + 1` + let f=$f+1 done } @@ -1140,7 +1140,7 @@ _descend() _nfiles $files # files for this dir [ $depth -eq 0 ] && return - deep=`expr $depth - 1` # go 1 down + let deep=$depth-1 # go 1 down [ $verbose = true ] && echo "descending, depth from leaves = $deep" @@ -1148,7 +1148,7 @@ _descend() while [ $d -lt $dirs ] do _descend d$d $deep & - d=`expr $d + 1` + let d=$d+1 wait done } -- 2.39.5