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

Re: topological index field for commit objects

From
Jeff King <peff@peff.net>
Date
Jul 1, 2016, 06:54 UTC
Message-ID
<20160701065452.GE5358@sigill.intra.peff.net>
In-Reply-To
<5774F4C7.805@gmail.com>
On Thu, Jun 30, 2016 at 12:30:31PM +0200, Jakub Narębski wrote:
Show 12 quoted lines
> > This is one of the open questions. My older patches turned them off when
> > replacements and grafts are in effect.
> 
> Well, if you store the cache of generation numbers in the packfile, or in
> the index of the packfile, or in the bitmap file, or in separate bitmap-like
> file, generating them on repack, then of course any grafts or replacements
> invalidate them... though for low level commands (like object counting)
> replacements are transparent -- or rather they are (and can be) treated as
> any other ref for reachability analysis.
> 
> Well, if there are no grafts, you could still use them for doing
> "git --no-replace-objects log ...", isn't it?

Yes, replace refs don't invalidate the concept of a cache. It just means that you invalidate the invariants of the cache for a specific view, so you need a cache which matches that view.

It has been several years, but I remember at one point having patches that summarized the graft/replace state as a single hash, and only used the cache if it matched that state. So you could actually keep a cache for some set of replace-refs that you have, as well as a cache for the case that you've turned them off, etc.

I don't think that level of complexity is really worth it, though.
Show 5 quoted lines
> >>> I have patches that generate and store the numbers at pack time, similar
> >>> to the way we do the reachability bitmaps.
> 
> Ah, so those cached generation numbers are generated and stored at pack
> time. Where you store them: is it a separate file? Bitmap file? Packfile?

There were a few iterations of the concept over the years, but the pack-time one uses a separate file with the same name prefix as a pack (similar to the way bitmaps are stored). The big advantage there is that we can piggy-back on the pack .idx to avoid having to write each sha1 again (20 bytes per commit, whereas the actual data we're caching is only 4 bytes).

Show 8 quoted lines
> > At GitHub we are using them for --contains analysis, along with mass
> > ahead/behind (e.g., as in https://github.com/gitster/git/branches). My
> > plan is to send patches upstream, but they need some cleanup first.
> 
> That would be nice to have, please.
> 
> Er, is mass ahead/behind something that can be plugged into Git
> (e.g. for "git branch -v -v"), or is it something GitHub-specific?

We have a custom command, "git ahead-behind", where you can specify arbitrary pairs of commits on stdin. But it's all backed by a function which, yes, could be plugged into "branch -v -v". It caches any bitmaps it needs, so if you are doing 100 ahead/behind comparisons against "master", for example, it only has to find the bitmap for "master" once (remember that we sometimes have to traverse to complete a bitmap when a branch has been updated since the last repack).

-Peff
Previous: Junio C HamanoNext: Jakub Narębski
Message 20 of 31 in “topological index field for commit objects”
  1. Marc StrapetzJun 29, 2016
  2. Junio C HamanoJun 29, 2016
  3. Stefan BellerJun 29, 2016
  4. Junio C HamanoJun 29, 2016
  5. Jeff KingJun 29, 2016
  6. Jakub NarębskiJun 29, 2016
  7. Jeff KingJun 29, 2016
  8. Junio C HamanoJun 29, 2016
  9. Jeff KingJun 29, 2016
  10. Johannes SchindelinJul 5, 2016
  11. Jakub NarębskiJul 5, 2016
  12. Jakub NarębskiJun 30, 2016
  13. Linus TorvaldsJun 30, 2016
  14. Jakub NarębskiJun 30, 2016
  15. Mike HommeyJun 30, 2016
  16. Jeff KingJul 1, 2016
  17. Marc StrapetzJul 1, 2016
  18. Jakub NarębskiJul 1, 2016
  19. Junio C HamanoJul 1, 2016
  20. Jeff KingJul 1, 2016
  21. Jakub NarębskiJul 1, 2016
  22. Jakub NarębskiJul 20, 2016
  23. Jeff KingJul 20, 2016
  24. Jakub NarębskiFeb 4, 2017
  25. Jeff KingFeb 17, 2017
  26. Jakub NarębskiFeb 17, 2017
  27. Stefan BellerJun 29, 2016
  28. Stefan BellerJun 29, 2016
  29. Jeff KingJun 29, 2016
  30. Marc StrapetzJun 29, 2016
  31. Jakub NarębskiJun 29, 2016

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.