From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by sourceware.org (Postfix) with ESMTPS id C8C183857005 for ; Wed, 27 Jul 2022 13:10:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C8C183857005 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-10e3852b463so5850043fac.3 for ; Wed, 27 Jul 2022 06:10:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=fsB2xib6f6857h5jq0UdYs690JWpTY9uuSs6fOdnLxc=; b=k9U0TXA8jvdOv6i0UtAFaHFWFqbnxuAUcNgNJZLe60ZP+Cpo/60uPwSf6mGZpbKQyW vKFN/hIP87jE/sARMfqjZPElkwrT17J1lkHovqloAjiDnkuGFxA8M00uW1Q2nhUJre6X eRk1xARA2y5QtUuU23dLa1ksUUElmBLWqMgpw8Pn+QXq8G5NJWkXwis+uMCRvrDtTk/0 W0+vl7C5SVtqzpQehGUSc+DQ2qfXyhKjdTF5HK1IucccSRE/ZGgOXxcM9BQ5Anehg87l a+oLWLG8zdSTG/ZWqnlFm7HMrL9FX7lPlu/OZENrd1f42D/96x6u4SPsN2yLQP+RidC8 5lEg== X-Gm-Message-State: AJIora8iZqin41sfosrD+l7yrELaWQYdY9X82jx4givmHeNpjazAWCha DK59Sf7hDnYJelKw2ZzgIPhrVpqvkj/eYQ== X-Google-Smtp-Source: AGRyM1tKy/t93BuX8t8s1nFnHYAi9GANcLpgX8qL8EPKjNys77tXnEj+404e9McnCd17nkPvAaWMdg== X-Received: by 2002:a05:6870:1607:b0:101:a7a7:3ece with SMTP id b7-20020a056870160700b00101a7a73ecemr1994410oae.99.1658927435538; Wed, 27 Jul 2022 06:10:35 -0700 (PDT) Received: from mandiga.. ([2804:431:c7cb:8ded:40b4:899c:8c0b:f670]) by smtp.gmail.com with ESMTPSA id l13-20020a05687014cd00b000f346e6d786sm8814607oab.54.2022.07.27.06.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 06:10:35 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Florian Weimer , "Jason A . Donenfeld" , Carlos O'Donell Subject: [PATCH v2] stdlib: Tuned down tst-arc4random-thread internal parameters Date: Wed, 27 Jul 2022 10:10:31 -0300 Message-Id: <20220727131031.2016648-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2022 13:10:44 -0000 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. --- stdlib/tst-arc4random-thread.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/stdlib/tst-arc4random-thread.c b/stdlib/tst-arc4random-thread.c index 3373d4d446..2441a44bf8 100644 --- a/stdlib/tst-arc4random-thread.c +++ b/stdlib/tst-arc4random-thread.c @@ -24,16 +24,16 @@ #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,15 @@ 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 online CPUs. */ + long int cpus = sysconf (_SC_NPROCESSORS_ONLN); + if (cpus != -1) + /* Limit the number to not overload the system. */ + outer_threads = (cpus / 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); -- 2.34.1