mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
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
87a6690cc6.
Updates PGSTAT_FILE_FORMAT_ID due to the addition of a new BackendType.
Reviewed-by: Noah Misch <noah@leadboat.com>
Co-authored-by: Thomas Munro <thomas.munro@gmail.com>
Co-authored-by: Andres Freund <andres@anarazel.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
This commit is contained in:
@@ -30,4 +30,8 @@ extern void pgaio_init_backend(void);
|
||||
extern void pgaio_error_cleanup(void);
|
||||
extern void AtEOXact_Aio(bool is_commit);
|
||||
|
||||
|
||||
/* aio_worker.c */
|
||||
extern bool pgaio_workers_enabled(void);
|
||||
|
||||
#endif /* AIO_SUBSYS_H */
|
||||
|
||||
22
src/include/storage/io_worker.h
Normal file
22
src/include/storage/io_worker.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* io_worker.h
|
||||
* IO worker for implementing AIO "ourselves"
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/storage/io.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef IO_WORKER_H
|
||||
#define IO_WORKER_H
|
||||
|
||||
|
||||
pg_noreturn extern void IoWorkerMain(const void *startup_data, size_t startup_data_len);
|
||||
|
||||
extern PGDLLIMPORT int io_workers;
|
||||
|
||||
#endif /* IO_WORKER_H */
|
||||
@@ -449,7 +449,9 @@ extern PGDLLIMPORT PGPROC *PreparedXactProcs;
|
||||
* 2 slots, but WAL writer is launched only after startup has exited, so we
|
||||
* only need 6 slots.
|
||||
*/
|
||||
#define NUM_AUXILIARY_PROCS 6
|
||||
#define MAX_IO_WORKERS 32
|
||||
#define NUM_AUXILIARY_PROCS (6 + MAX_IO_WORKERS)
|
||||
|
||||
|
||||
/* configurable options */
|
||||
extern PGDLLIMPORT int DeadlockTimeout;
|
||||
|
||||
Reference in New Issue
Block a user