3 ms·
With the concerns stated in the article, I can't see any benefits to adding swap vs adding an equivalent amount of ram. The author mentions that not needing swa
by accelbred 4y ago
With the concerns stated in the article, I can't see any benefits to adding swap vs adding an equivalent amount of ram. The author mentions that not needing swap due to having more than enough ram is a common misconception, but I cannot see how that can be. For any given workload, you could replace the useful amount of swap for an equivalent amount of additional ram. Sure some pages cannot be reclaimed, but the amount of anonymous pages that can be reclaimed is limited by swap size. In an alternate system with more ram instead, the pages that would be in swap instead are locked in memory, but this does not give more useful memory. More ram would be more flexible as it allows more cache than the swap scenario when you dont have swap full of pages. Thus we can conclude that there will always some amount of ram that is sufficient, and therefore if your system has enough memory that you dont face memory contention, you don't need swap.
If theres a better explanation for why swap is useful, I'd like to hear it, but the article is unconvincing.
- adrian_b 4y agoI also completely agree with everything you said. I have stopped using swap on all my servers, desktops and laptops about 20 years ago. I have never encountered any situation when swap could have been useful, but I have always installed generous quantities of RAM on all computers. As long as the quantity of used memory does not exceed the physical memory, swapping pages cannot improve the performance in any way. The only exception, which is mentioned in the parent article, is when some very seldom used memory pages would be swapped and the freed memory would be used as a disk cache, hopefully increasing the performance for a I/O bound application. Whether this strategy of hoping that a larger disk cache, filling all the available physical memory, can improve the performance more than what can be lost if the prediction that the swapped pages will not be needed soon is wrong, is extremely application dependent. This hypothesis, that a significant performance improvement can be enabled by a slightly larger disk cache, might happen to be true in certain cases on computers which still use slow HDDs. Except for backup/archiving, where the disk cache matters very little, I have not used HDDs for more than a decade. On computers with SSDs, the chances to find an application where a small increase in disk cache size can cause a noticeable performance increase, larger that what is lost by swapping the seldom used memory pages, are negligible, in my opinion.
- bluedino 4y agoWhat about when you can't add any more RAM?