Closed gdevenyi closed 7 months ago
Pseudocode:
calculate correct size Magic:
# Default to your system's RAM
swapfile_size: "{{ ((ansible_memtotal_mb | int)
if (ansible_memtotal_mb | int > 128000)
else '128000') }}"
^^ check here what ansible_memtotal_mb actually reports for 128GB, there might be MiB vs MB differences
if swapfile not correct size (since all systems have a ~2GB swapfile)
swapoff
rm /swapfile
fallocate -l ${correct size} /swapfile
mkswap /swapfile
chmod 0600 /swapfile
swapon -a
(swapfile is already in fstab on all machines)
I guess i never submitted my PR for this. What i did was check to see if there the machine has at least 200Gb of free disk space and if it did, create a 128GB swapfile. You want that instead?
What i did was check to see if there the machine has at least 200Gb of free dis
I think the check for free space is an obvious great idea :+1:. however, I don't think I want oodles of swap on a 8GB machine (which do exist). That will cause some ugly performance for systems that really shouldn't be used for processing at all.
I'm not sure if I understand the logic behind your psudeo code:
If the system has 128Gb or less of physical RAM then it will set the /swapfile size to 128GB. If the system has more than 128GB of RAM, then it will make the swap size match that amount.
From what I read, what I think makes sense is that if the system has 8GB or less, the max swap we give is 2X the RAM. If the system has more than 8GB we can set it to 128GB, and if has more than 128GB of RAM, we set the swap to that value. Sounds good?
The snip comes from this jinja2 code here modified.
Before we decide on such large swap, we should check there's enough free space everywhere
Well yes, in the context of that snippet it makes sense because it's looking at <= 2GB and if it a system has more than 2GB, it makes swap the same size as the RAM.
In our case, that logic doesn't apply. Here is the current breakdown of responsive machines (host,free space, RAM)
cicws01,164G,23Gi
cicws02,163G,23Gi
cicws03,1.7T,15Gi
cicws04,51G,23Gi
cicws06,162G,23Gi
cicws08,162G,23Gi
cicws09,51G,35Gi
cicws11,21G,23Gi
cicws12,58G,23Gi
cicws13,54G,23Gi
cicws15,53G,23Gi
cicws16,165G,23Gi
cicws18,53G,23Gi
cicws19,56G,23Gi
cicws24,153G,31Gi
cicws25,821G,31Gi
cicws26,820G,31Gi
cicws27,820G,31Gi
cicws28,821G,31Gi
cicws29,820G,31Gi
cicws30,820G,31Gi
cicws31,169G,31Gi
cicws35,166G,31Gi
cicws38,160G,31Gi
cicws41,387G,31Gi
cicws42,380G,31Gi
cicws43,373G,31Gi
cicws44,379G,31Gi
cicws46,380G,31Gi
cicws47,821G,125Gi
cicws48,820G,125Gi
dnpws01,389G,7.4Gi
dnpws02,388G,7.4Gi
dnpws03,387G,7.4Gi
dnpws04,389G,7.4Gi
dnpws05,386G,31Gi
dnpws06,386G,31Gi
dnpws07,375G,31Gi
dnpws08,178G,125Gi
dnpws09,388G,62Gi
dnpws10,386G,62Gi
dnpws11,382G,62Gi
dnpws12,382G,62Gi
dnpws13,690G,62Gi
dnpws15,1.6T,62Gi
dnpws16,1.7T,62Gi
cichm01,161G,117Gi
I would say for a good portion of these, 128G is too big for the remaining amount of diskspace. I think what makes sense is to make the swapsize 2 or 3 times the RAM providing there is at least twice the amount of free space as this new swapsize value. In the cases where there isn't enough free space, we either leave the swapsize at 2G or we make it equal to the same size of the RAM (providing there is at least twice as much free space as this value).
I'm fine with whatever you choose here, its clear swap should be larger than it is RAM++ is reasonable.
Default ubuntu install has tiny swap. Considering we're doing computation, swap = RAM (max 128G?) is probably worth setting up on all systems.