Unix & Linux
swap virtual-memory memory-management iommu huge-pages
Updated Tue, 27 Sep 2022 17:26:49 GMT

Can a Linux Swap Partition Be Too Big?


Can a Linux swap partition be too big?

I'm pretty certain the answer is, "no" but I haven't found any resources on-point, so thought I'd ask.

In contrast, the main Windows swap file, pagefile.sys, can be too large. A commonly cited cap is 3x installed RAM, else the system may have trouble functioning.

The distinction seems to lie in the fact that Linux virtual memory is highly configurable with kernel parameters, not to mention compile options, whereas Windows virtual memory is barely so. Windows virtual memory management consequently seems to rely on algorithms that are immutable or seem to rely on swap file size and how it is configured.

Linux has its own virtual memory management algorithms, of course, but the question is whether and how they are affected by the size of the specified swap partition or file.

This comes up because I have a system with 16GB physical RAM configured with a series of 64GB partitions to facilitate a multi-boot capability. For convenience / laziness, I've simply designated one of these 64GB partitions as swap, i.e., 4x physical RAM in contrast to Windows' 3x cap (the latter being relevant only as a frame of reference because this is a Linux-only system). I'm debugging some issues around memory management and VMware Workstation and have come to wonder what, if any, effect the swap partition's size has on compaction, swappiness, page faults, and performance generally.

Many thanks for any constructive input.




Solution

Seeing articles like this disturbs me although I haven't researched the issue enough to confirm their conclusions. Having an overly-large swap partition on Linux will not cause any performance problems. Swap is used as necessary and can be somewhat controlled by swappiness. The amount of swap space allocated is never considered in the algorithms for swapping (or paging) out processes. The biggest consideration is that if you have to start swapping your performance is going to drop considerably. Any system that relies on swapping needs to have more physical memory installed.





Comments (1)

  • +0 – It has been my take as well that Linux memory management is fully configured with kernel options, including swappiness, and that swap space size do not affect virtual memory management, but thanks for the confirmation. — Aug 24, 2022 at 16:20