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 1oSqk7-0000XX-6w for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 02:12:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oSqk5-00033z-MB for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 02:12:41 +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 1oSqk5-00033j-DD for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 02:12:41 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oSqk2-0002a8-K2 for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 02:12:40 +0000 Received: by mail-ed1-x52b.google.com with SMTP id b16so12333751edd.4 for ; Mon, 29 Aug 2022 19:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=tSIwajztTfaDENFbo7W0aAu9wXzEqqFT+fJkUkDTxv0=; b=lBl1QACOaMHV4MhXoLqXTKcAweHPzNvaZ5eHEiuF7H0L6R9IZc9TInJeRPyhf5+BcT sYqTt/iytDU0WCnuxmkQWnCFU+msESdzTjXH1Ji234fSmTdUCT6vM9jvK/PKNvXHbP74 hSZmAbGx0wQD7F/IDXsHkbVdD9JP5zDj9wA7zxfPeq3owXCdKLgT9TUx6uuLEu6EgBFP WCtKm90ehWVU/xWk5ZwcA/c02n+GJEXy8MJsPoQDULiaVsurhJrxgW3GELY7XKK3Tbk0 6gcF4NhG2xq5QVvp/CuWXDQLCqcQnQW8TXSfvtCbIttZz9iBcTUlsruUMTA/n5TK961g 5xrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=tSIwajztTfaDENFbo7W0aAu9wXzEqqFT+fJkUkDTxv0=; b=Coi3qkMhsZGIcWmnmurN9t1f72I81Z0BXWc1DYOk6/AO03hYlD3TJGZUCxvd5mJWfT biL7u1AEfZTT5My2+BWTPvdTPTJ0Xr2xJd/WhpuK39QFCJbgt7mbKDx3NC+AYcy/GyX+ pftP8e27d1Gik/wzyKZoYytQryKhO/3hxENcbxCrirJrmrAEooxKDRmsPBBw0FL9Nlfi 5w/wy2S5gSl/6QhYSIyHUOxq8BmzCtrI3bbdAZCyY7obrFDniNPYnCfmIcrLCkmqzIEl H/KrAD9aDn9mEAdqmTT1AesrUeTAGmf9YsvfqFqcqEJGiuiPddHi0s3ovzGHc57pCNgD mHRA== X-Gm-Message-State: ACgBeo15mAVkdrKDKDZVYMw4u6DGW+yI0e70aEiVtoNyhdJHsxjYEQyh /hcj5KAEncmcZfdI3v1E9/ps74J06U+PBHBOm++U3MH23wCtQj8qrCDCi/5u/1/gJOKtHVvZqpz oZgmFi2p2J63JuYCvEsv3nbKB4/9omsV9LANLutxcOyxhhCDwHPjabS8yYPzYEOsMvpqTW8g+CH v/xpjDQr5gdxj9mBwfO7Zqz+Kj9wyRkEChZhQETLSM6mDJIYRHMW/r X-Google-Smtp-Source: AA6agR7Gr0JT0qyrCAuTZ4KEzM8/+L1Sn36mKHlfVWdT7SfPm2i7jX9ztmk/Yle+yRgR3GY2kAOm9Q== X-Received: by 2002:aa7:d7c1:0:b0:447:d3ec:69cb with SMTP id e1-20020aa7d7c1000000b00447d3ec69cbmr15381058eds.105.1661825557505; Mon, 29 Aug 2022 19:12:37 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-229-52.bb.vodafone.cz. [86.49.229.52]) by smtp.gmail.com with ESMTPSA id u9-20020a1709060ec900b0073d6ab5bcaasm5086305eji.212.2022.08.29.19.12.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Aug 2022 19:12:36 -0700 (PDT) Message-ID: <59cda093-33aa-9775-952d-fbe6689eb9af@enterprisedb.com> Date: Tue, 30 Aug 2022 04:12:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: Reducing the chunk header sizes on all memory context types Content-Language: en-US To: Tom Lane Cc: David Rowley , Amit Kapila , Andres Freund , Robert Haas , Yura Sokolov , PostgreSQL Developers References: <3137572.1661780863@sss.pgh.pa.us> <3205803.1661786437@sss.pgh.pa.us> <3478405.1661824539@sss.pgh.pa.us> From: Tomas Vondra In-Reply-To: <3478405.1661824539@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/30/22 03:55, Tom Lane wrote: > 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. > +1 to that For aset that's fine not just because of power-of-2 behavior, but because we use it for chunks of many different sizes - so at least some of those will have sentinel. But Slab in used only for changes and txns in reorderbuffer, and it just so happens both structs are maxaligned on 32-bit and 64-bit machines (rpi and x86-64). We're unlikely to use slab in many other places, and the structs don't change very often, and it'd probably grow to another maxaligned size anyway. So it may be pretty rare to have a sentinel. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company