Swap or not to Swap?

I believe swap to file can adjust its size automatically, might be the swapiness

OS will increase its size if necessary.

1 Like

@Echoa @EOS I did this when I initially installed EndeavourOS:

Reduce Swappiness 
echo vm.swappiness=10 | sudo tee /etc/sysctl.d/99-swappiness.conf
systemctl reboot ##(this will reboot your system, so SAVE All YOUR WORK FIRST!)##
After reboot, check swappiness:
sudo nano /proc/sys/vm/swappiness ##(Value should now be set to 10, default is 60, FYI)##

youre not swapping till youre basically OOM. Mine was set to 10 previously which caused me problems in high pressure situations. I set mine currently to 40 which seems to work well for me.

1 Like

I use 10 also. It works fine on my computer. I am not a gamer.
I have not any OOM problems. (16GB ram)

edit: @Scotty_Trees And that one-liner corresponds to the Arch wiki instructions. Swappiness

Yeah no worries, I can set it back to the default of 60, and see if maybe Inkscape likes that a little better.

as long as you allow the system time to swap before the System memory is 100% full youre fine. I found 40% to be good for me because it gives the system time to use ZRam before Disk Swap if possible but then forces using disk swap if pressure gets to high. You just need enough time for things to be written to swap so while 60 is default it may not be needed on your system.

1 Like

Games arent usually too bad on memory TBH, Swapiness of 10 is fine for a lot of people but if you do anything that consumes significant portions of RAM higher values is a good idea.

1 Like

This is always a topic of debate. It is generally recommended that above a certain amount of RAM, if you are not used to hibernating your machine, no swap is required. I usually create a swap partition during installation.

Using ZRAM definetely helped me when I needed 160 GiB RAM but had only 4!

1 Like

just to make it more complicated: to swap, or not to swap, and if to swap, swap to dedicated swap partition or swap to file?

That sort of depends on how much memory, how much storage space, and how much use the swap is likely to see! All 3 options have pluses and minuses and special use cases - and vary in their suitability for SSD or nvme use too!

For myself, I just create a decent size partition on my nvme - allow it to be designated for the 5 builds on this machine - and assume it’ll never or rarely be used as I have 32Gib RAM.

As always - YMMV!

1 Like

i was being a tad pedantic when asking, but on a serious note: with a single OS installed and single drive, is there any technical advantage to using a swap partition over using a swap file (no hibernate function required) as both instances would be writing to exactly the same physical drive? Just curious.

With a partition, the space is gone for good - and is always full size. Depending on how the swap file is implemented, it might not take its full size until needed. Also, there is a theoretical security risk as encryption could not be counted on for a partition (AFAIK) - so if the :male_detective: gets your machine, and you have the bad luck that something critical happened to be swapped out, and…

One can always come up scenarios to worry about, if you try hard enough!

i was thinking along similar lines, so no real performance disadvantage to using a file over a partition, but an advantage due to the size being variable with a file depending on its use? Do you think that would be a fair bite sized assessment on a single OS, single drive machine?

As I mentioned, I went with a partition, but I run multi-build setups all with 1 swap. The variable size, and perhaps the encryption factor (depending on paranoia percentage, and its justification!) are the advantages I can see for the file method on a single build machine.

1 Like