Browse Source

toolset: Tune the AIO parameters for PostgreSQL 18 (#10378)

Signed-off-by: Anton Kirilov <[email protected]>
Anton Kirilov 4 days ago
parent
commit
36f19be611

+ 8 - 1
toolset/databases/postgres/config.sh

@@ -2,4 +2,11 @@
 
 set -e
 
-cat /tmp/postgresql.conf >> "${PGDATA}/postgresql.conf"
+cat /docker-entrypoint-initdb.d/postgresql.conf >> "${PGDATA}/postgresql.conf"
+
+IO_WORKERS="$(( (`nproc` + 3) / 4 ))"
+
+# The maximum valid value for the io_workers configuration parameter is 32.
+if [[ "$IO_WORKERS" -lt 32 ]]; then
+    sed -i "s/io_workers = 32/io_workers = ${IO_WORKERS}/" "${PGDATA}/postgresql.conf"
+fi

+ 2 - 4
toolset/databases/postgres/postgres.dockerfile

@@ -1,10 +1,8 @@
 FROM postgres:18-trixie
 
-ENV PGDATA=/ssd/postgresql \
-    POSTGRES_DB=hello_world \
+ENV POSTGRES_DB=hello_world \
     POSTGRES_PASSWORD=benchmarkdbpass \
     POSTGRES_USER=benchmarkdbuser
 
 COPY 60-postgresql-shm.conf /etc/sysctl.d/
-COPY config.sh create-postgres.sql /docker-entrypoint-initdb.d/
-COPY postgresql.conf /tmp/
+COPY config.sh create-postgres.sql postgresql.conf /docker-entrypoint-initdb.d/

+ 5 - 0
toolset/databases/postgres/postgresql.conf

@@ -5,6 +5,11 @@ listen_addresses = '*'
 max_connections = 2000
 ssl = false
 
+# Tuning AIO in PostgreSQL 18:
+# https://vondra.me/posts/tuning-aio-in-postgresql-18
+# The config.sh script sets the actual value based on that article and the runtime environment.
+io_workers = 32
+
 # values from: http://blog.pgaddict.com/posts/performance-since-postgresql-7-4-to-9-4-pgbench
 # details: http://www.postgresql.org/docs/9.4/static/runtime-config-resource.html
 # http://www.postgresql.org/docs/9.4/static/runtime-config-wal.html