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

Re: [PATCH 1/7] cat-file: disable object/refname ambiguity check for batch mode

From
Jeff King <peff@peff.net>
Date
Jul 15, 2013, 04:23 UTC
Message-ID
<20130715042348.GB20900@sigill.intra.peff.net>
In-Reply-To
<51DFDAAF.60808@alum.mit.edu>
On Fri, Jul 12, 2013 at 12:30:07PM +0200, Michael Haggerty wrote:
Show 14 quoted lines
> But with particular respect to "git cat-file", I see problems:
> 
> 1. get_ref_snapshot() would have to read all loose and packed refs
> within the specified subtree, because loose refs have to be read before
> packed refs.  So the call would be expensive if there are a lot of loose
> refs.  And DWIM wouldn't know in advance where the references might be,
> so it would have to set prefix="".  If many refs are looked up, then it
> would presumably be worth it.  But if only a couple of lookups are done
> and there are a lot of loose refs, then using a cache would probably
> slow things down.
> 
> The slowdown could be ameliorated by adding some more intelligence, for
> example only populating the loose refs cache after a certain number of
> lookups have already been done.

I had assumed we would load the loose ref cache progressively by directory. Of course that only helps avoiding "refs/foo/*" when you are interested in "refs/heads/foo". If your "refs/heads/*" is very large, you have to load all of it, and at some point it is cheaper to do a few stat() calls than to actually readdir() the whole directory. On the other hand, that is basically how packed-refs work now (if we hit any ref, we have to load the whole file), and repos with many refs would typically pack them all anyway.

> 2. A "git cat-file --batch" process can be long-lived.  What guarantees
> would users expect regarding its lookup results?

I hadn't really intended this for general lookups, but just to speed up the refname warning, where being out-of-date is more acceptable (since the warning is a purely informational hint).

-Peff
Previous: Michael HaggertyNext: Junio C Hamano
Message 6 of 16 in “cat-file --batch-check performance improvements”
  1. 0/7 cat-file --batch-check performance improvementsJeff King, Jul 12, 2013
  2. 1/7 cat-file: disable object/refname ambiguity check for batch modeJeff King, Jul 12, 2013
  3. Michael HaggertyJul 12, 2013
  4. Jeff KingJul 12, 2013
  5. Michael HaggertyJul 12, 2013
  6. Jeff KingJul 15, 2013
  7. Junio C HamanoJul 15, 2013
  8. Jeff KingJul 15, 2013
  9. 2/7 sha1_object_info_extended: rename "status" to "type"Jeff King, Jul 12, 2013
  10. 3/7 sha1_loose_object_info: make type lookup optionalJeff King, Jul 12, 2013
  11. 4/7 packed_object_info: hoist delta type resolution to helperJeff King, Jul 12, 2013
  12. 5/7 packed_object_info: make type lookup optionalJeff King, Jul 12, 2013
  13. 6/7 sha1_object_info_extended: make type calculation optionalJeff King, Jul 12, 2013
  14. 7/7 sha1_object_info_extended: pass object_info to helpersJeff King, Jul 12, 2013
  15. Junio C HamanoJul 12, 2013
  16. Jeff KingJul 12, 2013

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.