OPTIM: lb-random: use a cheaper PRNG to pick a server
authorUbuntu <ubuntu@ip-172-31-37-79.us-east-2.compute.internal>
Mon, 1 Mar 2021 07:57:54 +0000 (07:57 +0000)
committerWilly Tarreau <w@1wt.eu>
Fri, 5 Mar 2021 07:30:08 +0000 (08:30 +0100)
commit1adaddb494e16f365955af52785e31e522af55bd
tree42e19696377419a5c2c19bfd0e42e008251b86e8
parent06e69b556ce5839f74d82698350301d50e3b46ca
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.
src/backend.c