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 1oT1Q0-0005mV-Lm for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 13:36:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oT1Pz-0005Yk-Ab for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 13:36:39 +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 1oT1Pz-0005YF-1l for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 13:36:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oT1Pw-0008E3-VR for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 13:36:38 +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 27UDaVL13606832; Tue, 30 Aug 2022 09:36:31 -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.1661784942@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Tue, 30 Aug 2022 19:14:23 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3606830.1661866591.1@sss.pgh.pa.us> Date: Tue, 30 Aug 2022 09:36:31 -0400 Message-ID: <3606831.1661866591@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > On Tue, 30 Aug 2022 at 03:16, Robert Haas wrote: >> ../../../../src/include/utils/memutils_memorychunk.h:186:18: error: >> comparison of constant 7 with expression of type >> 'MemoryContextMethodID' (aka 'enum MemoryContextMethodID') is always >> true [-Werror,-Wtautological-constant-out-of-range-compare] >> Assert(methodid <= MEMORY_CONTEXT_METHODID_MASK); >> ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > I think the Assert is useful as if we were ever to add an enum member > with the value of 8 and forgot to adjust MEMORY_CONTEXT_METHODID_BITS > then bad things would happen inside MemoryChunkSetHdrMask() and > MemoryChunkSetHdrMaskExternal(). I think it's unlikely we'll ever get > that many MemoryContext types, but I don't know for sure and would > rather the person who adds the 9th one get alerted to the lack of bit > space in MemoryChunk as soon as possible. I think that's a weak argument, so I don't mind dropping this Assert. What would be far more useful is a comment inside the MemoryContextMethodID enum pointing out that we can support at most 8 values because XYZ. However, I'm still wondering why Robert sees this when the rest of us don't. regards, tom lane