From: Willy Tarreau Date: Thu, 24 Nov 2022 13:54:29 +0000 (+0100) Subject: MINOR: sample: make the rand() sample fetch function use the statistical_prng X-Git-Tag: v2.7-dev10~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95f40c698d3ef3ad25fded5a7c35e2d108d2b542;p=thirdparty%2Fhaproxy.git MINOR: sample: make the rand() sample fetch function use the statistical_prng Emeric noticed that producing many randoms to fill a stick table was saturating on the rand_lock. Since 2.4 we have the statistical PRNG for low-quality randoms like this one, there is no point in using the one that was originally implemented for the purpose of creating safe UUIDs, since the doc itself clearly states that these randoms are not secure and they have not been in the past either. With this change, locking contention is completely gone. --- diff --git a/src/sample.c b/src/sample.c index a3acfef143..62a372b81c 100644 --- a/src/sample.c +++ b/src/sample.c @@ -4096,7 +4096,7 @@ smp_fetch_thread(const struct arg *args, struct sample *smp, const char *kw, voi static int smp_fetch_rand(const struct arg *args, struct sample *smp, const char *kw, void *private) { - smp->data.u.sint = ha_random32(); + smp->data.u.sint = statistical_prng(); /* reduce if needed. Don't do a modulo, use all bits! */ if (args[0].type == ARGT_SINT)