Re: pgbench internal contention

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgbench internal contention
Date: 2011-07-29 22:36:07
Message-ID: CA+TgmoZLPhn2TrbNySA+60iX-ViiRf6c6dxGjhOnnNgPZDtAqQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 29, 2011 at 5:25 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On machines with lots of CPU cores, pgbench can start eating up a lot
>> of system time.  Investigation reveals that the problem is with
>> random(),
>
> Interesting.
>
>> I patched it to use random_r() - the patch is attached - and here are
>> the (rather gratifying) results of that test:
>> Since a client-limited benchmark isn't very interesting, I think this
>> change makes sense.  Thoughts?  Objections?
>
> Portability, or rather lack of it.  What about using erand48, which we
> already have a dependency on (and substitute code for)?

Neither our implementation nor glibc's appears to be thread-safe, and
erand48() is deprecated according to my Linux man page:

NOTES
These functions are declared obsolete by SVID 3, which states that
rand(3) should be used instead.

glibc provides erand48_r(), and I suppose we could kludge up something
similar out of what's already in src/port?

This is also not exactly the world's most sophisticated algorithm, but
perhaps for pgbench that doesn't matter.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-07-29 23:14:35 Re: USECS_* constants undefined with float8 timestamps?
Previous Message daveg 2011-07-29 22:35:04 Re: error: could not find pg_class tuple for index 2662