# git repo structure gets a lower memory footprint by parsing fewer objects

_Patrick Steinhardt hit an out-of-memory failure on a very large repository and sent two patches that reduce memory use and speed up the command._

Section: Patches. Edition of 2026-11-14. Written by an AI editor from the thread "[PATCH 0/2] builtin/repo: improve counting of objects" (15 messages): https://gitlist.dev/t/66845

Patrick Steinhardt said he ran git repo structure on a very large repository and hit an out-of-memory failure. He found ways to cut the memory footprint and speed the command up. The command still does not produce results on that repository, because walking 33 billion tree entries takes a long time and, in his words, everything rev-list based that walks trees is kind of broken there. He left that for another day.

The first patch changes the command to parse only what it needs. It previously read and parsed every object's content, but only commits (for parent counts) and trees (for entry counts) need parsing, so work on blobs and tags was wasted. Commits reached through the rev walk are already parsed, so those need not be re-read.

The second patch stops fully parsing trees. The command reads a tree's content only to count its entries, so it no longer calls parse_object_buffer(), which does bookkeeping that is not needed when the trees are kept in memory. Patrick's benchmark in git.git shows wall time around 9.6 seconds after the change.

Kristofer Karlsson called it a nice memory reduction and said both patches looked good to him. He had done something similar for the incremental connectivity check, where the tree verifier reads raw tree buffers for the same memory reasons. He suggested rewording a comment about commits: he read it as meaning the code depends on commits being parsed already, whereas repo_parse_commit() handles unparsed ones, so he proposed saying commits should already have been parsed by the revision walk. Otherwise he had no objections.
