[PATCH v3 0/9] Makefile: optimize noop runs, add shared.mak
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Feb 25, 2022, 09:04 UTC
- Message-ID
- <cover-v3-0.9-00000000000-20220225T090127Z-avarab@gmail.com>
- In-Reply-To
- <cover-v2-0.8-00000000000-20211224T173558Z-avarab@gmail.com>
As the v1 notes (among other things): https://lore.kernel.org/git/cover-0.8-00000000000-20211217T012902Z-avarab@gmail.com/
This speeds up noop runs of "make" by a lot. After a "make" running a
"make -j1" with this is ~1.5 faster than on "master"[2], and around 3x
as fast with "make -j1 NO_TCLTK=Y" (the TCL part takes a lot of time,
but that's another matter).This v3 re-roll:
* Addresses a minor comment/documentation issue pointed out by Taylor Blau.
* Adjusts the ".SUFFIXES" commit message to note the source of the speed-up from that change, in response to a question from Taylor.
* Changes the contrib/scalar/Makefile to make use of the new shared.mak, which allows for deleting some copy/pasted code in it in favor of the same shared logic.
The original version of these patches was written before that file landed in-tree.
For v2, see: https://lore.kernel.org/git/cover-v2-0.8-00000000000-20211224T173558Z-avarab@gmail.com/
Ævar Arnfjörð Bjarmason (9): scalar Makefile: set the default target after the includes Makefiles: add "shared.mak", move ".DELETE_ON_ERROR" to it Makefile: disable GNU make built-in wildcard rules Makefile: define $(LIB_H) in terms of $(FIND_SOURCE_FILES) Makefile: move ".SUFFIXES" rule to shared.mak Makefile: move $(comma), $(empty) and $(space) to shared.mak Makefile: add "$(QUIET)" boilerplate to shared.mak Makefile: use $(wspfx) for $(QUIET...) in shared.mak Makefiles: add and use wildcard "mkdir -p" template
Documentation/Makefile | 63 ++------------------ Makefile | 118 ++++++++++++-------------------------- config.mak.uname | 1 - contrib/scalar/Makefile | 19 ++---- contrib/scalar/t/Makefile | 3 + shared.mak | 109 +++++++++++++++++++++++++++++++++++ t/Makefile | 3 + t/interop/Makefile | 3 + t/perf/Makefile | 3 + templates/Makefile | 8 +-- 10 files changed, 170 insertions(+), 160 deletions(-) create mode 100644 shared.mak
Range-diff against v2:
-: ----------- > 1: 2404c4d8b96 scalar Makefile: set the default target after the includes
1: 97dccacce20 ! 2: 96a490bec54 Makefiles: add "shared.mak", move ".DELETE_ON_ERROR" to it
@@ Makefile: shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
# The generic compilation pattern rule and automatically
+ ## contrib/scalar/Makefile ##
+@@
++# Import tree-wide shared Makefile behavior and libraries
++include ../../shared.mak
++
+ QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
+ QUIET_SUBDIR1 =
+
+
+ ## contrib/scalar/t/Makefile ##
+@@
++# Import tree-wide shared Makefile behavior and libraries
++include ../../../shared.mak
++
+ # Run scalar tests
+ #
+ # Copyright (c) 2005,2021 Junio C Hamano, Johannes Schindelin
+
## shared.mak (new) ##
@@
+### Flags affecting all rules
@@ t/interop/Makefile
export GIT_TEST_OPTIONS
+ ## t/perf/Makefile ##
+@@
++# Import tree-wide shared Makefile behavior and libraries
++include ../../shared.mak
++
+ -include ../../config.mak
+ export GIT_TEST_OPTIONS
+
+
## templates/Makefile ##
@@
+# Import tree-wide shared Makefile behavior and libraries
2: b2bf32ab071 = 3: 9392e3c3e97 Makefile: disable GNU make built-in wildcard rules
3: 275aba624fa = 4: 07cf9daa9d6 Makefile: define $(LIB_H) in terms of $(FIND_SOURCE_FILES)
4: 7103c40de64 ! 5: 16f2e3ff35b Makefile: move ".SUFFIXES" rule to shared.mak
@@ Commit message
'make -C Documentation -j1 man' in 'HEAD~0' ran
1.25 ± 0.14 times faster than 'make -C Documentation -j1 man' in 'HEAD~1'
+ The reason for that can be seen when comparing that run with
+ "--debug=a". Without this change making a target like "git-status.1"
+ will cause "make" to consider not only "git-status.txt", but
+ "git-status.txt.o", as well as numerous other implicit suffixes such
+ as ".c", ".cc", ".cpp" etc. See [1] for a more detailed before/after
+ example.
+
+ So this is causing us to omit a bunch of work we didn't need to
+ do. For making "git-status.1" the "--debug=a" output is reduced from
+ ~140k lines to ~6k.
+
+ 1. https://lore.kernel.org/git/220222.86bkyz875k.gmgdl@evledraar.gmail.com/
+
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## Makefile ##
@@ shared.mak
+## Likewise delete default $(SUFFIXES). See:
+##
-+## info make --index-search=.DELETE_ON_ERROR
++## info make --index-search=.SUFFIXES
+.SUFFIXES:
+
### Flags affecting all rules
5: 4a5c647b5e7 = 6: 1b6ecb27f02 Makefile: move $(comma), $(empty) and $(space) to shared.mak
6: 940299d2a03 ! 7: 471067deefc Makefile: add "$(QUIET)" boilerplate to shared.mak
@@ config.mak.uname: vcxproj:
git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj
+ ## contrib/scalar/Makefile ##
+@@
+ # Import tree-wide shared Makefile behavior and libraries
+ include ../../shared.mak
+
+-QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
+-QUIET_SUBDIR1 =
+-
+-ifneq ($(findstring s,$(MAKEFLAGS)),s)
+-ifndef V
+- QUIET_GEN = @echo ' ' GEN $@;
+- QUIET_SUBDIR0 = +@subdir=
+- QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
+- $(MAKE) $(PRINT_DIR) -C $$subdir
+-else
+- export V
+-endif
+-endif
+-
+ include ../../config.mak.uname
+ -include ../../config.mak.autogen
+ -include ../../config.mak
+
## shared.mak ##
@@
comma = ,
7: 1e13fee526d = 8: 510306d2219 Makefile: use $(wspfx) for $(QUIET...) in shared.mak
8: 250b32540d9 = 9: 85bb74aa32f Makefiles: add and use wildcard "mkdir -p" template-- 2.35.1.1175.gf9e1b23ea35