Re: [PATCH 3/3] Avoid doing extra 'lstat()'s for d_type if we have an up-to-date cache entry
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 9, 2009, 18:34 UTC
- Message-ID
- <7vbpnt3dth.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <alpine.LFD.2.01.0907090954090.3352@localhost.localdomain>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 13 quoted lines
>> > + if (!ce_uptodate(ce)) >> > + break; /* continue? */ >> >> I think this should be continue, as the directory D you are interested in >> may have two files, one modified, the other uptodate. > > The thing is, the directory may have subdirectories, and there may be > tens of thousands of files there. And maybe this gets called by code that > hasn't done any cache preloading at all, so nothing will be up-to-date. > > Do we want to loop over thousands of entries? Or do we want to loop as > little as possible, and just say "most of the time the first entry will be > representative".
Ah, I see.
It depends on how expensive it is to iterate over an in-core array to check a single bit (that may not even have been updated) in the cache entries, compared to an extra lstat(). Perhaps we could autotune that, but it probably is not worth it. ;-)