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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Make pgbench use erand48() rather than random().
Date: 2011-08-03 22:36:56
Message-ID: 24981.1312411016@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Wed, Aug 3, 2011 at 5:53 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2011-08-03 23:08:32 Re: pgsql: Make pgbench use erand48() rather than random().
Previous Message Robert Haas 2011-08-03 22:16:23 Re: pgsql: Make pgbench use erand48() rather than random().