Skip to content

Commit 88b6197

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 966be95 commit 88b6197

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,9 @@ endif
22722272
ifdef GIT_PERF_MAKE_OPTS
22732273
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@+
22742274
endif
2275+
ifdef GIT_PERF_MAKE_COMMAND
2276+
@echo GIT_PERF_MAKE_COMMAND=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_COMMAND)))'\' >>$@+
2277+
endif
22752278
ifdef GIT_INTEROP_MAKE_OPTS
22762279
@echo GIT_INTEROP_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_INTEROP_MAKE_OPTS)))'\' >>$@+
22772280
endif

t/perf/README

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,22 @@ You can set the following variables (also in your config.mak):
6060

6161
GIT_PERF_MAKE_OPTS
6262
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.
6479

6580
GIT_PERF_REPO
6681
GIT_PERF_LARGE_REPO

t/perf/run

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ build_git_rev () {
3737
cp "../../$config" "build/$rev/"
3838
fi
3939
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'"
4249
}
4350

4451
run_dirs_helper () {

0 commit comments

Comments
 (0)