How do I reduce preference of ZRAM usage on Fedora 33?

Hi folks,

I just installed Fedora Workstation 33 afresh last night with an ext4 partitioning scheme and discovered that zram was enabled by default. About 4GB of space was allocated to it, which is half the size of the physical memory my laptop has. I was furthermore surprised when I discovered the following.

29825efc4c924b2505f8264fa83fd7b2efd6560b.png

Look at the swap bar of htop. Actually I allocated 1536MB of space for the designated swap partition and while installation, the zram got enabled as a new default and now I see them working together - hence resulting the 5.32GB of space that you see in the screenshot. Now that is definitely not a problem. The problem is even when I have reduced the swappiness value, the OS still finds reasons to make use of the swap space. I have at least half the memory left for use and then I feel the sluggishness in the interaction, so I quickly open up htop to see an active use of the swap partition.

Beginning to swap pages to back to the secondary memory and forth, even when almost half the physical memory is left unutilized is unsettling. It also messes up the experience as there’s a notable lag in the user interface. I am sure that my hardware is not the type where you would want to use swapping in the first place as I have only one 5600RPM 2.5" hard drive which is not a very fast disk, and the tendency of swapping every now and then bottlenecks the capability of how good the physical memory could have, otherwise, performed. I think that I have detected the symptoms right (Feel free to correct me if I have not).

But how do I reduce the preference of ZRAM usage?

https://discussion.fedoraproject.org/t/fedora-32-small-swap-problem/67455/11?u=vgaetera

1 Like

I think you can uninstall the zram-generator package if you wish to disable zram, but note that the defaults are default for a reason… adding a traditional swap partition of any size creates potential for sluggish performance.

I believe I should purge the traditional swap partition by reinstalling Fedora.

I would not want to touch /etc/fstab to disable swap for once I did that and Fedora failed to boot.

ZRAM only this time. Let me see if the sluggishness is gone.

Actually, you need to modify it:
Swap after upgrading from F32 to F33 - #3 by vgaetera

2 Likes
sudo cp /usr/share/doc/zram-generator/zram-generator.conf.example /etc/systemd/zram-generator.conf

Edit the /etc/systemd/zram-generator.conf config file (read the comments).
Restart zram-generator

sudo systemctl restart swap-create@zram0.service

Check the new size

zramctl
swapon

However, if you have zram and a swap partiton, zram has the priority over the disk based swap space.
I don’t know: if you suffer lags, I doubt that it is due to swap. You can try to temporarily disable disk based swap space using

swapoff /path/to/swap/device

And look if lags persist.
In addition, as far as I know (ooh well, I’m not an expert), swapping is not always triggered by a lack of free RAM.

2 Likes

I know I do but I messed it up really bad once that I try to keep myself from editing one in a critical system. :see_no_evil:

Thank you for listing the steps @alciregi. I would follow them and see if the lag persists.

Exactly, @alciregi! Here’s the thing - there’s ample RAM left but still swapping is preferred even when I had reduced the swappiness value. What really troubles me is the greater inclination of using the swap than that of using the physical memory. :worried:

You can safely experiment on a VM with a similar config:
Installing virtual operating systems with GNOME Boxes