Wednesday, 2 November 2016

partman, recipes, sizing, swap, and all the things

Our classic installers support dynamic sizing relative RAM size by
using percent specification. Most commonly this is used for defining
swap, e.g. 200% for the swap of double the size of ram.

However, nowadays the landscape and purpose of the swap have changed
somewhat. Which in the common case results in swap overallocation.
Specifically, for a long time ubuntu has hibernation disabled by
default and encouraging using only suspend. The common RAM sizes of
machines have gone up significantly. And many systems are configured
with very high RAM-to-disk ratios. In the cloud and on the beefy POWER
machines one can trivially configure 20GB of RAM with a 10GB disk and
use such instances for in-memory databases / cache. These days swap is
used as an IO cache for spinny rust, yet SSD/NVMe market penetration
is high. Another common use case is for temporary ballooning of memory
requirements when systems are under extreme memory pressure. Overall
x2 of RAM as a default, is a huge overallocation of memory.

At the same time, I think relative partition size specifications are
useful. However, the reference point being total RAM size, imho is no
longer a good one.

Furthermore, given the limited expected use-cases in the typical and
default usage scenarios, I also do not see the benefits of using swap
partitions (where LVM is not in use). I would rather see non-LVM
installations use swapfiles. This way users will be free to remove it,
or resize it, to their needs on the ongoing basis without being
limited by the disk partitioning.

The question what the new swap size should be is a hard one to answer.
On one hand, disk space should not be pointlessly wasted. On the other
hand, it should be sufficient to prevent OOM kills in desperate times.
So I Imagine a hypothetical system of 128GB of RAM with a 1TB NVMe SSD
drive, in addition to more regular sized desktops/laptops. And my goal
is to have some usable swap space allocated, but not overallocate.

= Proposal =

* Make partman recipe percentage be relative the 2.5% of disk size
being partitioned; instead of relative to the system total RAM size.

* Introduce swaplimit preseed key, with default set to 2GB.

* Keep 200% as the default swap partition limit, hence limiting swap
partition to swaplimit or 5% of disk space, whiever is lower.

* Change default partman-auto recipes and set defaultignore on swap
partitions, such that swap partition is created only when LVM
partitioning is in use.

* Introduce creating swapfile for non-LVM installations, with default
size set to 5% of free disk-space on the partition, or swaplimit (2GB)
whichever is lower.

= End result =

Typical systems will have a 2GB swapfile only.

If LVM2 or encrypted LVM2 is in use, the system will have swap LVM
volume instead of a swapfile.

Small disk systems, e.g. 10GB will get just 512MB of swap.

= Questions =

Is it sensible to change the semantics of the % specification in partman-auto?
Or should e.g. a brand new factor be introduced?
Is the introduction of pre-seedable swaplimit sensible?
Is 2GB a good generic upper swaplimit?
Is hardcoded 2 * 2.5% of disk space a sensible dynamic limit, or
should that be preseedable as well?



ubuntu-devel mailing list
[email protected]
Modify settings or unsubscribe at: