From: Junio C Hamano Date: Thu, 09 Jul 2009 18:34:50 GMT Subject: Re: [PATCH 3/3] Avoid doing extra 'lstat()'s for d_type if we have an up-to-date cache entry Message-ID: <7vbpnt3dth.fsf@alter.siamese.dyndns.org> In-Reply-To: Linus Torvalds writes: >> > + 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. ;-)