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

Re: [PATCH 1/3] fsck: free tree buffers after walking unreachable objects

From
Jeff King <peff@peff.net>
Date
Sep 22, 2022, 22:16 UTC
Message-ID
<YyzerG/hXFCsI7Lt@coredump.intra.peff.net>
In-Reply-To
<xmqq5yhfyztm.fsf@gitster.g>
On Thu, Sep 22, 2022 at 12:27:33PM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> > As a side note, IMHO having tree->buffer at all is a mistake, because it
> > leads to exactly this kind of confusion about when the buffer should be
> > discarded. We'd be better off having all callers parse directly into a
> > local buffer, and then clean up when they're done.
> 
> Yeah, tree-walk.c users woud use tree_desc structure anyway, and
> instead of having a moving pointer that points into a separate thing
> (i.e. tree->buffer), it could have its own copy of the "whole buffer"
> that can be used to free when it is done iterating over entries.
> 
> > .... But that's obviously a much bigger change.
> 
> Yup.

I took a (very) brief stab at this, out of curiosity. The sticking point becomes obvious very quickly: how do we get the buffer to the caller? If you are calling parse_tree(), we can add new out-parameters to provide the buffer. But something like parse_object() is just returning an object struct, and we have to stuff anything we want to communicate to the caller inside the polymorphic struct which contains it.

We could split the concept of "parse" away from "get the buffer" entirely, but then we have a potential slowdown. The "parse" functions really want to open the object contents and check the hash (and removing that in the general case would probably break part of fsck, at least). So we'd end up inflating the object contents twice, which would probably have a measurable impact.

I don't plan on digging any further on it for now, so this is just a note for future people who do. :)

-Peff
Previous: Junio C HamanoNext: Jeff King
Message 8 of 10 in “[INVESTIGATION] why is fsck --connectivity-only so much more expensive than rev-list --objects --all?”
  1. John CaiSep 20, 2022
  2. Jeff KingSep 20, 2022
  3. 0/3 reducing fsck memory usageJeff King, Sep 22, 2022
  4. 1/3 fsck: free tree buffers after walking unreachable objectsJeff King, Sep 22, 2022
  5. Junio C HamanoSep 22, 2022
  6. Jeff KingSep 22, 2022
  7. Junio C HamanoSep 22, 2022
  8. Jeff KingSep 22, 2022
  9. 2/3 fsck: turn off save_commit_bufferJeff King, Sep 22, 2022
  10. 3/3 parse_object_buffer(): respect save_commit_bufferJeff King, Sep 22, 2022

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.