You are not logged in.
with vm.swappiness set to =1 it casualy eats eats it, while RAM is filled on less than 50%
I want to swap be used only in case of emergency, cuz my swap is based on ssd and i don't want to transfer it on hdd and i don't want to turn it off eather
what do i do wrong, does it looks like vm.swappiness does not work?
and
Offline
vm.swappiness controls whether the system swap or drops file caches - it doesn't shift preferences between RAM and swap - that'd be insane and pointless.
Do you use zswap or a zram device as swap (or worse: both)?
One thing that might happen (since this is a static analysis of a specific moment in time), though is that you've some client genuinely eating lots of RAM, forcing the system to swap out, then the client terminates, the RAM frees again - but the memory that has been swapped out of course isn't read into RAM again until it's actually required.
=> you actually need to track RAM usage over time.
The file indexers are kinda prone to this behavior.
Offline
How often are you facing "emergencies" and in the case of such an emergency, is swapping really a benefit?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
vm.swappiness controls whether the system swap or drops file caches - it doesn't shift preferences between RAM and swap - that'd be insane and pointless.
Do you use zswap or a zram device as swap (or worse: both)?One thing that might happen (since this is a static analysis of a specific moment in time), though is that you've some client genuinely eating lots of RAM, forcing the system to swap out, then the client terminates, the RAM frees again - but the memory that has been swapped out of course isn't read into RAM again until it's actually required.
=> you actually need to track RAM usage over time.The file indexers are kinda prone to this behavior.
Thank you for reply, yes looks like ZSWAP is Working and i don't sure about zram, but i think more likely no, Since it's not ON by defoult
is not ZSWAP our bro in that case, since he use system's calls to cache pages in swap and partly cache tham on Ram, so if i turn it off i will ended up with even more SWAP usage
i wonder if it's possible to ask ZSWAP to hold more pages in RAM insted of SWAP
Last edited by xy1vro4 (2025-07-06 17:42:40)
Offline
How often are you facing "emergencies" and in the case of such an emergency, is swapping really a benefit?
Not very often, but not rare enough, like it shouldn't happen at all
Like once my system froze so much that it couldn't even kill some process to come back to life, I mean this
i want to system be able to recover it self from this situations, in that case i want to swap be used for
like it's not a problem to reastart few programs, but it's problem to restart fully
Last edited by xy1vro4 (2025-07-06 18:03:01)
Offline
Like once my system froze so much that it couldn't even kill some process to come back to life, I mean this
And in such a case, swap is *not* helpful - in fact it can make it take longer for such issues to sort out (i.e., if it is an "emergency" and the OOM killer will need to purge the problem, adding swap just makes this take longer but you get the same result).
EDIT: note I'm not weighing in here one way or the other on the value of swap - but rather I'm highlighting the incongruity between your stated goals and what you are doing. Swap is not meant to be used just for emergencies, that's not what it's for. If that's what you were looking for, you should just disable swap all together. In contrast, if you want swap to be used to improve performance, you shouldn't be worried that swap is being used ... that's the goal.
Last edited by Trilby (2025-07-06 21:56:20)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
https://wiki.archlinux.org/title/Improv … conditions
https://chrisdown.name/2018/01/02/in-de … -swap.html
Also, if you ended up with that swap pattern while vm.swappiness=1 you've been under memory and file cache pressure and would have otherwise lost processes for sure.
But in general Trilby is correct: if you're under so much pressure that the system starts thrashing and constantly is juggling swap and file cache, you're running OOM and the disk invocation slows that down.
See the above wiki link, but if that happens more frequently, you simply need more RAM (or close some browser tabs ![]()
You can configure the zswap behavior (and check whether it's active), https://wiki.archlinux.org/title/Zswap# … parameters but I doubt that's the problem here.
As mentioned you can end up w/ this pattern after intermittent memory pressure.
That aside, your "bro" can completely explode into your face when it decompresses into the swap, so it's not all glory - you can certainly still leave it enabled, but also nb. that it requires some physical swap as backend and that CAN NOT BE ZRAM, so maybe make sure that "swapon" lists some partition or swap file.
Offline
Some observations:
I found that in case you encounter a RAM explosion, bumping vm.min_free_kbytes to double the default value makes a big difference. With the bumped value, my system is much more likely to recover (anecdotal).
I use systemd-oomd and typically run all my programs from the command line using systemd-run or tmux panes (which have their own cgroup). When something blows up, oomd will kill only that process group. I use an aggressive setting for oomd described here.
If you have enough RAM, using only zram as swap (instead of zswap) can give you the needed cushioning to recover, while not touching any disks. This is of course up to you. I get 2-4x memory compression, so it makes a big difference.
Offline