pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Yura Sokolov <y.sokolov@postgrespro.ru>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Reducing the chunk header sizes on all memory context types
Date: Tue, 30 Aug 2022 11:05:47 +0200
Message-ID: <f88befd1-9f2a-b5e7-9dc5-de3a3874ff7c@enterprisedb.com> (raw)
In-Reply-To: <CAApHDvp0gzQq_sK=kTbFRm+p-1sxcSv5xt_n6cBvm1GAiSDskg@mail.gmail.com>
References: <CAApHDvpjauCRXcgcaL6+e3eqecEHoeRm9D-kcbuvBitgPnW=vw@mail.gmail.com>
	<CAApHDvrVppH=3NKzhD0v1XkHyWiT+DkdfOdnQPo=BgauVcL7fw@mail.gmail.com>
	<CAApHDvpuhcPWCzkXZuQQgB8YjPNQSvnncbzZ6pwpHFr2QMMD2w@mail.gmail.com>
	<CAApHDvrCkmvdcnyGBtxq6D8FfM50UiunN3qJquTBwOdUqoKYvg@mail.gmail.com>
	<CAApHDvo3ZaWQNO2AKYiH8y3oGKxWfa2EAkZz9peGBnXvZe2hvA@mail.gmail.com>
	<CAApHDvrbd3y4QxRANd7oFZBXVJ7ZmwUjxSYDLFEMOZY8uyQzRg@mail.gmail.com>
	<CAApHDvrvWMqB6kR-=6qz7n+Jb4Et8VkfnOufwKKLDz5kOm=AEA@mail.gmail.com>
	<CAApHDvociYOk=OTxw0XmO9BR38Covk13M_wg8nt8N7aySWKbLw@mail.gmail.com>
	<3137572.1661780863@sss.pgh.pa.us>
	<f1d04651-caf9-5c6d-1bf0-c9feac16df10@enterprisedb.com>
	<3205803.1661786437@sss.pgh.pa.us>
	<fc3a36eb-0767-d915-cdbd-e531983dc1de@enterprisedb.com>
	<b2f03d6e-083c-b500-b71b-d0acb06abe38@enterprisedb.com>
	<b6c0c5bb-d92d-5140-bbef-93d1a6a3a13e@enterprisedb.com>
	<3478405.1661824539@sss.pgh.pa.us>
	<CAApHDvp0gzQq_sK=kTbFRm+p-1sxcSv5xt_n6cBvm1GAiSDskg@mail.gmail.com>



On 8/30/22 04:31, David Rowley wrote:
> On Tue, 30 Aug 2022 at 13:55, Tom Lane <tgl@sss.pgh.pa.us> 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





view thread (152+ messages)  latest in thread

Message-ID: <f88befd1-9f2a-b5e7-9dc5-de3a3874ff7c@enterprisedb.com>
Permalink:  ../f88befd1-9f2a-b5e7-9dc5-de3a3874ff7c@enterprisedb.com/
Also on:    postgresql.org/message-id/f88befd1-9f2a-b5e7-9dc5-de3a3874ff7c@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tomas.vondra@enterprisedb.com, dgrowleyml@gmail.com, tgl@sss.pgh.pa.us, amit.kapila16@gmail.com, andres@anarazel.de, robertmhaas@gmail.com, y.sokolov@postgrespro.ru
  Subject: Re: Reducing the chunk header sizes on all memory context types
  In-Reply-To: <f88befd1-9f2a-b5e7-9dc5-de3a3874ff7c@enterprisedb.com>
  References: <CAApHDvpjauCRXcgcaL6+e3eqecEHoeRm9D-kcbuvBitgPnW=vw@mail.gmail.com> <CAApHDvpuhcPWCzkXZuQQgB8YjPNQSvnncbzZ6pwpHFr2QMMD2w@mail.gmail.com> <CAApHDvrCkmvdcnyGBtxq6D8FfM50UiunN3qJquTBwOdUqoKYvg@mail.gmail.com> <CAApHDvo3ZaWQNO2AKYiH8y3oGKxWfa2EAkZz9peGBnXvZe2hvA@mail.gmail.com> <CAApHDvrbd3y4QxRANd7oFZBXVJ7ZmwUjxSYDLFEMOZY8uyQzRg@mail.gmail.com> <CAApHDvrvWMqB6kR-=6qz7n+Jb4Et8VkfnOufwKKLDz5kOm=AEA@mail.gmail.com> <CAApHDvociYOk=OTxw0XmO9BR38Covk13M_wg8nt8N7aySWKbLw@mail.gmail.com> <3137572.1661780863@sss.pgh.pa.us> <f1d04651-caf9-5c6d-1bf0-c9feac16df10@enterprisedb.com> <3205803.1661786437@sss.pgh.pa.us> <fc3a36eb-0767-d915-cdbd-e531983dc1de@enterprisedb.com> <b2f03d6e-083c-b500-b71b-d0acb06abe38@enterprisedb.com> <b6c0c5bb-d92d-5140-bbef-93d1a6a3a13e@enterprisedb.com> <3478405.1661824539@sss.pgh.pa.us> <CAApHDvp0gzQq_sK=kTbFRm+p-1sxcSv5xt_n6cBvm1GAiSDskg@mail.gmail.com> <f88befd1-9f2a-b5e7-9dc5-de3a3874ff7c@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox