Re: pgsql: Make pgbench use erand48() rather than random(). - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Make pgbench use erand48() rather than random().
Date
Msg-id 24981.1312411016@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Make pgbench use erand48() rather than random().  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: pgsql: Make pgbench use erand48() rather than random().
List pgsql-committers
Robert Haas <robertmhaas@gmail.com> writes:
> On Wed, Aug 3, 2011 at 5:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Hmm.  I find the pgbench part of this a bit questionable, specifically
>> your decision to remove the code around line 2590 that installed a
>> variable srandom() seed in child processes.

> Unless I'm asleep at the switch, the srandom() calls you're worrying
> about execute in the parent thread, which still makes its own call to
> srandom().

[ looks more closely... ]  OK, you're right: the per-"thread" random
seeds are initialized in the parent process and then propagated to child
processes by fork(); we'll never call random() in the children so
there's no need to make their states diverge.  Never mind.

I do however notice a vestigial reference to MAX_RANDOM_VALUE at line
1063, which we probably should get rid of.  What I think we probably
need instead, and don't have, is a check that "max - min + 1" doesn't
overflow.

            regards, tom lane

pgsql-committers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pgsql: Make pgbench use erand48() rather than random().
Next
From: Robert Haas
Date:
Subject: Re: pgsql: Make pgbench use erand48() rather than random().