public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* "make check" times
@ 2019-07-19 22:11 DJ Delorie
  2019-07-20  0:05 ` Carlos O'Donell
  2020-03-11 19:32 ` DJ Delorie
  0 siblings, 2 replies; 28+ messages in thread
From: DJ Delorie @ 2019-07-19 22:11 UTC (permalink / raw)
  To: libc-alpha


While digging for some low-hanging fruit in "make" times, I did this:

diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
index 919bbae253..7088ef6996 100755
--- a/scripts/merge-test-results.sh
+++ b/scripts/merge-test-results.sh
@@ -35,7 +35,11 @@ case $type in
     subdir=${subdir:+$subdir/}
     for t in "$@"; do
       if [ -s "$objpfx$t.test-result" ]; then
-	head -n1 "$objpfx$t.test-result"
+	  #head -n1 "$objpfx$t.test-result"
+	  exec 6<"$objpfx$t.test-result"
+	  read line <&6
+	  echo $line
+	  exec 6<&-
       else
 	echo "UNRESOLVED: $subdir$t"
       fi

That one instance of "head" is called over 6000 times per "make
check", and as it's the only non-builtin in that script, it adds about
11 seconds of overhead compared to just reading that one line with
builtins.

My question here is: how much of a time savings is worth the
complexity of said savings?

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

* Re: "make check" times
  2019-07-19 22:11 "make check" times DJ Delorie
@ 2019-07-20  0:05 ` Carlos O'Donell
  2019-07-20  1:31   ` DJ Delorie
  2020-03-11 19:32 ` DJ Delorie
  1 sibling, 1 reply; 28+ messages in thread
From: Carlos O'Donell @ 2019-07-20  0:05 UTC (permalink / raw)
  To: DJ Delorie, libc-alpha

On 7/19/19 6:11 PM, DJ Delorie wrote:
> While digging for some low-hanging fruit in "make" times, I did this:
> 
> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
> index 919bbae253..7088ef6996 100755
> --- a/scripts/merge-test-results.sh
> +++ b/scripts/merge-test-results.sh
> @@ -35,7 +35,11 @@ case $type in
>       subdir=${subdir:+$subdir/}
>       for t in "$@"; do
>         if [ -s "$objpfx$t.test-result" ]; then
> -	head -n1 "$objpfx$t.test-result"
> +	  #head -n1 "$objpfx$t.test-result"
> +	  exec 6<"$objpfx$t.test-result"
> +	  read line <&6
> +	  echo $line
> +	  exec 6<&-
>         else
>   	echo "UNRESOLVED: $subdir$t"
>         fi
> 
> That one instance of "head" is called over 6000 times per "make
> check", and as it's the only non-builtin in that script, it adds about
> 11 seconds of overhead compared to just reading that one line with
> builtins.
> 
> My question here is: how much of a time savings is worth the
> complexity of said savings?

One needs to tackle the problem the other way around.

* First determine those things we cannot change and remove them
   form the accounting.
   - We cannot avoid compiling each file.

* Whatever is left over after removing the things we can't
   avoid doing is our "overhead".

* Sort the "overhead" by the amount of time spent, and find ways
   to reduce it.

If the "overhead" is small, then there isn't much value in adding
complexity.

If the "overhead" is large, we may want to rewrite the whole build
system to get that time back.

Does that make sense?

I can't answer your question without knowing how much is 11 seconds
out of the total time taken.

If the build took 20 seconds to complete, then yes this is a valuable
change ;-)

-- 
Cheers,
Carlos.

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

* Re: "make check" times
  2019-07-20  0:05 ` Carlos O'Donell
@ 2019-07-20  1:31   ` DJ Delorie
  2019-07-20  1:45     ` Carlos O'Donell
  0 siblings, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2019-07-20  1:31 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: libc-alpha

"Carlos O'Donell" <carlos@redhat.com> writes:
> I can't answer your question without knowing how much is 11 seconds
> out of the total time taken.

In this case, it's about a third of "make check" if you don't need to
rebuild/recheck anything (reduces 30 seconds to 19 seconds), but
compared to a full test run (lots of minutes) it's in the noise.

I've been looking at it from a "why does running one test take so long"
viewpoint - when a test takes under a second, but "make check" takes 30
seconds, there's a lot of overhead.

>   - We cannot avoid compiling each file.

