git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] defer expensive load_ref_decorations until needed

From
Jeff King <peff@peff.net>
Date
Nov 22, 2017, 21:27 UTC
Message-ID
<20171122212710.GB2854@sigill>
In-Reply-To
<20171121234336.10209-1-phil.hord@gmail.com>
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
Previous: Phil HordNext: Phil Hord
Message 5 of 9 in “defer expensive load_ref_decorations until needed”
  1. defer expensive load_ref_decorations until neededPhil Hord, Nov 21, 2017
  2. Junio C HamanoNov 22, 2017
  3. Junio C HamanoNov 22, 2017
  4. Phil HordNov 22, 2017
  5. Jeff KingNov 22, 2017
  6. Phil HordNov 22, 2017
  7. Jeff KingNov 22, 2017
  8. Junio C HamanoNov 23, 2017
  9. Jeff KingNov 23, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.