]> Git — Sourcephile - julm/julm-nix.git/blob - nixos/profiles/zramSwap.nix
aubergine: wireguard: move to port 43646
[julm/julm-nix.git] / nixos / profiles / zramSwap.nix
1 { pkgs, lib, config, ... }:
2 with lib;
3 {
4 zramSwap = {
5 enable = true;
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;
13 };
14
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;
21
22 # Increasing how aggressively the kernel will swap memory pages since we are
23 # using ZRAM first.
24 "vm.swappiness" = mkDefault 100;
25
26 # Background processes will start writing right away when it hits the 1% limit
27 "vm.dirty_background_ratio" = mkDefault 1;
28
29 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
30 "vm.dirty_ratio" = mkDefault 50;
31 };
32 }