There are ways of optimizing this, too, though... like better
parallelism.

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

* Re: "make check" times
  2019-07-20  1:31   ` DJ Delorie
@ 2019-07-20  1:45     ` Carlos O'Donell
  0 siblings, 0 replies; 28+ messages in thread
From: Carlos O'Donell @ 2019-07-20  1:45 UTC (permalink / raw)
  To: DJ Delorie; +Cc: libc-alpha

On 7/19/19 9:31 PM, DJ Delorie wrote:
> "Carlos O'Donell" <carlos@redhat.com> writes:
>> I can't answer your question without knowing how much is 11 seconds
>> out of the total time taken.
> 
> In this case, it's about a third of "make check" if you don't need to
> rebuild/recheck anything (reduces 30 seconds to 19 seconds), but
> compared to a full test run (lots of minutes) it's in the noise.

Then I think this is a worthwhile fix.

In the old days I often would remove *one* output file to trigger the
test to be re-run and then just hit 'make check'.

This fix would, IIUC, accelerate that use case, which is probably a
common "newcomer" behaviour e.g. remove the test target result, and
rerun 'make check' to re-run that test.
  
> I've been looking at it from a "why does running one test take so long"
> viewpoint - when a test takes under a second, but "make check" takes 30
> seconds, there's a lot of overhead.

Agreed. It should be way way less.
  
>>    - We cannot avoid compiling each file.
> 
> There are ways of optimizing this, too, though... like better
> parallelism.

Agreed completely. To do that we need to start understanding our
dependency graph, and I know you know that ;-)

-- 
Cheers,
Carlos.

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

* Re: "make check" times
  2019-07-19 22:11 "make check" times DJ Delorie
  2019-07-20  0:05 ` Carlos O'Donell
@ 2020-03-11 19:32 ` DJ Delorie
  2020-04-01  3:37   ` Carlos O'Donell
  2020-04-01  8:02   ` Andreas Schwab
  1 sibling, 2 replies; 28+ messages in thread
From: DJ Delorie @ 2020-03-11 19:32 UTC (permalink / raw)
  To: libc-alpha


Pinging this ancient patch, now that I've finished the build times
report which answers the questions asked about this:

Original patch thread:
https://sourceware.org/pipermail/libc-alpha/2019-July/105187.html
Build times report thread:
https://sourceware.org/pipermail/libc-alpha/2020-March/111782.html

DJ Delorie <dj@redhat.com> writes:
> While digging for some low-hanging fruit in "make" times, I did this:
>
> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
> index 919bbae253..7088ef6996 100755
> --- a/scripts/merge-test-results.sh
> +++ b/scripts/merge-test-results.sh
> @@ -35,7 +35,11 @@ case $type in
>      subdir=${subdir:+$subdir/}
>      for t in "$@"; do
>        if [ -s "$objpfx$t.test-result" ]; then
> -	head -n1 "$objpfx$t.test-result"
> +	  #head -n1 "$objpfx$t.test-result"
> +	  exec 6<"$objpfx$t.test-result"
> +	  read line <&6
> +	  echo $line
> +	  exec 6<&-
>        else
>  	echo "UNRESOLVED: $subdir$t"
>        fi
>
> That one instance of "head" is called over 6000 times per "make
> check", and as it's the only non-builtin in that script, it adds about
> 11 seconds of overhead compared to just reading that one line with
> builtins.
>
> My question here is: how much of a time savings is worth the
> complexity of said savings?


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

