[PATCH] tools/perf: Fix double/triple-build of the feature detectionlogic during 'make install' et al
From: Ingo Molnar
Date: Wed Oct 02 2013 - 03:31:52 EST
* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> [...]
>
> Another annoyance during that make was that "make install" seems to want
> to re-make the thing I just built. That's absolutely horrible, even if
> I've seen too many broken projects do that. Now, for perf it's not as
> horrible as for some (because you can do "make install" as a normal
> user), but it's still a pattern that needs to be called out and needs to
> die. It's not just that it slows down "make install", it's also that a
> normal pattern *should* be that you build things as a normal user, and
> do "make install" as root.
Ok, I think I managed to fix this bug too - see the patch below. Only
lightly tested, with the most common usecases.
Thanks,
Ingo
=========================>
Subject: tools/perf: Fix double/triple-build of the feature detection logic during 'make install' et al
From: Ingo Molnar <mingo@xxxxxxxxxx>
Date: Wed Oct 2 06:51:27 CEST 2013
Linus reported the following perf build system bug:
'Another annoyance during that make was that "make install" seems to
want to re-make the thing I just built. That's absolutely horrible, [...]'
The targets that got re-built were 'only' the (numerous) feature checks,
not the whole project - but still it was mighty annoying as the feature
checks took 9+ seconds even on reasonably fast boxes...
Even with the autodep patches where feature detection is much faster
double/triple checks waste resources, waste screen real estate and confuse
users.
There were two sources for these unnecessary re-builds of the feature
checks:
- Unnecessary nested invocations of $(MAKE), apparently to be able
to do conditional compilation dependent on documentation tools
presence. Use straight dependencies instead, with no nesting.
- A direct invocation of $(MAKE) to rebuild the PERF-VERSION-FILE.
This is apparently done to be able to include it into the
Makefile:
-include $(OUTPUT)PERF-VERSION-FILE
but that's entirely pointless for two reasons: 1) the version file
gets regenerated by the initial build pass anyway, 2) including it
is futile, given its contents:
#define PERF_VERSION "3.12.rc3.g8510c7"
'make' will interpret that as a comment line...
So just remove this part of the doc-generation logic.
With these things fixed a 'make install' now rebuilds only what is needed.
A repeated 'make install' on an already built tree is super fast now, it
finishes in under 0.3 seconds:
#
# After the patch:
#
$ time make install
...
real 0m0.280s
user 0m0.162s
sys 0m0.054s
Prior all the autodep changes and prior this fix, a repeat 'make install'
took 24.1 seconds (!) on the same system:
#
# Before the patches:
#
$ time make install
...
real 0m24.109s
user 0m21.171s
sys 0m2.449s
Which almost entirely was caused by fixable build system fat.
We are now literally ~86 times faster.
A fresh rebuild and install now takes just 11.4 seconds:
#
# After the patch:
#
$ make clean
$ time make -j16 install
...
real 0m11.457s
user 1m43.411s
sys 0m7.610s
Without the patches it took 27.8 seconds:
#
# Before the patches:
#
$ make clean
$ time make -j16 install
...
real 0m27.801s
user 1m59.242s
sys 0m9.749s
So even in the complete rebuild case we are now ~2.5 times faster.
Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
tools/perf/Documentation/Makefile | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
Index: tip/tools/perf/Documentation/Makefile
===================================================================
--- tip.orig/tools/perf/Documentation/Makefile
+++ tip/tools/perf/Documentation/Makefile
@@ -192,13 +192,14 @@ do-install-man: man
install-man: check-man-tools man
-try-install-man:
ifdef missing_tools
- $(warning Please install $(missing_tools) to have the man pages installed)
+ DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed)
else
- $(MAKE) do-install-man
+ DO_INSTALL_MAN = do-install-man
endif
+try-install-man: $(DO_INSTALL_MAN)
+
install-info: info
$(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
$(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir)
@@ -216,14 +217,6 @@ install-pdf: pdf
#install-html: html
# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(MAKECMDGOALS),tags)
-$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
- $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) $(OUTPUT)PERF-VERSION-FILE
-
--include $(OUTPUT)PERF-VERSION-FILE
-endif
-endif
#
# Determine "include::" file references in asciidoc files.
@@ -342,5 +335,3 @@ $(patsubst %.txt,%.html,$(wildcard howto
#quick-install-html:
# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
-
-.PHONY: .FORCE-PERF-VERSION-FILE
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/