diff --git a/docs/superpowers/evidence/swappiness-100-2026-11-22.json b/docs/superpowers/evidence/swappiness-100-2026-11-22.json new file mode 100644 index 00000000..d9d79760 --- /dev/null +++ b/docs/superpowers/evidence/swappiness-100-2026-11-22.json @@ -0,0 +1,41 @@ +{ + "intent": "Raise vm.swappiness from 10 to 100 permanently so the kernel uses the 32 GiB zram swap.", + "scope": [ + "linux_configuration/fixes/lib/arch_sysctl.sh (owns /etc/sysctl.d/90-desktop-performance.conf)", + "its test arch_sysctl_quarantined_cases.sh and the optimizer header comment", + "non-goal: other sysctl values, zram sizing, arch_perf_probes advice text" + ], + "changes": [ + "tweak_vm_sysctl: vm.swappiness 10 -> 100 in params map and drop-in", + "Test expectations updated to 100" + ], + "verification": [ + { + "command": "bash fixes/lib/tests/arch_sysctl_quarantined_cases.sh", + "result": "pass", + "evidence": "RED 18 passed 5 failed with tests at 100 and code at 10; GREEN 23 passed 0 failed after the code change" + }, + { + "command": "vm run swp: sysctl -n vm.swappiness before, tweak_vm_sysctl, after guest reboot", + "result": "pass", + "evidence": "60 -> 100 -> 100 after reboot (uptime 39s); guest deleted" + }, + { + "command": "sudo -n tweak_vm_sysctl on host; sysctl -n vm.swappiness", + "result": "pass", + "evidence": "100; drop-in has vm.swappiness = 100" + }, + { + "command": "fixes/lib/tests/test_*.sh in 4 shards; pre-commit run on touched files", + "result": "pass", + "evidence": "34 test files passed, 0 failed; pre-commit green" + } + ], + "risks": [ + "More anonymous pages move to zram earlier; a full zram holds about 11 GiB of RAM", + "arch_perf_probes.sh still suggests sysctl vm.swappiness=10 under memory pressure" + ], + "rollback": [ + "Set vm.swappiness = 10 in /etc/sysctl.d/90-desktop-performance.conf and run sysctl --system" + ] +} diff --git a/linux_configuration/fixes/lib/arch_sysctl.sh b/linux_configuration/fixes/lib/arch_sysctl.sh index 3f9423d5..f60b1218 100755 --- a/linux_configuration/fixes/lib/arch_sysctl.sh +++ b/linux_configuration/fixes/lib/arch_sysctl.sh @@ -13,9 +13,9 @@ tweak_vm_sysctl() { # by the test harness, which runs un-jailed in ci_mirror.sh and in CI. local dropin="${SYSCTL_DROPIN_DIR:-/etc/sysctl.d}/90-desktop-performance.conf" - # Desktop workloads: low swappiness, aggressive VFS caching, tuned dirty ratios + # Desktop workloads: high swappiness (zram swap is compressed RAM, see fixes/setup_zram.sh), aggressive VFS caching, tuned dirty ratios local -A params=( - ["vm.swappiness"]="10" + ["vm.swappiness"]="100" ["vm.vfs_cache_pressure"]="50" ["vm.dirty_ratio"]="15" ["vm.dirty_background_ratio"]="5" @@ -42,13 +42,13 @@ tweak_vm_sysctl() { cat >"$dropin" <<'VMEOF' # Desktop performance tuning — managed by optimize_arch_desktop.sh # -# vm.swappiness=10 — prefer keeping data in RAM over swapping +# vm.swappiness=100 — favor the 32 GiB zram swap (zstd, prio 100) over dropping page cache # vm.vfs_cache_pressure=50 — favor keeping inode/dentry caches (speeds up file operations) # vm.dirty_ratio=15 — allow up to 15% RAM dirty before synchronous writeback # vm.dirty_background_ratio=5 — start async writeback at 5% dirty # vm.dirty_writeback_centisecs=1500 — flush dirty pages every 15s (less I/O churn) # vm.page-cluster=0 — read one page at a time from swap (reduces latency on SSD) -vm.swappiness = 10 +vm.swappiness = 100 vm.vfs_cache_pressure = 50 vm.dirty_ratio = 15 vm.dirty_background_ratio = 5 diff --git a/linux_configuration/fixes/lib/tests/arch_sysctl_quarantined_cases.sh b/linux_configuration/fixes/lib/tests/arch_sysctl_quarantined_cases.sh index dad35898..09ddec2f 100755 --- a/linux_configuration/fixes/lib/tests/arch_sysctl_quarantined_cases.sh +++ b/linux_configuration/fixes/lib/tests/arch_sysctl_quarantined_cases.sh @@ -49,7 +49,7 @@ printf '\n-- tweak_vm_sysctl --\n' _stub_sysctl_tuned() { _t_stub_stdin sysctl <<'STUB' case "$2" in -vm.swappiness) echo 10 ;; +vm.swappiness) echo 100 ;; vm.vfs_cache_pressure) echo 50 ;; vm.dirty_ratio) echo 15 ;; vm.dirty_background_ratio) echo 5 ;; @@ -85,7 +85,7 @@ _t_lacks "$(_t_calls)" "sysctl --system" \ arch_desktop_reset _stub_sysctl_tuned _t_run tweak_vm_sysctl -_t_contains "$(_t_dropin 90-desktop-performance.conf)" "vm.swappiness = 10" \ +_t_contains "$(_t_dropin 90-desktop-performance.conf)" "vm.swappiness = 100" \ "tweak_vm_sysctl: writes the drop-in when it is missing" _t_lacks "$out" "already tuned" \ "tweak_vm_sysctl: does not report a skip when the drop-in is absent" @@ -100,7 +100,7 @@ esac STUB _t_run tweak_vm_sysctl dropin="$(_t_dropin 90-desktop-performance.conf)" -_t_contains "$dropin" "vm.swappiness = 10" "tweak_vm_sysctl: writes swappiness" +_t_contains "$dropin" "vm.swappiness = 100" "tweak_vm_sysctl: writes swappiness" _t_contains "$dropin" "vm.vfs_cache_pressure = 50" \ "tweak_vm_sysctl: writes vfs_cache_pressure" _t_contains "$dropin" "vm.page-cluster = 0" "tweak_vm_sysctl: writes page-cluster" diff --git a/linux_configuration/fixes/optimize_arch_desktop.sh b/linux_configuration/fixes/optimize_arch_desktop.sh index 0be7b15b..c21bfe2e 100755 --- a/linux_configuration/fixes/optimize_arch_desktop.sh +++ b/linux_configuration/fixes/optimize_arch_desktop.sh @@ -5,7 +5,7 @@ # Tuning areas: # 1. CPU scheduler — performance governor on all cores # 2. I/O scheduler — optimal scheduler per drive type (none for NVMe, mq-deadline for SATA SSD) -# 3. Memory / swap — lower swappiness, tune dirty page writeback for responsiveness +# 3. Memory / swap — high swappiness for zram swap, tune dirty page writeback for responsiveness # 4. Kernel network — TCP BBR, fastopen, larger buffers # 5. Filesystem — fstrim timer, noatime advisory # 6. NVIDIA GPU — max performance level via persistence mode