* Re: "make check" times
  2020-03-11 19:32 ` DJ Delorie
@ 2020-04-01  3:37   ` Carlos O'Donell
  2020-04-01 17:10     ` Joseph Myers
  2020-04-01 19:35     ` DJ Delorie
  2020-04-01  8:02   ` Andreas Schwab
  1 sibling, 2 replies; 28+ messages in thread
From: Carlos O'Donell @ 2020-04-01  3:37 UTC (permalink / raw)
  To: DJ Delorie, libc-alpha

On 3/11/20 3:32 PM, DJ Delorie via Libc-alpha wrote:
> 
> Pinging this ancient patch, now that I've finished the build times
> report which answers the questions asked about this:
> 
> Original patch thread:
> https://sourceware.org/pipermail/libc-alpha/2019-July/105187.html
> Build times report thread:
> https://sourceware.org/pipermail/libc-alpha/2020-March/111782.html
> 
> DJ Delorie <dj@redhat.com> writes:
>> While digging for some low-hanging fruit in "make" times, I did this:
>>
>> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
>> index 919bbae253..7088ef6996 100755
>> --- a/scripts/merge-test-results.sh
>> +++ b/scripts/merge-test-results.sh
>> @@ -35,7 +35,11 @@ case $type in
>>      subdir=${subdir:+$subdir/}
>>      for t in "$@"; do
>>        if [ -s "$objpfx$t.test-result" ]; then
>> -	head -n1 "$objpfx$t.test-result"
>> +	  #head -n1 "$objpfx$t.test-result"
>> +	  exec 6<"$objpfx$t.test-result"
>> +	  read line <&6
>> +	  echo $line
>> +	  exec 6<&-
>>        else
>>  	echo "UNRESOLVED: $subdir$t"
>>        fi
>>
>> That one instance of "head" is called over 6000 times per "make
>> check", and as it's the only non-builtin in that script, it adds about
>> 11 seconds of overhead compared to just reading that one line with
>> builtins.
>>
>> My question here is: how much of a time savings is worth the
>> complexity of said savings?
> 

This is worth it.

OK for master.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

-- 
Cheers,
Carlos.


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

* Re: "make check" times
  2020-03-11 19:32 ` DJ Delorie
  2020-04-01  3:37   ` Carlos O'Donell
@ 2020-04-01  8:02   ` Andreas Schwab
  2020-04-01 16:41     ` DJ Delorie
  1 sibling, 1 reply; 28+ messages in thread
From: Andreas Schwab @ 2020-04-01  8:02 UTC (permalink / raw)
  To: DJ Delorie via Libc-alpha

On Mär 11 2020, DJ Delorie via Libc-alpha wrote:

>> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
>> index 919bbae253..7088ef6996 100755
>> --- a/scripts/merge-test-results.sh
>> +++ b/scripts/merge-test-results.sh
>> @@ -35,7 +35,11 @@ case $type in
>>      subdir=${subdir:+$subdir/}
>>      for t in "$@"; do
>>        if [ -s "$objpfx$t.test-result" ]; then
>> -	head -n1 "$objpfx$t.test-result"
>> +	  #head -n1 "$objpfx$t.test-result"
>> +	  exec 6<"$objpfx$t.test-result"
>> +	  read line <&6
>> +	  echo $line
>> +	  exec 6<&-

Why do you need to use the exec dance?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: "make check" times
  2020-04-01  8:02   ` Andreas Schwab
@ 2020-04-01 16:41     ` DJ Delorie
  2020-04-01 17:50       ` Andreas Schwab
  0 siblings, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2020-04-01 16:41 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha


Andreas Schwab <schwab@linux-m68k.org> writes:
> Why do you need to use the exec dance?

Is "read line <$file" portable posix shell?


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

* Re: "make check" times
  2020-04-01  3:37   ` Carlos O'Donell
@ 2020-04-01 17:10     ` Joseph Myers
  2020-04-01 18:53       ` Carlos O'Donell
  2020-04-01 19:35     ` DJ Delorie
  1 sibling, 1 reply; 28+ messages in thread
From: Joseph Myers @ 2020-04-01 17:10 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: DJ Delorie, libc-alpha

On Tue, 31 Mar 2020, Carlos O'Donell via Libc-alpha wrote:

> >> That one instance of "head" is called over 6000 times per "make
> >> check", and as it's the only non-builtin in that script, it adds about
> >> 11 seconds of overhead compared to just reading that one line with
> >> builtins.
> >>
> >> My question here is: how much of a time savings is worth the
> >> complexity of said savings?
> > 
> 
> This is worth it.
> 
> OK for master.

It definitely needs a comment in the script explaining that it's 
deliberately using only built-in shell functionality for speed.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: "make check" times
  2020-04-01 16:41     ` DJ Delorie
@ 2020-04-01 17:50       ` Andreas Schwab
  2020-04-01 18:39         ` DJ Delorie
  0 siblings, 1 reply; 28+ messages in thread
From: Andreas Schwab @ 2020-04-01 17:50 UTC (permalink / raw)
  To: DJ Delorie; +Cc: libc-alpha

On Apr 01 2020, DJ Delorie wrote:

> Andreas Schwab <schwab@linux-m68k.org> writes:
>> Why do you need to use the exec dance?
>
> Is "read line <$file" portable posix shell?

Sure, why not?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: "make check" times
  2020-04-01 17:50       ` Andreas Schwab
