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

Re: [PATCH] fsck: snapshot default refs before object walk

From
Jeff King <peff@peff.net>
Date
Jan 14, 2026, 22:23 UTC
Message-ID
<20260114222351.GA1014423@coredump.intra.peff.net>
In-Reply-To
<CABPp-BGqiM8fmirgdqumRNfzWediC5v_uZ9qHjntTqPqABDhnA@mail.gmail.com>
On Tue, Jan 06, 2026 at 03:36:57PM -0800, Elijah Newren wrote:
Show 11 quoted lines
> >   Side note: I do not think I have ever run fsck with refs on the
> >   command-line. It is not like it saves you any time! Most of the
> >   expense comes from opening up and verifying the objects in the first
> >   step, not from looking at ref reachability.
> 
> Not to mention it produces spurious "dangling" object warnings,
> because while the objects might be reachable, they aren't necessarily
> reachable from the particular subset you specified on the command
> line.  I wonder if no one ever noticed that because it's such a
> useless mode; I only noticed it because you pointed out how Matthew
> and I overlooked races with command-line arguments.

Yep. It would be nice to get rid of it, but of course I worry about missing some obscure use case that somebody relies on. Anyway, way out of scope for this patch.

Show 10 quoted lines
> > That did make me wonder a bit about the other fields in "struct
> > reference" (which your snapshot just throws away). But it looks like
> > fsck_handle_ref() only cares about the name and oid, so it is OK.
> 
> Junio suggested the same thing, although he also suggested we might
> want to snapshot some reflog information at the same time, which then
> wouldn't make sense to be using a struct reference.  Even though I'm
> not implementing per-reflog snapshotting, I left a comment in the code
> about it so I think it made sense to just create my own data structure
> with just the name and oid.

I do wonder how expensive it would be to just snapshot all of the reflogs. It is a shame, because 99% of the time entry N will be reachable from N+1 (and thus does not need to be stored), but we don't know that until we traverse.

So we are potentially storing the oid of every reachable object in the repository in memory as a snapshot. But...isn't that exactly what we'll do anyway when we traverse, in the form of "struct object"?

Anyway, I can live with your timestamp-based hack for snapshotting the reflogs.

Show 14 quoted lines
> > There are a few other related interesting cases, too:
> >
> >   - We may use the index file for connectivity, as well. It suffers from
> >     the same race, and would benefit from a snapshot.
> 
> I left a couple TODO comments about this, so that those who are
> interested/motivated can extend the snapshotting further.
> 
> >   - In get_default_heads() we also look at worktree HEADs. Those have
> >     the same race (their normal refs we don't consider here, because
> >     they were already handled by the overall ref iteration).
> 
> I handled these in my newer version, since handling them is pretty
> similar to handling command line arguments.

Both sound like reasonable directions to me. I'll take a look at your latest version.

-Peff
Previous: Elijah NewrenNext: Elijah Newren via GitGitGadget
Message 7 of 11 in “fsck: snapshot default refs before object walk”
  1. fsck: snapshot default refs before object walkElijah Newren via GitGitGadget, Dec 29, 2025
  2. Junio C HamanoDec 30, 2025
  3. Elijah NewrenJan 6, 2026
  4. Matthew John CheethamJan 9, 2026
  5. Jeff KingJan 2, 2026
  6. Elijah NewrenJan 6, 2026
  7. Jeff KingJan 14, 2026
  8. fsck: snapshot default refs before object walkElijah Newren via GitGitGadget, Jan 7, 2026
  9. fsck: snapshot default refs before object walkElijah Newren via GitGitGadget, Jan 9, 2026
  10. Junio C HamanoJan 11, 2026
  11. Jeff KingJan 14, 2026

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.