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+2rzvro...@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(-)