@ 2020-04-01 18:39         ` DJ Delorie
  0 siblings, 0 replies; 28+ messages in thread
From: DJ Delorie @ 2020-04-01 18:39 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

Andreas Schwab <schwab@linux-m68k.org> writes:
>> Is "read line <$file" portable posix shell?
>
> Sure, why not?

Well, when you put it like that...

Yeah, tested on solaris 9's various shells, works fine.


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

* Re: "make check" times
  2020-04-01 17:10     ` Joseph Myers
@ 2020-04-01 18:53       ` Carlos O'Donell
  0 siblings, 0 replies; 28+ messages in thread
From: Carlos O'Donell @ 2020-04-01 18:53 UTC (permalink / raw)
  To: Joseph Myers; +Cc: DJ Delorie, libc-alpha

On 4/1/20 1:10 PM, Joseph Myers wrote:
> On Tue, 31 Mar 2020, Carlos O'Donell via Libc-alpha wrote:
> 
>>>> That one instance of "head" is called over 6000 times per "make
>>>> check", and as it's the only non-builtin in that script, it adds about
>>>> 11 seconds of overhead compared to just reading that one line with
>>>> builtins.
>>>>
>>>> My question here is: how much of a time savings is worth the
>>>> complexity of said savings?
>>>
>>
>> This is worth it.
>>
>> OK for master.
> 
> It definitely needs a comment in the script explaining that it's 
> deliberately using only built-in shell functionality for speed.

Good point. Agreed.

-- 
Cheers,
Carlos.


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

* Re: "make check" times
  2020-04-01  3:37   ` Carlos O'Donell
  2020-04-01 17:10     ` Joseph Myers
@ 2020-04-01 19:35     ` DJ Delorie
  2020-04-01 19:41       ` Andreas Schwab
  1 sibling, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2020-04-01 19:35 UTC (permalink / raw)
  To: libc-alpha


Carlos writes:
> This is worth it.

Thanks - reviewed-by removed as the patch has changed.

Andreas writes:
> Why do you need to use the exec dance?

Uneeded, fixed.

Joseph writes:
> It definitely needs a comment in the script

Added.

Ok now?

From 7af6c4b85394fd6cd2988e73331d6a0bc4ee4882 Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Wed, 1 Apr 2020 15:33:00 -0400
Subject: Optimize scripts/merge-test-results.sh

The inner loop is called thousands of times per "make check" even
if there's otherwise nothing to do.  Avoid calling /bin/head all
those times when a builtin will do.

diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
index 573a44d8cf..6fd0a28dc8 100755
--- a/scripts/merge-test-results.sh
+++ b/scripts/merge-test-results.sh
@@ -35,7 +35,11 @@ case $type in
     subdir=${subdir:+$subdir/}
     for t in "$@"; do
       if [ -s "$objpfx$t.test-result" ]; then
-	head -n1 "$objpfx$t.test-result"
+	# This loop is called thousands of times even when there's
+	# nothing to do.  Avoid using non-built-in commands (like
+	# /bin/head) where possible.
+	read line <"$objpfx$t.test-result"
+	echo $line
       else
 	echo "UNRESOLVED: $subdir$t"
       fi


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

* Re: "make check" times
  2020-04-01 19:35     ` DJ Delorie
@ 2020-04-01 19:41       ` Andreas Schwab
  2020-04-01 19:45         ` DJ Delorie
  2020-04-02 23:05         ` Matt Turner
  0 siblings, 2 replies; 28+ messages in thread
From: Andreas Schwab @ 2020-04-01 19:41 UTC (permalink / raw)
  To: DJ Delorie via Libc-alpha

On Apr 01 2020, DJ Delorie via Libc-alpha wrote:

> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
> index 573a44d8cf..6fd0a28dc8 100755
> --- a/scripts/merge-test-results.sh
> +++ b/scripts/merge-test-results.sh
> @@ -35,7 +35,11 @@ case $type in
>      subdir=${subdir:+$subdir/}
>      for t in "$@"; do
>        if [ -s "$objpfx$t.test-result" ]; then
> -	head -n1 "$objpfx$t.test-result"
> +	# This loop is called thousands of times even when there's
> +	# nothing to do.  Avoid using non-built-in commands (like
> +	# /bin/head) where possible.
> +	read line <"$objpfx$t.test-result"
> +	echo $line

Please use proper quoting.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: "make check" times
  2020-04-01 19:41       ` Andreas Schwab
