pgsql: Refactor AllocSetAlloc(), separating hot and cold paths

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Refactor AllocSetAlloc(), separating hot and cold paths
Date: 2024-02-28 01:21:19
Message-ID: E1rf8dL-0018j0-43@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Refactor AllocSetAlloc(), separating hot and cold paths

Allocating from a free list or from a block which contains enough space
already, we deem to be common code paths and want to optimize for those.
Having to allocate a new block, either a normal block or a dedicated one
for a large allocation, we deem to be less common, therefore we class
that as "cold". Both cold paths require a malloc so are going to be
slower as a result of that regardless.

The main motivation here is to remove the calls to malloc() in the hot
path and because of this, the compiler is now free to not bother setting
up the stack frame in AllocSetAlloc(), thus making the hot path much
cheaper.

Author: Andres Freund
Reviewed-by: David Rowley
Discussion: https://postgr.es/m/20210719195950.gavgs6ujzmjfaiig@alap3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/413c18401dcc170636429127e2494d8beba4b92f

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 481 +++++++++++++++++++++++-------------------
1 file changed, 268 insertions(+), 213 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2024-02-28 03:52:03 pgsql: Remove last NULL element in config_group_names[]
Previous Message Michael Paquier 2024-02-27 23:42:56 pgsql: Use C99-designated initializer syntax for more arrays