Re: pgbench - add pseudo-random permutation function

Поиск
Список
Период
Сортировка
От Fabien COELHO
Тема Re: pgbench - add pseudo-random permutation function
Дата
Msg-id alpine.DEB.2.22.394.2104011103460.702551@pseudo
обсуждение исходный текст
Ответ на Re: pgbench - add pseudo-random permutation function  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Ответы Re: pgbench - add pseudo-random permutation function
Re: pgbench - add pseudo-random permutation function
Список pgsql-hackers
>>   r = (uint64) (pg_erand48(random_state.xseed) * size);
>>
>> I do not understand why the random values are multiplied by anything in
>> the first place…
>
> These are just random integers in the range [0,mask] and [0,size-1],
> formed in exactly the same way as getrand().

Indeed, erand returns a double, this was the part I was missing. I did not 
realize that you had switched to doubles in your approach.

I think that permute should only use integer operations. I'd suggest to 
use one of the integer variants instead of going through a double 
computation and casting back to int. The internal state is based on 
integers, I do not see the added value of going through floats, possibly 
enduring floating point issues (undeflow, rounding, normalization, 
whatever) on the way, whereas from start to finish we just need ints.

See attached v27 proposal.

I still think that *rand48 is a poor (relatively small state) and 
inefficient (the implementation includes packing and unpacking 16 bits 
ints to build a 64 bits int) choice.

-- 
Fabien.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Julien Rouhaud
Дата:
Сообщение: Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: Fix pg_checksums progress report