OPTIM: lb-random: use a cheaper PRNG to pick a server

The PRNG used by the "random" LB algorithm was the central one which tries
hard to produce "correct" (i.e. hardly predictable) values suitable for use
in UUIDs or cookies. It's much too expensive for pure load balancing where
a cheaper thread-local PRNG is sufficient, and the current PRNG is part of
the hot places when running with many threads.

Let's switch to the stastistical PRNG instead, it's thread-local, very
fast, and with a period of (2^32)-1 which is more than enough to decide
on a server.
This commit is contained in:
Ubuntu 2021-03-01 07:57:54 +00:00 committed by Willy Tarreau
parent 06e69b556c
commit 1adaddb494

View File

@ -535,7 +535,7 @@ static struct server *get_server_rnd(struct stream *s, const struct server *avoi
curr = NULL;
do {
prev = curr;
hash = ha_random32();
hash = statistical_prng();
curr = chash_get_server_hash(px, hash, avoid);
if (!curr)
break;