Nowadays linux has this thing called zram disk. It compresses data in memory on the fly. I think general swapping advice would serve most people better if they always add swap on zram first, before swap on ssd or hdd. The difference is that getting data in and out of zram is so fast that you can actually use it as a tier of a slower ram, transparently compressed.
is this activated per default today? Last information I've got from Ubuntu 16.04 times is that it is not activated by default. I know that macOS and Windows do similar to this by default.
Linux Performance: Why You Should Almost Always Add Swap Space
71–80 of 120 posts
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#72I wondered this for a while, unfortunately a major question I have remains unanswered in the text: What about SSDs and SSD-only systems? (Like... any average laptop.) Should I be worried that putting a swap on an SSD will cause it to wear out fast due to many write cycles?
There is no worry putting swap on SSD.
Given the choice, you should prefer swap on SSD (since it's so much faster than spinny disks).
If swap on SSD was a bad idea, do you honestly think every laptop, desktop, and server manufacturer that uses exclusively SSD would still enable swap?
Every mainstream OS wants/needs swap - it helps all of them
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#73Earlier quoted context omitted.
Not exactly helpful. Swap is vital in modern systems: https://news.ycombinator.com/item?id=15952447
I don't think 2.6 kernel reasons are relevant anymore, in fact they apply to ram compression techniques better, than to old raw swap on disk.
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#74Earlier quoted context omitted.
You really need to learn more about swap. Start here: https://news.ycombinator.com/item?id=15952447
That is not a very helpful comment. Anyway, the quote from the article I was responding to above was talking about using swap to handle a situation where you have insufficient RAM, so you're off mark.
But nice try at deflecting your lack of understanding.
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#75Earlier quoted context omitted.
>I used to work in flash manufacturing How long ago? r/w cycles haven't really been an issue on SSDs in a long time
2010. I've been following the industry since I left, and I promise you neither the physics of FN flash nor the manufacturing process has fundamentally changed since then. Nor have the true endurance numbers substantially improved. If anything the situation is worse now with smaller device dimensions. The only thing standing between your collection of cat gifs and oblivion is the flash controller making intelligent gu…
SSDs have lifespans measured in years of constant use.
If you think it isn't the case, you need to go back and learn more about those devices you claim to know so much about.
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#76Cargo cult system administration. No, you should not 'almost always add swap space'. What you should do instead is tune your system for its intended use. If you need swap as an 'early warning system' that you're about to run out of memory you're already doing it wrong and the OOM killer is a piece of code that has default settings that can be tuned, ditto for the virtual memory manager in the kernel. http://www.oracl…
You should just about always add at least some swap. Anyone who thinks otherwise hasn't read much or seen very many systems. start here: - https://www.kernel.org/doc/gorman/html/understand/understand... - https://www.kernel.org/doc/gorman/html/understand/understand... - https://www.linuxquestions.org/questions/linux-kernel-70/why... - https://kerneltalks.com/disk-management/swap-addition-in-lin... - https://linuxaria…
I wrote a kernel from scratch, besides that I did quite a bit of transaction oriented stuff and built the server side of a very successful messaging platform. That does not make me an expert either but I do have some minimal understanding of what goes on under the hood. If you are simply configuring swap space on a better-safe-than-sorry basis then I would rather not have you near a system whose response has to be deterministic because it almost certainly will fail in some unpredictable way sooner rather than later.
Yes it is difficult stuff, no you do not get a free pass just because you messed with important stuff on a duct-tape-and-glue basis. See, swap is just a stay of execution, once a system starts swapping it is as good as out of control anyway so in the vast majority of cases that I am familiar with you want that situation to announce itself loud and clear and in a way that gives you back control. You then do postmortem and you fix it so it will not happen again. That is far preferably over having systems that remain partially broken but pretend to be fine.
I know plenty of people run after each other claiming great insight by quoting the various help-yourself sites but it amounts to absolutely nothing when you suddenly find yourself trying to figure out why your transaction queues are overflowing because some system in the pipe suddenly decided 100ms is as good as 10 as long as things keep flowing.
If on the other hand your systems are not important enough to properly set them up with static resources committed to long running processes and with strict limits on what logged in users can do from the command line then this advise is going to fall on deaf ears because you did not need reliability in the first place. Note that in many business context latency is far more important than throughput.
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#77This is dangerous advice. At least on Ubuntu 16.04 with stock kernel running due to memory pressure into swap kills the systems. Basically everything times out and you can only hard-reboot. Without swap you have an OOM at least something you can recover from. If you need swap just add a little like 1-4gb - because if you have spinning disks 64gb swap won't help you at all because every request to swap is magnitudes m…
Not just ubuntu. We tell our engineers to remove their swap partitions because sometimes the test suite will consume all remaining memory and push into swap. If that happens, pretty much the only thing you can do is a hard poweroff. If you're fast, you can Ctrl+C and only lose a minute or two, but often you're just completely stuck. Much better to OOM and have the test suite killed early.
Sounds like a non-swap system/kernel tuning issue - you should still be able to slowly switch to a virtual console or ssh in, etc, and kill the test suite..
Also, most linux distros run without any real usage of user/group resource limiting - setting up these appropriately is useful to limit the overall impact of runaway jobs
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#78I wondered this for a while, unfortunately a major question I have remains unanswered in the text: What about SSDs and SSD-only systems? (Like... any average laptop.) Should I be worried that putting a swap on an SSD will cause it to wear out fast due to many write cycles?
This risk is hugely overstated for most use cases based on people having 'baggage' from 'dumb' flash memory cards.
eMMC is another story (because these are basically 'dumb' flash memory cards)
Recently read an article by samsung where they claim that 3d nand SSD drives can handle ~1x full drive write per day (e.g. 1TB drive -> 1TB/day) and still last the rated lifetime, and that v-nand can handle something like 5-10x (don't remember off hand precice figures, but it was easily googlable). Yes, this is a vendor figure - but should be at least ballpark accurate I'd think.
Also, many SMART-capable drives show their estimated write cycle lifetime in SMART status (again, vendor figure, but still) .. if you check this on your laptop I bet you will be surprised at how low the figure is.
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#79Earlier quoted context omitted.
You should just about always add at least some swap. Anyone who thinks otherwise hasn't read much or seen very many systems. start here: - https://www.kernel.org/doc/gorman/html/understand/understand... - https://www.kernel.org/doc/gorman/html/understand/understand... - https://www.linuxquestions.org/questions/linux-kernel-70/why... - https://kerneltalks.com/disk-management/swap-addition-in-lin... - https://linuxaria…
The majority of your links seem to be chosen simply because they have the word 'swap' on it somewhere, not because they make the case why having 'some swap' is a must. I wrote a kernel from scratch, besides that I did quite a bit of transaction oriented stuff and built the server side of a very successful messaging platform. That does not make me an expert either but I do have some minimal understanding of what goes…
if your systems are so advanced that you've done all of this up front profiling, you'd know why the system in the pipe decided 100ms is as good as 10 because you'd be monitoring and alerting on memory/swap and would get the message when it hits 80%-90%, and be logging in while leaky process is blowing up into your swap space.
no need for a 'postmortem' if you can have a surgery..
Re: Linux Performance: Why You Should Almost Always Add Swap Space
#80Earlier quoted context omitted.
The majority of your links seem to be chosen simply because they have the word 'swap' on it somewhere, not because they make the case why having 'some swap' is a must. I wrote a kernel from scratch, besides that I did quite a bit of transaction oriented stuff and built the server side of a very successful messaging platform. That does not make me an expert either but I do have some minimal understanding of what goes…
if swap is 'cargo cult administration', pretending it won't save you a few times even with all the safeguards you claim that you perfectly do is 'narcissist administration'. if your systems are so advanced that you've done all of this up front profiling, you'd know why the system in the pipe decided 100ms is as good as 10 because you'd be monitoring and alerting on memory/swap and would get the message when it hits 8…
All you need to do is to monitor your memory usage, any growth that you do not understand is a reason to stop what you are doing immediately and to figure out what is going on.
A few GB extra swap space will not save your bacon, will make it much harder to get the system back under control because it is no longer responsive compared to a process killed with a supervisory process restarting that process immediately and logging a fault.
And if your systems can't handle that you have bigger problems, likely you then also won't be able to deal with hardware faults, crashes, power failures and other errors.
A postmortem is far preferable when it is about a process that is re-launched in a small fraction of a second after which the system is back to normal if the alternative is a system that causes a whole cascade of stuff to go out of whack down the line.
Pretty much only Erlang/OTP get this sort of thing right to begin with.
Errors - including out of memory errors - should be expected and should be dealt with in a deterministic manner.