1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

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.
This commit is contained in:
Robert Haas
2011-08-03 16:26:40 -04:00
parent ac36e6f71f
commit 4af43ee3f1
12 changed files with 40 additions and 62 deletions

14
configure vendored
View File

@ -20493,8 +20493,7 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
for ac_func in crypt erand48 getopt getrusage inet_aton random rint srandom strdup strerror strlcat strlcpy strtol strtoul
for ac_func in crypt getopt getrusage inet_aton random rint srandom strdup strerror strlcat strlcpy strtol strtoul
do
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
@ -21010,17 +21009,6 @@ esac
fi
# Cygwin's erand48() is broken (always returns zero) in some releases,
# so force use of ours.
if test "$PORTNAME" = "cygwin"; then
case " $LIBOBJS " in
*" erand48.$ac_objext "* ) ;;
*) LIBOBJS="$LIBOBJS erand48.$ac_objext"
;;
esac
fi
# Win32 support
if test "$PORTNAME" = "win32"; then