Re: pgbench - add pseudo-random permutation function - Mailing list pgsql-hackers

From Hironobu SUZUKI
Subject Re: pgbench - add pseudo-random permutation function
Date
Msg-id 29821e16-2877-4681-c9fd-3b3fdbfe089d@interdb.jp
Whole thread Raw
In response to Re: pgbench - add pseudo-random permutation function  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: pgbench - add pseudo-random permutation function  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
Hello,

 > Also, the alternate implementation should not change the result, so
 > something looks amiss in your version. Moreover, I'm unclear how to
 > implement an overflow multiply with the safe no overflow version.
(snip)

I made an honest mistake. I had assumed the modulo number of Knuth's LCG 
is (2 ^ 64 - 1).


BTW, I found other overflow issue.
In pseudorandom_perm(), `modular_multiply() + (key >> LCG_SHIFT)` may 
overflow if the result of modular_multiply() is large. Therefore, I've 
improved it.

Also, I've simplified Step 5 in modular_multiply().


I attached pgbench-prp-func-9.patch.

Best regards,

Attachment

pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Function to promote standby servers
Next
From: Andrey Lepikhov
Date:
Subject: Re: Making all nbtree entries unique by having heap TIDs participatein comparisons