pgsql: Add support for basic NUMA awareness

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add support for basic NUMA awareness
Date: 2025-04-07 21:18:10
Message-ID: E1u1tr8-003BbL-20@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add support for basic NUMA awareness

Add basic NUMA awareness routines, using a minimal src/port/pg_numa.c
portability wrapper and an optional build dependency, enabled by
--with-libnuma configure option. For now this is Linux-only, other
platforms may be supported later.

A built-in SQL function pg_numa_available() allows checking NUMA
support, i.e. that the server was built/linked with the NUMA library.

The main function introduced is pg_numa_query_pages(), which allows
determining the NUMA node for individual memory pages. Internally the
function uses move_pages(2) syscall, as it allows batching, and is more
efficient than get_mempolicy(2).

Author: Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>
Co-authored-by: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Reviewed-by: Tomas Vondra <tomas(at)vondra(dot)me>
Discussion: https://postgr.es/m/CAKZiRmxh6KWo0aqRqvmcoaX2jUxZYb4kGp3N%3Dq1w%2BDiH-696Xw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/65c298f61fc70f2f960437c05649f71b862e2c48

Modified Files
--------------
.cirrus.tasks.yml | 2 +
configure | 187 ++++++++++++++++++++++++++++++++++++
configure.ac | 14 +++
doc/src/sgml/func.sgml | 13 +++
doc/src/sgml/installation.sgml | 22 +++++
meson.build | 23 +++++
meson_options.txt | 3 +
src/Makefile.global.in | 6 +-
src/backend/utils/misc/guc_tables.c | 2 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 4 +
src/include/pg_config.h.in | 3 +
src/include/port/pg_numa.h | 40 ++++++++
src/include/storage/pg_shmem.h | 1 +
src/makefiles/meson.build | 3 +
src/port/Makefile | 1 +
src/port/meson.build | 1 +
src/port/pg_numa.c | 120 +++++++++++++++++++++++
18 files changed, 444 insertions(+), 3 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-04-07 22:59:18 pgsql: Flush the IO statistics of active WAL senders more frequently
Previous Message Álvaro Herrera 2025-04-07 19:58:33 pgsql: Use specific collation where needed in new test