Re: [PATCH 3/3] t5551: pack refs after creating many tags
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jun 30, 2026, 09:05 UTC
- Message-ID
- <akOG0oMu2KTqqyW7@pks.im>
- In-Reply-To
- <20260629203527.GA1895313@coredump.intra.peff.net>
On Mon, Jun 29, 2026 at 04:35:27PM -0400, Jeff King wrote:
Show 12 quoted lines
> There's one other thing you might find interesting. While poking at the > timings here the other day, I noticed that reftable is very eager to > stat the tables.list file. Try this: > > git init --ref-format=reftable > blob=$(echo foo | git hash-object -w --stdin) > seq -f "create refs/tags/foo-%g $blob" 2000 | > strace -c git update-ref --stdin > > We make 2000 fstat, which strace claims takes 85% of the time. I suspect > this is over-emphasized because strace inherently makes syscalls slow, > but running with perf also highlights it as a non-trivial cost.
Yeah, this rings a bell. If I remember correctly, this is because we call `refs_resolve_ref_unsafe()` to verify whether the target already exists. And as that function is generic, it wasn't easy to optimize it by reusing the already-loaded reftable stack.
> It has been a long time since I've thought about reftable internals, but > it feels like we ought to be able to take the lock and then trust that > the stack has not been manipulated.
Yeah, that would certainly be an option to explore.
> It may not be worth digging into too much, though. I can make 50,000 > refs in 150ms on my system, which is probably good enough (especially > compared to the files backend).
True, it's going to be much better compared to the "files" backend. But that isn't enough reason to not optimize it even further -- doubly so if it actually takes 85% of the time. Sounds like a low-hanging fruit to me that can result in a significant speedup.
I'll probably not get to it anytime soon, but I'll create an issue to keep track of it.
Patrick