pgbench randomness initialization
От | Andres Freund |
---|---|
Тема | pgbench randomness initialization |
Дата | |
Msg-id | 20160407082711.q7iq3ykffqxcszkv@alap3.anarazel.de обсуждение исходный текст |
Ответы |
Re: pgbench randomness initialization
|
Список | pgsql-hackers |
Hi, pondering http://archives.postgresql.org/message-id/CA%2BTgmoZJdA6K7-17K4A48rVB0UPR98HVuaNcfNNLrGsdb1uChg%40mail.gmail.com et al I was wondering why it's a good idea for pgbench to doINSTR_TIME_SET_CURRENT(start_time);srandom((unsigned int) INSTR_TIME_GET_MICROSEC(start_time)); to initialize randomness and thenfor (i = 0; i < nthreads; i++) thread->random_state[0] = random(); thread->random_state[1]= random(); thread->random_state[2] = random(); to initialize the individual thread random state which is then used by pg_erand48(). To me it seems better to instead initialize srandom() with a known value (say, uh, 0). Or even better don't use random() at all, and fill a global pg_erand48() with a known state; and use pg_erand48() to initialize the thread states. Obviously that doesn't make pgbench entirely reproducible, but it seems a lot better than now. Individual threads would do work in a reproducible order. I see very little reason to have the current behaviour, or at the very least not by default. Greetings, Andres Freund
В списке pgsql-hackers по дате отправления: