git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] t/perf/run: preserve GIT_PERF_* from environment

From
Jeff King <peff@peff.net>
Date
Jan 6, 2026, 10:16 UTC
Message-ID
<20260106101604.GB3727538@coredump.intra.peff.net>
In-Reply-To
<20260106101043.GA3723319@coredump.intra.peff.net>
If you run:
  GIT_PERF_LARGE_REPO=/some/path ./p1006-cat-file.sh

it will use the repo in /some/path. But if you use the "run" helper script to aggregate and compare results, like this:

  GIT_PERF_LARGE_REPO=/some/path ./run HEAD^ HEAD p1006-cat-file.sh

it will ignore that variable. This is because the presence of the LARGE_REPO variable in GIT-BUILD-OPTIONS overrides what's in the environment. This started with 4638e8806e (Makefile: use common template for GIT-BUILD-OPTIONS, 2024-12-06), which now writes even empty variables (though arguably it was wrong even before with a non-empty value, as we generally prefer the environment to take precedence over on-disk config).

We had the same problem in perf-lib.sh itself, and we hacked around it with 32b74b9809 (perf: do allow `GIT_PERF_*` to be overridden again, 2025-04-04). That's what lets the direct invocation of "./p1006" work above.

And in fact that was sufficient for "./run", too, until it started loading GIT-BUILD-OPTIONS itself in 5756ccd181 (t/perf: fix benchmarks with out-of-tree builds, 2025-04-28). Now it has the same problem: it clobbers any incoming GIT_PERF options from the environment.

We can use the same hack here in the "run" script. It's quite ugly, but it's just short enough that I don't think it's worth trying to factor it out into a common shell library.

In the long run, we might consider teaching GIT-BUILD-OPTIONS to be more gentle in overwriting existing entries. There are probably other GIT_TEST_* variables which would need the same treatment. And if and when we come up with a more complete solution, we can use it in both spots.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/perf/run | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/t/perf/run b/t/perf/run
index 073bcb2aff..13913db4a3 100755
--- a/t/perf/run
+++ b/t/perf/run
@@ -204,8 +204,18 @@ run_subsection () {
 get_var_from_env_or_config "GIT_PERF_CODESPEED_OUTPUT" "perf" "codespeedOutput" "--bool"
 get_var_from_env_or_config "GIT_PERF_SEND_TO_CODESPEED" "perf" "sendToCodespeed"
 
+# Preserve GIT_PERF settings from the environment when loading
+# GIT-BUILD-OPTIONS; see the similar hack in perf-lib.sh.
+git_perf_settings="$(env |
+        sed -n "/^GIT_PERF_/{
+                # escape all single-quotes in the value
+                s/'/'\\\\''/g
+                # turn this into an eval-able assignment
+                s/^\\([^=]*=\\)\\(.*\\)/\\1'\\2'/p
+        }")"
 cd "$(dirname $0)"
 . ../../GIT-BUILD-OPTIONS
+eval "$git_perf_settings"
 
 if test -n "$TEST_OUTPUT_DIRECTORY"
 then
-- 
2.52.0.664.g9f53c65b4c
Previous: Jeff KingNext: Ramsay Jones
Message 3 of 5 in “more t/perf meson/GIT-BUILD-OPTIONS fallout”
  1. 0/2 more t/perf meson/GIT-BUILD-OPTIONS falloutJeff King, Jan 6, 2026
  2. 1/2 t/perf/perf-lib: fix assignment of TEST_OUTPUT_DIRECTORYJeff King, Jan 6, 2026
  3. 2/2 t/perf/run: preserve GIT_PERF_* from environmentJeff King, Jan 6, 2026
  4. Ramsay JonesJan 6, 2026
  5. Jeff KingJan 16, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.