foundObjects / zram-swap

A simple zram swap service for modern systemd Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to tell if zram is properly working?

Latrolage opened this issue · comments

How can I tell if zram is properly working?

And also are the compression methods generic compression methods, or are they specifically for this purpose?
I found zstd well documented on a github page, are there benchmarks for those compress/decompression methods for specifically zram?

I've noticed my swap partition shows as larger than before. Is this where the zram is? Should I be disabling normal swap and are there any downsides to not disabling it? Edit: I commented out the swap partition in /etc/fstab, is this what I should be doing when using zram? Also is the swap thing from zram supposed to show a larger size than my actual ram?

The script seemed to work quickly out of the box though, thanks!

Another question. So with zram being shown as a swap file, is zram basically a proxy to ram but compressed?

Does this mean I should increase swappiness? (i read that this would increase likelihood of using swap)

Run zramctl to view in-use zram devices, swapon with no arguments will show swap devices as will cat /proc/swaps.

Depending on how much swap you actually need it's possibly safe to disable on-disk swap but there's no real downside to leaving a swap partition or file enabled unless you're actively trying to avoid paging to disk. As long as disk-based swap has a lower priority than your zram swap device it won't ever be used unless zram becomes completely full. On a normal desktop, or even a raspberry pi performing light work, it's pretty likely that you'll never swap to disk, but that will depend on how much your workload swaps.

I don't really know anything about your use case (what kind of computer, how much RAM you have, how much your workload swaps, what kinds of disks you have, etc) so I can't answer any of the "what's better" or "how fast is" tuning questions. If you're using the defaults in the script for a normal desktop/laptop or for a raspberry pi (or other SBC) you're probably good to go, if the machine is modern and fairly quick I'd change the compression algorithm to 'lzo-rle' and call it good.

I'll refer you to the kernel documentation for the general "how does zram work" and "should I change vm.swappiness" questions:
https://www.kernel.org/doc/Documentation/blockdev/zram.txt
https://www.kernel.org/doc/Documentation/sysctl/vm.txt

This might also be helpful to understand what zram is and what it does:
https://en.wikipedia.org/wiki/Zram

If you google around a bit I'm sure you can turn up some benchmarks of zram using lz4, lzo, lzo-rle and zstd. Or you could make various zram devices and test them yourself with something like bonnie++ or fio to get an idea of their performance. I will say though that just looking at the compression benchmarks from the zstd project should give you a fairly accurate idea of relative performance between the different algorithms without needing to replicate them all yourself; you can if you want to learn more though. If you take a peek at that you can see why I chose lz4 as the default compressor, it's quite fast; zstd is another good choice if you need more space efficiency and don't mind the extra CPU overhead to obtain it.