I figured I'd post this since I seem to keep mentioning enabling Zswap in topics and I don't believe there are any guides on Solus for enabling it.

Zswap is a compressed memory buffer like Zram but unlike Zram it's designed to work with a physical swap device (in fact it's useless without "real" swap). Zswap is generally a better option if you have a swap file or partition as it is smart enough to keep more actively used memory pages in the zswap buffer while moving inactive pages to the backing physical swap. Zram doesn't do this which can lead to inefficient behavior where the physical swap will start being used once the zram device is full even if the zram device is full of rarely used memory pages.

To enable zswap you first need to disable zram (otherwise they'll interact together and be really inefficient). Disabling Zram is as simple as creating an empty zram-generator configuration which will tell zram-generator to do nothing when you boot.

sudo touch /etc/systemd/zram-generator.conf

Then you can enable Zswap. The easiest way to enable Zswap is to do it by adding a argument to the kernel command line:

# Make sure the folder exists
sudo mkdir -p /etc/kernel/cmdline.d

# Create the file
echo "zswap.enabled=1" | sudo tee /etc/kernel/cmdline.d/20_zswap.conf

# Update the boot configuration so the new argument is applied
sudo clr-boot-manager update

Then reboot and it should be working! You can do both steps of disabling Zram and enabling Zswap in the same boot, you don't need to reboot between them.

After you boot you can make sure that it's working by running dmesg | grep zswap. If you see zswap: loaded using pool zstd/z3fold then it's working. You can see if Zram is running by doing dmesg | grep zram, which should display nothing if zram is disabled.

More information on Zswap available on the Arch wiki on the topic: https://wiki.archlinux.org/title/zswap

    ReillyBrogan I figured I'd post this since I seem to keep mentioning enabling Zswap

    All these steps completed with no drama. And looking at the partition manager, I can see that zram is now gone. I don't actually see any evidence of zswap anywhere, but I trust that it's there somewhere. Again, thanks for your help.

    ReillyBrogan That all seems to be working nicely thank you. Should swappiness be reduced a little, the two are often recommended to be changed together? At the moment I'm is still running the Solus Budgie 4.4 default of 100. I think it always used to be 10 in earlier versions.
    Edit: I changed it myself to 10 by creating a file /etc/sysctl.d/99-sysctl.conf and then writing vm.swappiness = 10 to the file. Old instructions for changing Solus swappiness involved editing this file but it wasn't on my PC.
    After a reboot swappiness was reported as being 10.
    Just looking for a little approval that my adjustments are about right.

      ReillyBrogan

      Thanks for sharing this useful knowledge, with a good step-by-step tutorial. Everything worked smoothly and as described.

      BuzzPCSOS Solus actually already sets the swappiness to 100 in /usr/lib/sysctl.d/70-zram.conf (if you don't have this file then you probably didn't have zram enabled in the first place since the file is part of zram-generator-defaults which is only installed by default on recent Solus installations).

      Actually, my understanding is that having a higher swappiness is a good thing with Zram and Zswap since you want the kernel to be willing to move less frequently used pages to the swap in order to leave room for more actively used memory. I'd probably keep the default of 100 for systems that use Zram only without physical swap and maybe go down to 80/90 on systems that use Zswap with physical swap. With Zram and Zswap the "cost" of moving pages back and forth from RAM to the compressed memory buffer is much lower than what it is with only using physical swap.

        ReillyBrogan Thank you for your reply and experience. Swappiness has been restored by deleting my recent addition of 99-sysctl.conf.
        There seem to be a lot of Linux tweakers who think the opposite is true and that swappiness should be reduced to a very low value to compliment the effects of zswap.
        Never really seen it explained like you did before, it certainly made enough sense to win my vote.
        Keep up the good work.

        Many guides haven't been updated since MGLRU was added to the Linux kernel. Before MGLRU the kernel's memory management, especially in low-memory conditions, was pretty poor. The kernel would often choose memory pages that were still fairly active to move to swap which slows things down unnecessarily (since those pages would often just need to be moved back) which is where many of the recommendations on setting a low swappiness comes from (basically to tell the kernel not to swap unless it has to).

        Now kernel memory management is much better and the kernel should really only swap fairly inactive memory pages. This ends up being a good thing because those memory pages will go to the compressed memory device (zswap or zram) where they are much "cheaper" to retrieve instead of being written out to disk. This frees up more memory for active things, generally meaning the user can do more things at once before they start seeing performance issues.

        Now granted, I haven't done a lot of benchmarks to confirm this one way or the other so I could still very well be completely wrong, but this is my understanding after all of the research I've done on the subject (I've been the Solus kernel maintainer for the last couple of years or so and the fact that Solus has Zram/Zswap at all is something I chose to make sure was enabled).

          ReillyBrogan Probably overthinking here, please bear with me.

          I enabled Zswap on another Solus computer following all the instructions above. Everything went without a hitch but after rebooting the swappiness was at 10, not 100. I looked for /usr/lib/sysctl.d/70-zram.conf but it was not there, probably because Zram had not previously been enabled. Should there be a function where enabling Zswap sets it own values for swappiness regardless of the previous state of Zram?
          Or will the issue just go away with the implementation of Solus 4.5 for existing users as well as new ones.
          Thank you for your time. Solus is truly a remarkable distro in all of its flavours. The solus team are doing sterling work and are much admired by me.

          I run zram on low spec laptop the difference is with it I think memory and swap from what I see
          try to stay at a certain level at least on mine it never wonders far from a certain memory usage and swap.
          my point was i use defaults. no issues

            Axios Thanks for your reply, I probably should have been more concise.
            My issue was that enabling Zswap onto a machine that had not previously had Zram enabled (and then disabled before the install of Zswap) did not change the swappiness from 10 to 100 as 70-zram.conf had not been written to /usr/lib/sysctl.d/ as that appears to only get done when Zram is enabled.

              So if you installed a Solus system before we added Zram then you would have never gotten the "zram enablement" package installed. It was added as a default package to the 4.4 ISO but not retroactively installed on user systems since we wanted people to be able to uninstall it if they wanted and eopkg doesn't handle "suggested" packages. The /usr/lib/sysctl.d/70-zram.conf file is added by this package, which is why it's not present on your system. You can install it if you want, the enablement package is called zram-generator-defaults. Installing this will install the default configuration for Zram which causes it to be enabled by default, but it also installs a couple other files to set settings elsewhere to better work with zram (like the sysctl file). You can also just create /etc/sysctl.d/70-zswap.conf or whatever with the desired values you want.

                ReillyBrogan Thank you again. I thought my OS was installed from the 4.4 iso but must have been mistaken. Keep up the good work.

                BuzzPCSOS Ahh sorry I was just making a general comment how well zram zswap
                worked with defaults. (but its nice we can change it if needed)
                I remb ReillyBrogan having me do what he said to set mine up way back when.