diff --git a/puppet/zulip/lib/facter/io_uring_available.rb b/puppet/zulip/lib/facter/io_uring_available.rb new file mode 100644 index 0000000000..a0f6265cde --- /dev/null +++ b/puppet/zulip/lib/facter/io_uring_available.rb @@ -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 diff --git a/puppet/zulip/templates/postgresql/zulip.conf.template.erb b/puppet/zulip/templates/postgresql/zulip.conf.template.erb index 3ded2e203b..e2fd1890cf 100644 --- a/puppet/zulip/templates/postgresql/zulip.conf.template.erb +++ b/puppet/zulip/templates/postgresql/zulip.conf.template.erb @@ -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 -%>