Skip to content

Commit f141fff

Browse files
committed
toolset: Tune the AIO parameters for PostgreSQL 18
Signed-off-by: Anton Kirilov <[email protected]>
1 parent 80c46e9 commit f141fff

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

toolset/databases/postgres/config.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22

33
set -e
44

5-
cat /tmp/postgresql.conf >> "${PGDATA}/postgresql.conf"
5+
cat /docker-entrypoint-initdb.d/postgresql.conf >> "${PGDATA}/postgresql.conf"
6+
7+
IO_WORKERS="$(( `nproc` / 4 ))"
8+
9+
# The maximum valid value for the io_workers configuration parameter is 32.
10+
if [[ "$IO_WORKERS" -lt 32 ]]; then
11+
sed -i "s/io_workers = 32/io_workers = ${IO_WORKERS}/" "${PGDATA}/postgresql.conf"
12+
fi
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
FROM postgres:18-trixie
22

3-
ENV PGDATA=/ssd/postgresql \
4-
POSTGRES_DB=hello_world \
3+
ENV POSTGRES_DB=hello_world \
54
POSTGRES_PASSWORD=benchmarkdbpass \
65
POSTGRES_USER=benchmarkdbuser
76

87
COPY 60-postgresql-shm.conf /etc/sysctl.d/
9-
COPY config.sh create-postgres.sql /docker-entrypoint-initdb.d/
10-
COPY postgresql.conf /tmp/
8+
COPY config.sh create-postgres.sql postgresql.conf /docker-entrypoint-initdb.d/

toolset/databases/postgres/postgresql.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ listen_addresses = '*'
55
max_connections = 2000
66
ssl = false
77

8+
# Tuning AIO in PostgreSQL 18:
9+
# https://vondra.me/posts/tuning-aio-in-postgresql-18
10+
# The config.sh script sets the actual value based on that article and the runtime environment.
11+
io_workers = 32
12+
813
# values from: http://blog.pgaddict.com/posts/performance-since-postgresql-7-4-to-9-4-pgbench
914
# details: http://www.postgresql.org/docs/9.4/static/runtime-config-resource.html
1015
# http://www.postgresql.org/docs/9.4/static/runtime-config-wal.html

0 commit comments

Comments
 (0)