Eric Blake wrote:

According to Christian Franke on 11/27/2008 2:41 PM:
PS: find is not as smart as expected: 'find /path -type d' calls lstat()
for each entry, even if d_type != DT_UNKNOWN.
So 'find /path' is 2-3 times faster than 'find /path -type d'.

This seems like it might be a bug in gnulib's fts implementation.  How
does 'oldfind /path -type d' perform?  oldfind has the advantage of not
using fts, so if it performs better, then there is a hole where we need to
improve gnulib's fts to make directory-only or non-directory-only
traversals use d_type for optimization.


Performance of 'oldfind /path -type d' is actually similar to 'oldfind /path':

$ export TIMEFORMAT='%1R'

$ time find /cygdrive/c/cygwin >/dev/null
29.6

$ time find /cygdrive/c/cygwin -type d >/dev/null
29.5

$ time find-with-d_type /cygdrive/c/cygwin >/dev/null
10.4

$ time find-with-d_type /cygdrive/c/cygwin -type d >/dev/null
29.4


$ time oldfind /cygdrive/c/cygwin  >/dev/null
33.1

$ time oldfind /cygdrive/c/cygwin -type d >/dev/null
32.9

$ time oldfind-with-d_type /cygdrive/c/cygwin  >/dev/null
12.0

$ time oldfind-with-d_type /cygdrive/c/cygwin -type d >/dev/null
12.1


Christian



Reply via email to