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 1gM7hl-0002ai-7B for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Nov 2018 08:36: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 1gM7fc-0006Ml-0I for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Nov 2018 08:34:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gM7fb-0006Me-PU for pgsql-hackers@lists.postgresql.org; Mon, 12 Nov 2018 08:34:07 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gM7fY-00077u-Rl for pgsql-hackers@postgresql.org; Mon, 12 Nov 2018 08:34:07 +0000 Received: by mail-pf1-x430.google.com with SMTP id v76-v6so1147732pfa.5 for ; Mon, 12 Nov 2018 00:34:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=2oxSYDKqu/3TKv05t+vO36iiZboa4o2u6qfMAaYWXJQ=; b=MLEdHsYlwpQwg1RTYsRwzc1mqZ9soGIEhMbIN1mXh03y3BWkhuTnuYNExPZB3a33VV P5yJZrwGtatxuf+h36idxZcA7QjPnC8TEZTB105EietUOGOMLRoktNYShNFIIxoS7pUx qIwsrgLNMWoFBZa3cMzF94fwy1me7+4mVjy+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2oxSYDKqu/3TKv05t+vO36iiZboa4o2u6qfMAaYWXJQ=; b=jrgAcr7h5MVAUvXlfGHIvTnsrpJNaD5uRE30076d1P7ZeXp+HhrNhHLxxvGEqMeat/ yDiqGG9PoxpZvU4Lg0yo/tj08b49voGqLwIeqTjMVgXkYtsIoHZ9kmIpxPtlaOg4wiKM wYy37msNUe06SEal16IlIQSLahxr35Im5BAnuRQmwycXA4MYBGxkcA8iLZ47YxkzN1ui fSsAUufgQcMUZ0RpTZC8g2AIaBhxV3rxnnOgIgfgaEqbTD2rSZctHLdWoG8gS3qq+0cp u5pCLZim0ermdGPbTfOrbpyrR+aAmjzVh3vaZT6Gb+IepwVREu4v/maXiXFmgkAK+1Qt Kchw== X-Gm-Message-State: AGRZ1gLxLcnr58o10Md75twHeuMVPbjZutqjNNPo0Ze9vRF3VkwfFZKz l46KH0rSkPo9nLMEPoGV9eWmlQ== X-Google-Smtp-Source: AJdET5dWHh9pHGWa3K4SGVz8VnV1UhBqqBKfW+W5noatxInvIlx13ezUV159GhXObwRIp92gdgCR+g== X-Received: by 2002:a65:5103:: with SMTP id f3-v6mr59163pgq.54.1542011641823; Mon, 12 Nov 2018 00:34:01 -0800 (PST) Received: from rfd.leadboat.com (c-73-158-248-138.hsd1.ca.comcast.net. [73.158.248.138]) by smtp.gmail.com with ESMTPSA id 196-v6sm47885668pfc.71.2018.11.12.00.34.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 00:34:01 -0800 (PST) Date: Mon, 12 Nov 2018 08:33:58 +0000 From: Noah Misch To: Thomas Munro Cc: Tom Lane , Pg Hackers Subject: Re: DSM segment handle generation in background workers Message-ID: <20181112083358.GA1073796@rfd.leadboat.com> References: <17043.1539046409@sss.pgh.pa.us> <9879.1539233472@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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?