From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 2D9EF3858429; Fri, 29 Jul 2022 12:24:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D9EF3858429 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc] stdlib: Tuned down tst-arc4random-thread internal parameters X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/master X-Git-Oldrev: bce0218d9a8355f82f76543fc4acdc721e22dcd6 X-Git-Newrev: 35363b53cef00c3b9886b2c1f45612869f304960 Message-Id: <20220729122413.2D9EF3858429@sourceware.org> Date: Fri, 29 Jul 2022 12:24:13 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2022 12:24:13 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=35363b53cef00c3b9886b2c1f45612869f304960 commit 35363b53cef00c3b9886b2c1f45612869f304960 Author: Adhemerval Zanella Date: Wed Jul 27 08:59:15 2022 -0300 stdlib: Tuned down tst-arc4random-thread internal parameters With new arc4random implementation, the internal parameters might require a lot of runtime and/or trigger some contention on older kernels (which might trigger spurious timeout failures). Also, since we are now testing getrandom entropy instead of an userspace RNG, there is no much need to extensive testing. With this change the tst-arc4random-thread goes from about 1m to 5s on a Ryzen 9 with 5.15.0-41-generic. Checked on x86_64-linux-gnu. Reviewed-by: Szabolcs Nagy Diff: --- stdlib/tst-arc4random-thread.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/stdlib/tst-arc4random-thread.c b/stdlib/tst-arc4random-thread.c index 3373d4d446..daba828fad 100644 --- a/stdlib/tst-arc4random-thread.c +++ b/stdlib/tst-arc4random-thread.c @@ -17,23 +17,23 @@ . */ #include +#include #include -#include #include +#include #include #include #include #include /* Number of arc4random_buf calls per thread. */ -enum { count_per_thread = 5000 }; +enum { count_per_thread = 2048 }; /* Number of threads computing randomness. */ -enum { inner_threads = 5 }; +enum { inner_threads = 4 }; -/* Number of threads launching other threads. Chosen as to not to - overload the system. */ -enum { outer_threads = 7 }; +/* Number of threads launching other threads. */ +static int outer_threads = 1; /* Number of launching rounds performed by the outer threads. */ enum { outer_rounds = 10 }; @@ -331,6 +331,18 @@ do_test_func (const char *fname, void (*func)(unsigned char *, size_t)) static int do_test (void) { + /* Do not run more threads than the maximum of schedulable CPUs. */ + cpu_set_t cpuset; + if (sched_getaffinity (0, sizeof cpuset, &cpuset) == 0) + { + unsigned int ncpus = CPU_COUNT (&cpuset); + /* Limit the number to not overload the system. */ + outer_threads = (ncpus / 2) / inner_threads ?: 1; + } + + printf ("info: outer_threads=%d inner_threads=%d\n", outer_threads, + inner_threads); + do_test_func ("arc4random", generate_arc4random); do_test_func ("arc4random_buf", generate_arc4random_buf); do_test_func ("arc4random_uniform", generate_arc4random_uniform);