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 1oT3vt-00051S-5F for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 16:17:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oT3vr-0008VD-JB for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 16:17:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oT3vr-0008Ug-A1 for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 16:17:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oT3vl-0003Ux-GF for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 16:17:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 27UGHXWo3680170; Tue, 30 Aug 2022 12:17:33 -0400 From: Tom Lane To: David Rowley cc: Robert Haas , Amit Kapila , Andres Freund , Yura Sokolov , PostgreSQL Developers Subject: Re: Reducing the chunk header sizes on all memory context types In-reply-to: References: <9dec1bd42fed3e263de294116380e5b51c427267.camel@postgrespro.ru> <20220712174404.polbc5it7j6mzmql@awork3.anarazel.de> <20220809184410.g6yzu6pvttuphag5@awork3.anarazel.de> <3137572.1661780863@sss.pgh.pa.us> <3201943.1661! 784942@sss.pgh.pa.us> <3606831.1661866591@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Wed, 31 Aug 2022 03:39:00 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3680168.1661876253.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 30 Aug 2022 12:17:33 -0400 Message-ID: <3680169.1661876253@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > Here's a patch which adds a comment to MemoryContextMethodID to Robert's= patch. OK, but while looking at that I noticed the adjacent #define MEMORY_CONTEXT_METHODID_MASK \ UINT64CONST((1 << MEMORY_CONTEXT_METHODID_BITS) - 1) I'm rather astonished that that compiles; UINT64CONST was only ever meant to be applied to *literals*. I think what it's expanding to is ((1 << MEMORY_CONTEXT_METHODID_BITS) - 1UL) (or on some machines 1ULL) which only accidentally does approximately what you want. It'd be all right perhaps to write ((UINT64CONST(1) << MEMORY_CONTEXT_METHODID_BITS) - 1) but you might as well avoid the Postgres-ism and just write ((uint64) ((1 << MEMORY_CONTEXT_METHODID_BITS) - 1)) Nobody's ever going to make MEMORY_CONTEXT_METHODID_BITS large enough for the shift to overflow in int arithmetic. regards, tom lane