pgsql: Shrink memory contexts struct sizes - Mailing list pgsql-committers

From David Rowley
Subject pgsql: Shrink memory contexts struct sizes
Date
Msg-id E1qLB0D-000i8g-Pc@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Nathan Bossart
Date:
Subject: pgsql: Simplify option handling in pg_ctl.
Next
From: Nathan Bossart
Date:
Subject: pgsql: Remove db_user_namespace.