git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Josh Steadmon <steadmon@google.com>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: js/partial-clone-connectivity-check (was: What's cooking in git.git (Apr 2019, #05; Thu, 25))
Date: Thu, 2 May 2019 18:24:09 -0400	[thread overview]
Message-ID: <20190502222409.GA15631@sigill.intra.peff.net> (raw)
In-Reply-To: <20190502214509.GA19188@sigill.intra.peff.net>

On Thu, May 02, 2019 at 05:45:09PM -0400, Jeff King wrote:

> Here's what I came up with. Note that there's a bug in 'master' right
> now which causes perf to produce nonsense results. It's due to my
> 0baf78e7bc (perf-lib.sh: rely on test-lib.sh for --tee handling,
> 2019-03-15). I'll fix that separately (the timing below is done with
> that commit reverted).

And here's the fix for that. It's rather subtle, so I hope I explained
it sufficiently. I didn't notice it while working on the original
because everything _appears_ to run fine, but you just get timings from
the wrong version of Git. Which is only noticeable if you're literally
testing two versions that you expect to differ.

-- >8 --
Subject: [PATCH] t/perf: set GIT_TEST_INSTALLED before including test-lib.sh

Commit 0baf78e7bc (perf-lib.sh: rely on test-lib.sh for --tee handling,
2019-03-15) introduced a bug which causes perf test runs to always find
git in the $PATH, rather than actually testing $GIT_TEST_INSTALLED
(which is used by the "run" script).

That commit bumped the conversion of $GIT_TEST_INSTALLED to an absolute
path until after test-lib.sh was been included. That solved the original
problem of generating a bogus $perf_results_prefix value from the
absolute path. But it introduced a new one: test-lib.sh needs to see
that absolute value because it will put it at the front of the $PATH.

The root of the issue is that we need both the relative and the absolute
paths available. That earlier commit chose to stuff the absolute path
into $ABSOLUTE_GIT_TEST_INSTALLED, keep the relative one in
$GIT_TEST_INSTALLED, and then resolve the two after test-lib.sh has been
loaded. We can fix it by reversing our strategy: we'll keep the absolute
path in $GIT_TEST_INSTALLED, drop our now-useless ABSOLUTE variable, and
introduce a new $TEST_INSTALLED_ORIG variable to hold the original value
(from which we will later derive the prefix).

Note that we need to export our ORIG variable because the whole point of
0baf78e7bc is that test-lib.sh may actually re-exec a new copy of the
script to handle tee-ing the output.

I'd hoped to add a test to p0000-perf-lib-sanity to cover this, but the
bug is actually outside that scope. It triggers if you do something
like:

  cat >t/perf/p1234-foo.sh <<-\EOF
  #!/bin/sh
  test_description=debugging
  . ./perf-lib.sh
  test_expect_success 'version' 'which git && git version'
  test_perf 'fake timing' 'true'
  test_done
  EOF

  chmod +x t/perf/p1234-foo.sh
  make GIT_TEST_OPTS=--verbose-log
  cd t/perf
  ./run origin p1234-foo.sh
  cat test-results/p1234-foo.out

Without this patch, you'll see that we're running whatever git is in
your $PATH, not the one from "origin". With this patch, we should see:

  - the correct git is run

  - we get timing results out of ./run, showing that the prefix bug from
    0baf78e7bc was not regressed

  - our values make it across the script re-exec due to --verbose-log

Signed-off-by: Jeff King <peff@peff.net>
---
 t/perf/perf-lib.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 169f92eae3..8317dbef44 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -21,7 +21,11 @@
 # because it will change our working directory.
 TEST_DIRECTORY=$(pwd)/..
 TEST_OUTPUT_DIRECTORY=$(pwd)
