Re: [PATCH 2/2] builtin/repo: don't fully parse trees
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Nov 16, 2026, 13:43 UTC
- Message-ID
- <0b4f65e1-bebc-4dcd-961d-42da1fe02a77@gmail.com>
- In-Reply-To
- <20261113-pks-repo-count-objects-speedup-v1-2-7ba4f29e74fb@pks.im>
On 11/13/2026 6:46 AM, Patrick Steinhardt wrote:
Show 11 quoted lines
> When the rev walk hits a tree object we read its content and then parse > it via `parse_object_buffer()`. This requires us to perform some extra > bookkeeping that is ultimately unnecessary as we keep those trees in > memory. > > The only thing that we need the tree object's content for is so that we > can count its entries. But that can easily be done without having a > parsed tree object, all we need is its content. > > Refactor the code accordingly, which gives us another significant > speedup when executing `git repo structure` in "git.git":
> Memory 3.4 GiB ± 0.0 GiB 3.4 GiB … 3.4 GiB > Memory 0.7 GiB ± 0.0 GiB 0.7 GiB … 0.7 GiB -80.4% (5.1x less)
This is an impressive memory reduction! Very nice.
(I'd comment on v2, but my email host must have bounced those.0
Thanks, -Stolee