@ 2020-04-01 19:45         ` DJ Delorie
  2020-04-01 19:51           ` Andreas Schwab
  2020-04-02 23:05         ` Matt Turner
  1 sibling, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2020-04-01 19:45 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

Andreas Schwab <schwab@linux-m68k.org> writes:
>> -	head -n1 "$objpfx$t.test-result"
>> +	# This loop is called thousands of times even when there's
>> +	# nothing to do.  Avoid using non-built-in commands (like
>> +	# /bin/head) where possible.
>> +	read line <"$objpfx$t.test-result"
>> +	echo $line
>
> Please use proper quoting.

Could you be more specific?


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

* Re: "make check" times
  2020-04-01 19:45         ` DJ Delorie
@ 2020-04-01 19:51           ` Andreas Schwab
  2020-04-01 19:58             ` DJ Delorie
  0 siblings, 1 reply; 28+ messages in thread
From: Andreas Schwab @ 2020-04-01 19:51 UTC (permalink / raw)
  To: DJ Delorie; +Cc: libc-alpha

Never expand a variable unquoted.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: "make check" times
  2020-04-01 19:51           ` Andreas Schwab
@ 2020-04-01 19:58             ` DJ Delorie
  2020-04-01 20:10               ` Carlos O'Donell
  0 siblings, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2020-04-01 19:58 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha


Andreas Schwab <schwab@linux-m68k.org> writes:
> Never expand a variable unquoted.

How's this?  Also, comment updated to note we assume "echo" is a
builtin.

From 98e461fd50f1617acc78caeaa70547b92a54cf5c Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Wed, 1 Apr 2020 15:33:00 -0400
Subject: Optimize scripts/merge-test-results.sh

The inner loop is called thousands of times per "make check" even
if there's otherwise nothing to do.  Avoid calling /bin/head all
those times when a builtin will do.

diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
index 573a44d8cf..e75123a730 100755
--- a/scripts/merge-test-results.sh
+++ b/scripts/merge-test-results.sh
@@ -35,7 +35,12 @@ case $type in
     subdir=${subdir:+$subdir/}
     for t in "$@"; do
       if [ -s "$objpfx$t.test-result" ]; then
-	head -n1 "$objpfx$t.test-result"
+	# This loop is called thousands of times even when there's
+	# nothing to do.  Avoid using non-built-in commands (like
+	# /bin/head) where possible.  We assume "echo" is typically a
+	# built-in.
+	read line < "$objpfx$t.test-result"
+	echo "$line"
       else
 	echo "UNRESOLVED: $subdir$t"
       fi


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

* Re: "make check" times
  2020-04-01 19:58             ` DJ Delorie
@ 2020-04-01 20:10               ` Carlos O'Donell
  2020-04-01 23:01                 ` Joseph Myers
  0 siblings, 1 reply; 28+ messages in thread
From: Carlos O'Donell @ 2020-04-01 20:10 UTC (permalink / raw)
  To: DJ Delorie, Andreas Schwab; +Cc: libc-alpha

On 4/1/20 3:58 PM, DJ Delorie via Libc-alpha wrote:
> 
> Andreas Schwab <schwab@linux-m68k.org> writes:
>> Never expand a variable unquoted.
> 
> How's this?  Also, comment updated to note we assume "echo" is a
> builtin.
> 

LGTM. All variable expansions quoted. Non-builtins removed for performance.
Comment added to explain what we're doing.

