Re: rand48 replacement

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: rand48 replacement
Дата
Msg-id CAEZATCXvzDSNhH2uRMUt5K_vmMBDrvo+D7Sn66--1Z_ELz==5Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: rand48 replacement  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: rand48 replacement
Список pgsql-hackers
On Thu, 1 Jul 2021 at 19:41, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Anyway, after taking a very quick look at the patch itself, I've
> got just one main objection: I don't approve of putting this in
> port.h or src/port/.

I haven't looked at the patch in detail, but one thing I object to is
the code to choose a random integer in an arbitrary range.

Currently, this is done in pgbench by getrand(), which has its
problems. However, this patch seems to be replacing that with a simple
modulo operation, which is perhaps the worst possible way to do it.
There's plenty of research out there on how to do it better -- see,
for example, [1] for a nice summary.

Also, I'd say that functions to choose random integers in an arbitrary
range ought to be part of the common API, as they are in almost every
language's random API.

Regards,
Dean

[1] https://www.pcg-random.org/posts/bounded-rands.html



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

Предыдущее
От: Ranier Vilela
Дата:
Сообщение: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)
Следующее
От: Mahendra Singh Thalor
Дата:
Сообщение: Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)