1 { pkgs, lib, config, ... }:
6 algorithm = mkDefault "zstd";
7 # There is little point creating a zram greater
8 # than twice the size of memory.
9 memoryPercent = mkDefault 150;
10 # Linux supports multithreaded compression for 1 device since 3.15.
11 # See https://lkml.org/lkml/2014/2/28/404 for details.
12 swapDevices = mkDefault 1;
15 boot.kernel.sysctl = {
16 # Increase cache pressure, which increases the tendency of the kernel to
17 # reclaim memory used for caching of directory and inode objects. You will use
18 # less memory over a longer period of time. The performance hit is negated by
19 # the downside of swapping sooner.
20 "vm.vfs_cache_pressure" = mkDefault 500;
22 # Increasing how aggressively the kernel will swap memory pages since we are
24 "vm.swappiness" = mkDefault 100;
26 # Background processes will start writing right away when it hits the 1% limit
27 "vm.dirty_background_ratio" = mkDefault 1;
29 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
30 "vm.dirty_ratio" = mkDefault 50;