You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
glibc renders random() thread-safe by wrapping a futex lock around it;testing reveals that this limits the performance of pgbench on machineswith many CPU cores. Rather than switching to random_r(), which isonly available on GNU systems and crashes unless you use undocumentedalchemy to initialize the random state properly, switch to our built-inimplementation 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 similarlyfor our implementations of lrand48() and srand48()) and just alwaysuse those. We were already doing this on Cygwin anyway, and theglibc implementation is not quite thread-safe, so pgbench wouldn'tbe able to use that either.Per discussion with Tom Lane.