Re: Automatically sizing the IO worker pool
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-06T15:02:52Z
Lists: pgsql-hackers
Attachments
- v4-0002-Refactor-the-postmaster-s-periodic-job-scheduling.patch (text/x-patch) patch v4-0002
- v4-0001-aio-Adjust-I-O-worker-pool-size-automatically.patch (text/x-patch) patch v4-0001
Here's an updated patch. It's mostly just rebased over the recent firehose, but with lots of comments and a few names (hopefully) improved. There is one code change to highlight though: maybe_start_io_workers() knows when it's not allowed to create new workers, an interesting case being FatalError before we have started the new world. The previous coding of DetermineSleepTime() didn't know about that, so it could return 0 (don't sleep), and then the postmaster could busy-wait for restart progress. Maybe there were other cases like that, but in general DetermineSleepTime() and maybe_start_io_workers() really need to be 100% in agreement. So I have moved that knowledge into a new function maybe_start_io_workers_scheduled_at(). Both DetermineSleepTime() and maybe_start_io_workers() call that so there is a single source of truth. I think I got confused about that because it's not that obvious why the existing code doesn't test FatalError. I thought of a slightly bigger refactoring that might deconfuse DetermineSleepTime() a bit more. Probably material for the next cycle, but basically the idea is to stop using a bunch of different conditions and different units of time and convert the whole thing to a simple find-the-lowest-time function. I kept that separate. I'll post a new version of the patch that was v3-0002 separately.
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
aio: Adjust I/O worker pool automatically.
- d1c01b79d4ae 19 (unreleased) landed
-
Convert lwlock.c to use the new shmem allocation functions
- a006bc7b1699 19 (unreleased) cited
-
aio: Simplify pgaio_worker_submit().
- fc44f106657a 19 (unreleased) landed
-
Conditional locking in pgaio_worker_submit_internal
- 29a0fb215779 19 (unreleased) cited
-
aio: Remove obsolete IO worker ID references.
- b4c19da93a08 18.0 landed
- 177c1f059338 19 (unreleased) landed
-
aio: Regularize IO worker internal naming.
- b2afb0676337 18.0 landed
- 01d618bcd782 19 (unreleased) landed