Thanks for the changes. There are some issues:
- the changed DEVMAJOR line uses wrong var (i)
Oops, yes I messed that one up completely, it should be "DEVMAJOR=${DEVMAJOR%%:*}" there of course.
- it calls fstype potentially many more times
How do you come to this conclusion (besides due to the DEVMAJOR error)?
For me this script shows that the same number of file system device lines are run through the parts of the loop where the fstype and grep calls are located. If the DEVNAME and DEVMAJOR variables are also the same in each version, then I don't see where there can be a difference in the behaviour.
#!/bin/busybox ash
rm -f /tmp/blkdev.txt
for i in /sys/block/*/dev /sys/block/*/*/dev; do
case "$i" in
*loop*|*ram*)
continue
;;
esac
DEVNAME=${i%*/dev}
DEVNAME=${DEVNAME##*/}
[ -b "/dev/$DEVNAME" ] || continue
echo "$i" >> /tmp/blkdev.txt
done
echo rebuildfstab-mod:
wc -l /tmp/blkdev.txt
rm /tmp/blkdev.txt
for i in `find /sys/block/*/ -name dev`; do
case "$i" in
*loop*|*ram*)
continue
;;
esac
echo "$i" >> /tmp/blkdev.txt
done
echo rebuildfstab:
wc -l /tmp/blkdev.txt
rm /tmp/blkdev.txt
- it calls grep many times, which is what an earlier patch specifically changed to the combined awk
Oh right, I forgot to check
the current version on Github and just based this on the version in TC 13. Now that I've seen that, I see what you're talking about (it took a while) - you're using "read" to advance through the list of block devices now, and feeding it from find and awk.
- if there is no glob match, the pattern is passed as-is (I guess the -b test was added for this)
Yes the -b test catches that.
It may not be simple to apply just the globbing; when I tried, it was slower.
OK. Testing against the 'new' rebuildfstab on GitHub the execution time is much closer with my version Vs 'rebuildfstab-new', and that's on a test machine with only four mountable file systems so not many calls to Grep which affect the older design that I based mine on. I'll believe you that the new layout is no faster with globbing (fed to awk via "echo", presumably), I've spent enough time on this already now.
# echo original:; time rebuildfstab; echo github: ; time ./rebuildfstab-new;echo modified: ;time rebuildfstab-mod;echo modified: ;time rebuild
fstab-mod; echo github: ; time ./rebuildfstab-new;echo original:; time rebuildfstab;
original:
real 0m 0.82s
user 0m 0.22s
sys 0m 0.50s
github:
real 0m 0.37s
user 0m 0.09s
sys 0m 0.26s
modified:
real 0m 0.33s
user 0m 0.12s
sys 0m 0.16s
modified:
real 0m 0.36s
user 0m 0.12s
sys 0m 0.19s
github:
real 0m 0.37s
user 0m 0.09s
sys 0m 0.26s
original:
real 0m 0.81s
user 0m 0.21s
sys 0m 0.51s
EDIT: Oops again, posted test results before applying the DEVMAJOR fix to my version before.