Skip to content

Commit 83336cf

Browse files
committed
aio: Add io_method=posix_aio for FreeBSD.
Add support for native kernel-based AIO on FreeBSD, using its vectored I/O extension and kqueue for completion events. (Earlier versions worked on about 5 other OSes, but not very well.)
1 parent b8aa808 commit 83336cf

File tree

9 files changed

+433
-0
lines changed

9 files changed

+433
-0
lines changed

.cirrus.tasks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ task:
140140
# - Specifies configuration options that test reading/writing/copying of node trees
141141
# - Specifies debug_parallel_query=regress, to catch related issues during CI
142142
# - Also runs tests against a running postgres instance, see test_running_script
143+
# - Uses io_method=posix_aio
143144
task:
144145
name: FreeBSD - Meson
145146

@@ -162,6 +163,7 @@ task:
162163
-c debug_write_read_parse_plan_trees=on
163164
-c debug_raw_expression_coverage_test=on
164165
-c debug_parallel_query=regress
166+
-c io_method=posix_aio
165167
PG_TEST_PG_UPGRADE_MODE: --link
166168

167169
<<: *freebsd_task_template

meson.build

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,21 @@ endif
977977

978978

979979

980+
###############################################################
981+
# Library: posix_aio (FreeBSD only)
982+
###############################################################
983+
984+
posix_aioopt = get_option('posix_aio')
985+
posix_aio = not_found_dep
986+
if cc.has_function('aio_readv',
987+
args: test_c_args, prefix: '#include <aio.h>',
988+
include_directories: postgres_inc)
989+
cdata.set('USE_POSIX_AIO', 1)
990+
posix_aio = declare_dependency()
991+
endif
992+
993+
994+
980995
###############################################################
981996
# Library: libxml
982997
###############################################################

meson_options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ option('plpython', type: 'feature', value: 'auto',
139139
option('pltcl', type: 'feature', value: 'auto',
140140
description: 'Build with Tcl support (PL/Tcl)')
141141

142+
option('posix_aio', type: 'feature', value: 'auto',
143+
description: 'Build POSIX AIO support (FreeBSD only)')
144+
142145
option('tcl_version', type: 'string', value: 'tcl',
143146
description: 'Tcl version')
144147

src/backend/storage/aio/aio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ const struct config_enum_entry io_method_options[] = {
6969
{"worker", IOMETHOD_WORKER, false},
7070
#ifdef IOMETHOD_IO_URING_ENABLED
7171
{"io_uring", IOMETHOD_IO_URING, false},
72+
#endif
73+
#ifdef IOMETHOD_POSIX_AIO_ENABLED
74+
{"posix_aio", IOMETHOD_POSIX_AIO, false},
7275
#endif
7376
{NULL, 0, false}
7477
};
@@ -90,6 +93,9 @@ static const IoMethodOps *const pgaio_method_ops_table[] = {
9093
#ifdef IOMETHOD_IO_URING_ENABLED
9194
[IOMETHOD_IO_URING] = &pgaio_uring_ops,
9295
#endif
96+
#ifdef IOMETHOD_POSIX_AIO_ENABLED
97+
[IOMETHOD_POSIX_AIO] = &pgaio_posix_aio_ops,
98+
#endif
9399
};
94100

95101
/* callbacks for the configured io_method, set by assign_io_method */

src/backend/storage/aio/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ backend_sources += files(
99
'aio_io.c',
1010
'aio_target.c',
1111
'method_io_uring.c',
12+
'method_posix_aio.c',
1213
'method_sync.c',
1314
'method_worker.c',
1415
'read_stream.c',

0 commit comments

Comments
 (0)