This commit introduces a hugepages configuration for postgres via a rhizome lib+bin. At the moment, it uses the default huge page size (2M), and calculates the number of huge pages as 25% of the total available memory. The setup adjusts the shared_buffers accordingly to fit the shared memory within the allocated number of hugepages. The configuration happens as an `ExecStartPre` script added to the existing systemd unit managed by pg_ctlcluster. To keep the semantics of the `start` command unchanged, the hugepages script *does not* stop an existing cluster to configure hugepages, and only does it when the cluster is not running. In a subsequent change, we can consider adding the boot parameters to setup 1G hugepages for larger instances (possibly standard-30+), where they are most useful. [1]: https://www.postgresql.org/docs/current/kernel-resources.html#LINUX-HUGE-PAGES
18 lines
325 B
Ruby
Executable File
18 lines
325 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
|
|
|
require_relative "../lib/hugepages_setup"
|
|
require "logger"
|
|
|
|
if ARGV.count != 1
|
|
fail "Wrong number of arguments. Expected 1, Given #{ARGV.count}"
|
|
end
|
|
|
|
instance = ARGV[0]
|
|
|
|
logger = Logger.new($stdout)
|
|
logger.level = Logger::INFO
|
|
|
|
HugepagesSetup.new(instance, logger).setup
|