Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzclh-0003k9-U6 for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Jul 2021 10:21:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lzclg-0007Lj-UT for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Jul 2021 10:21:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzclg-0007Lb-Kg for pgsql-hackers@lists.postgresql.org; Sat, 03 Jul 2021 10:21:00 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lzcla-0004wE-0t for pgsql-hackers@lists.postgresql.org; Sat, 03 Jul 2021 10:21:00 +0000 Received: from mail.postgrespro.ru (cyclops.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 74AEC21C8A92; Sat, 3 Jul 2021 13:20:52 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1625307652; bh=VlX0THnRtJJdxhcb4S2fJ14XcYFZ2bVFNVZWRRf58Oo=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=hy1CMLy5H5yVLUtoIxc04+81I/yjhqD4cMvEOdKZWW3RTsHpUHUtlI0p/COOmFjbU 7jS4WP3g7dGV1Gr/l5UjmSN+X8rU8ymY5xXNnURpHip7iAiPIt1apVpb2c6mE16U4i GM2ijqCoXvE4eqkUX066t+jd8bac87Y1BIY3yCB0= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 03 Jul 2021 13:20:52 +0300 From: Yura Sokolov To: Fabien COELHO Cc: Dean Rasheed , Tom Lane , Aleksander Alekseev , PostgreSQL Developers Subject: Re: rand48 replacement In-Reply-To: References: <43a6e30b-542f-671a-e7bb-b7f78cf90e8c@enterprisedb.com> <699567.1625156441@sss.pgh.pa.us> <746421.1625164869@sss.pgh.pa.us> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <25e12be71909b5716ab4dd2d64d65da0@postgrespro.ru> X-Sender: y.sokolov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Fabien COELHO wrote 2021-07-03 11:45: > And a v5 where an unused test file does also compile if we insist. About patch: 1. PostgreSQL source uses `uint64` and `uint32`, but not `uint64_t`/`uint32_t` 2. I don't see why pg_prng_state could not be `typedef uint64 pg_prng_state[2];` 3. Then SamplerRandomState and pgbench RandomState could stay. Patch will be a lot shorter. I don't like mix of semantic refactoring and syntactic refactoring in the same patch. While I could agree with replacing `SamplerRandomState => pg_prng_state`, I'd rather see it in separate commit. And that separate commit could contain transition: `typedef uint64 pg_prng_state[2];` => `typedef struct { uint64 s0, s1 } pg_prng_state;` 4. There is no need in ReservoirStateData->randstate_initialized. There could be macros/function: `bool pg_prng_initiated(state) { return (state[0]|state[1]) != 0; }` 5. Is there need for 128bit prng at all? At least 2*64bit. There are 2*32bit xoroshiro64 https://prng.di.unimi.it/xoroshiro64starstar.c And there is 4*32bit xoshiro128: https://prng.di.unimi.it/xoshiro128plusplus.c 32bit operations are faster on 32bit platforms. But 32bit platforms are quite rare in production this days. Therefore I don't have strong opinion on this. regards, Sokolov Yura.