git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] "git describe --match" performance

From
JPJosh Poimboeuf <jpoimboe@kernel.org>
Date
Oct 30, 2024, 04:43 UTC
Message-ID
<20241030044322.b5n3ji2n6gaeo5u6@treble.attlocal.net>
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
> 
> What did you do before the bug happened? (Steps to reproduce your issue)

$ git clone https://github.com/torvalds/linux $ cd linux $ git checkout c61e41121036

$ time git describe --match=v6.10-rc7 --debug
describe HEAD
No exact match on refs or tags, searching to describe
finished search at d8470b7c13e11c18cf14a7e3180f0b00e715e4f0
 annotated       1844 v6.10-rc7
traversed 1282750 commits
v6.10-rc7-1844-gc61e41121036

real 0m9.243s user 0m8.940s sys 0m0.268s

$ time git describe v6.10-rc7-1844-gc61e41121036

real 0m0.149s user 0m0.111s sys 0m0.036s

> What did you expect to happen? (Expected behavior)

I expected "git describe --match=v6.10-rc7" to be faster than plain "git describe".

> What happened instead? (Actual behavior)
It takes over 9 seconds and traverses 1282750 commits.

(In my actual Linux git repo it's even worse at 15 seconds due to more git history.)

> What's different between what you expected and what actually happened?
Over 9 seconds :-)
> Anything else you want to add:
I see this with both version 2.47.0 and the next branch.

This command is used by the kernel setlocalversion script, which is run for every kernel build, so it adds 10-15 seconds to every build on an untagged commit.

I suspect the problem is that there's only a single match for "v6.10-rc7", but it tries to find 10 candidates so it ends up searching the entire history. But "--candidates=1" doesn't seem to help unless I add a second match like so:

$ time git describe --match=v6.10-rc7 --match=v6.10-rc6 --candidates=1 v6.10-rc7-1844-gc61e41121036

real 0m0.112s user 0m0.081s sys 0m0.031s

> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.
[System Info]
git version:
git version 2.47.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.6.0
OpenSSL: OpenSSL 3.2.2 4 Jun 2024
zlib: 1.3.1.zlib-ng
uname: Linux 6.10.12-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Sep 30 21:38:25 UTC 2024 x86_64
compiler info: gnuc: 14.2
libc info: glibc: 2.39
$SHELL (typically, interactive shell): /bin/bash
[Enabled Hooks]
-- 
Josh
Next: Jeff King
Message 1 of 10 in “[BUG] "git describe --match" performance”
  1. Josh PoimboeufOct 30, 2024
  2. Jeff KingOct 31, 2024
  3. Josh PoimboeufOct 31, 2024
  4. Jeff KingOct 31, 2024
  5. Josh PoimboeufOct 31, 2024
  6. Jeff KingOct 31, 2024
  7. Taylor BlauOct 31, 2024
  8. Kristoffer HaugsbakkOct 31, 2024
  9. Jeff KingOct 31, 2024
  10. Taylor BlauOct 31, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.