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 1oSqTm-0008NA-GF for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 01:55:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oSqTj-00016V-Nx for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 01:55:47 +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 1oSqTj-00016M-Ed for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 01:55:47 +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 1oSqTg-0002RV-BS for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 01:55:45 +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 27U1tdOY3478406; Mon, 29 Aug 2022 21:55:39 -0400 From: Tom Lane To: Tomas Vondra cc: David Rowley , Amit Kapila , Andres Freund , Robert Haas , Yura Sokolov , PostgreSQL Developers Subject: Re: Reducing the chunk header sizes on all memory context types In-reply-to: References: <20220809184410.g6yzu6pvttuphag5@awork3.anarazel.de> <3137572.1661780863@sss.pgh.pa.us> <3205803.1661786437@sss.pgh.pa.us> Comments: In-reply-to Tomas Vondra message dated "Tue, 30 Aug 2022 03:24:47 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3478404.1661824539.1@sss.pgh.pa.us> Date: Mon, 29 Aug 2022 21:55:39 -0400 Message-ID: <3478405.1661824539@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tomas Vondra writes: > On 8/30/22 02:45, David Rowley wrote: >> I think the existing sentinel check looks wrong: >> if (!sentinel_ok(chunk, slab->chunkSize)) >> shouldn't that be passing the pointer rather than the chunk? > I agree the check in SlabCheck() looks wrong, as it's ignoring the chunk > header (unlike the other contexts). > But yeah, I ran "make check-world" and it passed just fine, so my only > explanation is that the check never actually executes because there's no > space for the sentinel thanks to alignment, and the tweak you did breaks > that. Strange ... A quick code-coverage check confirms that the sentinel_ok() line is not reached in core or test_decoding tests as of HEAD (on a 64-bit machine anyway). So we just happen to be using only allocation requests that are already maxaligned. I wonder if slab ought to artificially bump up such requests when MEMORY_CONTEXT_CHECKING is enabled, so there's room for a sentinel. I think it's okay for aset.c to not do that, because its power-of-2 behavior means there usually is room for a sentinel; but slab's policy makes it much more likely that there won't be. regards, tom lane