This is for academic use only. I know how much RAM my machine has, and if I oom, it usually isn't because I tried to squeeze in just a tiny bit too much data, but rather because I made some stupid mistake and keep allocating small chunks of memory very rapidly. On a system with even a moderate amount of swap, this makes everything grind to a halt, and it is usually much faster to just reboot the machine and deal with the problems later in the unlikely event that rebooting actually causes problems.
In defence of swap: common misconceptions
81–90 of 151 posts
Re: In defence of swap: common misconceptions
#82I also think that a convincing case for swap would have to discuss the concepts of latency, interactivity, and (soft) real-time performance, things that largely weren't to the fore in the salad days of the 370 family or the VAX. Virtual memory is the TCP of local storage.
Re: In defence of swap: common misconceptions
#83Earlier quoted context omitted.
You can use Alt+SysRq+f to manually call oom_kill.
On many distros, this is disabled by default because there's a chance that the OOM killer will hit something important, like the screen lock. For Ubuntu, enable it in /etc/sysctl.d/10-magic-sysrq.conf.
If the daemon responsible for this is killed, all your sessions will simply be killed.
In no situation will your screen unlock due to a process being killed (in contrast to the pre-logind world, where, if the screenlocker dies, your screen is free for all, as there the locker is just a fullscreen window)
Re: In defence of swap: common misconceptions
#84All of this boils down to "because buying more disk is cheaper than buying more RAM" and "avoid memory contention." The author discusses the situation as if the quantity of RAM is fixed and swap can be added (or not). But that isn't the only possibility — you can also add more RAM (it's just expensive). For the same number of GB of RAM+swap vs just RAM, there is no reason to prefer the option with swap.
One counter example:
If your processes in sum tend to A) access many disk locations, at large total disk space B) hold a lot of underused data in ram
This isn't totally impossible. Maybe an Ethereum node with a script doing a bunch of data reads, running side by side with hundreds of Chrome tabs, few of which are regularly accessed. (Totally hypothetical, of course...)
Swapping some rarely used ram out so the OS can buffer disk into ram seems like a reasonable approach (although maybe even more reasonable is: close some tabs).
Your point still stands that more ram is strictly as good or better performance in this scenario, but you might be able to get an equivalent performance boost much more cheaply with some swap space for the underused ram. Also, upgrading past 32 GB ram starts to veer from expensive to impossible on a laptop.
Re: In defence of swap: common misconceptions
#85Swap was a great idea, but its time is gone. Swap doesn't make sense anymore, hard drives have not scaled and kept up with the improvements in RAM. In the Pentium 1 era EDO RAM maxed out at 256MB/s and hard disk xfer was 10MB/s. Common RAM size was 16MB. In today's era DDR4 maxes out at 32GB/s and hard disk xfer is 500 MB/s. Common RAM size is 16GB. RAM xfer rate has grown is 320x. RAM capacity has grown 100x. Disk x…
There have been times when I have needed to do something which requires more memory than is physically available on the machine. Without swap, those tasks would have been literally impossible to do without upgrading the machine. With swap, it just takes a little longer - but still much shorter than it would take to order more RAM sticks. One of those times was on a 512MB RAM VPS, where I needed to compile something -…
Re: In defence of swap: common misconceptions
#86Earlier quoted context omitted.
What function does the 0.5GB swap have?
I just wish Linux distro installers would make opting out the default option; no, I don't want to swap on my SSD. The last time I installed a distro, I still had to select the manual option for partitioning. With an 8 Gig stick in my NUC, for normal desktop usage it never goes above 3.
Re: In defence of swap: common misconceptions
#87Very few people on this thread read and understood the article. The point isn't working with data sets larger than RAM. The point is making better use of the RAM you do have by taking pages you'll almost never touch and spilling them to disk so that there's more room in RAM for pages you will touch. Banning swap is like making self-storage companies illegal and forcing everyone to hold all possessions in their homes.…
> self storage is plenty useful With self-storage rising to over $300 per month, it's more cost effective to take the stuff to the dump and buy it again if it is ever needed.
Re: In defence of swap: common misconceptions
#88In my experience, a misbehaving linux system that's out of RAM and has swap to spare will be unusably slow. The process of switching to a tty, logging in, and killing whatever the offending process is can easily take a good 15 minutes. Xorg will just freeze. Oh, and hopefully you know what process it is, else good luck running `top`. Until this is fixed, I'll just keep running my systems with very small amounts of sw…
And it caused huge problems for me, would run out of swap while having plenty of free memory and then go cripplingly slow.
Re: In defence of swap: common misconceptions
#89> Under temporary spikes in memory usage > With swap: We’re more resilient to temporary spikes, but in cases of severe memory starvation, the period from memory thrashing beginning to the OOM killer may be prolonged. We have more visibility into the instigators of memory pressure and can act on them more reasonably, and can perform a controlled intervention. Somehow that doesn't resonate with my experience. I tend to…
Re: In defence of swap: common misconceptions
#90Earlier quoted context omitted.
If I may ask, which disks are you using?
the highest end NVMe SSDs can sustain those multi-gigabyte/second reads. https://smile.amazon.com/Samsung-950-PRO-Internal-MZ-V5P512B... for instance. not sure even they could pull off those speeds with random reads, though.