From: Willy Tarreau Date: Sat, 17 Apr 2021 13:50:28 +0000 (+0200) Subject: MINOR: pools: use cheaper randoms for fault injections X-Git-Tag: v2.4-dev17~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20f88abad5f2a7bca45d9a9288c93d8cc259ca70;p=thirdparty%2Fhaproxy.git MINOR: pools: use cheaper randoms for fault injections ha_random() is quite heavy and uses atomic ops or even a lock on some architectures. Here we don't seek good randoms, just statistical ones, so let's use the statistical prng instead. --- diff --git a/src/pool.c b/src/pool.c index db5d931015..48cc46788b 100644 --- a/src/pool.c +++ b/src/pool.c @@ -498,9 +498,7 @@ int mem_should_fail(const struct pool_head *pool) int ret = 0; if (mem_fail_rate > 0 && !(global.mode & MODE_STARTING)) { - int randnb = ha_random() % 100; - - if (mem_fail_rate > randnb) + if (mem_fail_rate > statistical_prng_range(100)) ret = 1; else ret = 0;