pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: DSM segment handle generation in background workers
Date: Mon, 12 Nov 2018 08:33:58 +0000
Message-ID: <20181112083358.GA1073796@rfd.leadboat.com> (raw)
In-Reply-To: <CAEepm=20PEf5bM3FAtD=CL7x0_WxFXfQ4Se9N9nConKucsr8pg@mail.gmail.com>
References: <CAEepm=2eJj_6=B+2tEpGu2nf1BjthCf9nXXUouYvJJ4C5WSwhg@mail.gmail.com>
	<CAEepm=1oRxe3n3a6bq23-2MQTSWagHTghPbpGJ1YcZEyZ_KWQA@mail.gmail.com>
	<17043.1539046409@sss.pgh.pa.us>
	<CAEepm=2RqzvRyEXWxq8B9zR8p45tt-xsvA4S8ZNKNwpiUzMVKA@mail.gmail.com>
	<CAEepm=1xxETRCZexNSxkABpNg-65U6Z2pxynJ8V0vURqob+Rqw@mail.gmail.com>
	<9879.1539233472@sss.pgh.pa.us>
	<CAEepm=20PEf5bM3FAtD=CL7x0_WxFXfQ4Se9N9nConKucsr8pg@mail.gmail.com>

On Sat, Oct 13, 2018 at 11:45:17PM +1300, Thomas Munro wrote:
> +	/* Set a different seed for random() in every backend. */
> +	srandom((unsigned int) MyProcPid ^ (unsigned int) MyStartTimestamp);

> -	TimestampDifference(0, port->SessionStartTime, &secs, &usecs);
> -	srandom((unsigned int) (MyProcPid ^ (usecs << 12) ^ secs));

Compared to the old code, the new code requires more wall time to visit every
possible seed value.  New code xor's the PID bits into the fastest-changing
timestamp bits, so only about twenty bits can vary within any given one-second
period.  (That assumes a PID space of twenty or fewer bits; fifteen bits is
the Linux default.)  Is that aspect of the change justified?




view thread (19+ messages)  latest in thread

Message-ID: <20181112083358.GA1073796@rfd.leadboat.com>
Permalink:  ../20181112083358.GA1073796@rfd.leadboat.com/
Also on:    postgresql.org/message-id/20181112083358.GA1073796@rfd.leadboat.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: noah@leadboat.com, thomas.munro@enterprisedb.com, tgl@sss.pgh.pa.us
  Subject: Re: DSM segment handle generation in background workers
  In-Reply-To: <20181112083358.GA1073796@rfd.leadboat.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox