mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 13:51:26 +02:00
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:
parent
06e69b556c
commit
1adaddb494
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user