]> git.kaiwu.me - haproxy.git/commit
MINOR: tools: provide a function to generate a hashed random pair
authorWilly Tarreau <w@1wt.eu>
Mon, 25 May 2026 15:30:58 +0000 (17:30 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 26 May 2026 11:13:24 +0000 (13:13 +0200)
commit26c3b3f41d37f058f358565fd8c6c84823be18f1
tree94d035b155517f113c224aa39a6a8087faba470f
parent9b6389c8a007cd86ebd61f1d3b33c13468abf26d
MINOR: tools: provide a function to generate a hashed random pair

A lot of places call two ha_random64() in a row to generate a 128-bit
random. While it's now safe against linear analysis thanks to the XXH64
call, it's still particularly expensive due to the lock.

Here we introduce a new function ha_random64_pair_hashed(), that feeds
two uint64_t with a hash of the PRNG's internal state, and make it
advance. This will cut in half the number of calls to ha_random64()
and should recover a part of the performance lost in the lock. For
now it's not used.
include/haproxy/tools-t.h
include/haproxy/tools.h
src/tools.c