Better use zswap, as it will work in conjunction with swap devices https://www.addictivetips.com/ubuntu-linux-tips/enable-zswap-on-linux/
In /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=40 zswap.zpool=z3fold"
run sudo update-grub
Need to add
sudo su
echo lz4 >> /etc/initramfs-tools/modules
echo lz4_compress >> /etc/initramfs-tools/modules
echo z3fold >> /etc/initramfs-tools/modules
update-initramfs -u
verify
cat /sys/module/zswap/parameters/enabled
dmesg | grep -i zswap