{"thread":{"id":"63689","subject":"Possible performance regression in for-each-ref in git 2.40.0","startedAt":"2025-06-25T11:56:31Z","lastAt":"2025-06-25T13:17:39Z","messageCount":2,"participants":["Andrzej Dębski","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"520681","messageId":"CAHKcSH2_Xse3o5Cq88Fu2s26AAJGNJMGeSvgHAyp-RLruVPnJQ@mail.gmail.com","threadId":"63689","inReplyTo":null,"subject":"Possible performance regression in for-each-ref in git 2.40.0","fromName":"Andrzej Dębski","fromEmail":"adebski@dropbox.com","sentAt":"2025-06-25T11:28:09Z","receivedAt":"2025-06-25T11:56:31Z","isPatch":false,"sender":{"key":"adebski@dropbox.com","avatar":null},"body":"One of Dropbox SWEs observed that a specific git command in Go\nlanguage tooling\nhttps://github.com/golang/go/blob/e515ef8bc271f632bb2ebb94e8e700ab67274268/src/cmd/go/internal/modfetch/codehost/git.go#L758\ntook over 20 seconds. Internally we distribute git 2.46.0 right now\nbut the SWE had an older version of git around (2.39.5) and observed a\nperformance regression between those 2 versions.\n\nWe've did some performance measurements and the command like \"git\nfor-each-ref --format=\"%(refname)\" refs/tags --merged HEAD >\n/dev/null\"\nspent majority of time in function \"tips_reachable_from_bases\"\nintroduced in git 2.40.0:\nhttps://github.com/git/git/commit/cbfe360b140fe92d9c4a763bf630c3b8ba431522\n\nSimilar performance degradation can be observed in git 2.50\n\nGiven that the command references tags I've experimented and observed\nthat the command execution time decreased with the amount of tags I've\nremoved from the local copy of the repo.\n\nContext: in Dropbox we operate a large monorepo with around 65K tags\nright now and growing every day.\n\nThe question is, given the same command used to be much faster in\nolder versions of git is this considered a regression and can be fixed\nin future releases of git?\n\n\n[System Info]\ngit version: 2.46.0\ncpu: bazel\nbuilt from commit: bazel\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nlibcurl: 7.82.0\nOpenSSL: OpenSSL 1.1.1w  11 Sep 2023\nzlib: 1.2.13\nuname: Linux 6.8.0-1029-aws #31~22.04.1-Ubuntu SMP Thu Apr 24 21:16:18\nUTC 2025 x86_64\ncompiler info: gnuc: 11.2\nlibc info: glibc: 2.35\n$SHELL (typically, interactive shell): /bin/bash\n"},{"id":"520696","messageId":"c0170328-764b-4d31-a66d-5ac56ff87be7@app.fastmail.com","threadId":"63689","inReplyTo":"CAHKcSH2_Xse3o5Cq88Fu2s26AAJGNJMGeSvgHAyp-RLruVPnJQ@mail.gmail.com","subject":"Re: Possible performance regression in for-each-ref in git 2.40.0","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-06-25T13:17:18Z","receivedAt":"2025-06-25T13:17:39Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Jun 25, 2025, at 13:28, Andrzej Dębski wrote:\n> One of Dropbox SWEs observed that a specific git command in Go\n> language tooling\n> https://github.com/golang/go/blob/e515ef8bc271f632bb2ebb94e8e700ab67274268/src/cmd/go/internal/modfetch/codehost/git.go#L758\n> took over 20 seconds. Internally we distribute git 2.46.0 right now\n> but the SWE had an older version of git around (2.39.5) and observed a\n> performance regression between those 2 versions.\n>\n> We've did some performance measurements and the command like \"git\n> for-each-ref --format=\"%(refname)\" refs/tags --merged HEAD >\n> /dev/null\"\n> spent majority of time in function \"tips_reachable_from_bases\"\n> introduced in git 2.40.0:\n> https://github.com/git/git/commit/cbfe360b140fe92d9c4a763bf630c3b8ba431522\n>\n> Similar performance degradation can be observed in git 2.50\n>\n> Given that the command references tags I've experimented and observed\n> that the command execution time decreased with the amount of tags I've\n> removed from the local copy of the repo.\n>\n> Context: in Dropbox we operate a large monorepo with around 65K tags\n> right now and growing every day.\n>\n> The question is, given the same command used to be much faster in\n> older versions of git is this considered a regression and can be fixed\n> in future releases of git?\n>\n>\n> [System Info]\n> git version: 2.46.0\n> cpu: bazel\n> built from commit: bazel\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> libcurl: 7.82.0\n> OpenSSL: OpenSSL 1.1.1w  11 Sep 2023\n> zlib: 1.2.13\n> uname: Linux 6.8.0-1029-aws #31~22.04.1-Ubuntu SMP Thu Apr 24 21:16:18\n> UTC 2025 x86_64\n> compiler info: gnuc: 11.2\n> libc info: glibc: 2.35\n> $SHELL (typically, interactive shell): /bin/bash\n\n+CC author.\n\n-- \nKristoffer Haugsbakk\n"}]}