Skip to content

Commit

Permalink
hydra: postgres tuning
Browse files Browse the repository at this point in the history
Main thing that seemed to make a difference in pgbench was
full_page_writes=off
  • Loading branch information
lopsided98 committed Dec 2, 2024
1 parent 61a64c0 commit ec7933e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions modules/config/hydra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@
useSubstitutes = true;
};

# ZFS dataset properties:
# atime=off
# compression=zstd
# recordsize=16K
services.postgresql = {
package = pkgs.postgresql_13;
package = pkgs.postgresql_17;
dataDir = "/var/db/postgresql-${config.services.postgresql.package.psqlSchema}";
settings = {
max_connections = 250;
work_mem = "8MB";
shared_buffers = "512MB";
shared_buffers = "4GB";
# ZFS ARC defaults to 50% of RAM
effective_cache_size = "64GB";
# ZFS writes are atomic, so this is unnecessary
# See: https://wiki.postgresql.org/wiki/Full_page_writes
full_page_writes = "off";
# Useless with CoW
wal_init_zero = "off";
wal_recycle = "off";
};
};

Expand Down
3 changes: 2 additions & 1 deletion modules/tasks/filesystems/zfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
{ config, lib, pkgs, ... }: with lib; mkIf (config.boot.supportedFilesystems.zfs or false) (mkMerge [
({
boot = {
# Use default LTS kernel
# Lower priority than mkForce to allow devices to use custom kernels
kernelPackages = mkOverride 75 config.boot.zfs.package.latestCompatibleLinuxPackages;
kernelPackages = mkOverride 75 pkgs.linuxPackages;
zfs = {
# Recommended to be disabled to avoid potential corruption
forceImportRoot = false;
Expand Down

0 comments on commit ec7933e

Please sign in to comment.