Optimize GenerationAlloc() and SlabAlloc() In a similar effort to 413c18401, separate out the hot and cold paths in GenerationAlloc() and SlabAlloc() to avoid having to setup the stack frame for the hot path.
This additionally adjusts how we use the GenerationContext's freeblock. Freeblock, when set, is now always empty and we only switch to using it when the current allocation request finds the current block does not have enough space and the freeblock is large enough to accomodate the allocation. This commit also adjusts GenerationFree() so that if we pfree the final allocation in the current generation block, we now mark that block as empty and keep it as the current block. Previously we free'd that block and set the current block to NULL. Doing that meant we needed a special case in GenerationAlloc to check if GenerationContext.block was NULL. So this both reduces free/malloc calls and reduces the work done in GenerationAlloc(). In passing, improve some comments in aset.c Discussion: https://postgr.es/m/CAApHDvpHVSJqqb4B4OZLixr=cotkq-ekkbwzqvzvo_biyvu...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/a0cd95448067273a5cf92ad578a1e2de3b62aa2f Modified Files -------------- src/backend/utils/mmgr/aset.c | 16 +- src/backend/utils/mmgr/generation.c | 415 ++++++++++++++++++++---------------- src/backend/utils/mmgr/slab.c | 232 ++++++++++++-------- 3 files changed, 386 insertions(+), 277 deletions(-)