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 <david@fromorbit.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Dave Chinner
2009-03-25 20:53:36 +01:00
committed by Christoph Hellwig
parent d3592f9b21
commit e714acc0ef
30 changed files with 72 additions and 72 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ num_filenames=100
i=1 i=1
while [ $i -le $num_filenames ]; do while [ $i -le $num_filenames ]; do
echo "nametest.$i" >>$sourcefile echo "nametest.$i" >>$sourcefile
i=`expr $i + 1` let i=$i+1
done done
mkdir $testdir/$seq mkdir $testdir/$seq
+1 -1
View File
@@ -44,7 +44,7 @@ while [ $i -lt 5 ]; do
fi fi
rm $dump_file rm $dump_file
sleep 2 sleep 2
i=`expr $i + 1` let i=$i+1
done done
echo "middate = $middate" >>$seq.full echo "middate = $middate" >>$seq.full
+1 -1
View File
@@ -71,7 +71,7 @@ EOF
while [ $count -lt $total ] while [ $count -lt $total ]
do do
count=`expr $count + 1` let count=$count+1
cat >>$tmp.proto <<EOF cat >>$tmp.proto <<EOF
${count}_of_${total}_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---755 3 1 /bin/true ${count}_of_${total}_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---755 3 1 /bin/true
EOF EOF
+1 -1
View File
@@ -44,7 +44,7 @@ while [ $i -lt 5 ]; do
fi fi
rm $dump_file rm $dump_file
sleep 2 sleep 2
i=`expr $i + 1` let i=$i+1
done done
echo "middate = $middate" >>$seq.full echo "middate = $middate" >>$seq.full
+2 -2
View File
@@ -54,7 +54,7 @@ for acl in $acls
do do
_do "touch $test.$i" _do "touch $test.$i"
_do "chacl $acl $test.$i" _do "chacl $acl $test.$i"
i=`expr $i + 1` let i=$i+1
done done
list_acls() list_acls()
@@ -63,7 +63,7 @@ list_acls()
for acl in $acls for acl in $acls
do do
chacl -l $test.$i | _acl_filter_id | sed -e "s!$SCRATCH_MNT!\$SCRATCH_MNT!" chacl -l $test.$i | _acl_filter_id | sed -e "s!$SCRATCH_MNT!\$SCRATCH_MNT!"
i=`expr $i + 1` let i=$i+1
done done
} }
+4 -4
View File
@@ -58,7 +58,7 @@ while [ $i -le 9 ]; do
date >>$seq.full date >>$seq.full
find $SCRATCH_MNT -exec $here/src/lstat64 {} \; | sed 's/(00.*)//' >$tmp.dates.$i find $SCRATCH_MNT -exec $here/src/lstat64 {} \; | sed 's/(00.*)//' >$tmp.dates.$i
if [ $i -gt 0 ]; then 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 diff -c $tmp.dates.$level_1 $tmp.dates.$i >>$seq.full
else else
cat $tmp.dates.$i >>$seq.full cat $tmp.dates.$i >>$seq.full
@@ -66,7 +66,7 @@ while [ $i -le 9 ]; do
dump_file=$tmp.df.level$i dump_file=$tmp.df.level$i
_do_dump_file -l $i _do_dump_file -l $i
i=`expr $i + 1` let i=$i+1
done done
echo "Listing of what files we start with:" echo "Listing of what files we start with:"
@@ -79,7 +79,7 @@ while [ $i -le 9 ]; do
echo "restoring from df.level$i" echo "restoring from df.level$i"
dump_file=$tmp.df.level$i dump_file=$tmp.df.level$i
_do_restore_toc _do_restore_toc
i=`expr $i + 1` let i=$i+1
done done
echo "Do the cumulative restores" echo "Do the cumulative restores"
@@ -91,7 +91,7 @@ while [ $i -le 9 ]; do
_do_restore_file_cum -l $i _do_restore_file_cum -l $i
echo "ls -l restore_dir" echo "ls -l restore_dir"
ls -lR $restore_dir | _ls_size_filter | _check_quota_file ls -lR $restore_dir | _ls_size_filter | _check_quota_file
i=`expr $i + 1` let i=$i+1
done done
# success, all done # success, all done
+4 -4
View File
@@ -146,7 +146,7 @@ while [ $i -le $num_dumps ]; do
dump_file=$tmp.df.level$i dump_file=$tmp.df.level$i
_do_dump_file -l $i _do_dump_file -l $i
i=`expr $i + 1` let i=$i+1
done done
echo "Look at what files are contained in the inc. dump" 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" echo "restoring from df.level$i"
dump_file=$tmp.df.level$i dump_file=$tmp.df.level$i
_do_restore_toc _do_restore_toc
i=`expr $i + 1` let i=$i+1
done done
echo "Do the cumulative restores" echo "Do the cumulative restores"
@@ -168,7 +168,7 @@ while [ $i -le $num_dumps ]; do
_do_restore_file_cum -l $i _do_restore_file_cum -l $i
echo "list restore_dir" echo "list restore_dir"
_list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i _list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i
i=`expr $i + 1` let i=$i+1
done done
echo "" echo ""
@@ -178,7 +178,7 @@ while [ $i -le $num_dumps ]; do
echo "Comparing ls of FS with restored FS at level $i" echo "Comparing ls of FS with restored FS at level $i"
diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g" diff -s $tmp.ls.$i $tmp.restorals.$i | sed "s#$tmp#TMP#g"
echo "" echo ""
i=`expr $i + 1` let i=$i+1
done done
+3 -3
View File
@@ -75,7 +75,7 @@ touch $tmp.running
} & } &
i=0 i=0
ITERATIONS=`expr $ITERATIONS - 1` let ITERATIONS=$ITERATIONS-1
echo | tee -a $seq.full echo | tee -a $seq.full
while [ $i -le $ITERATIONS ] while [ $i -le $ITERATIONS ]
@@ -94,7 +94,7 @@ do
sleep 2 sleep 2
echo | tee -a $seq.full echo | tee -a $seq.full
i=`expr $i + 1` let i=$i+1
done done
# stop fsstress iterations # stop fsstress iterations
@@ -105,4 +105,4 @@ wait
_check_scratch_fs _check_scratch_fs
exit 1 exit 1
+1 -1
View File
@@ -137,7 +137,7 @@ do
echo === Iterating, `expr $upperbound - $count` remains echo === Iterating, `expr $upperbound - $count` remains
echo echo
echo echo
count=`expr $count + 1` let count=$count+1
done done
# success, all done # success, all done
+1 -1
View File
@@ -30,7 +30,7 @@ addentries()
while [ $count -gt 0 ]; do while [ $count -gt 0 ]; do
touch `printf $pattern $count` touch `printf $pattern $count`
count=`expr $count - 1` let count=$count-1
done done
} }
+4 -4
View File
@@ -38,7 +38,7 @@ populate()
while [ $i -le $files -a "X$faststart" = "X" ]; do while [ $i -le $files -a "X$faststart" = "X" ]; do
file=$SCRATCH_MNT/f$i file=$SCRATCH_MNT/f$i
xfs_io -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null xfs_io -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null
i=`expr $i + 1` let i=$i+1
done done
# remove every second file, freeing up lots of space # remove every second file, freeing up lots of space
@@ -46,7 +46,7 @@ populate()
i=1 i=1
while [ $i -le $files -a "X$faststart" = "X" ]; do while [ $i -le $files -a "X$faststart" = "X" ]; do
rm $SCRATCH_MNT/f$i rm $SCRATCH_MNT/f$i
i=`expr $i + 2` let i=$i+2
done done
echo "flushing changes via umount/mount." echo "flushing changes via umount/mount."
@@ -67,10 +67,10 @@ allocate()
xfs_io -f -c 'pwrite -b 64k 0 16m' $file \ xfs_io -f -c 'pwrite -b 64k 0 16m' $file \
>/dev/null 2>&1 >/dev/null 2>&1
rm $file rm $file
j=`expr $j + 1` let j=$j+1
done done
} & } &
i=`expr $i + 1` let i=$i+1
done done
wait wait
+3 -3
View File
@@ -52,8 +52,8 @@ E=10030600
while [ $I -le $E ] while [ $I -le $E ]
do do
echo > $SCRATCH_MNT/test/${STR1}${STR2}${STR3}${I} echo > $SCRATCH_MNT/test/${STR1}${STR2}${STR3}${I}
I=`expr $I + 1` let I=$I+1
[ `expr $I % 1000` -eq 0 ] && echo "Created $I/$E" [ $[$I % 1000] -eq 0 ] && echo "Created $I/$E"
done done
sync sync
@@ -63,7 +63,7 @@ E=10030599
while [ $I -le $E ] while [ $I -le $E ]
do do
rm $SCRATCH_MNT/test/${STR1}${STR2}${STR3}${I} & rm $SCRATCH_MNT/test/${STR1}${STR2}${STR3}${I} &
I=`expr $I + 1` let I=$I+1
done done
_check_scratch_fs _check_scratch_fs
+1 -1
View File
@@ -39,7 +39,7 @@ I=0
while [ $I -lt 1000 ] while [ $I -lt 1000 ]
do do
cp src/itrash.c $SCRATCH_MNT/${I} cp src/itrash.c $SCRATCH_MNT/${I}
I=`expr $I + 1` let I=$I+1
done done
umount $SCRATCH_DEV umount $SCRATCH_DEV
+1 -1
View File
@@ -41,7 +41,7 @@ _do_test()
[ $__proc -gt 1 ] && _param="-t $__proc $_param" [ $__proc -gt 1 ] && _param="-t $__proc $_param"
while [ $__proc -gt 1 ]; do while [ $__proc -gt 1 ]; do
_files="$_files $testdir/aiostress.$$.$_n.$__proc" _files="$_files $testdir/aiostress.$$.$_n.$__proc"
__proc=`expr $__proc - 1` let __proc=$__proc-1
done done
rm -f $_files rm -f $_files
+2 -2
View File
@@ -135,8 +135,8 @@ _test_hardlink()
paths="$d/l1 $d/l2 $d/l3 $d2/l4 $d2/l5 $d2/l6" paths="$d/l1 $d/l2 $d/l3 $d2/l4 $d2/l5 $d2/l6"
i=0 i=0
for x in $paths; do for x in $paths; do
i=`expr $i + 1` let i=$i+1
j=`expr $i % 2` let j=$i%2
if [ $j -eq 0 ]; then if [ $j -eq 0 ]; then
echo "rm'ing $x" echo "rm'ing $x"
rm $x rm $x
+1 -1
View File
@@ -71,7 +71,7 @@ while [ $i -lt $ITERATIONS ]; do
-s $seed \ -s $seed \
-S -p 1 -n 1000 >>$seq.full 2>&1 -S -p 1 -n 1000 >>$seq.full 2>&1
i=`expr $i + 1` let i=$i+1
done done
cd / cd /
+1 -1
View File
@@ -54,7 +54,7 @@ while [ $i -lt $max ]; do
xfs_freeze -f $SCRATCH_MNT xfs_freeze -f $SCRATCH_MNT
xfs_freeze -u $SCRATCH_MNT xfs_freeze -u $SCRATCH_MNT
echo -n . echo -n .
i=`expr $i + 1` let i=$i+1
done done
echo "done" echo "done"
+7 -7
View File
@@ -61,7 +61,7 @@ add_eas()
i=$start i=$start
while [ $i -le $end ]; do while [ $i -le $end ]; do
attr -s name.$i -V value $file >/dev/null attr -s name.$i -V value $file >/dev/null
i=`expr $i + 1` let i=$i+1
done done
} }
@@ -73,7 +73,7 @@ rm_eas()
i=$start i=$start
while [ $i -le $end ]; do while [ $i -le $end ]; do
attr -r name.$i $file >/dev/null attr -r name.$i $file >/dev/null
i=`expr $i + 1` let i=$i+1
done done
} }
@@ -171,7 +171,7 @@ _test_add_extents()
while [ $j -le 30 ]; do while [ $j -le 30 ]; do
do_extents $j do_extents $j
_print_inode _print_inode
j=`expr $j + 2` let j=$j+2
done done
#scale down #scale down
@@ -179,7 +179,7 @@ _test_add_extents()
while [ $j -ge 1 ]; do while [ $j -ge 1 ]; do
do_extents $j do_extents $j
_print_inode _print_inode
j=`expr $j - 2` let j=$j-2
done done
#build up #build up
@@ -187,7 +187,7 @@ _test_add_extents()
while [ $j -le 30 ]; do while [ $j -le 30 ]; do
do_extents $j do_extents $j
_print_inode _print_inode
j=`expr $j + 2` let j=$j+2
done done
} }
@@ -211,7 +211,7 @@ _test_extents_eas()
_print_inode _print_inode
_print_inode_u > $tmp.u1 _print_inode_u > $tmp.u1
for j in `seq 1 $EAs_inc $EAs_max`; do 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 add_eas $j $k
done done
# should have same extents # should have same extents
@@ -256,7 +256,7 @@ _test_eas_extents()
EAs_inc=5 EAs_inc=5
for j in `seq 1 $EAs_inc $EAs_max`; do 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 add_eas $j $k
echo "--- EAs: $j ---" echo "--- EAs: $j ---"
+2 -2
View File
@@ -47,7 +47,7 @@ do
echo error creating/writing file $file echo error creating/writing file $file
exit exit
fi fi
i=`expr $i + 1` let i=$i+1
done done
# give the system a chance to write something out # give the system a chance to write something out
@@ -90,7 +90,7 @@ do
rm -f $file rm -f $file
fi fi
fi fi
i=`expr $i + 1` let i=$i+1
done done
status=0 status=0
+2 -2
View File
@@ -53,7 +53,7 @@ do
echo error truncating file $file echo error truncating file $file
exit exit
fi fi
i=`expr $i + 1` let i=$i+1
done done
# give the system a chance to write something out # give the system a chance to write something out
@@ -96,7 +96,7 @@ do
rm -f $file rm -f $file
fi fi
fi fi
i=`expr $i + 1` let i=$i+1
done done
status=0 status=0

Some files were not shown because too many files have changed in this diff Show More