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

[PATCH 0/3] reducing fsck memory usage

From
Jeff King <peff@peff.net>
Date
Sep 22, 2022, 10:09 UTC
Message-ID
<Yyw0PSVe3YTQGgRS@coredump.intra.peff.net>
In-Reply-To
<YyoljwDIn7PxRlC9@coredump.intra.peff.net>
On Tue, Sep 20, 2022 at 04:41:51PM -0400, Jeff King wrote:
Show 11 quoted lines
> And this is data we've allocated for trees. It kind of looks like
> fsck_walk_tree() never bothers to clean up the trees it parses, leaving
> the buffers attached to the tree structs. But that can't be the case,
> because linux.git has something like 16GB of trees. These may be entries
> we keep in the internal delta cache, though it should be a bit smaller
> than what you have here (the default is 96MB; you can drop it with
> core.deltaBaseCacheLimit, but runtime may suffer).
> 
> There's a call to free_tree_buffer() in builtin/fsck.c:traverse_one();
> that may be what ends up freeing things. It's been a while since I've
> traced through the call paths for fsck.

I dug into this a bit more. We do indeed free the trees correctly in most of the code paths, but there's one where we don't, and you can convince it to hold all of the trees in memory at once (though in practice few people are likely to hit this case).

So here's a fix for that, plus a cleaned up version of the patch I sent earlier which should drop your memory usage, plus a bonus small memory reduction and cleanup in the third patch.

  [1/3]: fsck: free tree buffers after walking unreachable objects
  [2/3]: fsck: turn off save_commit_buffer
  [3/3]: parse_object_buffer(): respect save_commit_buffer
 builtin/fsck.c | 6 +++---
 object.c       | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
-Peff
Previous: Jeff KingNext: Jeff King
Message 3 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.