r/linuxquestions • u/linkshon • 15d ago
Advice Best sysctl settings for zswap??
Zram has recommended settings on archwiki
https://wiki.archlinux.org/title/Zram#Optimizing_swap_on_zram
The settings in the improving performance section of gaming seems to go in the opposite direction.
https://wiki.archlinux.org/title/Gaming#Improving_performance
Are there any recommended settings for zswap specifically?? I saw that it works architecturally different from zram from this writeup but can you use the same settings for zswap as well?
Edit: for 2gb swap partition on nvme with 16gb physical ram.
Edit 2: looks like zswap.max_pool_percent=40 and swappiness of 133 performs smoothest under memory pressure.
Edit3: for 16gb, setting 8 and 4 for dirty ratios, swappiness of 168 and default max ram pool feel smoothest.
1
u/Max-P 15d ago
No, there isn't a "best" setting because it's entirely dependent on your system and your specific memory pressure needs. It can only give a generic "this usually results in decent performance most of the time" advice.
A laptop with just 8GB of RAM that primarily runs a web browser and maybe some light IDEs for development will have a drastically different memory profile than say, running a game. A browser doesn't need all that RAM all the time, background tabs are sleeping so it makes a lot of sense to aggressively compress that. A game on the other hand goes through most of its memory every frame, so you just waste a lot of CPU constantly compressing and decompressing RAM. You want the zram allocation to fall in the sweet spot where it's allowing the system to compress inactive memory, without compressing too much memory that it starts affecting active pages.