Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

postgresql: Default to io_method=io_uring on PostgreSQL 18.

Alex Vandiverf0cc982e52a6
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 00000000000..a0f6265cdeb
--- /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 3ded2e203b7..e2fd1890cf8 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 -%>