Update the documentation and implementation of swap calculation.
Make the ramps consistent between suspend-to-disk and not, and don't do the weird drop from 8GiB swap down to 4GiB for large-memory systems.
This commit is contained in:
parent
0f38e86223
commit
e0cd90cab1
@ -45,17 +45,7 @@ using CalamaresUtils::operator""_MiB;
|
|||||||
qint64
|
qint64
|
||||||
swapSuggestion( const qint64 availableSpaceB )
|
swapSuggestion( const qint64 availableSpaceB )
|
||||||
{
|
{
|
||||||
/* If suspend-to-disk is demanded, then we always need enough
|
// See partition.conf for explanation
|
||||||
* swap to write the whole memory to disk -- between 2GB and 8GB
|
|
||||||
* RAM give proportionally more swap, and from 8GB RAM keep
|
|
||||||
* swap = RAM.
|
|
||||||
*
|
|
||||||
* If suspend-to-disk is not demanded, then ramp up more slowly,
|
|
||||||
* to 8GB swap at 16GB memory, and then drop to 4GB for "large
|
|
||||||
* memory" machines, on the assumption that those don't need swap
|
|
||||||
* because they have tons of memory (or whatever they are doing,
|
|
||||||
* had better not run into swap).
|
|
||||||
*/
|
|
||||||
qint64 suggestedSwapSizeB = 0;
|
qint64 suggestedSwapSizeB = 0;
|
||||||
auto memory = CalamaresUtils::System::instance()->getTotalMemoryB();
|
auto memory = CalamaresUtils::System::instance()->getTotalMemoryB();
|
||||||
qint64 availableRamB = memory.first;
|
qint64 availableRamB = memory.first;
|
||||||
@ -65,36 +55,25 @@ swapSuggestion( const qint64 availableSpaceB )
|
|||||||
Calamares::JobQueue::instance()->globalStorage()->
|
Calamares::JobQueue::instance()->globalStorage()->
|
||||||
value( "ensureSuspendToDisk" ).toBool();
|
value( "ensureSuspendToDisk" ).toBool();
|
||||||
|
|
||||||
if ( ensureSuspendToDisk )
|
// Ramp up quickly to 8GiB, then follow memory size
|
||||||
{
|
if ( availableRamB <= 4_GiB )
|
||||||
if ( availableRamB < 4_GiB )
|
suggestedSwapSizeB = availableRamB * 2;
|
||||||
suggestedSwapSizeB = qMax( 2_GiB, availableRamB * 2 );
|
else if ( availableRamB <= 8_GiB )
|
||||||
else if ( availableRamB >= 4_GiB && availableRamB < 8_GiB )
|
|
||||||
suggestedSwapSizeB = 8_GiB;
|
suggestedSwapSizeB = 8_GiB;
|
||||||
else
|
else
|
||||||
suggestedSwapSizeB = availableRamB;
|
suggestedSwapSizeB = availableRamB;
|
||||||
|
|
||||||
suggestedSwapSizeB *= overestimationFactor;
|
// .. top out at 8GiB if we don't care about suspend
|
||||||
}
|
if ( !ensureSuspendToDisk )
|
||||||
else //if we don't care about suspend to disk
|
suggestedSwapSizeB = qMin( 8_GiB, suggestedSwapSizeB );
|
||||||
{
|
|
||||||
if ( availableRamB < 2_GiB )
|
|
||||||
suggestedSwapSizeB = qMax( 2_GiB, availableRamB * 2 );
|
|
||||||
else if ( availableRamB >= 2_GiB && availableRamB < 8_GiB )
|
|
||||||
suggestedSwapSizeB = availableRamB;
|
|
||||||
else if ( availableRamB >= 8_GiB && availableRamB < 16_GiB )
|
|
||||||
suggestedSwapSizeB = 8_GiB;
|
|
||||||
else
|
|
||||||
suggestedSwapSizeB = 4_GiB;
|
|
||||||
|
|
||||||
|
|
||||||
|
// Allow for a fudge factor
|
||||||
suggestedSwapSizeB *= overestimationFactor;
|
suggestedSwapSizeB *= overestimationFactor;
|
||||||
|
|
||||||
// don't use more than 10% of available space
|
// don't use more than 10% of available space
|
||||||
qreal maxSwapDiskRatio = 0.10;
|
if ( !ensureSuspendToDisk )
|
||||||
qint64 maxSwapSizeB = availableSpaceB * maxSwapDiskRatio;
|
suggestedSwapSizeB = qMin( suggestedSwapSizeB, qint64( 0.10 * availableSpaceB ) );
|
||||||
if ( suggestedSwapSizeB > maxSwapSizeB )
|
|
||||||
suggestedSwapSizeB = maxSwapSizeB;
|
|
||||||
}
|
|
||||||
|
|
||||||
cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. / 1024. << "GiB";
|
cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. / 1024. << "GiB";
|
||||||
|
|
||||||
|
@ -6,11 +6,17 @@ efiSystemPartition: "/boot/efi"
|
|||||||
# Make sure an autogenerated swap partition is big enough for hibernation in
|
# Make sure an autogenerated swap partition is big enough for hibernation in
|
||||||
# automated partitioning modes. Swap can be disabled through *neverCreateSwap*.
|
# automated partitioning modes. Swap can be disabled through *neverCreateSwap*.
|
||||||
#
|
#
|
||||||
# When *ensureSuspendToDisk* is true, swap is never smaller than physical
|
# - *neverCreateSwap* is true: no swap is created
|
||||||
# memory, follows the guideline 2 * memory until swap reaches 8GiB.
|
# - *neverCreateSwap* is false (the default): swap is created, as follows:
|
||||||
# When *ensureSuspendToDisk* is false, swap size scales up with memory
|
# - *ensureSuspendToDisk* is true (default): Swap is always at least total
|
||||||
# size until 8GiB, then at roughly half of memory size.
|
# memory size, and up to 4GiB RAM follows the rule-of-thumb 2 * memory;
|
||||||
#
|
# from 4GiB to 8 GiB it stays steady at 8GiB, and over 8 GiB memory
|
||||||
|
# swap is the size of main memory.
|
||||||
|
# - *ensureSuspendToDisk* is false: Follows the rules above, but Swap is at
|
||||||
|
# most 8GiB, and no more than 10% of available disk.
|
||||||
|
# In both cases, a fudge factor (usually 10% extra) is applied so that there
|
||||||
|
# is some space for administrative overhead (e.g. 8 GiB swap will allocate
|
||||||
|
# 8.8GiB on disk in the end).
|
||||||
#
|
#
|
||||||
# Default is true.
|
# Default is true.
|
||||||
ensureSuspendToDisk: true
|
ensureSuspendToDisk: true
|
||||||
|
Loading…
Reference in New Issue
Block a user