pgsql: Make pgbench use erand48() rather than random().

Поиск
Список
Период
Сортировка
От Robert Haas
Тема pgsql: Make pgbench use erand48() rather than random().
Дата
Msg-id E1Qoi4d-0005mC-25@gemulon.postgresql.org
обсуждение исходный текст
Ответы Re: pgsql: Make pgbench use erand48() rather than random().  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-committers
Make pgbench use erand48() rather than random().

glibc renders random() thread-safe by wrapping a futex lock around it;
testing reveals that this limits the performance of pgbench on machines
with many CPU cores.  Rather than switching to random_r(), which is
only available on GNU systems and crashes unless you use undocumented
alchemy to initialize the random state properly, switch to our built-in
implementation of erand48(), which is both thread-safe and concurrent.

Since the list of reasons not to use the operating system's erand48()
is getting rather long, rename ours to pg_erand48() (and similarly
for our implementations of lrand48() and srand48()) and just always
use those.  We were already doing this on Cygwin anyway, and the
glibc implementation is not quite thread-safe, so pgbench wouldn't
be able to use that either.

Per discussion with Tom Lane.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4af43ee3f165c8e4b332a7e680a44f4b7ba2d3c1

Modified Files
--------------
configure                                   |   14 +-----------
configure.in                                |    8 +------
contrib/pgbench/pgbench.c                   |   32 ++++++++++++--------------
src/backend/optimizer/geqo/geqo_random.c    |    2 +-
src/backend/optimizer/geqo/geqo_selection.c |    6 ++--
src/include/optimizer/geqo.h                |    2 +-
src/include/pg_config.h.in                  |    3 --
src/include/port.h                          |    9 ++-----
src/port/Makefile                           |    4 +-
src/port/erand48.c                          |   18 +++++++++------
src/port/random.c                           |    2 +-
src/port/srandom.c                          |    2 +-
12 files changed, 40 insertions(+), 62 deletions(-)


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

Предыдущее
От: andrewsn@pgfoundry.org (User Andrewsn)
Дата:
Сообщение: ip4r - ip4r: First cut at ip6/ip6r/ipaddress/iprange support (2.0
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgsql: Make pgbench use erand48() rather than random().