Re: pgbench - add pseudo-random permutation function
От | Fabien COELHO |
---|---|
Тема | Re: pgbench - add pseudo-random permutation function |
Дата | |
Msg-id | alpine.DEB.2.22.394.2103311933490.620883@pseudo обсуждение исходный текст |
Ответ на | Re: pgbench - add pseudo-random permutation function (Dean Rasheed <dean.a.rasheed@gmail.com>) |
Ответы |
Re: pgbench - add pseudo-random permutation function
|
Список | pgsql-hackers |
Hello Dean, > OK, attached is an update making this change and simplifying the rotate > code, which hopefully just leaves the question of what (if anything) to > do with pg_erand48(). Yep. While looking at it, I have some doubts on this part: m = (uint64) (pg_erand48(random_state.xseed) * (mask + 1)) | 1; r = (uint64) (pg_erand48(random_state.xseed) * (mask + 1)); r = (uint64) (pg_erand48(random_state.xseed) * size); I do not understand why the random values are multiplied by anything in the first place… This one looks like a no-op : r = (uint64) (pg_erand48(random_state.xseed) * size); v = (v + r) % size; v = (v + r) % size = (v + rand * size) % size =? (v % size + rand * size % size) % size =? (v % size + 0) % size = v % size = v I'm also skeptical about this one: r = (uint64) (pg_erand48(random_state.xseed) * (mask + 1)); if (v <= mask) v = ((v * m) ^ r) & mask; v = ((v * m) ^ r) & mask = ((v * m) ^ r) % (mask+1) = ((v * m) ^ (rand * (mask+1))) % (mask+1) =? ((v * m) % (mask+1)) ^ (rand * (mask+1) % (mask+1)) =? ((v * m) % (mask+1)) ^ (0) = (v * m) & mask Or possibly I'm missing something obvious and I'm wrong with my arithmetic? -- Fabien.
В списке pgsql-hackers по дате отправления: