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
+5 -5
View File
@@ -152,7 +152,7 @@ _mount_ops_filter()
params="$*"
#get mount point to handle dmapi mtpt option correctly
last_index=`expr $# - 1`
let last_index=$#-1
[ $last_index -gt 0 ] && shift $last_index
FS_ESCAPED=$1
@@ -1122,11 +1122,11 @@ _nfiles()
while [ $f -lt $1 ]
do
file=f$f
touch $file
echo > $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
}