OK, thank you. To rephrase the question, if I have no swap, my 32GB RAM desktop goes belly up if somehow it runs out of RAM, right?
Same will do if I have only 30 GB RAM + 2GB swap, right?
Are there any hidden advantages, or maybe hidden needs for the OS, to keep a swap as long as I only use half of RAM?
Do I have to have a swap if the physical RAM is plenty?
Is the swap needed because it extends the amount of RAM
or is it also needed because it will help the OS fail graciously (vs an allegedly sudden fail when the OS only has RAM)?
if it actually runs out, which means all file cache has been evicted and there's nothing left for the kernel to reclaim. Then it will invoke the OOM killer, which will choose a process to kill, in order to make more memory available. If swap is available, then the same situation will lead to thrashing as active pages are swapped on and off disk as they are needed, which can make the system barely usable.
Just thinking, you can buy a small HDD and use it only as swap device and temp files.
Partition1 swap
Partition2 temp
It will make long life and prosper for your SSD.
Just thinking, you can buy a small HDD and use it only as swap device and temp files.
Partition1 swap
Partition2 temp
It will make long life and prosper for your SSD.
What did I say just above?
I was mentioning a "small" SSD instead though, as they have become quite cheap, will still provide much better performance when accessed, and if it wears out, it's absolutely no big deal.
OK, thank you. To rephrase the question, if I have no swap, my 32GB RAM desktop goes belly up if somehow it runs out of RAM, right? Same will do if I have only 30 GB RAM + 2GB swap, right? For my desktop usage 30 or 32 GB is the same, never run out of RAM so far.
Is the swap needed because it extends the amount of RAM, or is it also needed because it will help the OS fail graciously (vs an allegedly sudden fail when the OS only has RAM)?
In the distant past there were two “common knowledge” approaches. One was “as much as RAM”, the other “2× RAM size”. One comes from Microsoft Windows; the source of the other is more obscure, but appears to be somewhat related to enterprise usage of Linux. Both are ancient, devised when 4GiB RAM was nerds’ wet dream, and the Windows one is specifically bound to “swap is an emergency RAM” approach.
For me, the reason to add a relatively small swap partition, is just to "get notified by slowlyness" when
the system is about to run out of memory.
I'm thinking about to write myself a little desktop widget that notifies me when used ram reaches
a threshold. In that case I will not use a swap partition anymore.
For me, the reason to add a relatively small swap partition, is just to "get notified by slowlyness" when
the system is about to run out of memory.
I'm thinking about to write myself a little desktop widget that notifies me when used ram reaches
a threshold. In that case I will not use a swap partition anymore.
the wear on the SSD is such that the machine itself will be long dead before it exceeds the endurance of the flash
____________________________
| |
| reverse initiator |
| | brdige
| HBA iSCSI FC-optic ---------- FC-optic <========> SAS
|__ ____________|
| |
| |
| |
| PCI64 |
___|___________|____________
| |DMA |
| ___|_______ |
| | | allocated |
| | 31GB ram | to iSCSI |
| |__________| |
| uart
| SBC PA8900 |
| 1GB ram eth0 ------ ssh
| ramrootfs |
| GNU/Linux |
| reverse initiator |
|___________________________|
For deskop systems I disable swap. There is no use for it with tens of GB of memory. Even a super fast SSD will be considerably slower. On embedded targets with a smaller memory, I setup a swap to prevent the OOM killer to kick in when an application reserves a lot of memory. In most cases the memory isn't even used. Ofcourse swappiness is set to 0
For deskop systems I disable swap. There is no use for it with tens of GB of memory. Even a super fast SSD will be considerably slower.
There's always use for swap.
$ uptime
11:47:31 up 32 days, 20:21, 30 users, load average: 0.79, 1.01, 0.99
$ free -h
total used free shared buff/cache available
Mem: 62Gi 27Gi 3.5Gi 395Mi 32Gi 34Gi
5. On SSDs, swapping out anonymous pages and reclaiming file pages are essentially equivalent in terms of performance and latency.
Quote5. On SSDs, swapping out anonymous pages and reclaiming file pages are essentially equivalent in terms of performance and latency.
is only valid for the "dirty pages", aka data in the buffers that has yet to be flushed to the underlying storage device and that will be forced to flush if the pages need to be reclaimed. If it's for the read cache, then the cost of reclaiming those pages is nowhere near the swap operations, which is typical for a desktop system where the disk workload is mostly read-only.
Here you assume that the anonymous pages and read cache are equally likely to be needed;
but if the kernel decided to swap out the anonymous page, its algorithm predicted that the read cache page is more likely to be needed.
So, for typical desktop use (not talking about server use), assuming you're actually not running out of memory, whether this actually gets your better performance on average in any given, real-life situation (as is often claimed here and there) is almost undecidable. You can only cherry pick very specific situations for which it actually would
then claim that whoever disables swap is an idiot