Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMDOz-0004EF-P9 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Nov 2018 14:41:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMDMs-0004YF-8U for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Nov 2018 14:39:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMDMr-0004XS-Tt for pgsql-hackers@lists.postgresql.org; Mon, 12 Nov 2018 14:39:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMDMp-0003Rr-An for pgsql-hackers@postgresql.org; Mon, 12 Nov 2018 14:39:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wACEd1UE032456; Mon, 12 Nov 2018 09:39:01 -0500 From: Tom Lane To: Thomas Munro cc: Noah Misch , Pg Hackers Subject: Re: DSM segment handle generation in background workers In-reply-to: References: <17043.1539046409@sss.pgh.pa.us> <9879.1539233472@sss.pgh.pa.us> <20181112083358.GA1073796@rfd.leadboat.com> Comments: In-reply-to Thomas Munro message dated "Mon, 12 Nov 2018 23:11:19 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32454.1542033541.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 12 Nov 2018 09:39:01 -0500 Message-ID: <32455.1542033541@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > On Mon, Nov 12, 2018 at 9:34 PM Noah Misch wrote: >> 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-chan= ging >> 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 bit= s is >> the Linux default.) Is that aspect of the change justified? > Hmm, right. How about applying pg_bswap32() to one of the terms, as > an easy approximation of reversing the bits? I doubt that's a good idea; to a first approximation, it would mean that half the seed depends only on the PID and the other half only on the timestamp. Maybe we could improve matters a little by left-shifting the PID four bits or so, but I think we still want it to mix with some rapidly-changing time bits. I'm not really sure that we need to do anything though. Basically, what we've got here is a tradeoff between how many bits change over a given timespan and how unpredictable those bits are. I don't see that one of those is necessarily more important than the other. regards, tom lane