public inbox for [email protected]  
help / color / mirror / Atom feed
From: David Rowley <[email protected]>
To: [email protected]
Subject: pgsql: Optimize GenerationAlloc() and SlabAlloc()
Date: Mon, 04 Mar 2024 04:42:31 +0000
Message-ID: <[email protected]> (raw)

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_biYvUvQA@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(-)



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: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Optimize GenerationAlloc() and SlabAlloc()
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox