Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756300Ab2J3IqL (ORCPT ); Tue, 30 Oct 2012 04:46:11 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:55175 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753462Ab2J3IqG (ORCPT ); Tue, 30 Oct 2012 04:46:06 -0400 Date: Tue, 30 Oct 2012 09:46:00 +0100 From: Ingo Molnar To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Andrew Vagin , Borislav Petkov , David Howells , Frederic Weisbecker , Jiri Olsa , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Stephane Eranian , Steven Rostedt Subject: [PATCH] perf tools: Speed up the perf build time by simplifying the perf --version string generation Message-ID: <20121030084600.GB8245@gmail.com> References: <1351261913-28250-1-git-send-email-acme@infradead.org> <20121026145451.GA14379@gmail.com> <20121026170503.GC20695@ghostprotocols.net> <20121027131935.GA30001@gmail.com> <20121030081807.GA8245@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121030081807.GA8245@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2842 Lines: 75 * Ingo Molnar wrote: > Btw., there's another thing that would be nice in addition to > simplifying the PERF-VERSION-GEN script: [...] Here's a stab at that. -----------------> Building perf is pretty slow on trees that have a lot of commits relative to the nearest Git tag. This slowness manifests itself during version string generation: $ perf stat --null --repeat 3 --sync --pre "rm -f PERF-VERSION-FILE" util/PERF-VERSION-GEN PERF_VERSION = 3.7.rc3.1458.g5399b3b PERF_VERSION = 3.7.rc3.1458.g5399b3b PERF_VERSION = 3.7.rc3.1458.g5399b3b Performance counter stats for 'util/PERF-VERSION-GEN' (3 runs): 2.857503976 seconds time elapsed ( +- 0.22% ) The build can be even slower than that, when one over NFS volumes. The reason for the slowness is that util/PERF-VERSION-GEN uses "git describe" to generate the string, which has to count the "number of commits distance" from the nearest tag - the ".1458." count in the output above. For that Git had to extract and decompress 1458 Git objects, which takes time and bandwidth. But this "number of commits" value is mostly irrelevant in practice. We either want to know an approximate tag name, or we want to know the precise sha1. So this patch simplifies the version string to: PERF_VERSION = 3.7.rc3.g5399b3b.dirty which speeds up the version string generation script by an order of magnitude: $ perf stat --null --repeat 3 --sync --pre "rm -f PERF-VERSION-FILE" util/PERF-VERSION-GEN PERF_VERSION = 3.7.rc3.g5399b3b.dirty PERF_VERSION = 3.7.rc3.g5399b3b.dirty PERF_VERSION = 3.7.rc3.g5399b3b.dirty Performance counter stats for 'util/PERF-VERSION-GEN' (3 runs): 0.307633559 seconds time elapsed ( +- 0.84% ) Signed-off-by: Ingo Molnar --- tools/perf/util/PERF-VERSION-GEN | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index 95264f3..c774b89 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN @@ -12,7 +12,7 @@ LF=' # First check if there is a .git to get the version from git describe # otherwise try to get the version from the kernel makefile if test -d ../../.git -o -f ../../.git && - VN=$(git describe --match 'v[0-9].[0-9]*' --abbrev=4 HEAD 2>/dev/null) && + VN=$(echo $(git tag --list "v[0-9].[0-9]*" | tail -1)"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD) 2>/dev/null) && case "$VN" in *$LF*) (exit 1) ;; v[0-9]*) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/