On Fri, Aug 09, 2019 at 03:50:43PM -0600, Chris Murphy wrote:
Problem and thesis statement:
Certain workloads, such as building webkitGTK from source, results in
heavy swap usage eventually leading to the system becoming totally
unresponsive. Look into switching from disk based swap, to swap on a
Summary of findings (restated, but basically the same as found at ):
Test system, Macbook Pro, Intel Core i7-2820QM (4/8 cores), 8GiB RAM,
Samsung SSD 840 EVO, Fedora Rawhide Workstation.
Test case, build WebKitGTK from source.
To avoid such issues I disable swap on my machines. I really don't see
the point of having a swap partition if you have 16 or 32 GiB RAM. Even
with 8 GiB I disable swap.
is worth a read - TL;DR the kernel used (pre 4.0) to be awful about swap, but modern kernels use it to avoid paging executable (file-backed) pages in low memory. If any paging is needed, lack of swap means that the kernel will page out active code before it gets as far as an OOM kill, resulting in a longer time to recover from memory contention (regardless of whether there's an OOM kill or the system recovers naturally).
Further, a sensible amount of swap (say 2 GiB or so) means that unused anonymous pages (e.g. data that's left over from initialization, or data that will only be needed when a process exits) can be swapped out and left on disk, freeing up valuable RAM for useful work.
Basically, a sane amount of swap is healthy - old advice about large amounts of swap is not.