feat(idols-ai): enable zswap with zstd and 10% pool

Compressed writeback cache in front of the disk swapfile keeps cold anon
pages in RAM instead of the SSD, freeing page cache for the ~78GB mmap'd
LLM weights. zstd's ratio keeps ~5G more anon bytes in the capped pool
than lz4 at negligible cost (CPU peaks ~30% on this host); pool capped at
10% so it never competes with the weight cache.
This commit is contained in:
Ryan Yin
2026-08-29 11:32:15 +08:00
parent 4b7375c077
commit db953c0504
+14
View File
@@ -42,6 +42,20 @@ in
# Disable the whole module (zram device + its swappiness=180 sysctl tunings); this host uses a disk swapfile instead.
modules.zram.enable = false;
# zswap: compressed writeback cache in front of the disk swapfile.
# Keeps swapped cold anon pages compressed in RAM instead of the SSD, which frees more
# page cache for the ~78GB mmap'd LLM weights (mmap file pages never go through zswap).
# Safe here: disk swapfile remains the real backing store, no zram deadlock structure.
# - zstd: CPU is not the bottleneck here (llama.cpp peaks ~30% util); its ~2.5x ratio
# keeps ~5G more anon bytes in the capped pool than lz4, and ~5us decompress is noise
# vs the ~100us SSD fault it avoids.
# - 10% pool (~9G): the module default 25% (~23G) would compete with the weight cache.
boot.zswap = {
enable = true;
compressor = "zstd";
maxPoolPercent = 10;
};
services.sunshine.enable = false;
services.tuned.ppdSettings.main.default = lib.mkForce "performance";