3 ms·
Something I've never understood is why, say, 60GB RAM + 4GB swap is supposed to be faster than 64GB RAM + no swap. Or why 64GB RAM + 4GB swap is supposed to be
by quectophoton 21d ago
Something I've never understood is why, say, 60GB RAM + 4GB swap is supposed to be faster than 64GB RAM + no swap. Or why 64GB RAM + 4GB swap is supposed to be faster than 68GB RAM.
I get the hibernation argument, but not the arguments implying swap is always better.
Actively using 60GB RAM and moving 4GB of unused pages to swap (60+4), is somehow faster than actively using 60GB RAM and keeping unused pages in the remaining 4GB RAM (64+0)?
EDIT: If you prefer more round numbers, feel free to replace them with "32GB RAM + 32GB swap" and "64GB RAM + no swap" respectively.
- anyfoo 21d agoI’m not sure I understand. In your equations, why is swap taking away from RAM? It’s purely additive. Say you have 64GB of RAM, of which 4GB are dirty pages that are never, or at least very rarely, accessed. With 64GB RAM + 4GB swap, you filled up your swap with them and have 64GB RAM left to use actively. With 64GB RAM + 0GB swap, you only have 60GB RAM left to use actively.
- quectophoton 21d agoIn my examples nothing is taking away from nothing, I'm just asking if, if two situations have the same total amount of GB, what's the actual difference between RAM+swap vs entirely RAM. Use the 32+32 numbers if you're more comfortable with those round numbers. If I have a system running comfortably with 32GB RAM + 32GB swap (no OOM, no swap thrashing), and I upgrade to 64GB RAM + 0 swap, what actual negative effects would I be getting for the lack of swap? That's my question, to know if swap has any benefits other than being additional slow RAM.
- anyfoo 21d agoAdding 32GB of RAM is vastly better than adding 32GB of swap, it’s not even close. However, it’s also vastly more expensive. That has always been the case, not just in the current insane situation. We use swap because we have plenty of disk space, but (comparably) very little DRAM. The same goes for another level on the hierarchy: If you could choose between 1GB of DRAM vs. 1GB of SRAM (which your CPU cache is), you’d definitely choose the SRAM. But you’d be paying out of your nose both with money and area, it’s not economical at all. My CPU has 96MB of cache, and that’s considered massive.
- mitxela 21d agoThe actual choice is 32GB RAM + 32GB swap or 32GB RAM + no swap. This is because people already bought their RAM and disks by the time they make the decision, and aren't using the whole disk.
- quectophoton 21d agoI mentioned this in a response[1] to a sibling comment, but my question is more about learning what are the advantages of swap itself, other than just cheaper slow RAM. What does the OS do differently with swap vs RAM? What can I do with swap that I cannot do with RAM? Things like that. [1]: https://news.ycombinator.com/item?id=49670574 https://news.ycombinator.com/item?id=49670574
- mitxela 21d agoNothing besides having more of it. Apparently also hibernation, but that's more of an artificial limitation - there's no good reason a system couldn't create a hibernation file on demand.