postgresql: Default to io_method=io_uring on PostgreSQL 18.

This is more performant than the PostgreSQL 18 default of
`io_method=workers`, but requires kernel 5.1.  All supported OSes of
Zulip have at least that -- however, it may not be available inside
containers, so add a puppet fact to check the syscall before enabling
it in PostgreSQL.
This commit is contained in:
Alex Vandiver 2025-12-11 11:42:30 -05:00 committed by Tim Abbott
parent 48a89464a2
commit f0cc982e52
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,16 @@
Facter.add(:io_uring_available) do
confine :kernel => 'Linux'
setcode do
# Syscall 425 is io_uring_setup
# https://www.chromium.org/chromium-os/developer-library/reference/linux-constants/syscalls/#x86_64_425
# https://manpages.debian.org/trixie/liburing-dev/io_uring_setup.2.en.html
#
# We get ENOSYS if the kernel doesn't have the syscall, or EPERM
# if it's disabled or restricted via seccomp (i.e. in Docker)
result = Facter::Core::Execution.execute(
"perl -MErrno=EPERM,ENOSYS -e 'syscall(425); exit((\$! != EPERM and \$! != ENOSYS) ? 0 : 1)'",
:on_fail => :failed
)
result != :failed && $?.success?
end
end

View File

@ -42,6 +42,9 @@ max_wal_size = <%= @max_wal_size %>
<% unless @random_page_cost.nil? -%>
random_page_cost = <%= @random_page_cost %>
<% end -%>
<% if @version.to_i >= 18 && @io_uring_available -%>
io_method = io_uring
<% end -%>
<% unless @effective_io_concurrency.nil? -%>
effective_io_concurrency = <%= @effective_io_concurrency %>
<% end -%>