Even if you could run `type -t echo` to determine if echo was a builitin,
I'm not sure we could do anything different with that knowledge. It's probably
still faster to do read+echo than head.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> From 98e461fd50f1617acc78caeaa70547b92a54cf5c Mon Sep 17 00:00:00 2001
> From: DJ Delorie <dj@redhat.com>
> Date: Wed, 1 Apr 2020 15:33:00 -0400
> Subject: Optimize scripts/merge-test-results.sh
> 
> The inner loop is called thousands of times per "make check" even
> if there's otherwise nothing to do.  Avoid calling /bin/head all
> those times when a builtin will do.
> 
> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
> index 573a44d8cf..e75123a730 100755
> --- a/scripts/merge-test-results.sh
> +++ b/scripts/merge-test-results.sh
> @@ -35,7 +35,12 @@ case $type in
>      subdir=${subdir:+$subdir/}
>      for t in "$@"; do
>        if [ -s "$objpfx$t.test-result" ]; then
> -	head -n1 "$objpfx$t.test-result"
> +	# This loop is called thousands of times even when there's
> +	# nothing to do.  Avoid using non-built-in commands (like
> +	# /bin/head) where possible.  We assume "echo" is typically a
> +	# built-in.
> +	read line < "$objpfx$t.test-result"
> +	echo "$line"
>        else
>  	echo "UNRESOLVED: $subdir$t"
>        fi
> 


-- 
Cheers,
Carlos.


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

* Re: "make check" times
  2020-04-01 20:10               ` Carlos O'Donell
@ 2020-04-01 23:01                 ` Joseph Myers
  2020-04-01 23:05                   ` DJ Delorie
  2020-10-05 21:17                   ` DJ Delorie
  0 siblings, 2 replies; 28+ messages in thread
From: Joseph Myers @ 2020-04-01 23:01 UTC (permalink / raw)
  To: Carlos O'Donell; +Cc: DJ Delorie, Andreas Schwab, libc-alpha

On Wed, 1 Apr 2020, Carlos O'Donell via Libc-alpha wrote:

> On 4/1/20 3:58 PM, DJ Delorie via Libc-alpha wrote:
> > 
> > Andreas Schwab <schwab@linux-m68k.org> writes:
> >> Never expand a variable unquoted.
> > 
> > How's this?  Also, comment updated to note we assume "echo" is a
> > builtin.
> > 
> 
> LGTM. All variable expansions quoted. Non-builtins removed for performance.
> Comment added to explain what we're doing.

Strictly speaking a safe "read" would be IFS= read -r line (IFS= to avoid 
stripping leading whitespace, -r to avoid backslash escapes being 
processed).  However, in this case that's not needed because valid test 
result lines do not start with whitespace and do not contain backslash 
(and nor do they start -n or -e, being cases where the "echo" would be 
unsafe).

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: "make check" times
  2020-04-01 23:01                 ` Joseph Myers
@ 2020-04-01 23:05                   ` DJ Delorie
  2020-10-05 21:17                   ` DJ Delorie
  1 sibling, 0 replies; 28+ messages in thread
From: DJ Delorie @ 2020-04-01 23:05 UTC (permalink / raw)
  To: Joseph Myers; +Cc: carlos, schwab, libc-alpha

Joseph Myers <joseph@codesourcery.com> writes:
> Strictly speaking a safe "read" would be IFS= read -r line (IFS= to avoid 
> stripping leading whitespace, -r to avoid backslash escapes being 
> processed).  However, in this case that's not needed because valid test 
> result lines do not start with whitespace and do not contain backslash 
> (and nor do they start -n or -e, being cases where the "echo" would be 
> unsafe).

I did think of those, but yeah, we're parsing our own data and it's
"safe".


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

* Re: "make check" times
  2020-04-01 19:41       ` Andreas Schwab
  2020-04-01 19:45         ` DJ Delorie
@ 2020-04-02 23:05         ` Matt Turner
  1 sibling, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-04-02 23:05 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: DJ Delorie via Libc-alpha

On Wed, Apr 1, 2020 at 12:42 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Apr 01 2020, DJ Delorie via Libc-alpha wrote:
>
> > diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
> > index 573a44d8cf..6fd0a28dc8 100755
> > --- a/scripts/merge-test-results.sh
> > +++ b/scripts/merge-test-results.sh
> > @@ -35,7 +35,11 @@ case $type in
> >      subdir=${subdir:+$subdir/}
> >      for t in "$@"; do
> >        if [ -s "$objpfx$t.test-result" ]; then
> > -     head -n1 "$objpfx$t.test-result"
> > +     # This loop is called thousands of times even when there's
> > +     # nothing to do.  Avoid using non-built-in commands (like
> > +     # /bin/head) where possible.
> > +     read line <"$objpfx$t.test-result"
> > +     echo $line
>
> Please use proper quoting.