-ABSOLUTE_GIT_TEST_INSTALLED=$(
+
+# Likewise we must turn GIT_TEST_INSTALLED into an absolute path; but remember
+# and export the original value, since we'll later generate our prefix from it.
+: ${TEST_INSTALLED_ORIG=$GIT_TEST_INSTALLED}; export TEST_INSTALLED_ORIG
+GIT_TEST_INSTALLED=$(
 	test -n "$GIT_TEST_INSTALLED" && cd "$GIT_TEST_INSTALLED" && pwd)
 
 TEST_NO_CREATE_REPO=t
@@ -32,8 +36,7 @@ TEST_NO_MALLOC_CHECK=t
 if test -z "$GIT_TEST_INSTALLED"; then
 	perf_results_prefix=
 else
-	perf_results_prefix=$(printf "%s" "${GIT_TEST_INSTALLED%/bin-wrappers}" | tr -c "[a-zA-Z0-9]" "[_*]")"."
-	GIT_TEST_INSTALLED=$ABSOLUTE_GIT_TEST_INSTALLED
+	perf_results_prefix=$(printf "%s" "${TEST_INSTALLED_ORIG%/bin-wrappers}" | tr -c "[a-zA-Z0-9]" "[_*]")"."
 fi
 
 # Variables from test-lib that are normally internal to the tests; we
-- 
2.21.0.1314.g224b191707


  reply	other threads:[~2019-05-02 22:24 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 10:15 What's cooking in git.git (Apr 2019, #05; Thu, 25) Junio C Hamano
2019-04-25 14:50 ` Elijah Newren
2019-04-25 22:16 ` js/partial-clone-connectivity-check (was: What's cooking in git.git (Apr 2019, #05; Thu, 25)) Josh Steadmon
2019-05-02  2:52   ` Jeff King
2019-05-02 16:48     ` Josh Steadmon
2019-05-02 21:45     ` Jeff King
2019-05-02 22:24       ` Jeff King [this message]
2019-05-06 19:16         ` [PATCH] perf-lib.sh: make "./run <revisions>" use the correct gits Ævar Arnfjörð Bjarmason
2019-05-06 20:24           ` Jeff King
2019-05-06 23:23             ` [PATCH v2 0/2] perf-lib.sh: fix 0baf78e7bc regression, refactor & fix bugs Ævar Arnfjörð Bjarmason
2019-05-07  7:06               ` Jeff King
2019-05-07 10:54               ` [PATCH v3 0/6] " Ævar Arnfjörð Bjarmason
2019-05-07 21:36                 ` Jeff King
2019-05-08  1:59                   ` Junio C Hamano
2019-05-07 10:54               ` [PATCH v3 1/6] perf README: correct docs for 3c8f12c96c regression Ævar Arnfjörð Bjarmason
2019-05-07 10:54               ` [PATCH v3 2/6] perf aggregate: remove GIT_TEST_INSTALLED from --codespeed Ævar Arnfjörð Bjarmason
2019-05-07 10:54               ` [PATCH v3 3/6] perf-lib.sh: make "./run <revisions>" use the correct gits Ævar Arnfjörð Bjarmason
2019-05-07 10:54               ` [PATCH v3 4/6] perf-lib.sh: remove GIT_TEST_INSTALLED from perf-lib.sh Ævar Arnfjörð Bjarmason
2019-05-07 10:54               ` [PATCH v3 5/6] perf tests: add "bindir" prefix to git tree test results Ævar Arnfjörð Bjarmason
2019-05-07 10:54               ` [PATCH v3 6/6] perf-lib.sh: forbid the use of GIT_TEST_INSTALLED Ævar Arnfjörð Bjarmason
2019-05-06 23:23             ` [PATCH v2 1/2] perf-lib.sh: make "./run <revisions>" use the correct gits Ævar Arnfjörð Bjarmason
2019-05-07  7:19               ` Jeff King
2019-05-06 23:23             ` [PATCH v2 2/2] perf-lib.sh: remove GIT_TEST_INSTALLED from perf-lib.sh Ævar Arnfjörð Bjarmason
2019-05-07  7:16               ` Jeff King
2019-05-07  8:31                 ` Ævar Arnfjörð Bjarmason
2019-05-07 21:23                   ` Jeff King
2019-04-26  5:05 ` What's cooking in git.git (Apr 2019, #05; Thu, 25) Taylor Blau
2019-04-26  5:41   ` Junio C Hamano
2019-04-26  5:53     ` Taylor Blau
2019-04-26  6:01       ` Junio C Hamano
2019-04-26 17:58     ` Kaartic Sivaraam
2019-04-27  5:06       ` Junio C Hamano
2019-04-27  5:57         ` Kaartic Sivaraam
2019-05-02  3:09         ` Jeff King
2019-04-29 22:20 ` js/macos-gettext-build, was " Johannes Schindelin
2019-05-05  5:13   ` Junio C Hamano
2019-05-06  9:11 ` Duy Nguyen
2019-05-07  2:36   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190502222409.GA15631@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=steadmon@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).