swap (was: Re: disable akonadi)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



René J.V. Bertin - 02.09.18, 11:00:
> >On the first machine machine I put KDE 5 on, it only has 2 gigs of
> >ram and 2 gig swap partition. It's sort of reflex for me to create
> >swap partition same size as ram. In hindsight I probably should have
> >gone with a 4 gig
> The reflex should be to create a swap partition 2x the size of RAM.
> More is possible but I'm not sure if it will help. Of course one uses
> a fast part of the disk for this

A general recommendation for swap does not really make any sense IMHO 
these days.

If you have a server with 512 GiB or even 1 TiB of RAM, giving twice the 
amount for swap just does not make sense. Unless that swap is on the 
fastest flash you can buy for money, but then it may make sense to just 
stuff even more memory into the box. Harddisks will just be to slow for 
this amount of swap and flash might be too expensive for it. On a 
Proxmox box I use to provide Linux VMs to participants of my Linux 
trainings I think I just disabled swap completely. Cause what is the 
point with the server with 256 GiB of RAM and KVM using Kernel Samepage 
Merging (KSM) aka memory deduplication in case ksmtuned in Proxmox host 
enables it on demand? But maybe I did not even bother with disabling it.

As for laptops and desktops for Linux users: I had 12 GiB of swap for 
this ThinkPad T520 as it still had 8 GiB of RAM. Then I upgraded it to 
16 GiB of RAM and still used 12 GiB of swap. No issue whatsoever. 
Suspend to disk worked. Suspend to disk, I use the in-kernel variant, 
but the userspace one did this even before the kernel did, compresses 
the RAM before writing to it to disk. It also removes caches as much as 
it needs to. So you can usually even suspend to disk just fine if your 
swap partition is smaller than the amount of memory.

Nowadays I have 20 GiB of swap for 16 GiB of RAM. Reason? Cause I do not 
care. This machine has almost 1,5 TB of SSD capacity and I hardly notice 
those 20 GiB reserved for swap on the larger Samsung 860 Pro 1 TB SSD. 
Especially as I have almost 200 GiB still completely unused in LVM on 
that SSD. But having this much swap is not at all needed on this box, 
unless you aim at editing large images or video files or doing other 
work that uses an high amount of memory.

With 32 or 64 GiB of RAM you may even go with a minimal swap or no swap 
at all unless you aim at suspend to disk and do not set up a different 
device for that (which I think is possible at least with userspace 
software suspend).

Anyway: The best way of using swap is actually not using it even when 
you have an SSD. Unless you provide VMs to cloud users and like to 
reduce your costs. And unless something is swapped out and for a long 
time not used again. Swap is just too slow… especially swapping in – 
also with SSD. I saw rates of not more than 20 MiB/second on Intel SSD 
320 based swap. Unless it has been optimized by kernel developers 
lately. I read something about that, as… well cloud providers like to 
use swap again for the reasons I mentioned (thin provisioning for RAM).

Thanks,
-- 
Martin






[Index of Archives]     [Trinity (TDE) Desktop Users]     [Fedora KDE]     [Fedora Desktop]     [Linux Kernel]     [Gimp]     [GIMP for Windows]     [Gnome]     [Yosemite Hiking]
  Powered by Linux