pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yura Sokolov <y.sokolov@postgrespro.ru>
To: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Reducing the chunk header sizes on all memory context types
Date: Wed, 07 Sep 2022 10:15:24 +0300
Message-ID: <92702110c65128e8ce0e73505bbb770af3f755e6.camel@postgrespro.ru> (raw)
In-Reply-To: <CAApHDvrbg1QmHLB3NB_3D22m8Jsq26x98ZjO05pGac+RLn705w@mail.gmail.com>
References: <CAApHDvpjauCRXcgcaL6+e3eqecEHoeRm9D-kcbuvBitgPnW=vw@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>
	<3605020.1661865981@sss.pgh.pa.us>
	<3613565.1661869054@sss.pgh.pa.us>
	<CAApHDvp0DKT9F+d9tVZquzLhiHz3B7S4K7TtT2XUu_5eo+Tn9g@mail.gmail.com>
	<60560f75-8b15-a7cc-67bc-a7bf3e8472ee@enterprisedb.com>
	<CAApHDvrkeikW+ovQb-j4v53mXzpt9qJoXPuE3U6gS7tgK=2q6g@mail.gmail.com>
	<209211.1661991821@sss.pgh.pa.us>
	<CAApHDvoKg1Nf1GZgaL9WeS+srja2+UBgFxjYDkO-A2_XHbfU-A@mail.gmail.com>
	<217242.1661993189@sss.pgh.pa.us>
	<CAApHDvqOJ8Uo8=pQwq0nF6EH4ugCdEOMd6sZRgFHL35j5WZv6w@mail.gmail.com>
	<CAApHDvopbjBKHNOY5VADMgQF2v9aud3eAXh2TNPOnX26=7of7Q@mail.gmail.com>
	<CAApHDvrbg1QmHLB3NB_3D22m8Jsq26x98ZjO05pGac+RLn705w@mail.gmail.com>

В Ср, 07/09/2022 в 16:13 +1200, David Rowley пишет:
> On Tue, 6 Sept 2022 at 01:41, David Rowley <dgrowleyml@gmail.com> wrote:
> > 
> > On Fri, 2 Sept 2022 at 20:11, David Rowley <dgrowleyml@gmail.com> wrote:
> > > 
> > > On Thu, 1 Sept 2022 at 12:46, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > > > 
> > > > David Rowley <dgrowleyml@gmail.com> writes:
> > > > > Maybe we should just consider always making room for a sentinel for
> > > > > chunks that are on dedicated blocks. At most that's an extra 8 bytes
> > > > > in some allocation that's either over 1024 or 8192 (depending on
> > > > > maxBlockSize).
> > > > 
> > > > Agreed, if we're not doing that already then we should.
> > > 
> > > Here's a patch to that effect.
> > 
> > If there are no objections, then I plan to push that patch soon.
> 
> I've now pushed the patch which adds the sentinel space in more cases.
> 
> The final analysis I did on the stats gathered during make
> installcheck show that we'll now allocate about 19MBs more over the
> entire installcheck run out of about 26GBs total allocations.
> 
> That analysis looks something like:
> 
> Before:
> 
> SELECT CASE
>          WHEN pow2_size > 0
>               AND pow2_size = size THEN 'No'
>          WHEN pow2_size = 0
>               AND size = maxalign_size THEN 'No'
>          ELSE 'Yes'
>        END                    AS has_sentinel,
>        Count(*)               AS n_allocations,
>        Sum(CASE
>              WHEN pow2_size > 0 THEN pow2_size
>              ELSE maxalign_size
>            END) / 1024 / 1024 mega_bytes_alloc
> FROM   memstats
> GROUP  BY 1;
> has_sentinel | n_allocations | mega_bytes_alloc
> --------------+---------------+------------------
>  No           |      26445855 |            21556
>  Yes          |      37602052 |             5044
> 
> After:
> 
> SELECT CASE
>          WHEN pow2_size > 0
>               AND pow2_size = size THEN 'No'
>          WHEN pow2_size = 0
>               AND size = maxalign_size THEN 'Yes' -- this part changed
>          ELSE 'Yes'
>        END                    AS has_sentinel,
>        Count(*)               AS n_allocations,
>        Sum(CASE
>              WHEN pow2_size > 0 THEN pow2_size
>              WHEN size = maxalign_size THEN maxalign_size + 8
>              ELSE maxalign_size
>            END) / 1024 / 1024 mega_bytes_alloc
> FROM   memstats
> GROUP  BY 1;
> has_sentinel | n_allocations | mega_bytes_alloc
> --------------+---------------+------------------
>  No           |      23980527 |             2177
>  Yes          |      40067380 |            24442
> 
> That amounts to previously having about 58.7% of allocations having a
> sentinel up to 62.6% currently, during the installcheck run.
> 
> It seems a pretty large portion of allocation request sizes are
> power-of-2 sized and use AllocSet.

19MB over 26GB is almost nothing. If it is only for enable-casserts
builds, then it is perfectly acceptable.

regards
Yura


view thread (152+ messages)  latest in thread

Message-ID: <92702110c65128e8ce0e73505bbb770af3f755e6.camel@postgrespro.ru>
Permalink:  ../92702110c65128e8ce0e73505bbb770af3f755e6.camel@postgrespro.ru/
Also on:    postgresql.org/message-id/92702110c65128e8ce0e73505bbb770af3f755e6.camel@postgrespro.ru

 · 

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: y.sokolov@postgrespro.ru, dgrowleyml@gmail.com, tgl@sss.pgh.pa.us, tomas.vondra@enterprisedb.com, amit.kapila16@gmail.com, andres@anarazel.de, robertmhaas@gmail.com
  Subject: Re: Reducing the chunk header sizes on all memory context types
  In-Reply-To: <92702110c65128e8ce0e73505bbb770af3f755e6.camel@postgrespro.ru>
  References: <CAApHDvpjauCRXcgcaL6+e3eqecEHoeRm9D-kcbuvBitgPnW=vw@mail.gmail.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> <3605020.1661865981@sss.pgh.pa.us> <3613565.1661869054@sss.pgh.pa.us> <CAApHDvp0DKT9F+d9tVZquzLhiHz3B7S4K7TtT2XUu_5eo+Tn9g@mail.gmail.com> <60560f75-8b15-a7cc-67bc-a7bf3e8472ee@enterprisedb.com> <CAApHDvrkeikW+ovQb-j4v53mXzpt9qJoXPuE3U6gS7tgK=2q6g@mail.gmail.com> <209211.1661991821@sss.pgh.pa.us> <CAApHDvoKg1Nf1GZgaL9WeS+srja2+UBgFxjYDkO-A2_XHbfU-A@mail.gmail.com> <217242.1661993189@sss.pgh.pa.us> <CAApHDvqOJ8Uo8=pQwq0nF6EH4ugCdEOMd6sZRgFHL35j5WZv6w@mail.gmail.com> <CAApHDvopbjBKHNOY5VADMgQF2v9aud3eAXh2TNPOnX26=7of7Q@mail.gmail.com> <CAApHDvrbg1QmHLB3NB_3D22m8Jsq26x98ZjO05pGac+RLn705w@mail.gmail.com> <92702110c65128e8ce0e73505bbb770af3f755e6.camel@postgrespro.ru>

* 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