Re: Asynchronous and "direct" IO support for PostgreSQL.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Subject: Re: Asynchronous and "direct" IO support for PostgreSQL.
Date: 2021-09-01 05:56:59
Message-ID: 20210901055659.52doj7oc5uglvezv@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v3-0001-windows-Only-consider-us-to-be-running-as-service.patch.gz application/x-patch-gzip 2.0 KB
v3-0002-WIP-Fix-non-aio-bug-leading-to-checkpointer-not-s.patch.gz application/x-patch-gzip 1.4 KB
v3-0003-aio-WIP-align-PGAlignedBlock-to-page-size.patch.gz application/x-patch-gzip 652 bytes
v3-0004-Add-allocator-support-for-larger-allocation-align.patch.gz application/x-patch-gzip 4.5 KB
v3-0005-ilist.h-debugging-improvements.patch.gz application/x-patch-gzip 1.9 KB
v3-0006-lwlock-xlog-Report-caller-wait-event-for-LWLockWa.patch.gz application/x-patch-gzip 1.3 KB
v3-0007-heapam-Don-t-re-inquire-block-number-for-each-tup.patch.gz application/x-patch-gzip 1.0 KB
v3-0008-Add-pg_prefetch_mem-macro-to-load-cache-lines.patch.gz application/x-patch-gzip 2.0 KB
v3-0009-heapam-WIP-cacheline-prefetching-for-hot-pruning.patch.gz application/x-patch-gzip 825 bytes
v3-0010-WIP-Change-instr_time-to-just-store-nanoseconds-t.patch.gz application/x-patch-gzip 1.7 KB
v3-0011-aio-Add-some-error-checking-around-pinning.patch.gz application/x-patch-gzip 1.2 KB
v3-0012-aio-allow-lwlocks-to-be-unowned.patch.gz application/x-patch-gzip 1.6 KB
v3-0013-condvar-add-ConditionVariableCancelSleepEx.patch.gz application/x-patch-gzip 915 bytes
v3-0014-Use-a-global-barrier-to-fix-DROP-TABLESPACE-on-Wi.patch.gz application/x-patch-gzip 2.8 KB
v3-0015-pg_buffercache-Add-pg_buffercache_stats.patch.gz application/x-patch-gzip 1.9 KB
v3-0016-bufmgr-Add-LockBufHdr-fastpath.patch.gz application/x-patch-gzip 787 bytes
v3-0017-lwlock-WIP-add-extended-locking-functions.patch.gz application/x-patch-gzip 5.2 KB
v3-0018-io-Add-O_DIRECT-non-buffered-IO-mode.patch.gz application/x-patch-gzip 3.8 KB
v3-0019-io-Increase-default-ringbuffer-size.patch.gz application/x-patch-gzip 779 bytes
v3-0020-Use-aux-process-resource-owner-in-walsender.patch.gz application/x-patch-gzip 1.6 KB
v3-0021-Ensure-a-resowner-exists-for-all-paths-that-may-p.patch.gz application/x-patch-gzip 1.2 KB
v3-0022-aio-Add-asynchronous-IO-infrastructure.patch.gz application/x-patch-gzip 89.1 KB
v3-0023-aio-Use-AIO-in-pg_prewarm.patch.gz application/x-patch-gzip 2.1 KB
v3-0024-aio-Use-AIO-in-bulk-relation-extension.patch.gz application/x-patch-gzip 8.0 KB
v3-0025-aio-Use-AIO-in-checkpointer-bgwriter.patch.gz application/x-patch-gzip 5.0 KB
v3-0026-aio-bitmap-heap-scan-Minimal-and-hacky-improvemen.patch.gz application/x-patch-gzip 1.1 KB
v3-0027-aio-Use-AIO-in-heap-vacuum-s-lazy_scan_heap-and-l.patch.gz application/x-patch-gzip 5.9 KB
v3-0028-aio-Use-AIO-in-nbtree-vacuum-scan.patch.gz application/x-patch-gzip 2.4 KB
v3-0029-aio-Use-AIO-for-heap-table-scans.patch.gz application/x-patch-gzip 3.9 KB
v3-0030-aio-Use-AIO-in-SyncDataDirectory.patch.gz application/x-patch-gzip 4.2 KB
v3-0031-aio-Use-AIO-in-ProcessSyncRequests.patch.gz application/x-patch-gzip 7.3 KB
v3-0032-aio-wal-concurrent-WAL-flushes.patch.gz application/x-patch-gzip 19.4 KB
v3-0033-wal-Use-LWLockAcquireOrWait-in-AdvanceXLInsertBuf.patch.gz application/x-patch-gzip 1.2 KB
v3-0034-wip-wal-async-commit-reduce-frequency-of-latch-se.patch.gz application/x-patch-gzip 987 bytes
v3-0035-aio-wal-padding-of-partial-records.patch.gz application/x-patch-gzip 2.8 KB
v3-0036-aio-wal-extend-pg_stat_wal.patch.gz application/x-patch-gzip 3.2 KB
v3-0037-aio-initial-sketch-for-design-document.patch.gz application/x-patch-gzip 2.0 KB
v3-0038-aio-CI-and-README.md.patch.gz application/x-patch-gzip 5.1 KB
v3-0039-XXX-Add-temporary-workaround-for-partition_prune-.patch.gz application/x-patch-gzip 19.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2021-09-01 06:01:43 Re: prevent immature WAL streaming
Previous Message hubert depesz lubaczewski 2021-09-01 05:45:27 Re: Can we get rid of repeated queries from pg_dump?