I have 8 GiB of RAM(7.23 usable), and it’s quite good. So, I don’t want the system to use the Swap until it really needs it!
I set the swappiness in /etc/sysctl.d/20-swappiness.conf to 10, then to 5, then to 1, but it didn’t have any effect!
I also tried $sudo sysctl vm.swappiness=1, and I even tried $sudo sysctl vm.swappiness=0 but nothing happened! it still uses Swap even if the ram usage is just 4-6/7.23!
I turned off the swap, then repeated 2), but no effect too!
Have you confirmed that it did in fact change with
cat /sys/fs/cgroup/memory/memory.swappiness
or
cat /proc/sys/vm/swappiness
I don’t believe setting it to 0 is a good idea, use 1-100
I have a laptop with 8Gb of RAM and I have the opposite issue, I can’t get the kernel to use the swap without upping the swappiness, funny how that works
I read this article and set /proc/sys/vm/vfs_cache_pressure to 40, then swappiness to 4, (I made sure they’re set up using sysctl) and I really was not very sure it had a serious effect on the swap usage
I turned swap off, then it was 6G usage, turned it on again, then opened a lot of chrome tabs, and it started to be filled when the usage reached 6.45G :3
I’m not sure what’s going on. but I’m sure I didn’t miss anything!
You can always set swappiness to 1, which essentially only uses it when absolutely necessary, note that you’ll need to reboot or swapoff/swapon to make sure swap is cleared. Otherwise can take awhile to notice it take effect.
For the record: I also find that vm.swappiness has absolutely no effect on the swap usage in my Debian stable system, I am convinced it is a placebo knob
@OP: can you drop the caches?
sudo tee /proc/sys/vm/drop_caches <<<"3"
^ That should free up swap space, not really a solution though.
I use zswap, that might help a bit, add this kernel parameter:
zswap.enable=1
It won’t change the swap usage per se but it will apply compression and make if faster and more efficient.
In order to have the swappiness to be in effect without to have to reboot after it s saved in your sysctl file , you have to do this command in your /etc/sysctl.conf file in terminal;