pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Shrink memory contexts struct sizes
Date: Sun, 16 Jul 2023 23:18:10 +0000
Message-ID: <E1qLB0D-000i8g-Pc@gemulon.postgresql.org> (raw)

Shrink memory contexts struct sizes

Here we reduce the block size fields in AllocSetContext, GenerationContext
and SlabContext from Size down to uint32.  Ever since c6e0fe1f2, blocks
for non-dedicated palloc chunks can no longer be larger than 1GB, so
there's no need to store the various block size fields as 64-bit values.
32 bits are enough to store 2^30.

Here we also further reduce the memory context struct sizes by getting rid
of the 'keeper' field which stores a pointer to the context's keeper
block.  All the context types which have this field always allocate the
keeper block in the same allocation as the memory context itself, so the
keeper block always comes right at the end of the context struct.  Add
some macros to calculate that address rather than storing it in the
context.

Overall, in AllocSetContext and GenerationContext, this saves 20 bytes on
64-bit builds which for ALLOCSET_SMALL_SIZES can sometimes mean the
difference between having to allocate a 2nd block and storing all the
required allocations on the keeper block alone.  Such contexts are used
in relcache to store cache entries for indexes, of which there can be
a large number in a single backend.

Author: Melih Mutlu
Reviewed-by: David Rowley
Discussion: https://postgr.es/m/CAGPVpCSOW3uJ1QJmsMR9_oE3X7fG_z4q0AoU4R_w+2RzvroPFg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2c2eb0d6b27f498851bace47fc19e4c7fc90af4f

Modified Files
--------------
src/backend/utils/mmgr/aset.c       | 44 ++++++++++++++++++++-----------------
src/backend/utils/mmgr/generation.c | 42 +++++++++++++++++++----------------
src/backend/utils/mmgr/slab.c       | 22 +++++++++++--------
3 files changed, 60 insertions(+), 48 deletions(-)



Message-ID: <E1qLB0D-000i8g-Pc@gemulon.postgresql.org>
Permalink:  ../E1qLB0D-000i8g-Pc@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qLB0D-000i8g-Pc@gemulon.postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Shrink memory contexts struct sizes
  In-Reply-To: <E1qLB0D-000i8g-Pc@gemulon.postgresql.org>

* 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