]> Git — Sourcephile - sourcephile-nix.git/blob - nixos/profiles/systems/zramSwap.nix
upnpc: fix on empty description
[sourcephile-nix.git] / nixos / profiles / systems / zramSwap.nix
1 { pkgs, lib, config, ... }:
2 {
3 zramSwap = {
4 enable = true;
5 algorithm = lib.mkDefault "zstd";
6 memoryPercent = lib.mkDefault 50;
7 # Linux supports multithreaded compression for 1 device since 3.15.
8 # See https://lkml.org/lkml/2014/2/28/404 for details.
9 swapDevices = lib.mkDefault 1;
10 };
11
12 boot.kernel.sysctl = {
13 # Increase cache pressure, which increases the tendency of the kernel to
14 # reclaim memory used for caching of directory and inode objects. You will use
15 # less memory over a longer period of time. The performance hit is negated by
16 # the downside of swapping sooner.
17 "vm.vfs_cache_pressure" = lib.mkDefault 500;
18
19 # Increasing how aggressively the kernel will swap memory pages since we are
20 # using ZRAM first.
21 "vm.swappiness" = lib.mkDefault 100;
22
23 # Background processes will start writing right away when it hits the 1% limit
24 "vm.dirty_background_ratio" = lib.mkDefault 1;
25
26 # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
27 "vm.dirty_ratio" = lib.mkDefault 50;
28 };
29 }