find vs ls performance for walking folders, are there any faster options?
Olav Grønås Gjerde
olavgg at gmail.com
Wed Dec 12 14:20:01 UTC 2012
I'm working on scanning filesystems to build a file search engine and
came over something interesting.
I can walk through 300 000 folders in ~19.5seconds with this command:
ls -Ra | grep -e "./.*:" | sed "s/://"
With find, it surprisingly takes ~50.5 seconds.:
find . -type d
My results are based on five runs of each command to warm up the disk cache.
I've tried both this with both UFS and ZFS, and both filesystems shows
the same speed difference.
On a modern Linux distribution(Ubuntu 12.10 with EXT4), ls is just
slight faster than find(about 15-20%).
Are there a faster way to walk folders on FreeBSD? Are there some
options(sysctl) I could tune to improve the performance?
More information about the freebsd-performance