Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda72269

Browse files
anarazelmacdicenbyavuzmelanieplageman
committed
aio: Add core asynchronous I/O infrastructure
The main motivations to use AIO in PostgreSQL are:a) Reduce the time spent waiting for IO by issuing IO sufficiently early. In a few places we have approximated this using posix_fadvise() based prefetching, but that is fairly limited (no completion feedback, double the syscalls, only works with buffered IO, only works on some OSs).b) Allow to use Direct-I/O (DIO). DIO can offload most of the work for IO to hardware and thus increase throughput / decrease CPU utilization, as well as reduce latency. While we have gained the ability to configure DIO ind4e71df, it is not yet usable for real world workloads, as every IO is executed synchronously.For portability, the new AIO infrastructure allows to implement AIO usingdifferent methods. The choice of the AIO method is controlled by the newio_method GUC. As of this commit, the only implemented method is "sync",i.e. AIO is not actually executed asynchronously. The "sync" method exists toallow to bypass most of the new code initially.Subsequent commits will introduce additional IO methods, including across-platform method implemented using worker processes and a linux specificmethod using io_uring.To allow different parts of postgres to use AIO, the core AIO infrastructuredoes not need to know what kind of files it is operating on. The necessarybehavioral differences for different files are abstracted as "AIOTargets". One example target would be smgr. For boring portability reasons,all targets currently need to be added to an array in aio_target.c. Thiscommit does not implement any AIO targets, just the infrastructure forthem. The smgr target will be added in a later commit.Completion (and other events) of IOs for one type of file (i.e. one AIOtarget) need to be reacted to differently, based on the IO operation and thecallsite. This is made possible by callbacks that can be registered onIOs. E.g. an smgr read into a local buffer does not need to update thecorresponding BufferDesc (as there is none), but a read into shared buffersdoes. This commit does not contain any callbacks, they will be added insubsequent commits.For now the AIO infrastructure only understands READV and WRITEV operations,but it is expected that more operations will be added. E.g. fsync/fdatasync,flush_range and network operations like send/recv.As of this commit, nothing uses the AIO infrastructure. Later commits will addan smgr target, md.c and bufmgr.c callbacks and then finally use AIO forread_stream.c IO, which, in one fell swoop, will convert all read stream usersto AIO.The goal is to use AIO in many more places. There are patches to use AIO forcheckpointer and bgwriter that are reasonably close to being ready. There alsoare prototypes to use it for WAL, relation extension, backend writes and manymore. Those prototypes were important to ensure the design of the AIOsubsystem is not too limiting (e.g. WAL writes need to happen in criticalsections, which influenced a lot of the design).A future commit will add an AIO README explaining the AIO architecture and howto use the AIO subsystem. The README is added later, as it references detailsonly added in later commits.Many many more people than the folks named below have contributed withfeedback, work on semi-independent patches etc. E.g. various folks havecontributed patches to use the read stream infrastructure (added by Thomas inb5a9b18) in more places. Similarly, a *lot* of folks have contributed tothe CI infrastructure, which I had started to work on to make adding AIOfeasible.Some of the work by contributors has gone into the "v1" prototype of AIO,which heavily influenced the current design of the AIO subsystem. None of thecode from that directly survives, but without the prototype, the currentversion of the AIO infrastructure would not exist.Similarly, the reviewers below have not necessarily looked at the currentdesign or the whole infrastructure, but have provided very valuable input. Iam to blame for problems, not they.Author: Andres Freund <andres@anarazel.de>Co-authored-by: Thomas Munro <thomas.munro@gmail.com>Co-authored-by: Nazir Bilal Yavuz <byavuz81@gmail.com>Co-authored-by: Melanie Plageman <melanieplageman@gmail.com>Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>Reviewed-by: Noah Misch <noah@leadboat.com>Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>Reviewed-by: Robert Haas <robertmhaas@gmail.com>Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>Reviewed-by: Antonin Houska <ah@cybertec.at>Discussion:https://postgr.es/m/uvrtrknj4kdytuboidbhwclo4gxhswwcpgadptsjvjqcluzmah%40brqs62irg4dtDiscussion:https://postgr.es/m/20210223100344.llw5an2aklengrmn@alap3.anarazel.deDiscussion:https://postgr.es/m/stj36ea6yyhoxtqkhpieia2z4krnam7qyetc57rfezgk4zgapf@gcnactj4z56m
1 parent0284401 commitda72269

File tree

13 files changed

+2834
-0
lines changed

13 files changed

+2834
-0
lines changed

‎src/backend/storage/aio/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ include $(top_builddir)/src/Makefile.global
1010

1111
OBJS =\
1212
aio.o\
13+
aio_callback.o\
1314
aio_init.o\
15+
aio_io.o\
16+
aio_target.o\
17+
method_sync.o\
1418
read_stream.o
1519

1620
include$(top_srcdir)/src/backend/common.mk

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp