Closed ibrokemypie closed 3 years ago
SwapFC allows for you to dynamically allocate more and more swap as is needed, so in my opinion it should always be enabled. It will after all only be activated when you're running low on free swap
Enabling both seems to show the SwapFC being prioritised much higher than the sawp partition:
NAME TYPE SIZE USED PRIO
/dev/sdc1 partition 17179865088 1585152 -2
/data/swapfc/1 file 268431360 2371584 50
is this intentional? It seems in this case that the swap file (stored on my main disk which may be under heavy IO already) would be always referenced before the swap partition on another disk that is the only IO on that disk.
You can manually specify the priority of the /dev/sdc1
swapfile to be higher than the swapfiles created by swapfc, here is a random guide.
Stopping systemd-swap, running swapoff -a, adding fstab entry with prio as an option and then re-enabling systemd-swap ignores the prio option, setting the partition to -2 and file to 50, and manually changing priority each boot doesnt sound great, maybe an option in systemd-swap to set priority of found swap partitions would be good?
swapd_prio
already does that and sets the priority to 1024 by default...
Are you 100% sure that your setting the priority right? https://wiki.archlinux.org/index.php/swap#Priority
Yes, although I removed the entry from the fstab, changed the swapd_prio to 51, stopped systemd-swap, swapoff -a, started systemd-swap with following log output:
INFO: Zswap: backup current configuration: start
INFO: Zswap: backup current configuration: complete
INFO: Zswap: set new parameters: start
INFO: Zswap: Enable: 1, Comp: zstd, Max pool %: 25, Zpool: z3fold
INFO: Zswap: set new parameters: complete
INFO: swapD: pickup devices from systemd-gpt-auto-generator
INFO: swapD: searching swap devices
INFO: swapD: enabled device: /dev/sdc1
INFO: swapFC: on-demand swap activation at >10360 MiB memory usage
INFO: swapFC: free ram: 4 < 35 - allocate chunk: 1
and this output in dmesg:
Adding 16777212k swap on /dev/sdc1. Priority:-2 extents:1 across:16777212k FS
Adding 262140k swap on /data/swapfc/1. Priority:50 extents:1 across:262140k FS
I'm going to reboot later and see if somehow the old default priority of -2 is being saved somewhere? But I explicitly have swapfc_priority=50
and swapd_prio=51
in the /etc/systemd/swap.conf, so if thats what is happening then it would be quite weird.
Seems like the swapd_prio
doesn't actually do anything... Working on a patch
Latest master should fix this (or you could patch it yourself, it's only one line) https://github.com/Nefelim4ag/systemd-swap/commit/9758322556d0abc2783bd664226c01934bbed63d.patch
That seems to have solved it!
NAME TYPE SIZE USED PRIO
/dev/sdc1 partition 16G 3M 1024
/data/swapfc/1 file 256M 0B 50
If I already have a swap partition on another drive (drive is only used for swap), is there any benefit of also enabling SwapFC on my main drive? Would one be better than the other, or would both be the best option?