diff options
author | aszlig <aszlig@nix.build> | 2018-07-14 04:18:18 +0200 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2018-07-14 04:42:40 +0200 |
commit | 753d37c21993283ac93352adb0c01a0cddce186d (patch) | |
tree | 48c439f1b287de529b8a7d8341aafb0da5da16c6 | |
parent | 70c116b879164250d707d8e5aec052203fec93ce (diff) |
profiles/workstation: Refine zswap configuration
Since kernel 4.18 contains the zstd compression module in the crypto API, it really makes sense to use that instead of the default (lzo) as it seems to have lower CPU usage with higher compression ratios. Another change I've made is to use z3fold for the pooling, so that 3 pages are cramped into one page of the pool. I did also have a look at zsmalloc, but it seems to come with the cost of additional CPU usage. Signed-off-by: aszlig <aszlig@nix.build>
-rw-r--r-- | modules/user/aszlig/profiles/workstation/default.nix | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/user/aszlig/profiles/workstation/default.nix b/modules/user/aszlig/profiles/workstation/default.nix index f0eb4501..c425d750 100644 --- a/modules/user/aszlig/profiles/workstation/default.nix +++ b/modules/user/aszlig/profiles/workstation/default.nix @@ -4,6 +4,9 @@ let cfg = config.vuizvui.user.aszlig.profiles.workstation; inherit (config.services.xserver) xrandrHeads; + kernelVersion = config.boot.kernelPackages.kernel.version; + hasZstd = lib.versionAtLeast kernelVersion "4.18"; + in { options.vuizvui.user.aszlig.profiles.workstation = { enable = lib.mkEnableOption "Workstation profile for aszlig"; @@ -12,7 +15,23 @@ in { config = lib.mkIf cfg.enable { vuizvui.user.aszlig.profiles.base.enable = true; - boot.kernelParams = [ "zswap.enabled=1" "panic=1800" ]; + boot.kernelPatches = lib.singleton { + name = "zswap-config"; + patch = null; + extraConfig = '' + CRYPTO_${if hasZstd then "ZSTD" else "LZO"} y + ZSWAP y + Z3FOLD y + ''; + }; + + boot.kernelParams = [ + "zswap.enabled=1" + "zswap.zpool=z3fold" + "zswap.compressor=${if hasZstd then "zstd" else "lzo"}" + "panic=1800" + ]; + boot.cleanTmpDir = true; environment.systemPackages = with lib; let |