Re: [PATCH] check_refname_component: Optimize
- From
Jeff King <peff@peff.net>
- Date
- May 29, 2014, 23:41 UTC
- Message-ID
- <20140529234109.GA28683@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8BS_YhMB9ZZRx4faj=_YWZQrqm7B9AHkTGye=okja=m-Q@mail.gmail.com>
On Fri, May 30, 2014 at 06:24:30AM +0700, Duy Nguyen wrote:
Show 13 quoted lines
> >> I wonder if we can get away without SSE code by saving stat info of > >> the packed-refs version that we have verified. When we read pack-refs, > >> if stat info matches, skip check_refname_component(). Assuming that > >> pack-refs does not change often, of course. > > > > Can you elaborate a bit more? > > The first time we read packed_refs, check_refname_format() is called > in read_packed_refs()->create_ref_entry() as usual. If we find no > problem, we store packed_refs stat() info in maybe packed_refs.stat. > Next time we read packed_refs, if packed_refs.stat is there and > indicates that packed_refs has not changed, we can make > create_ref_entry() ignore check_refname_format() completely.
I'm confused. Why would we re-open packed-refs at all if the stat information hasn't changed?
read_packed_refs is only called from get_packed_ref_cache, and we only do so if !refs->packed. And refs->packed is only NULL if we haven't read the file yet, or it is stat-dirty.
If that is working as intended, then we should generally only open and read packed-refs once per invocation of git.
-Peff