So I was digging in to the need for a Swap file tonight. I have 32GB of RAM and a high-performance NVMe SSD. Surely I don’t need a 32GB swap partition? After some research I came to the opinion that I should keep the Swap. But maybe, just maybe; there are ways to tweak it?
This led me down a rabbit hole. This is a great starting resource btw.
After a bunch of searching and reading I ended up bouncing questions off of ChatGPT. What I eventually found out was that the default Garuda swappiness is set to 133. This isn’t quite right for normal configs but ChatGPT informed me that it’s probably 33 + 100 (ZRAM flags). As I went down the rabbit hole it started to sound like the swappiness should still be set to 10-30.
I settled on 20 which can be set by:
kate /usr/lib/sysctl.d/99-sysctl-garuda.conf
Once there you change vm.swappiness=133 to =20
Save and Exit
Then in a terminal to load the new settings and verify the value:
sudo sysctl --system
cat /proc/sys/vm/swappiness
Does it help? Hell if I know; it’s still as fast as ever. Anyone have any thoughts/opinions?
The higher swappiness is, the earlier and more the Linux kernel will write to swap.
Since Garuda Linux has zram by default, almost all of your swap will be compressed ram instead of actual swap to disk. This is why the swappiness is so high.
The reason your swap partition is so big is that a swap partition at least the size of your system ram is needed to enable the hibernate functionality of the Linux kernel.
In reality, this will not make much of a difference unless you get close to maxing out your ram. If you do, the higher swappiness will make the kernel deal with the memory shortage earlier before it has potential to slow your system down.
(Of course, this only works well if there are parts of your ram that aren’t actively used. In most desktop usecases, a lot of occupied memory sits idle however. In case it is needed, it will still be pretty fast since it is just compressed ram, after all.)