Swappiness and ssd/nvme

After some investigation I found out that recommendations for swappiness have not changed while HDDs are being supplanted by SSD and NVME drives. Do you think that such a change in storage technology implies that some OS/kernel parameters have to be tuned somehow? E.g. what about ‘swappiness’?

4 Likes

Awesome discussion honestly. I keep revisiting. I’m of the position now (for now) that if we are in HDD we should have ZRAM or ZSWAP enabled. So the swappiness then largely depends on use case: server, desktop, laptop.

I’ve written on this before but honestly I think needed updating because things keep changing including hardware. Now with NVMe swap isn’t that big of a hit. I have mine set to 60 because the 16GB on the both systems I use is often full and being swapped out. Which when NVMe-backed isn’t that bad.

Have a look at some of these, I’d be really interested to know your thoughts:

I say this to say, I’m wrong again :joy:

There is just no generally universal right setting. Just a generally approach that helps us arrive at the best setting for swappiness and cache pressure which is just as important - based on our use case, hardware and preferences.

2 Likes

You are absolutely correct. What I am looking for is how general ‘classic’ guidelines may or must change to comply with the change in storage technology.

To me, swapping itself is a disaster prevention measure, and not an ingenious method to constantly use more than physically installed RAM. Provided that attitude I do not understand swappiness very well. I agree, that swapping should begin a bit earlier than RAM becomes full.
But I do not understand that wide swappines range. What is it for? And how it can be translated into RAM availability terms? High swappines most certainly increases I/O rate, slows down a system and harms HDD/SSD/NVME health. Probably that is a factor to be accounted as well. All in all, common talks regarding ‘swappiness’ level are not crystal clear for me.

2 Likes

Yes, true partially. Swappiness hurts a system almost always with HDD, it’s can hurt or help with SSD depending on the many factors and how tuned. But for NVMe, it allows you with very little to no penalty to put your RAM to better use.

Swapping hurts HDD performance greatly and SSD health over time. While’s NVMe says: “give me what you got!”

Set swappiness to 60 for NVMe, swap early and notice no difference in performance unless you needed 2x the installed ram in the first place.

Then there’s zram and zswap which are amazing for HDD, useful on SSD and almost pointless with NVMe.

And this is for desktop of course. For high throughput / high spec’d servers you don’t want paging regardless of storage speed.

1 Like

Thank you for this discussion and your articles! That really helped me to comprehend which factors have to be evaluated to select proper swap-cache-app ram ratios.

2 Likes

Likewise. Yes, thats it. If I were to delete any of those articles it would be this one: Linux Performance - Part 3: No Swap Space

But where we were once one wrong, is just as important because it’s the part that leads to better understanding and results.

2 Likes