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 1oSxBy-0003cQ-Lo for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 09:05:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oSxBx-00047Q-Bw for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Aug 2022 09:05:53 +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 1oSxBx-00047E-3M for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 09:05:53 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oSxBu-00060x-Vg for pgsql-hackers@lists.postgresql.org; Tue, 30 Aug 2022 09:05:52 +0000 Received: by mail-ed1-x530.google.com with SMTP id c59so7092868edf.10 for ; Tue, 30 Aug 2022 02:05:50 -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=6DLBsQUbMfJodhpdGboIQSoYdlAWkKwnCi4WU2YszCE=; b=VXZQGYlPqrUqUVtTDF7gcULVi/qRCutFtE5w4A4zy2E6IubKkNhJNb/QyDv3KulN5j S8Sd7utj4uFHf9YrV8UmKtmd/NBTcBFva6xih71dO4ucoI7i3yOq94faf9/+JV35Exac 8ZYb79MpcGAd0ukXY/jPdp6vXUk4iZcmZ1AJmqo+Qstt4ZEIxMj1X14feH8DlyMa0uOw GpThr/OwhKIyHwZoMd3wLD55yzcnTC2t9VP4uDch1qh76Sz1Vv2p7gyv/UYlcPdWNmRY 0P0FieDR2r8yK/nNJuAGzmtccrRANJCYbIozK+L8lC1CpvfGt8R8aRe15COp5Q8oT74Q 4GNA== 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=6DLBsQUbMfJodhpdGboIQSoYdlAWkKwnCi4WU2YszCE=; b=BVAJVzDIKZQrovsy4kYzkjNCdOftCdY2Ar+GpZuESydsUrheIME56FTXyS0w83LgQs EaH84mK3RzrJBsLW37e9FOfoGb1KSF4FRANY7Vgw8omweyMbNaOCeXYSfYwGmbowI/w/ IG4XYs1vPdCbeNEo61aualWC422XGLyieiti8UemHPzhlnCjtIBBB836jxJwQ9dQcDHj /t7ZuuVh09v/1BkQ2+6597sY8jyotGLNNFhhg2GZFXImZMd5Tvhf8GS9RP5IXkT9uv7G WE0DwdDksKyRmcMgJ/u4G5BOOgpMFyXsgTUe7ft5mU87Ji9IThi+diCsw6oaiRiZgfNu bxPw== X-Gm-Message-State: ACgBeo1SFcu4rMyuzp4Ofrnh9+oWZvY1XZtpaIdJc4FnlPXsXJjZZafF FADagm4DtdSbZpDbby8fSzYcHGUuiPaeoCafBh+KbblfvDI5PNoI+YpCIMBAu0WSJyDHg5Q9WRG K3GLw+6o9hXpXSqewIg0mNRLB3ynY5KQsZIB+EHH/VtgS7WflB1OUfgwz3BGALXflzG2otczWy3 AvyVwksRMpV9rWIjL2MXUu9lxZjloYa1HKao8GlYugDoeUA3QfwldH X-Google-Smtp-Source: AA6agR6nDVHx/D7LLtDDhfU8QIQRj1VWxa9NTqEY9xRUYU6m1PdogKufOG8xUrfLxkiBchxXwqVwtA== X-Received: by 2002:a05:6402:1a51:b0:448:3d18:b110 with SMTP id bf17-20020a0564021a5100b004483d18b110mr9902414edb.238.1661850349827; Tue, 30 Aug 2022 02:05:49 -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 bh23-20020a170906a0d700b0073d7e58b1bcsm5479719ejb.157.2022.08.30.02.05.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Aug 2022 02:05:48 -0700 (PDT) Message-ID: Date: Tue, 30 Aug 2022 11:05:47 +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: David Rowley , Tom Lane Cc: 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: 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 04:31, David Rowley wrote: > On Tue, 30 Aug 2022 at 13:55, Tom Lane wrote: >> 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. > > I think it's fairly likely that small allocations are a power of 2, > and I think most of our allocates are small, so I imagine that if we > didn't do that for aset.c, we'd miss out on most of the benefits. > Yeah. I think we have a fair number of "larger" allocations (once you get to ~100B it probably won't be a 2^N), but we may easily miss whole sections of allocations. I guess the idea was to add a sentinel only when there already is space for it, but perhaps that's a bad tradeoff limiting the benefits. Either we add the sentinel fairly often (and then why not just add it all the time - it'll need a bit more space), or we do it only very rarely (and then it's a matter of luck if it catches an issue). Considering we only do this with asserts, I doubt the extra bytes / CPU is a major issue, and a (more) reliable detection of issues seems worth it. But maybe I underestimate the costs. The only alternative seems to be valgrind, and that's way costlier, though. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company