Re: Slow git pack-refs --all
Show 18 quoted lines
> From: Jeff King <peff@peff.net>
> Sent: Thursday, December 25, 2025 9:45 PM
>
> On Thu, Dec 25, 2025 at 11:38:30PM +0000, brian m. carlson wrote:
>> I think this is from `should_pack_ref`:
>>
>> /* Do not pack broken refs: */
>> if (!ref_resolves_to_object(ref->name, refs->base.repo, ref->oid, ref->flags))
>> return 0;
>>
>> So Git is going to need to verify that the object at least exists. I
>> don't know why we would need to _open_ them, however. Perhaps someone
>> else has ideas.
>
>The packed-refs file stores tag-peeling information. So pack-refs opens
>the object for any newly written ref via peel_object(), which has to at
>least read the header to get the type. That call happens via
>write_with_updates() in packed-backend.c.
Thanks, this makes sense. However, since jgit needs to peel these objects also, it doesn't make sense to me that this would be the bottleneck unless git is doing something terribly inefficient here. :(
Except for the fact that repacking objects made it faster, my observations make it look like it's the writing that is actually slow, not the reads. Could there be too many small unbuffered writes, could this write path have missed being optimized (it likely isn't used elsewhere)?
-Martin