Skip to content

Commit b29429e

Browse files
lukechEvergreen Agent
authored andcommitted
Import wiredtiger: a7f6fa07f90d701b73206a768ae0cc6fb50ff9b4 from branch mongodb-master
ref: 2a414fdee9..a7f6fa07f9 for: 6.3.0-rc0 WT-10338 Ensure threads get uncorrelated sequences of random values.
1 parent 0ecf915 commit b29429e

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/third_party/wiredtiger/import.data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"vendor": "wiredtiger",
33
"github": "wiredtiger/wiredtiger.git",
44
"branch": "mongodb-master",
5-
"commit": "2a414fdee92400156ab05de39b6f0c2363a73469"
5+
"commit": "a7f6fa07f90d701b73206a768ae0cc6fb50ff9b4"
66
}

src/third_party/wiredtiger/src/support/rand.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,25 @@ __wt_random_init_seed(WT_SESSION_IMPL *session, WT_RAND_STATE volatile *rnd_stat
8383
{
8484
struct timespec ts;
8585
WT_RAND_STATE rnd;
86-
uint32_t v;
86+
uintmax_t threadid;
8787

8888
__wt_epoch(session, &ts);
89+
__wt_thread_id(&threadid);
8990

9091
/*
91-
* Use this, instead of __wt_random_init if we need to vary the initial state of the RNG. This
92-
* is (currently) only used by test programs, where, for example, an initial set of test data is
92+
* Use this, instead of __wt_random_init, to vary the initial state of the RNG. This is
93+
* (currently) only used by test programs, where, for example, an initial set of test data is
9394
* created by a single thread, and we want more variability in the initial state of the RNG.
9495
*
95-
* Take the seconds and nanoseconds from the clock as seeds, and smear that value across the
96-
* value space, using algorithm "xor" from Marsaglia, "Xorshift RNGs".
96+
* Take the seconds and nanoseconds from the clock together with the thread ID to generate a
97+
* 64-bit seed, then smear that value using algorithm "xor" from Marsaglia, "Xorshift RNGs".
9798
*/
98-
v = (uint32_t)ts.tv_sec;
99-
v ^= v << 13;
100-
v ^= v >> 17;
101-
v ^= v << 5;
102-
M_W(rnd) = v + 521288629;
103-
104-
v = (uint32_t)ts.tv_nsec;
105-
v ^= v << 13;
106-
v ^= v >> 17;
107-
v ^= v << 5;
108-
M_Z(rnd) = v + 362436069;
99+
M_W(rnd) = (uint32_t)ts.tv_sec ^ 521288629;
100+
M_Z(rnd) = (uint32_t)ts.tv_nsec ^ 362436069;
101+
rnd.v ^= (uint64_t)threadid;
102+
rnd.v ^= rnd.v << 13;
103+
rnd.v ^= rnd.v >> 7;
104+
rnd.v ^= rnd.v << 17;
109105

110106
*rnd_state = rnd;
111107
}

0 commit comments

Comments
 (0)