Omarchy installed zram-generator but never shipped a config for it, so the only zram tuning any machine had was whatever the ISO wrote once, and the VM sysctls were untouched kernel defaults aimed at spinning disks. The generator's own default caps the device at 4G, which on a large machine sends reclaim to the hibernation swapfile far earlier than it needs to go. Ship min(ram / 2, 8192) instead, matching what Fedora settles on, and state the priority explicitly since it has to sit above the pri=0 that omarchy-hibernation-setup gives the disk swapfile. The four sysctls follow from swap being RAM rather than a disk. swappiness above 100 says evicting an anonymous page beats dropping a page-cache page that would have to be read back, which is true once swap is compressed memory. page-cluster drops to one page per fault because the default of 8 buys readahead for a seek zram doesn't have and pays a decompression for each page. Zeroing watermark_boost_factor stops fragmentation from producing reclaim bursts while memory is still free, and raising watermark_scale_factor gives kswapd room to reclaim in the background instead of letting allocations stall in direct reclaim. The last two are what actually addresses the stutter people notice and misread as swap being used too eagerly: proactive swapping to zram is the cure, and synchronous direct reclaim is the disease. Every ISO-installed machine already has an unowned zram-generator.conf, which pacman would refuse to overwrite, so both upgrade paths need it listed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
25 lines
1023 B
Bash
25 lines
1023 B
Bash
echo "Tune reclaim for swap on zram"
|
|
|
|
# Everything here only applies the shipped config early; boot picks it up
|
|
# regardless. Nothing is worth failing the migration chain over, so each step
|
|
# falls back to asking for a reboot.
|
|
|
|
# Load our file specifically rather than --system, which returns nonzero for
|
|
# any invalid key in any admin sysctl file on the machine.
|
|
sudo sysctl -p /etc/sysctl.d/99-omarchy-sysctl.conf >/dev/null || true
|
|
|
|
if sudo systemctl daemon-reload; then
|
|
# Resizing swaps the device off first, which faults every stored page back
|
|
# into memory. That's only cheap while it's empty, so a device under
|
|
# pressure keeps its old size until the next boot. A device that doesn't
|
|
# exist yet reads as empty, which is what we want: the restart brings it up
|
|
# against the unit daemon-reload just generated.
|
|
zram_used=$(awk '$1 == "/dev/zram0" {print $4}' /proc/swaps)
|
|
|
|
if [[ ${zram_used:-0} == 0 ]] && sudo systemctl restart dev-zram0.swap; then
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
omarchy-state set reboot-required
|