From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Subject: [PATCH] setlocalversion: Add workaround for "git describe" performance issue
Date: Wed, 30 Oct 2024 18:20:21 -0700 [thread overview]
Message-ID: <309549cafdcfe50c4fceac3263220cc3d8b109b2.1730337435.git.jpoimboe@kernel.org> (raw)
If HEAD isn't associated with an annotated tag, a bug (or feature?) in
"git describe --match" causes it to search every commit in the entire
repository looking for additional match candidates. Instead of it
taking a fraction of a second, it adds 10-15 seconds to the beginning of
every kernel build.
Fix it by adding an additional dummy match which is slightly further
away from the most recent one, along with setting the max candidate
count to 1 (not 2, apparently another bug).
Before:
$ git checkout c1e939a21eb1
$ time make kernel/fork.o -s
real 0m12.403s
user 0m11.591s
sys 0m0.967s
After:
$ time make kernel/fork.o -s
real 0m1.119s
user 0m0.658s
sys 0m0.659s
Link: https://lore.kernel.org/git/20241030044322.b5n3ji2n6gaeo5u6@treble.attlocal.net/
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
scripts/setlocalversion | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 38b96c6797f4..bb8c0bcb7368 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -57,6 +57,8 @@ scm_version()
return
fi
+ githack=" --match=v6.11 --candidates=1"
+
# mainline kernel: 6.2.0-rc5 -> v6.2-rc5
# stable kernel: 6.1.7 -> v6.1.7
version_tag=v$(echo "${KERNELVERSION}" | sed -E 's/^([0-9]+\.[0-9]+)\.0(.*)$/\1\2/')
@@ -67,7 +69,7 @@ scm_version()
tag=${file_localversion#-}
desc=
if [ -n "${tag}" ]; then
- desc=$(git describe --match=$tag 2>/dev/null)
+ desc=$(git describe --match=$tag $githack 2>/dev/null)
fi
# Otherwise, if a localversion* file exists, and the tag
@@ -76,13 +78,13 @@ scm_version()
# it. This is e.g. the case in linux-rt.
if [ -z "${desc}" ] && [ -n "${file_localversion}" ]; then
tag="${version_tag}${file_localversion}"
- desc=$(git describe --match=$tag 2>/dev/null)
+ desc=$(git describe --match=$tag $githack 2>/dev/null)
fi
# Otherwise, default to the annotated tag derived from KERNELVERSION.
if [ -z "${desc}" ]; then
tag="${version_tag}"
- desc=$(git describe --match=$tag 2>/dev/null)
+ desc=$(git describe --match=$tag $githack 2>/dev/null)
fi
# If we are at the tagged commit, we ignore it because the version is
--
2.47.0
next reply other threads:[~2024-10-31 1:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-31 1:20 Josh Poimboeuf [this message]
2024-10-31 10:37 ` Rasmus Villemoes
2024-10-31 11:42 ` Jeff King
2024-10-31 12:24 ` Jeff King
2024-10-31 14:43 ` Jeff King
2024-11-04 12:37 ` Benno Evers
2024-11-01 10:23 ` Rasmus Villemoes
2024-11-01 11:39 ` Jeff King
2024-10-31 11:43 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=309549cafdcfe50c4fceac3263220cc3d8b109b2.1730337435.git.jpoimboe@kernel.org \
--to=jpoimboe@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®