I see a lot of replies from you (like this) that read as very aloof.
Just from a pragmatic perspective, explaining what you mean initially
would save you the inevitable round-trip.

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

* Re: "make check" times
  2020-04-01 23:01                 ` Joseph Myers
  2020-04-01 23:05                   ` DJ Delorie
@ 2020-10-05 21:17                   ` DJ Delorie
  2020-10-05 21:39                     ` Andreas Schwab
  1 sibling, 1 reply; 28+ messages in thread
From: DJ Delorie @ 2020-10-05 21:17 UTC (permalink / raw)
  To: Joseph Myers; +Cc: carlos, schwab, libc-alpha


Sorry for the delay.  I applied Joseph's suggestions, retested, and
committed the patch as attached.

From 43be1301f65f62b48ed6d200657d47c79ee22bc3 Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Wed, 1 Apr 2020 15:33:00 -0400
Subject: Optimize scripts/merge-test-results.sh

The inner loop is called thousands of times per "make check" even
if there's otherwise nothing to do.  Avoid calling /bin/head all
those times when a builtin will do.

diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
index 573a44d8cf..1e236db4a7 100755
--- a/scripts/merge-test-results.sh
+++ b/scripts/merge-test-results.sh
@@ -35,7 +35,12 @@ case $type in
     subdir=${subdir:+$subdir/}
     for t in "$@"; do
       if [ -s "$objpfx$t.test-result" ]; then
-	head -n1 "$objpfx$t.test-result"
+	# This loop is called thousands of times even when there's
+	# nothing to do.  Avoid using non-built-in commands (like
+	# /bin/head) where possible.  We assume "echo" is typically a
+	# built-in.
+	IFS= read -r line < "$objpfx$t.test-result"
+	echo "$line"
       else
 	echo "UNRESOLVED: $subdir$t"
       fi


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

* Re: "make check" times
  2020-10-05 21:17                   ` DJ Delorie
@ 2020-10-05 21:39                     ` Andreas Schwab
  2020-10-05 21:51                       ` DJ Delorie
  0 siblings, 1 reply; 28+ messages in thread
From: Andreas Schwab @ 2020-10-05 21:39 UTC (permalink / raw)
  To: DJ Delorie; +Cc: Joseph Myers, carlos, libc-alpha

On Okt 05 2020, DJ Delorie wrote:

> diff --git a/scripts/merge-test-results.sh b/scripts/merge-test-results.sh
> index 573a44d8cf..1e236db4a7 100755
> --- a/scripts/merge-test-results.sh
> +++ b/scripts/merge-test-results.sh
> @@ -35,7 +35,12 @@ case $type in
>      subdir=${subdir:+$subdir/}
>      for t in "$@"; do
>        if [ -s "$objpfx$t.test-result" ]; then
> -	head -n1 "$objpfx$t.test-result"
> +	# This loop is called thousands of times even when there's
> +	# nothing to do.  Avoid using non-built-in commands (like
> +	# /bin/head) where possible.  We assume "echo" is typically a
> +	# built-in.
> +	IFS= read -r line < "$objpfx$t.test-result"
> +	echo "$line"

If you want to avoid any interpretation you should use printf %s.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: "make check" times
  2020-10-05 21:39                     ` Andreas Schwab
@ 2020-10-05 21:51                       ` DJ Delorie
  2020-10-05 22:41                         ` Paul Eggert
  2020-10-06  7:36                         ` Andreas Schwab
  0 siblings, 2 replies; 28+ messages in thread
From: DJ Delorie @ 2020-10-05 21:51 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: joseph, carlos, libc-alpha


Is printf a guaranteed builtin in posix shells?

(and as noted back when, the data we're reading does not require such
protections anyway)


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

* Re: "make check" times
  2020-10-05 21:51                       ` DJ Delorie
