Patchwork Speedup various nptl/tst-cancel20 and nptl/tst-cancel21 tests.

login
register
mail settings
Submitter Stefan Liebler
Date Sept. 12, 2019, 12:15 p.m.
Message ID <c2818c4a-3afe-e691-6589-1c24651b43a5@linux.ibm.com>
Download mbox | patch
Permalink /patch/34513/
State New
Headers show

Comments

Stefan Liebler - Sept. 12, 2019, 12:15 p.m.
Hi,

each of thease tests - tst-cancel20, tst-cancelx20, tst-cancel21,
tst-cancelx21 and tst-cancel21-static - runs for 8s.

do_one_test is called 4 times. Either in do_one_test (tst-cancel20.c)
or in tf (tst-cancel21.c) "sleep (1)" is called 2 times.

This patch reduces the sleep time. Using usleep (5ms) leads to a
runtime of one tst-cancel... invocation of roughly 40ms instead of 8s.
As the nptl tests run in sequence, this patch saves roughly 39s of
runtime for "make check".

Bye,
Stefan

ChangeLog:

	* nptl/tst-cancel20.c (do_one_test): Reduce sleep times.
	* nptl/tst-cancel21.c (tf): Likewise.
Carlos O'Donell - Sept. 12, 2019, 2:07 p.m.
On 9/12/19 8:15 AM, Stefan Liebler wrote:
> Hi,
> 
> each of thease tests - tst-cancel20, tst-cancelx20, tst-cancel21,
> tst-cancelx21 and tst-cancel21-static - runs for 8s.
> 
> do_one_test is called 4 times. Either in do_one_test (tst-cancel20.c)
> or in tf (tst-cancel21.c) "sleep (1)" is called 2 times.
> 
> This patch reduces the sleep time. Using usleep (5ms) leads to a
> runtime of one tst-cancel... invocation of roughly 40ms instead of 8s.
> As the nptl tests run in sequence, this patch saves roughly 39s of
> runtime for "make check".
> 
> Bye,
> Stefan
> 
> ChangeLog:
> 
>     * nptl/tst-cancel20.c (do_one_test): Reduce sleep times.
>     * nptl/tst-cancel21.c (tf): Likewise.

I see two possible solutions:

(a) Explain in detail why the sleep is needed, and why reducing
    the sleep is safe.

(b) Remove the sleep and use proper barriers to provide the
    synchronization the test is using sleep to accomplish.

Your current patch does (a) without explaining why it is safe
to reduce the sleep period, and that the test continues to test
what it was written to test.

Is it safe to reduce the sleep timing?

Why is it there?

Patch

commit e89d0d6819799737a6133d3994e6f38d00c745e4
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Wed Sep 11 09:43:08 2019 +0200

    Speedup various nptl/tst-cancel20 and nptl/tst-cancel21 tests.
    
    Each of thease tests - tst-cancel20, tst-cancelx20, tst-cancel21,
    tst-cancelx21 and tst-cancel21-static - runs for 8s.
    
    do_one_test is called 4 times. Either in do_one_test (tst-cancel20.c)
    or in tf (tst-cancel21.c) "sleep (1)" is called 2 times.
    
    This patch reduces the sleep time. Using usleep (5ms) leads to a
    runtime of one tst-cancel... invocation of roughly 40ms instead of 8s.
    As the nptl tests run in sequence, this patch saves roughly 39s of
    runtime for "make check".
    
    ChangeLog:
    
            * nptl/tst-cancel20.c (do_one_test): Reduce sleep times.
            * nptl/tst-cancel21.c (tf): Likewise.

diff --git a/nptl/tst-cancel20.c b/nptl/tst-cancel20.c
index 96dfb71fa9..abf250d508 100644
--- a/nptl/tst-cancel20.c
+++ b/nptl/tst-cancel20.c
@@ -126,7 +126,7 @@  do_one_test (void)
       return 1;
     }
 
-  sleep (1);
+  usleep (5000);
 
   r = pthread_kill (th, SIGHUP);
   if (r)
@@ -137,7 +137,7 @@  do_one_test (void)
     }
 
   while (in_sh_body == 0)
-    sleep (1);
+    usleep (5000);
 
   if (pthread_cancel (th) != 0)
     {
diff --git a/nptl/tst-cancel21.c b/nptl/tst-cancel21.c
index 361510b027..371759c551 100644
--- a/nptl/tst-cancel21.c
+++ b/nptl/tst-cancel21.c
@@ -104,7 +104,7 @@  tf (void *arg)
       exit (1);
     }
 
-  sleep (1);
+  usleep (5000);
 
   r = pthread_kill (th, SIGHUP);
   if (r)
@@ -115,7 +115,7 @@  tf (void *arg)
     }
 
   while (in_sh_body == 0)
-    sleep (1);
+    usleep (5000);
 
   if (pthread_cancel (th) != 0)
     {