Hacker News new | ask | show | jobs
by adrian_b 745 days ago
I have the same experience.

I have stopped using swap on any computers, laptops, desktops or servers, more than 2 decades ago.

At that time, removing the swap was definitely a great improvement (with the condition of having installed enough real memory in the computers; but even with insufficient memory it was much better to have a few processes killed instead of having an unusable computer that had to be forcefully rebooted, losing everything that had not been already saved).

Perhaps the handling of swap has been improved meanwhile and in certain unusual niche environments having swap might provide some benefits.

Nevertheless, I doubt very much that this is true. I have never seen any such case where swap could have been useful.

When there is enough memory, there should be no writes to the swap, because such writes can only diminish the performance, and in an unpredictable way, because they can trigger the SSD garbage collector. If there are no writes to the swap, there is no reason for it to exist. If there isn't enough memory, the cheapest solution is to buy more memory, instead of trying to find a software workaround for that.

The memory pages that are not dirty can always be discarded by the operating system and read again later from the SSD if needed. No swap is needed for that. There exists no way in which swap can improve performance in comparison with having enough memory. Having to also discard dirty pages is just another way of saying that there isn't enough memory and you are willing to degrade the performance instead of paying for enough memory.

Swap memory is certainly never needed in personal computers, outside of temporary use in certain exceptional situations, when one would be willing to run very slowly a program that does not fit in the memory, due to lack of access to a computer with more memory.

Swap could be useful only when configured in a great number of servers that run a well characterized workload, where one could make a trade-off between application performance and total memory cost.