perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do

Add a git GIT_PERF_MAKE_COMMAND variable to compliment the existing GIT_PERF_MAKE_OPTS facility. This allows specifying an arbitrary shell command to execute instead of 'make'. This is useful e.g. in cases where the name, semantics or defaults of a Makefile flag have changed over time. It can even be used to change the contents of the tree, useful for monkeypatching ancient versions of git to get them to build. This opens Pandora's box in some ways, it's now possible to "jailbreak" the perf environment and e.g. modify the source tree via this arbitrary instead of just issuing a custom "make" command, such a command has to be re-entrant in the sense that subsequent perf runs will re-use the possibly modified tree. It would be pointless to try to mitigate or work around that caveat in a tool purely aimed at Git developers, so this change makes no attempt to do so. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed May 20, 2017 at 21:42 UTC 88b6197d0b4f5ad480e9585baa984cac51f4771f
3 files changed +28 -3
Makefile
+3
@@ -2272,6 +2272,9 @@ endif
2272 ifdef GIT_PERF_MAKE_OPTS
2273 @echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@+
2274 endif
2275 +ifdef GIT_PERF_MAKE_COMMAND
2276 + @echo GIT_PERF_MAKE_COMMAND=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_COMMAND)))'\' >>$@+
2277 +endif
2278 ifdef GIT_INTEROP_MAKE_OPTS
2279 @echo GIT_INTEROP_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_INTEROP_MAKE_OPTS)))'\' >>$@+
2280 endif
t/perf/README
+16 -1
@@ -60,7 +60,22 @@ You can set the following variables (also in your config.mak):
60
61 GIT_PERF_MAKE_OPTS
62 Options to use when automatically building a git tree for
63 - performance testing. E.g., -j6 would be useful.
63 + performance testing. E.g., -j6 would be useful. Passed
64 + directly to make as "make $GIT_PERF_MAKE_OPTS".
65 +
66 + GIT_PERF_MAKE_COMMAND
67 + An arbitrary command that'll be run in place of the make
68 + command, if set the GIT_PERF_MAKE_OPTS variable is
69 + ignored. Useful in cases where source tree changes might
70 + require issuing a different make command to different
71 + revisions.
72 +
73 + This can be (ab)used to monkeypatch or otherwise change the
74 + tree about to be built. Note that the build directory can be
75 + re-used for subsequent runs so the make command might get
76 + executed multiple times on the same tree, but don't count on
77 + any of that, that's an implementation detail that might change
78 + in the future.
79
80 GIT_PERF_REPO
81 GIT_PERF_LARGE_REPO
t/perf/run
+9 -2
@@ -37,8 +37,15 @@ build_git_rev () {
37 cp "../../$config" "build/$rev/"
38 fi
39 done
40 - (cd build/$rev && make $GIT_PERF_MAKE_OPTS) ||
41 - die "failed to build revision '$mydir'"
40 + (
41 + cd build/$rev &&
42 + if test -n "$GIT_PERF_MAKE_COMMAND"
43 + then
44 + sh -c "$GIT_PERF_MAKE_COMMAND"
45 + else
46 + make $GIT_PERF_MAKE_OPTS
47 + fi
48 + ) || die "failed to build revision '$mydir'"
49 }
50
51 run_dirs_helper () {