I'm using zram on my computer as a compressed RAM-backed swap. When the system needs to swap something out, swapping it to a zram-backed swap file is more or less equivalent to compressing that data in-memory to free up space. This makes swapping very fast most of the time, relative to disk-backed swap. Because of this, I wonder if there is some performance to be gained by encouraging the system to swap out unused stuff more aggressively, since it can do so without actually hitting the disk?
So has anyone messed around with, say, setting vm.swappiness
to 100 while using zram? Would this be desirable?
sysctl -w vm.swappiness=100
Best Answer
Short answer:
vm.swappiness=100
is appropriate value for zram(At least on Debian Stretch with Linux 4.9 , I believe that is best value )I already test
vm.swappiness=100
for me.I think you can do some simple test to sure which value is best for you.
Also I made another simple program for test this question. x On my machine a very low
vm.swappiness
value(such asvm.swappiness=1
) will cause obvious responsiveness problem.About
SwapCached
in/proc/meminfo
:First,try
vm.page-cluster=0
,this maybe can reduce some uselessSwapCached
from swap-in.SwapCached can speed up zram same as non-zram swap device
SwapCached
is can reuse(free) when necessary: