builtin/remote: rework how remote refs get renamed
Hi,
this patch series is the result from the discussion at 1. On the one
hand this series fixes the reported bug where dangling symrefs are not
renamed via git remote rename
.
On the other hand this series reworks the logic used to rename remotes so that we use two transactions instead of one transaction per ref. This fixes quadratic runtime behaviour, where renaming 10k refs takes ~4 minutes, 100k takes hours. This results in a significant speedup with both the "files" backend (benchmarked with a smaller number of refs to retain sanity):
Benchmark 1: rename remote (refformat = files, refcount = 10000, revision = HEAD~)
Time (mean ± σ): 239.880 s ± 7.789 s [User: 91.223 s, System: 144.874 s]
Range (min … max): 226.739 s … 250.443 s 10 runs
Benchmark 2: rename remote (refformat = files, refcount = 10000, revision = HEAD)
Time (mean ± σ): 1.258 s ± 0.134 s [User: 0.246 s, System: 0.994 s]
Range (min … max): 0.943 s … 1.353 s 10 runs
Summary
rename remote (refformat = files, refcount = 10000, revision = HEAD) ran
190.64 ± 21.20 times faster than rename remote (refformat = files, refcount = 10000, revision = HEAD~)
For the "reftable" backend we see a significant speedup, as well, but not as extreme as with the "files" backend:
Benchmark 1: rename remote (refformat = reftable, refcount = 10000, revision = HEAD~)
Time (mean ± σ): 8.965 s ± 0.602 s [User: 5.191 s, System: 2.464 s]
Range (min … max): 8.036 s … 9.748 s 10 runs
Benchmark 2: rename remote (refformat = reftable, refcount = 10000, revision = HEAD)
Time (mean ± σ): 255.1 ms ± 0.9 ms [User: 240.3 ms, System: 12.3 ms]
Range (min … max): 253.7 ms … 256.5 ms 11 runs
Summary
rename remote (refformat = reftable, refcount = 10000, revision = HEAD) ran
35.14 ± 2.36 times faster than rename remote (refformat = reftable, refcount = 10000, revision = HEAD~)
But in any case, it's one more case where the "reftable" backend outperforms the "files" backend.
The series is built on top of 97e14d99 (The thirteenth batch, 2025-07-23) with version 2 of ps/reflog-migrate-fixes merged into it. I don't provide a commit ID for that version here as I only sent that series to the mailing list a couple hours ago.
I'd normally have withheld sending until that series was merged to "next", but given that I promised to send something today I decided to just get it out. In any case, if that causes problems I'm happy to wait a bit before this series here gets merged into "seen".
Thanks!
Patrick
To: git@vger.kernel.org Cc: Junio C Hamano gitster@pobox.com Cc: Jeff King peff@peff.net Cc: Han Jiang jhcarl0814@gmail.com
--- b4-submit-tracking ---
This section is used internally by b4 prep for tracking purposes.
{ "series": { "revision": 1, "change-id": "20250725-pks-remote-rename-improvements-85ce262146e0", "prefixes": [] } }
Closes Renaming remotes is inefficient and may cause p... (#577 - closed).