git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] perf-lib: remove old result files before running tests
@ 2019-11-19 18:50 Thomas Gummerer
  2019-11-20  4:12 ` Junio C Hamano
  2019-11-21 10:20 ` Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: Thomas Gummerer @ 2019-11-19 18:50 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Thomas Gummerer

The perf tests write files recording the results of tests.  These
results are later aggregated by 'aggregate.perl'.  If the tests are
run multiple times, those results are overwritten by the new results.
This works just fine as long as there are only perf tests measuring
the times, whose results are stored in "$base".times files.

However 22bec79d1a ("t/perf: add infrastructure for measuring sizes",
2018-08-17) introduced a new type of test for measuring the size of
something.  The results of this are written to "$base".size files.

"$base" is essentially made up of the basename of the script plus the
test number.  So if test numbers shift because a new test was
introduced earlier in the script we might end up with both a ".times"
and a ".size" file for the same test.  In the aggregation script the
".times" file is preferred over the ".size" file, so some size tests
might end with performance numbers from a previous run of the test.

This is mainly relevant when writing perf tests that check both
performance and sizes, and can get quite confusing during
developement.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---

This came out of something different that I'm working on, but makes
most sense as a standalone patch, rather than part of that series, so
I'm sending this out separately.

 t/perf/perf-lib.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index b58a43ea43..7e80251889 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -178,10 +178,11 @@ test_wrapper_ () {
 	export test_prereq
 	if ! test_skip "$@"
 	then
-		base=$(basename "$0" .sh)
-		echo "$test_count" >>"$perf_results_dir"/$base.subtests
-		echo "$1" >"$perf_results_dir"/$base.$test_count.descr
 		base="$perf_results_dir"/"$PERF_RESULTS_PREFIX$(basename "$0" .sh)"."$test_count"
+		rm -f "$base".*
+		no_prefix_base="$perf_results_dir"/$(basename "$0" .sh)
+		echo "$test_count" >>$no_prefix_base.subtests
+		echo "$1" >$no_prefix_base.$test_count.descr
 		"$test_wrapper_func_" "$@"
 	fi
 
-- 
2.24.0.155.gd9f6f3b619


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf-lib: remove old result files before running tests
  2019-11-19 18:50 [PATCH] perf-lib: remove old result files before running tests Thomas Gummerer
@ 2019-11-20  4:12 ` Junio C Hamano
  2019-11-20  8:00   ` Thomas Gummerer
  2019-11-21 10:20 ` Jeff King
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2019-11-20  4:12 UTC (permalink / raw)
  To: Thomas Gummerer; +Cc: git, Jeff King

Thomas Gummerer <t.gummerer@gmail.com> writes:

> @@ -178,10 +178,11 @@ test_wrapper_ () {
>  	export test_prereq
>  	if ! test_skip "$@"
>  	then

> -		base=$(basename "$0" .sh)

So we used to use $base to hold the number and the filename here

> -		echo "$test_count" >>"$perf_results_dir"/$base.subtests
> -		echo "$1" >"$perf_results_dir"/$base.$test_count.descr
>  		base="$perf_results_dir"/"$PERF_RESULTS_PREFIX$(basename "$0" .sh)"."$test_count"

and then redefined it to be the results-prefix specific one.


> +		rm -f "$base".*

you now remove those results-prefix specific one for the $test_count
(I guess that is as specific you can go) before writing the count
and the description.  

So this "rm -f" is a no-op when perf-results-prefix is not empty?

> +		no_prefix_base="$perf_results_dir"/$(basename "$0" .sh)
> +		echo "$test_count" >>$no_prefix_base.subtests
> +		echo "$1" >$no_prefix_base.$test_count.descr
>  		"$test_wrapper_func_" "$@"
>  	fi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf-lib: remove old result files before running tests
  2019-11-20  4:12 ` Junio C Hamano
@ 2019-11-20  8:00   ` Thomas Gummerer
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Gummerer @ 2019-11-20  8:00 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jeff King

On 11/20, Junio C Hamano wrote:
> Thomas Gummerer <t.gummerer@gmail.com> writes:
> 
> > @@ -178,10 +178,11 @@ test_wrapper_ () {
> >  	export test_prereq
> >  	if ! test_skip "$@"
> >  	then
> 
> > -		base=$(basename "$0" .sh)
> 
> So we used to use $base to hold the number and the filename here
> 
> > -		echo "$test_count" >>"$perf_results_dir"/$base.subtests
> > -		echo "$1" >"$perf_results_dir"/$base.$test_count.descr
> >  		base="$perf_results_dir"/"$PERF_RESULTS_PREFIX$(basename "$0" .sh)"."$test_count"
> 
> and then redefined it to be the results-prefix specific one.
> 
> 
> > +		rm -f "$base".*
> 
> you now remove those results-prefix specific one for the $test_count
> (I guess that is as specific you can go) before writing the count
> and the description.  
> 
> So this "rm -f" is a no-op when perf-results-prefix is not empty?

No, not quite.  It is a no-op the first time a particular test runs
for a specific prefix.  The prefix is usually set by the 't/perf/run'
script, and indicates the revision that is tested.

So if we were running for example

    ./run deadbeef... p0001-rev-list.sh

we'd have a file 'test-results/build_deadbeef....p0001-rev-list.1.times' 
in the t/perf directory.

Now we add a 'test_size' test before the first 'test_perf' test, and
run the tests again.  After this run we'd still have that original
file from the test results from the previous run, as well as a
'test-results/build_deadbeef....p0001-rev-list.1.size'.

This duplicate file at the matching "$base" is what we want to avoid.
The "rm -f" above would remove
'test-results/build_deadbeef....p0001-rev-list.1.times' so we now only
have the '.size' file left, and 'aggregate.perl' gives us the right
result.

> > +		no_prefix_base="$perf_results_dir"/$(basename "$0" .sh)
> > +		echo "$test_count" >>$no_prefix_base.subtests
> > +		echo "$1" >$no_prefix_base.$test_count.descr
> >  		"$test_wrapper_func_" "$@"
> >  	fi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf-lib: remove old result files before running tests
  2019-11-19 18:50 [PATCH] perf-lib: remove old result files before running tests Thomas Gummerer
  2019-11-20  4:12 ` Junio C Hamano
@ 2019-11-21 10:20 ` Jeff King
  2019-11-22  8:11   ` Thomas Gummerer
  1 sibling, 1 reply; 7+ messages in thread
From: Jeff King @ 2019-11-21 10:20 UTC (permalink / raw)
  To: Thomas Gummerer; +Cc: git

On Tue, Nov 19, 2019 at 06:50:47PM +0000, Thomas Gummerer wrote:

> The perf tests write files recording the results of tests.  These
> results are later aggregated by 'aggregate.perl'.  If the tests are
> run multiple times, those results are overwritten by the new results.
> This works just fine as long as there are only perf tests measuring
> the times, whose results are stored in "$base".times files.
> 
> However 22bec79d1a ("t/perf: add infrastructure for measuring sizes",
> 2018-08-17) introduced a new type of test for measuring the size of
> something.  The results of this are written to "$base".size files.
> 
> "$base" is essentially made up of the basename of the script plus the
> test number.  So if test numbers shift because a new test was
> introduced earlier in the script we might end up with both a ".times"
> and a ".size" file for the same test.  In the aggregation script the
> ".times" file is preferred over the ".size" file, so some size tests
> might end with performance numbers from a previous run of the test.
> 
> This is mainly relevant when writing perf tests that check both
> performance and sizes, and can get quite confusing during
> developement.

The problem description makes sense to me.

> diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
> index b58a43ea43..7e80251889 100644
> --- a/t/perf/perf-lib.sh
> +++ b/t/perf/perf-lib.sh
> @@ -178,10 +178,11 @@ test_wrapper_ () {
>  	export test_prereq
>  	if ! test_skip "$@"
>  	then
> -		base=$(basename "$0" .sh)
> -		echo "$test_count" >>"$perf_results_dir"/$base.subtests
> -		echo "$1" >"$perf_results_dir"/$base.$test_count.descr
>  		base="$perf_results_dir"/"$PERF_RESULTS_PREFIX$(basename "$0" .sh)"."$test_count"
> +		rm -f "$base".*
> +		no_prefix_base="$perf_results_dir"/$(basename "$0" .sh)
> +		echo "$test_count" >>$no_prefix_base.subtests
> +		echo "$1" >$no_prefix_base.$test_count.descr
>  		"$test_wrapper_func_" "$@"

I had a little trouble following the patch because of a few things:

  - the reordering of earlier lines. We don't care about subtests at
    all, and that line could stay the same. But we do have to reorder
    the "descr" one because of the broad wildcard in the "rm". That
    could be narrowed, but I guess you wanted to future-proof it against
    new types.

  - the $no_prefix_base variable differs from $base not just in lacking
    the prefix, but also in lacking $test_count at the end.

So I think it's doing the right thing overall, though there is one bug:
$no_prefix_base is not quoted, but could contain spaces due to
$perf_results_dir. I think that would cause bash to complain if there's
a space in your path.

But I wonder if it would be simpler to just always use the same file for
the test result, overwriting it each time, and let the reader figure out
the type. The aggregate script's get_times() already uses a regex to
distinguish the two. That's enough for the two types we have, and we
could later add a header line if it becomes necessary.

Something like the patch below. That removes any confusion about cruft
files being left behind, or which file should be preferred, etc.

The diff would be even smaller if we just kept calling it "times", but
that's probably unnecessarily confusing.

-Peff

---
diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 66554d2161..112fc23dbe 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -219,13 +219,7 @@ sub print_default_results {
 		for my $i (0..$#dirs) {
 			my $d = $dirs[$i];
 			my $base = "$resultsdir/$prefixes{$d}$t";
-			$times{$prefixes{$d}.$t} = [];
-			foreach my $type (qw(times size)) {
-				if (-e "$base.$type") {
-					$times{$prefixes{$d}.$t} = [get_times("$base.$type")];
-					last;
-				}
-			}
+			$times{$prefixes{$d}.$t} = [get_times("$base.result")];
 			my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}};
 			my $w = length format_times($r,$u,$s,$firstr);
 			$colwidth[$i] = $w if $w > $colwidth[$i];
@@ -267,7 +261,7 @@ sub print_sorted_results {
 		my ($prevr, $prevu, $prevs, $prevrev);
 		for my $i (0..$#dirs) {
 			my $d = $dirs[$i];
-			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
+			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
 			if ($i > 0 and defined $r and defined $prevr and $prevr > 0) {
 				my $percent = 100.0 * ($r - $prevr) / $prevr;
 				push @evolutions, { "percent"  => $percent,
@@ -327,7 +321,7 @@ sub print_codespeed_results {
 			my $commitid = $prefixes{$d};
 			$commitid =~ s/^build_//;
 			$commitid =~ s/\.$//;
-			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
+			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
 
 			my %vals = (
 				"commitid" => $commitid,
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index b58a43ea43..13e389367a 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -214,7 +214,7 @@ test_perf_ () {
 	else
 		test_ok_ "$1"
 	fi
-	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
+	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result
 }
 
 test_perf () {
@@ -223,7 +223,7 @@ test_perf () {
 
 test_size_ () {
 	say >&3 "running: $2"
-	if test_eval_ "$2" 3>"$base".size; then
+	if test_eval_ "$2" 3>"$base".result; then
 		test_ok_ "$1"
 	else
 		test_failure_ "$@"

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf-lib: remove old result files before running tests
  2019-11-21 10:20 ` Jeff King
@ 2019-11-22  8:11   ` Thomas Gummerer
  2019-11-25 14:09     ` Jeff King
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Gummerer @ 2019-11-22  8:11 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On 11/21, Jeff King wrote:
> But I wonder if it would be simpler to just always use the same file for
> the test result, overwriting it each time, and let the reader figure out
> the type. The aggregate script's get_times() already uses a regex to
> distinguish the two. That's enough for the two types we have, and we
> could later add a header line if it becomes necessary.
> 
> Something like the patch below. That removes any confusion about cruft
> files being left behind, or which file should be preferred, etc.

Yeah, I like what you have below much more than what I had, thanks!

> The diff would be even smaller if we just kept calling it "times", but
> that's probably unnecessarily confusing.

Yup, I prefer a more readable end result to a small diff :)

> -Peff
> 
> ---
> diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
> index 66554d2161..112fc23dbe 100755
> --- a/t/perf/aggregate.perl
> +++ b/t/perf/aggregate.perl
> @@ -219,13 +219,7 @@ sub print_default_results {
>  		for my $i (0..$#dirs) {
>  			my $d = $dirs[$i];
>  			my $base = "$resultsdir/$prefixes{$d}$t";
> -			$times{$prefixes{$d}.$t} = [];
> -			foreach my $type (qw(times size)) {
> -				if (-e "$base.$type") {
> -					$times{$prefixes{$d}.$t} = [get_times("$base.$type")];
> -					last;
> -				}
> -			}
> +			$times{$prefixes{$d}.$t} = [get_times("$base.result")];
>  			my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}};
>  			my $w = length format_times($r,$u,$s,$firstr);
>  			$colwidth[$i] = $w if $w > $colwidth[$i];
> @@ -267,7 +261,7 @@ sub print_sorted_results {
>  		my ($prevr, $prevu, $prevs, $prevrev);
>  		for my $i (0..$#dirs) {
>  			my $d = $dirs[$i];
> -			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
> +			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
>  			if ($i > 0 and defined $r and defined $prevr and $prevr > 0) {
>  				my $percent = 100.0 * ($r - $prevr) / $prevr;
>  				push @evolutions, { "percent"  => $percent,
> @@ -327,7 +321,7 @@ sub print_codespeed_results {
>  			my $commitid = $prefixes{$d};
>  			$commitid =~ s/^build_//;
>  			$commitid =~ s/\.$//;
> -			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
> +			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
>  
>  			my %vals = (
>  				"commitid" => $commitid,
> diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
> index b58a43ea43..13e389367a 100644
> --- a/t/perf/perf-lib.sh
> +++ b/t/perf/perf-lib.sh
> @@ -214,7 +214,7 @@ test_perf_ () {
>  	else
>  		test_ok_ "$1"
>  	fi
> -	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
> +	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result
>  }
>  
>  test_perf () {
> @@ -223,7 +223,7 @@ test_perf () {
>  
>  test_size_ () {
>  	say >&3 "running: $2"
> -	if test_eval_ "$2" 3>"$base".size; then
> +	if test_eval_ "$2" 3>"$base".result; then
>  		test_ok_ "$1"
>  	else
>  		test_failure_ "$@"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf-lib: remove old result files before running tests
  2019-11-22  8:11   ` Thomas Gummerer
@ 2019-11-25 14:09     ` Jeff King
  2019-11-25 17:04       ` Thomas Gummerer
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2019-11-25 14:09 UTC (permalink / raw)
  To: Thomas Gummerer; +Cc: git, Junio C Hamano

On Fri, Nov 22, 2019 at 08:11:08AM +0000, Thomas Gummerer wrote:

> On 11/21, Jeff King wrote:
> > But I wonder if it would be simpler to just always use the same file for
> > the test result, overwriting it each time, and let the reader figure out
> > the type. The aggregate script's get_times() already uses a regex to
> > distinguish the two. That's enough for the two types we have, and we
> > could later add a header line if it becomes necessary.
> > 
> > Something like the patch below. That removes any confusion about cruft
> > files being left behind, or which file should be preferred, etc.
> 
> Yeah, I like what you have below much more than what I had, thanks!
> 
> > The diff would be even smaller if we just kept calling it "times", but
> > that's probably unnecessarily confusing.
> 
> Yup, I prefer a more readable end result to a small diff :)

OK, here it is wrapped up in a commit message. I wasn't sure how to
attribute it, since you really did most of the interesting work and I
just swooped in with an alternative. I'm happy to make you the author,
but I didn't want you to get blamed for my bugs. ;)

Junio, this would replace tg/perf-remove-stale-result.

-- >8 --
Subject: [PATCH] perf-lib: use a single filename for all measurement types

The perf tests write files recording the results of tests.  These
results are later aggregated by 'aggregate.perl'.  If the tests are run
multiple times, those results are overwritten by the new results.  This
works just fine as long as there are only perf tests measuring the
times, whose results are stored in "$base".times files.

However 22bec79d1a ("t/perf: add infrastructure for measuring sizes",
2018-08-17) introduced a new type of test for measuring the size of
something.  The results of this are written to "$base".size files.

"$base" is essentially made up of the basename of the script plus the
test number.  So if test numbers shift because a new test was
introduced earlier in the script we might end up with both a ".times"
and a ".size" file for the same test.  In the aggregation script the
".times" file is preferred over the ".size" file, so some size tests
might end with performance numbers from a previous run of the test.

This is mainly relevant when writing perf tests that check both
performance and sizes, and can get quite confusing during
developement.

We could fix this by doing a more thorough job of cleaning out old
".times" and ".size" files before running each test. However, an even
easier solution is to just use the same filename for both types of
measurement, meaning we'll always overwrite the previous result. We
don't even need to change the file format to distinguish the two;
aggregate.perl already decides which is which based on a regex of the
content (this may become ambiguous if we add new types in the future,
but we could easily add a header field to the file at that point).

Based on an initial patch from Thomas Gummerer, who discovered the
problem and did all of the analysis (which I stole for the commit
message above):

  https://public-inbox.org/git/20191119185047.8550-1-t.gummerer@gmail.com/

Helped-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 t/perf/aggregate.perl | 12 +++---------
 t/perf/perf-lib.sh    |  4 ++--
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 66554d2161..112fc23dbe 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -219,13 +219,7 @@ sub print_default_results {
 		for my $i (0..$#dirs) {
 			my $d = $dirs[$i];
 			my $base = "$resultsdir/$prefixes{$d}$t";
-			$times{$prefixes{$d}.$t} = [];
-			foreach my $type (qw(times size)) {
-				if (-e "$base.$type") {
-					$times{$prefixes{$d}.$t} = [get_times("$base.$type")];
-					last;
-				}
-			}
+			$times{$prefixes{$d}.$t} = [get_times("$base.result")];
 			my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}};
 			my $w = length format_times($r,$u,$s,$firstr);
 			$colwidth[$i] = $w if $w > $colwidth[$i];
@@ -267,7 +261,7 @@ sub print_sorted_results {
 		my ($prevr, $prevu, $prevs, $prevrev);
 		for my $i (0..$#dirs) {
 			my $d = $dirs[$i];
-			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
+			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
 			if ($i > 0 and defined $r and defined $prevr and $prevr > 0) {
 				my $percent = 100.0 * ($r - $prevr) / $prevr;
 				push @evolutions, { "percent"  => $percent,
@@ -327,7 +321,7 @@ sub print_codespeed_results {
 			my $commitid = $prefixes{$d};
 			$commitid =~ s/^build_//;
 			$commitid =~ s/\.$//;
-			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
+			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
 
 			my %vals = (
 				"commitid" => $commitid,
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index b58a43ea43..13e389367a 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -214,7 +214,7 @@ test_perf_ () {
 	else
 		test_ok_ "$1"
 	fi
-	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
+	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result
 }
 
 test_perf () {
@@ -223,7 +223,7 @@ test_perf () {
 
 test_size_ () {
 	say >&3 "running: $2"
-	if test_eval_ "$2" 3>"$base".size; then
+	if test_eval_ "$2" 3>"$base".result; then
 		test_ok_ "$1"
 	else
 		test_failure_ "$@"
-- 
2.24.0.716.g722aff65ed


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf-lib: remove old result files before running tests
  2019-11-25 14:09     ` Jeff King
@ 2019-11-25 17:04       ` Thomas Gummerer
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Gummerer @ 2019-11-25 17:04 UTC (permalink / raw)
  To: Jeff King; +Cc: git, Junio C Hamano

On 11/25, Jeff King wrote:
> On Fri, Nov 22, 2019 at 08:11:08AM +0000, Thomas Gummerer wrote:
> 
> > On 11/21, Jeff King wrote:
> > > But I wonder if it would be simpler to just always use the same file for
> > > the test result, overwriting it each time, and let the reader figure out
> > > the type. The aggregate script's get_times() already uses a regex to
> > > distinguish the two. That's enough for the two types we have, and we
> > > could later add a header line if it becomes necessary.
> > > 
> > > Something like the patch below. That removes any confusion about cruft
> > > files being left behind, or which file should be preferred, etc.
> > 
> > Yeah, I like what you have below much more than what I had, thanks!
> > 
> > > The diff would be even smaller if we just kept calling it "times", but
> > > that's probably unnecessarily confusing.
> > 
> > Yup, I prefer a more readable end result to a small diff :)
> 
> OK, here it is wrapped up in a commit message. I wasn't sure how to
> attribute it, since you really did most of the interesting work and I
> just swooped in with an alternative. I'm happy to make you the author,
> but I didn't want you to get blamed for my bugs. ;)

Thanks for tying this up.  I wasn't sure how to proceed either, so I'm
glad you submitted the patch.  And I'm happy to have you as author
with the helped-by attribution as you are the one that actually wrote
the code :)

I eyeballed the patch again and applied and tested it for good measure
and it all looks good to me!

> Junio, this would replace tg/perf-remove-stale-result.
> 
> -- >8 --
> Subject: [PATCH] perf-lib: use a single filename for all measurement types
> 
> The perf tests write files recording the results of tests.  These
> results are later aggregated by 'aggregate.perl'.  If the tests are run
> multiple times, those results are overwritten by the new results.  This
> works just fine as long as there are only perf tests measuring the
> times, whose results are stored in "$base".times files.
> 
> However 22bec79d1a ("t/perf: add infrastructure for measuring sizes",
> 2018-08-17) introduced a new type of test for measuring the size of
> something.  The results of this are written to "$base".size files.
> 
> "$base" is essentially made up of the basename of the script plus the
> test number.  So if test numbers shift because a new test was
> introduced earlier in the script we might end up with both a ".times"
> and a ".size" file for the same test.  In the aggregation script the
> ".times" file is preferred over the ".size" file, so some size tests
> might end with performance numbers from a previous run of the test.
> 
> This is mainly relevant when writing perf tests that check both
> performance and sizes, and can get quite confusing during
> developement.
> 
> We could fix this by doing a more thorough job of cleaning out old
> ".times" and ".size" files before running each test. However, an even
> easier solution is to just use the same filename for both types of
> measurement, meaning we'll always overwrite the previous result. We
> don't even need to change the file format to distinguish the two;
> aggregate.perl already decides which is which based on a regex of the
> content (this may become ambiguous if we add new types in the future,
> but we could easily add a header field to the file at that point).
> 
> Based on an initial patch from Thomas Gummerer, who discovered the
> problem and did all of the analysis (which I stole for the commit
> message above):
> 
>   https://public-inbox.org/git/20191119185047.8550-1-t.gummerer@gmail.com/
> 
> Helped-by: Thomas Gummerer <t.gummerer@gmail.com>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  t/perf/aggregate.perl | 12 +++---------
>  t/perf/perf-lib.sh    |  4 ++--
>  2 files changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
> index 66554d2161..112fc23dbe 100755
> --- a/t/perf/aggregate.perl
> +++ b/t/perf/aggregate.perl
> @@ -219,13 +219,7 @@ sub print_default_results {
>  		for my $i (0..$#dirs) {
>  			my $d = $dirs[$i];
>  			my $base = "$resultsdir/$prefixes{$d}$t";
> -			$times{$prefixes{$d}.$t} = [];
> -			foreach my $type (qw(times size)) {
> -				if (-e "$base.$type") {
> -					$times{$prefixes{$d}.$t} = [get_times("$base.$type")];
> -					last;
> -				}
> -			}
> +			$times{$prefixes{$d}.$t} = [get_times("$base.result")];
>  			my ($r,$u,$s) = @{$times{$prefixes{$d}.$t}};
>  			my $w = length format_times($r,$u,$s,$firstr);
>  			$colwidth[$i] = $w if $w > $colwidth[$i];
> @@ -267,7 +261,7 @@ sub print_sorted_results {
>  		my ($prevr, $prevu, $prevs, $prevrev);
>  		for my $i (0..$#dirs) {
>  			my $d = $dirs[$i];
> -			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
> +			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
>  			if ($i > 0 and defined $r and defined $prevr and $prevr > 0) {
>  				my $percent = 100.0 * ($r - $prevr) / $prevr;
>  				push @evolutions, { "percent"  => $percent,
> @@ -327,7 +321,7 @@ sub print_codespeed_results {
>  			my $commitid = $prefixes{$d};
>  			$commitid =~ s/^build_//;
>  			$commitid =~ s/\.$//;
> -			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
> +			my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.result");
>  
>  			my %vals = (
>  				"commitid" => $commitid,
> diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
> index b58a43ea43..13e389367a 100644
> --- a/t/perf/perf-lib.sh
> +++ b/t/perf/perf-lib.sh
> @@ -214,7 +214,7 @@ test_perf_ () {
>  	else
>  		test_ok_ "$1"
>  	fi
> -	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".times
> +	"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result
>  }
>  
>  test_perf () {
> @@ -223,7 +223,7 @@ test_perf () {
>  
>  test_size_ () {
>  	say >&3 "running: $2"
> -	if test_eval_ "$2" 3>"$base".size; then
> +	if test_eval_ "$2" 3>"$base".result; then
>  		test_ok_ "$1"
>  	else
>  		test_failure_ "$@"
> -- 
> 2.24.0.716.g722aff65ed
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-25 17:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19 18:50 [PATCH] perf-lib: remove old result files before running tests Thomas Gummerer
2019-11-20  4:12 ` Junio C Hamano
2019-11-20  8:00   ` Thomas Gummerer
2019-11-21 10:20 ` Jeff King
2019-11-22  8:11   ` Thomas Gummerer
2019-11-25 14:09     ` Jeff King
2019-11-25 17:04       ` Thomas Gummerer

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).