Summary
Our random-number generator function __wt_random(), even when it is initialized from different seeds, eventually converges to the same state.
Analysis
The convergence happen as soon as z or w become 0:
if (z == 0 || w == 0) {
__wt_random_init(&rnd);
w = M_W(rnd);
z = M_Z(rnd);
}
Function __wt_random_init() uses fixed values, so as soon as this branch is hit, the generation of random numbers across different runs (even with the same seed) converges.
Near-instant convergence
To make the matter worse, this converges instantly in test push_pull! The test initializes the seed like this:
/* Seed the random number generator */
v = (uint32_t)getpid() + num_records + (2 * counter);
__wt_random_init_custom_seed(&rnd, v);
This generates a number that is less than 2^32, which means that value z of the test state starts by being initialized to 0. This triggers re-initialization to the fixed values as explained above on the first use of the function.
- is related to
-
WT-2177 Add an optional per-thread seed to random number generator
- Closed