bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does -inum require stat(2)?


From: James Youngman
Subject: Re: Why does -inum require stat(2)?
Date: Sun, 21 Sep 2008 21:40:11 +0100

On Sat, Sep 20, 2008 at 10:36 PM, George Spelvin <address@hidden> wrote:
> Looking for an inode that fsck complained about, I did a find,
> and noticed that it was statting every file name it found.
>
> Hunting through the code, I see that, in tree.c, pred_inum is marked
> NeedsStatInfo.  Is there a reason that struct dirent's d_ino field
> can't be used instead?  That would drastically reduce the cost of this
> predicate.
>
> (This would also benefit pred_samefile.)

Based on what you write I would assume that this is true for both the
find and the oldfind executables buily in all even vaguely-recent
findutils releases.

But in the case where the file we're currently considering is a
non-directory, it can't also be a mount point.   Therefore where d_ino
is available we should be able to trust it (famous last words :).
Using stat only for directories is essentially zero cost, since we
need to stat them as part of the traversal operations.

So I guess this is a performance issue we can likely fix.   Could you
add it as a findutils bug at savannah.gnu.org so that we don't forget
it?

(In practice changing find in this way may not fix the problem for the
version of find that uses fts, so we may not get the full benefit of
the fix, but I think changing this would at least be progress).

Thanks for spotting the problem!

James.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]