On Tue, Nov 21, 2017 at 03:43:36PM -0800, Phil Hord wrote: > With many thousands of references, a simple `git rev-parse HEAD` may take > more than a second to return because it first loads all the refs into > memory even though it will never use them. The overall goal of lazy-loading seems reasonable, but I'm slightly confused: how and why does "git rev-parse HEAD" load ref decorations? Grepping around I find that we mostly load them only when appropriate (when the "log" family sees a decorate option, when we see %d/%D in a pretty format, or with --simplify-by-decoration in a traversal). And poking at "rev-parse HEAD" in gdb seems to confirm that it does not hit that function. I have definitely seen "rev-parse HEAD" be O(# of refs), but that is mostly attributable to having all the refs packed (and until v2.15.0, the packed-refs code would read the whole file into memory). I've also seen unnecessary ref lookups due to replace refs (we load al of the packed refs to find out that no, there's nothing in refs/replace). -Peff