aio: Adjust I/O worker pool automatically.
Thomas Munro <tmunro@postgresql.org>
aio: Adjust I/O worker pool automatically. The size of the I/O worker pool used to implement io_method=worker was previously controlled by the io_workers setting, defaulting to 3. It was hard to know how to tune it effectively. That is replaced with: io_min_workers=2 io_max_workers=8 (up to 32) io_worker_idle_timeout=60s io_worker_launch_interval=100ms The pool is automatically sized within the configured range according to recent variation in demand. It grows when existing workers detect that latency might be introduced by queuing, and shrinks when the highest-numbered worker is idle for too long. Work was already concentrated into low-numbered workers in anticipation of this logic. The logic for waking extra workers now also tries to measure and reduce the number of spurious wakeups, though they are not entirely eliminated. Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com> Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com> Discussion: https://postgr.es/m/CA%2BhUKG%2Bm4xV0LMoH2c%3DoRAdEXuCnh%2BtGBTWa7uFeFMGgTLAw%2BQ%40mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/config.sgml | modified | +64 −5 |
| src/backend/postmaster/postmaster.c | modified | +134 −41 |
| src/backend/storage/aio/method_worker.c | modified | +546 −90 |
| src/backend/utils/activity/wait_event_names.txt | modified | +1 −0 |
| src/backend/utils/misc/guc_parameters.dat | modified | +30 −4 |
| src/backend/utils/misc/postgresql.conf.sample | modified | +5 −1 |
| src/include/storage/io_worker.h | modified | +10 −1 |
| src/include/storage/lwlocklist.h | modified | +1 −0 |
| src/include/storage/pmsignal.h | modified | +1 −0 |
| src/test/modules/test_aio/t/002_io_workers.pl | modified | +9 −6 |
| src/tools/pgindent/typedefs.list | modified | +1 −0 |
Discussion
- Automatically sizing the IO worker pool 26 messages · 2025-04-12 → 2026-04-14