Re: Asynchronous and "direct" IO support for PostgreSQL.
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@postgresql.org
Cc: Thomas Munro <thomas.munro@gmail.com>, David Rowley <dgrowleyml@gmail.com>, Melanie Plageman <melanieplageman@gmail.com>
Date: 2021-09-01T05:56:59Z
Lists: pgsql-hackers
Attachments
- v3-0001-windows-Only-consider-us-to-be-running-as-service.patch.gz (application/x-patch-gzip) patch v3-0001
- v3-0002-WIP-Fix-non-aio-bug-leading-to-checkpointer-not-s.patch.gz (application/x-patch-gzip) patch v3-0002
- v3-0003-aio-WIP-align-PGAlignedBlock-to-page-size.patch.gz (application/x-patch-gzip) patch v3-0003
- v3-0004-Add-allocator-support-for-larger-allocation-align.patch.gz (application/x-patch-gzip) patch v3-0004
- v3-0005-ilist.h-debugging-improvements.patch.gz (application/x-patch-gzip) patch v3-0005
- v3-0006-lwlock-xlog-Report-caller-wait-event-for-LWLockWa.patch.gz (application/x-patch-gzip) patch v3-0006
- v3-0007-heapam-Don-t-re-inquire-block-number-for-each-tup.patch.gz (application/x-patch-gzip) patch v3-0007
- v3-0008-Add-pg_prefetch_mem-macro-to-load-cache-lines.patch.gz (application/x-patch-gzip) patch v3-0008
- v3-0009-heapam-WIP-cacheline-prefetching-for-hot-pruning.patch.gz (application/x-patch-gzip) patch v3-0009
- v3-0010-WIP-Change-instr_time-to-just-store-nanoseconds-t.patch.gz (application/x-patch-gzip) patch v3-0010
- v3-0011-aio-Add-some-error-checking-around-pinning.patch.gz (application/x-patch-gzip) patch v3-0011
- v3-0012-aio-allow-lwlocks-to-be-unowned.patch.gz (application/x-patch-gzip) patch v3-0012
- v3-0013-condvar-add-ConditionVariableCancelSleepEx.patch.gz (application/x-patch-gzip) patch v3-0013
- v3-0014-Use-a-global-barrier-to-fix-DROP-TABLESPACE-on-Wi.patch.gz (application/x-patch-gzip) patch v3-0014
- v3-0015-pg_buffercache-Add-pg_buffercache_stats.patch.gz (application/x-patch-gzip) patch v3-0015
- v3-0016-bufmgr-Add-LockBufHdr-fastpath.patch.gz (application/x-patch-gzip) patch v3-0016
- v3-0017-lwlock-WIP-add-extended-locking-functions.patch.gz (application/x-patch-gzip) patch v3-0017
- v3-0018-io-Add-O_DIRECT-non-buffered-IO-mode.patch.gz (application/x-patch-gzip) patch v3-0018
- v3-0019-io-Increase-default-ringbuffer-size.patch.gz (application/x-patch-gzip) patch v3-0019
- v3-0020-Use-aux-process-resource-owner-in-walsender.patch.gz (application/x-patch-gzip) patch v3-0020
- v3-0021-Ensure-a-resowner-exists-for-all-paths-that-may-p.patch.gz (application/x-patch-gzip) patch v3-0021
- v3-0022-aio-Add-asynchronous-IO-infrastructure.patch.gz (application/x-patch-gzip) patch v3-0022
- v3-0023-aio-Use-AIO-in-pg_prewarm.patch.gz (application/x-patch-gzip) patch v3-0023
- v3-0024-aio-Use-AIO-in-bulk-relation-extension.patch.gz (application/x-patch-gzip) patch v3-0024
- v3-0025-aio-Use-AIO-in-checkpointer-bgwriter.patch.gz (application/x-patch-gzip) patch v3-0025
- v3-0026-aio-bitmap-heap-scan-Minimal-and-hacky-improvemen.patch.gz (application/x-patch-gzip) patch v3-0026
- v3-0027-aio-Use-AIO-in-heap-vacuum-s-lazy_scan_heap-and-l.patch.gz (application/x-patch-gzip) patch v3-0027
- v3-0028-aio-Use-AIO-in-nbtree-vacuum-scan.patch.gz (application/x-patch-gzip) patch v3-0028
- v3-0029-aio-Use-AIO-for-heap-table-scans.patch.gz (application/x-patch-gzip) patch v3-0029
- v3-0030-aio-Use-AIO-in-SyncDataDirectory.patch.gz (application/x-patch-gzip) patch v3-0030
- v3-0031-aio-Use-AIO-in-ProcessSyncRequests.patch.gz (application/x-patch-gzip) patch v3-0031
- v3-0032-aio-wal-concurrent-WAL-flushes.patch.gz (application/x-patch-gzip) patch v3-0032
- v3-0033-wal-Use-LWLockAcquireOrWait-in-AdvanceXLInsertBuf.patch.gz (application/x-patch-gzip) patch v3-0033
- v3-0034-wip-wal-async-commit-reduce-frequency-of-latch-se.patch.gz (application/x-patch-gzip) patch v3-0034
- v3-0035-aio-wal-padding-of-partial-records.patch.gz (application/x-patch-gzip) patch v3-0035
- v3-0036-aio-wal-extend-pg_stat_wal.patch.gz (application/x-patch-gzip) patch v3-0036
- v3-0037-aio-initial-sketch-for-design-document.patch.gz (application/x-patch-gzip) patch v3-0037
- v3-0038-aio-CI-and-README.md.patch.gz (application/x-patch-gzip) patch v3-0038
- v3-0039-XXX-Add-temporary-workaround-for-partition_prune-.patch.gz (application/x-patch-gzip) patch v3-0039
Hi, Attached is an updated patch AIO series. The major changes are: - rebased onto master (Andres) - lots of progress on posix AIO backend (Thomas) - lots of progress towards a windows native AIO implementation - not yet quite merged (Thomas & David) - considerably improved "worker" io_method (Thomas) - some preliminary patches merged (Thomas) and thus dropped - error handling overhaul, AIO references now use resource owners - quite a few more localized bugfixes - further CI improvements Unfortunately there's a few tests that don't pass on windows. At least some of those failures also happen on master - hence the alternative output file added in the last commit. Thanks to Thomas there's now a new wiki page for AIO support: https://wiki.postgresql.org/wiki/AIO It's currently mostly a shared todo list.... My own next steps are to try to get some of the preliminary patches merged into master, and to address some of the higher level things that aren't yet quite right with the AIO interface, and to split the "main" AIO patch into smaller patches. I hope that we soon send in a new version with native AIO support for windows. I'm mostly interested in that to make sure that we get the shared infrastructure right. Melanie has some work improving bitmap heap scan AIO support and some IO stats / explain improvements. I think a decent and reasonably simple example for the way the AIO interface can be used to do faster IO is v3-0028-aio-Use-AIO-in-nbtree-vacuum-scan.patch.gz which adds AIO for nbtree vacuum. It's not perfectly polished, but I think it shows that it's not too hard to add AIO usage to individual once the general infrastructure is in place. I've attached the code for posterity, but the series is large enough that I don't think it makes sense to do that all that often... The code is at https://github.com/anarazel/postgres/tree/aio Greetings, Andres Freund
Commits
-
aio: Add README.md explaining higher level design
- fdd146a8ef2b 18.0 landed
-
bufmgr: Use AIO in StartReadBuffers()
- 12ce89fd0708 18.0 landed
-
bufmgr: Implement AIO read support
- 047cba7fa0f8 18.0 landed
-
aio: Implement support for reads in smgr/md/fd
- 50cb7505b301 18.0 landed
-
aio: Add io_method=io_uring
- c325a7633fcb 18.0 landed
-
aio: Add io_method=worker
- 247ce06b883d 18.0 landed
-
aio: Infrastructure for io_method=worker
- 55b454d0e140 18.0 landed
-
aio: Add core asynchronous I/O infrastructure
- da7226993fd4 18.0 landed