Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Dec 2012 15:19:58 +0100
From:      =?ISO-8859-1?Q?Olav_Gr=F8n=E5s_Gjerde?= <olavgg@gmail.com>
To:        freebsd-performance@freebsd.org, freebsd-fs@freebsd.org
Subject:   find vs ls performance for walking folders, are there any faster options?
Message-ID:  <CALL7tK9uRz2qLDqHKOqKLrM7oPc4UvYj0s6zxh6VNFQLYoyPTQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALL7tK9uRz2qLDqHKOqKLrM7oPc4UvYj0s6zxh6VNFQLYoyPTQ>