@ 2020-10-05 22:41                         ` Paul Eggert
  2020-10-05 22:48                           ` DJ Delorie
  2020-10-06  7:36                         ` Andreas Schwab
  1 sibling, 1 reply; 28+ messages in thread
From: Paul Eggert @ 2020-10-05 22:41 UTC (permalink / raw)
  To: DJ Delorie; +Cc: Andreas Schwab, libc-alpha, joseph

On 10/5/20 2:51 PM, DJ Delorie via Libc-alpha wrote:
> Is printf a guaranteed builtin in posix shells?

It's not a "Special Built-In Utility" in the POSIX sense, but neither are 'echo' 
or 'read'.

To answer what I think is your real question, these days I believe that "printf 
'%s\n' 'FOO'" is typically nearly as fast as "echo 'FOO'" on the shells that 
glibc developers use. I just tried a simple benchmark with bash and dash on 
Ubuntu 20.04 x86-64 with a loop that just output 'x' on a line, and the echo 
version was about 20% faster with dash and about 15% faster with Bash.

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

* Re: "make check" times
  2020-10-05 22:41                         ` Paul Eggert
@ 2020-10-05 22:48                           ` DJ Delorie
  0 siblings, 0 replies; 28+ messages in thread
From: DJ Delorie @ 2020-10-05 22:48 UTC (permalink / raw)
  To: Paul Eggert; +Cc: libc-alpha

Paul Eggert <eggert@cs.ucla.edu> writes:
> To answer what I think is your real question, these days I believe that "printf 
> '%s\n' 'FOO'" is typically nearly as fast as "echo 'FOO'" on the shells that 
> glibc developers use. I just tried a simple benchmark with bash and dash on 
> Ubuntu 20.04 x86-64 with a loop that just output 'x' on a line, and the echo 
> version was about 20% faster with dash and about 15% faster with Bash.

Oooo, that.  Faster is better :-)


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

* Re: "make check" times
  2020-10-05 21:51                       ` DJ Delorie
  2020-10-05 22:41                         ` Paul Eggert
@ 2020-10-06  7:36                         ` Andreas Schwab
  2020-10-06 15:32                           ` DJ Delorie
  1 sibling, 1 reply; 28+ messages in thread
From: Andreas Schwab @ 2020-10-06  7:36 UTC (permalink / raw)
  To: DJ Delorie; +Cc: joseph, carlos, libc-alpha

On Okt 05 2020, DJ Delorie wrote:

> (and as noted back when, the data we're reading does not require such
> protections anyway)

Neither is read -r needed.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* Re: "make check" times
  2020-10-06  7:36                         ` Andreas Schwab
@ 2020-10-06 15:32                           ` DJ Delorie
  0 siblings, 0 replies; 28+ messages in thread
From: DJ Delorie @ 2020-10-06 15:32 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: joseph, carlos, libc-alpha

Andreas Schwab <schwab@linux-m68k.org> writes:
>> (and as noted back when, the data we're reading does not require such
>> protections anyway)
>
> Neither is read -r needed.

True, but I felt that not including that and IFS= meant I was putting a
bad example out there for others to follow.


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

end of thread, other threads:[~2020-10-06 15:32 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 22:11 "make check" times DJ Delorie
2019-07-20  0:05 ` Carlos O'Donell
2019-07-20  1:31   ` DJ Delorie
2019-07-20  1:45     ` Carlos O'Donell
2020-03-11 19:32 ` DJ Delorie
2020-04-01  3:37   ` Carlos O'Donell
2020-04-01 17:10     ` Joseph Myers
2020-04-01 18:53       ` Carlos O'Donell
2020-04-01 19:35     ` DJ Delorie
2020-04-01 19:41       ` Andreas Schwab
2020-04-01 19:45         ` DJ Delorie
2020-04-01 19:51           ` Andreas Schwab
2020-04-01 19:58             ` DJ Delorie
2020-04-01 20:10               ` Carlos O'Donell
2020-04-01 23:01                 ` Joseph Myers
2020-04-01 23:05                   ` DJ Delorie
2020-10-05 21:17                   ` DJ Delorie
2020-10-05 21:39                     ` Andreas Schwab
2020-10-05 21:51                       ` DJ Delorie
2020-10-05 22:41                         ` Paul Eggert
2020-10-05 22:48                           ` DJ Delorie
2020-10-06  7:36                         ` Andreas Schwab
2020-10-06 15:32                           ` DJ Delorie
2020-04-02 23:05         ` Matt Turner
2020-04-01  8:02   ` Andreas Schwab
2020-04-01 16:41     ` DJ Delorie
2020-04-01 17:50       ` Andreas Schwab
2020-04-01 18:39         ` DJ Delorie

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