Skip to content

Commit 2a07565

Browse files
committed
perf: do allow GIT_PERF_* to be overridden again
A common way to run Git's performance benchmarks on repositories other than Git's own repository (which is not exactly large when compared to actually large repositories) is to run them like this: GIT_PERF_LARGE_REPO=/path/to/my/large/repo \ ./p1234-*.sh -ivx Contrary to developers' common expectations, this failed to work when Git was built with a different `GIT_PERF_LARGE_REPO` value specified at build time: That build-time option would have been written to the `GIT-BUILD-OPTIONS` file, which in turn would have been sourced by `test-lib.sh`, which in turn would have been sourced by `perf-lib.sh`, which in turn would have been sourced by the perf test script, _overriding_ the environment variable specified in the way illustrated above. Since perf tests are not run as part of the build, this most likely unintended behavior was not caught and certainly not fixed, as the `GIT_PERF_*` values would have been empty at build-time. However, in 4638e88 (Makefile: use common template for GIT-BUILD-OPTIONS, 2024-12-06), a subtle change of behavior was introduced: Whereas before, a couple of build-time options (the `GIT_PERF_*` ones included) were written to `GIT-BUILD-OPTIONS` only when their values were non-empty. With this commit, they are also written when they are empty. The consequence is that above-mentioned way to run the perf tests will not only fail to pick up the desired `GIT_PERF_*` settings when they were specified differently while building Git, instead the desired settings will be only respected when specified _while building_ Git. Let's work around the original issue, i.e. let `GIT_PERF_*` environment variables override what is recorded in `GIT-BUILD-OPTIONS`. Note that this is just the tip of the iceberg, there are a couple of `GIT_TEST_*` options that may want a similar fix in `test-lib.sh`. Due to time constraints on my side, this here patch focuses exclusively on the `GIT_PERF_*` settings. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 683c54c commit 2a07565

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

t/perf/perf-lib.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ TEST_OUTPUT_DIRECTORY=$(pwd)
2525
TEST_NO_CREATE_REPO=t
2626
TEST_NO_MALLOC_CHECK=t
2727

28+
# GIT-BUILD-OPTIONS, sourced by test-lib.sh, overwrites the `GIT_PERF_*`
29+
# values that are set by the user (if any). Let's stash them away as
30+
# `eval`-able assignments.
31+
git_perf_settings="$(env |
32+
sed -n "/^GIT_PERF_/{
33+
# escape all single-quotes in the value
34+
s/'/'\\\\''/g
35+
# turn this into an eval-able assignment
36+
s/^\\([^=]*=\\)\\(.*\\)/\\1'\\2'/p
37+
}")"
38+
2839
. ../test-lib.sh
40+
eval "$git_perf_settings"
2941

3042
unset GIT_CONFIG_NOSYSTEM
3143
GIT_CONFIG_SYSTEM="$TEST_DIRECTORY/perf/config"

0 commit comments

Comments
 (0)