Request for Fedora users with 8GB of RAM — is zram helping you?

8GB laptop. This is at the end of a work day: a lot of open terminals, Firefox, DBeaver, Telegram, Evolution.

NAME       ALGORITHM DISKSIZE  DATA  COMPR  TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       3.7G  2.6G 842.7M 876.1M       4 [SWAP]
3 Likes

I don’t use my 8GB laptop enough to run into ram issues, but I recently filled up the ram and (4GB) zram swap on my 32GB system. It slowed down and nearly locked up at some point, probably due to heavy I/O when an automated borg backup started running, but never crashed. If I come across a similar situation again, I’ll post the results of /sbin/zramctl.

Previously with Ubuntu I would normally have weeks of uptime, rebooting around once a month. With Fedora having more frequent kernel updates, I typically go 7-10 days between reboots. Sometimes there are more than one kernel and software updates installed requiring reboots in that timeframe.

2 Likes

Thanks everyone! Next thing: if you found your zram swap to be heavily used, can you follow the steps here to increase the limit (as planned for F34) to see what effect that has?

https://fedoraproject.org/wiki/Changes/Scale_ZRAM_to_full_memory_size#How_To_Test

4 Likes

If in the How_To_Test, can give the full path of conf files to be modified, will be even better for starters.

2 Likes

Install the new version of the zram-generator-defaults package

Is this already on Pagure somewhere?

2 Likes

Hi,

I’ve just done this test:

$ sudo cp /lib/systemd/zram-generator.conf /etc/systemd/
$ sudo vi /etc/systemd/zram-generator.conf

/etc/systemd//zram-generator.conf:

# This config file enables a /dev/zram0 device with the default settings:
# — size — half of available RAM or 4GB, whichever is less
# — compression — most likely lzo-rle
#
# To disable, uninstall zram-generator-defaults or create empty
# /etc/systemd/zram-generator.conf file.
[zram0]
zram-fraction=1.0
max-zram-size=8192

$ sudo systemctl daemon-reload && sudo systemctl restart swap-create@zram0

$ zramctl
    NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
    /dev/zram0 lzo-rle       7.3G   4K   74B   12K       4 [SWAP]

Seems to work ok to me. Would remove after testing or certainly before updating to F34.

Thanks Tom.

5 Likes

Thanks! Seems to be working fine for me so far. I’ll do some further testing right now.

So, will my ram fill up to 8G (with 16G), then start compressing anything that goes into the next 8G?

Edit: Never mind. It seems to be more like a literal swap partition? Either way, this is pretty cool:

9661a8961cca46508714e2bb6c9dd9a603df39aa.png

And my system, and all the VMs, are all running at near 100%, if not 100% speed!

1 Like

It’s unfortunately much more complicated than that, because code can’t actually run from the compressed space; it has to be swapped in. So, basically when there is memory pressure (which is complicated), code that hasn’t run for a while gets pushed to the compressed area, making more room for active code. But when that now-compressed code needs to do something, it needs to come back out. When this hits disk (even SSD), it’s really, really painful. When it’s all in RAM (as with this feature) it is quite fast, but it’s still not free.

4 Likes

Yeah, going over my head a bit, but still pretty cool!

1 Like

So, it’s basically just swap space but on a ram disk? I misunderstood this completely lol

1 Like

It is exactly that — swap space on a ram disk that is compressed.

4 Likes

Great and Cool!
F34 Test Server - Run and show zramctl…

[root@cosmos simmon]# uname -ar
Linux cosmos 5.11.0-0.rc5.20210128git76c057c84d28.137.fc34.x86_64 #1 SMP Thu Jan 28 21:10:47 UTC       2021 x86_64 x86_64 x86_64 GNU/Linux
[root@cosmos simmon]# zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       6.4G   4K   80B   12K       4 [SWAP]

so, it’s a start change something?

1 Like

In this case, not really. There’s only 4K in there. You’ll need to use up some more RAM to see an effect. :slight_smile:

3 Likes

Oh, Hey! First time posting something on the Fedora Forums. I am currently using two pcs. A desktop with GNOME, and a All-In-One with KDE.

Gnome Desktop

NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       2.9G  36M    9M  9.7M       4 [SWAP]

KDE All-IN-ONE

NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       3.6G   4K   74B   12K       4 [SWAP]

I really have noticed a difference on ram usage since switching to Fedora. I was a pretty frequent distro hopper but I have actually am thinking of sticking with Fedora.

Hopefully this helps you out!

4 Likes

It does, thanks. And I do hope we can convince you to stick around!

2 Likes

It seems like a really great community. I’m also looking to see into other ways I can help out.

2 Likes

I do not understand this output. Data is more than twice the size of total, so how does this get interpreted with the individual fields. At first glance it seems disksize and total should really be the only items of real concern, then the larger data item is a glaring discrepancy that I can’t seem to interpret. BTW, this is on a system with 32G RAM.

DISKSIZE is just a limit — it’s not actively being used. DATA is the raw amount of uncompressed data in swap, and COMPR is the compressed size. TOTAL is that plus overhead. From zramctl --help

Available output columns:
        NAME  zram device name
    DISKSIZE  limit on the uncompressed amount of data
        DATA  uncompressed size of stored data
       COMPR  compressed size of stored data
   ALGORITHM  the selected compression algorithm
     STREAMS  number of concurrent compress operations
  ZERO-PAGES  empty pages with no allocated memory
       TOTAL  all memory including allocator fragmentation and metadata overhead
   MEM-LIMIT  memory limit used to store compressed data
    MEM-USED  memory zram have been consumed to store compressed data
    MIGRATED  number of objects migrated by compaction
  MOUNTPOINT  where the device is mounted
1 Like
$ zramctl
NAME       ALGORITHM DISKSIZE   DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle         4G 234.5M 85.9M 88.7M      12 [SWAP]

So if I am understanding this right then total is the compressed + overhead. Data is then the total uncompressed size of all that is in swap. Yet that line in the help says “all memory” + overhead. Seems a bit conflicting since in my experience total would be ALL and here data seems to be ALL and total is a fraction of that.

1 Like

DATA is “how much would be consumed if this had not been compressed”. It is not included in TOTAL because it isn’t actually taking up that amount of memory. It is taking COMPR amount of memory.

I agree that it is a little confusing for TOTAL to mean “total memory actually used” rather than “all numbers added together”, but the latter wouldn’t be a useful number in any way while the former is.

Pragmatically, the two numbers you want to compare are DATA and TOTAL. The difference between the two is memory made free by compression.

2 Likes