-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday, 2017-12-15 at 09:57 +0100, Richard Brown wrote:
On 14 December 2017 at 22:44, Carlos E. R. <> wrote:
How much swap do I need if I'm planning to suspend to disk (aka hibernate as compared to sleep, but I forget the s2/s3/... stages)?
Well, you need as much as you need... :-)
There can't be an exact reccomendation. You initial choice of 17G is fine (it is what I have, more or less). Only experience with your actual usage pattern will tell.
For hibernation you need the same ammount of used RAM + the ammount of already used swap at the instant of hibernation. However, the hibernation image can be compressed, perhaps half.
This instant I'm using 6.1 GB of swa, and a bit under 5GB of RAM, so I might need up to 11GB to hibernate.
Some people say "2 times RAM", but that comes, IMO, from the Windows times when that was the maximum. Others disagree.
I had a Linux system with 20 times at least. And yes, it was actually needed.
Please avoid giving recommendations that imply that more swap is somehow better
I didn't say that.
In other words, for peak performance you want your swap to be _as small as it needs to be_, but still enough to give the kernel the space it requires to page out unused portions of RAM to disk to give it more space to allocate RAM for more useful data.
And this is the key paragraph, in line with my actual recommendation: set up as much as you actually need.
For small systems (4GB of RAM or less) the old formulae of Swap = 2x RAM are a fair approximation of 'small enough as it needs to be', but in an era where 8GB is normal and 64GB is not extreme, the simple fact is those old recommendations do not hold true.
This is where the arbitrary "2GB is normally enough" recommendation comes from.
_normally_ I'm actually using normally 2..3 GB, and yesterday I was using 6. With your recommendation, my system would crash.
Hibernation is the exception, as you need to have enough to store the system RAM to disk. However it's worth noting that the hibernation process will COMPRESS that RAM image, so sizing your swap to equal your RAM size is actually going to oversize the swap somewhat even for that usecase..but better safe than sorry considering the possibly variable compressability of the data in RAM.
I know. Which is why I always set up somewhat more than RAM.
On large systems you do however then have the compromise of slowing down general memory performance when hibernation is enabled due to a large swap space which you only needed for hibernation
On the other hand, with large swap space, in the OOM situation the operator has time to notice and kill the culprit himself. If the system becomes slow in the large RAM and SWAP situation, as your old paper describes, the solution is the kernel be aware of the situation and act appropriately. However, nobody has a 1 TB laptop machine which he wishes to hibernate. Non issue. The OP has 8 GiB, just like me.
I suppose it would be nice if we had some mechanism for hibernating to disk somewhere other than swap for that reason.
Maybe. Well, Windows does that. - -- Cheers, Carlos E. R. (from openSUSE 42.2 x86_64 "Malachite" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlo0CdQACgkQtTMYHG2NR9X6ZQCggcE7Sv2CAWA8ccMzPFObmymC u2QAoJUojFVluODUyHbfI85agwnc2wG/ =J9vZ -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org