pgsql: aio: Infrastructure for io_method=worker

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: aio: Infrastructure for io_method=worker
Date: 2025-03-18 16:01:43
Message-ID: E1tuZNv-0037Gs-34@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

aio: Infrastructure for io_method=worker

This commit contains the basic, system-wide, infrastructure for
io_method=worker. It does not yet actually execute IO, this commit just
provides the infrastructure for running IO workers, kept separate for easier
review.

The number of IO workers can be adjusted with a PGC_SIGHUP GUC. Eventually
we'd like to make the number of workers dynamically scale up/down based on the
current "IO load".

To allow the number of IO workers to be increased without a restart, we need
to reserve PGPROC entries for the workers unconditionally. This has been
judged to be worth the cost. If it turns out to be problematic, we can
introduce a PGC_POSTMASTER GUC to control the maximum number.

As io workers might be needed during shutdown, e.g. for AIO during the
shutdown checkpoint, a new PMState phase is added. IO workers are shut down
after the shutdown checkpoint has been performed and walsender/archiver have
shut down, but before the checkpointer itself shuts down. See also
87a6690cc69.

Updates PGSTAT_FILE_FORMAT_ID due to the addition of a new BackendType.

Reviewed-by: Noah Misch <noah(at)leadboat(dot)com>
Co-authored-by: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Co-authored-by: Andres Freund <andres(at)anarazel(dot)de>
Discussion: https://postgr.es/m/uvrtrknj4kdytuboidbhwclo4gxhswwcpgadptsjvjqcluzmah%40brqs62irg4dt
Discussion: https://postgr.es/m/20210223100344.llw5an2aklengrmn@alap3.anarazel.de
Discussion: https://postgr.es/m/stj36ea6yyhoxtqkhpieia2z4krnam7qyetc57rfezgk4zgapf@gcnactj4z56m

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/55b454d0e14084c841a034073abbf1a0ea937a45

Modified Files
--------------
doc/src/sgml/config.sgml | 19 +++
src/backend/postmaster/launch_backend.c | 2 +
src/backend/postmaster/pmchild.c | 1 +
src/backend/postmaster/postmaster.c | 174 ++++++++++++++++++++++--
src/backend/storage/aio/Makefile | 1 +
src/backend/storage/aio/meson.build | 1 +
src/backend/storage/aio/method_worker.c | 88 ++++++++++++
src/backend/tcop/postgres.c | 7 +
src/backend/utils/activity/pgstat_backend.c | 1 +
src/backend/utils/activity/pgstat_io.c | 1 +
src/backend/utils/activity/wait_event_names.txt | 1 +
src/backend/utils/init/miscinit.c | 3 +
src/backend/utils/misc/guc_tables.c | 13 ++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/miscadmin.h | 2 +
src/include/pgstat.h | 2 +-
src/include/storage/aio_subsys.h | 4 +
src/include/storage/io_worker.h | 22 +++
src/include/storage/proc.h | 4 +-
src/test/regress/expected/stats.out | 10 +-
20 files changed, 342 insertions(+), 15 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2025-03-18 16:01:44 pgsql: aio: Add io_method=worker
Previous Message Jeff Davis 2025-03-18 15:37:55 pgsql: Fix headerscheck warning.

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Pyhalov 2025-03-18 16:04:49 Re: Add semi-join pushdown to postgres_fdw
Previous Message Jeff Davis 2025-03-18 15:53:56 Re: Update Unicode data to Unicode 16.0.0