[PATCH] stdlib: Tune down thread arc4random tests
Noah Goldstein
goldstein.w.n@gmail.com
Wed Aug 2 16:44:10 GMT 2023
On Thu, Jun 1, 2023 at 11:00 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> There is no per-thread state on current arc4random implementation,
> so limit the maximum number of threads. The tests now run on 1s
> instead of 8s on a aarch64 system with 160 cores.
>
> Checked on aarch64-linux-gnu.
> ---
> stdlib/tst-arc4random-thread.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/stdlib/tst-arc4random-thread.c b/stdlib/tst-arc4random-thread.c
> index 010828920e..4f8cc27b03 100644
> --- a/stdlib/tst-arc4random-thread.c
> +++ b/stdlib/tst-arc4random-thread.c
> @@ -25,6 +25,7 @@
> #include <support/namespace.h>
> #include <support/support.h>
> #include <support/xthread.h>
> +#include <sys/param.h>
>
> /* Number of arc4random_buf calls per thread. */
> enum { count_per_thread = 2048 };
> @@ -35,6 +36,9 @@ enum { inner_threads = 4 };
> /* Number of threads launching other threads. */
> static int outer_threads = 1;
>
> +/* Maximum number of other threads. */
> +enum { max_outer_threads = 4 };
> +
> /* Number of launching rounds performed by the outer threads. */
> enum { outer_rounds = 10 };
>
> @@ -337,7 +341,8 @@ do_test (void)
> {
> unsigned int ncpus = CPU_COUNT (&cpuset);
> /* Limit the number to not overload the system. */
> - outer_threads = (ncpus / 2) / inner_threads ?: 1;
> + outer_threads = MIN ((ncpus / 2) / inner_threads ?: 1,
> + max_outer_threads);
Since this is properly no random state how about just MAX(ncpus, 2)?
> }
>
> printf ("info: outer_threads=%d inner_threads=%d\n", outer_threads,
> --
> 2.34.1
>
More information about the Libc-alpha
mailing list