Why is find so slow (Re: Why use find?)

Dan Mercer mercer at npdiss1.StPaul.NCR.COM
Tue Oct 16 05:17:40 AEST 1990


In article <26919 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
:In article <F6.rhxm2 at cs.psu.edu> flee at guardian.cs.psu.edu (Felix Lee) writes:
:>"descend" is fast because it recognizes leaf directories and avoids
:>stat()ing the files in that directory.  This is usually a big win,
:>since most files tend to be in leaf directories.
:>
:>"find" can't do this in general, since most of its predicates require
:>stat()ing each file, but it wouldn't be too hard to add lazy stat()ing
:>to find.  And it may even be worth it.
:
:Quite likely.
:
:4.3BSD-reno's `find' reimplementation (a redistributable version) uses
:the C library `fts' routines (from POSIX) which take flags indicating
:whether `stat's are desired.  If you say `no', it stats only when this
:is required to search the directory.  The new find sets the `I need
:stat information' only when at least one predicate requires it.  The
:result:

Maybe I'm dense,  but how does find know whether a file is a directory
(and should be descended) or another type of file without stat()ing the
file?



-- 

Dan Mercer
Reply-To: mercer at npdiss1.StPaul.NCR.COM (Dan Mercer)
"MAN - the only one word oxymoron in the English Language"



More information about the Comp.unix.internals mailing list