What does that mean? You configure all your RAM as zram swap?
EDIT:
Just seeing your swap usage now:
You have all your RAM configured as zram swap. That explains why your PC swaps 25 GiB. That is a huge amount. I am not sure if that makes sense. Why dont you just assign a fraction of your RAM as zram swap?
With CONFIG_ZRAM_MULTI_COMP, zram can recompress pages using alternative (secondary) > compression algorithms. The basic idea is that alternative compression algorithm can
provide better compression ratio at a price of (potentially) slower
compression/decompression speeds. Alternative compression algorithm can,
for example, be more successful compressing huge pages (those that default algorithm
failed to compress). Another application is idle pages recompression - pages that
are cold and sit in the memory can be recompressed using more effective algorithm
and, hence, reduce zsmalloc memory usage.
Though I couldn’t see any “double configuration” of zram on my system before, I redid the whole thing and just created a new /etc/systemd/zram-generator.conf.
zram-size=ram is a fairly common configuration. Some distros like Fedora or Garuda use it as the default. Keep in mind that due to the compression of zram, it typically uses only a third of the RAM that it would be uncompressed.
Initially the created zram block device does not reserve or use any RAM. Only as files need or want to be swapped out, they will be compressed and moved into the zram block device. The zram block device will then dynamically grow or shrink as required.
Even when assuming that zstd only achieves a conservative 1:2 compression ratio (real world data shows a common ratio of 1:3), zram will offer the advantage of being able to store more content in RAM than without memory compression.
Note:
When configuring zram, the size of the zram device controls the maximum uncompressed amount of data it can store, not the maximum compressed size. You can configure the zram’s size to be equal to or even greater than your system’s physical RAM capacity, as long as the compressed size on physical RAM will not exceed your system’s physical RAM capacity.
When you configure zram, the zram block device is created, but it only starts to use RAM when data needs to be swapped out. If your system is actively using its RAM and there are no memory pressures or situations that require swapping, then the zram device will remain unused.
In other words, if you have 16 GB of RAM and 16 GB of zram for swap, you can have all 16 GB of RAM in use with no zram being used if nothing is swapping yet; the zram does not reserve or otherwise occupy RAM, or prevent it from being used normally.
Well, technically zram is exactly this - a block device like any ssd, hdd and so on - but stored in memory then on an actually “disk” (or drive).
There are much more use cases besides using zram partition as a swap device.
Thank you for the explanation. That makes me wonder why it makes sense to reduce the zram-size to only half or even a quarter of the RAM? To me it sounds like zram-size=ram is the one size that fits all.
For example, I think Fedora is using zram-size=ram up to a max of 8GB. I am not sure it makes sense to have a massive amount of zram unless you have a specialized use case that warrants it.
I do not allow write-backs. Just because something isn’t compressable, doesn’t mean I want it on slower storage.
I would only enable this in situations where I was memory constrained.
Pop! OS uses zram + swap which i already said this would not be advised at all. This article already says the same. It’s either Swap or Swap file or Zram or Zswap.
From Pop! OS 22.04: zram will not show as swap on disc, picture below you see zram activated and a swap partition on disc.
This is not entirely correct.
You cannot have zswap at all without the backing of a swap device. Be it a partition or file.
Zram however can work without such backing.
The difference compared to zram is that zswap works in conjunction with a swap device while zram with created swap on top of it is a swap device in RAM that does not require a backing swap device.
Also, you could use zram, in conjunction with a swapfile (as I do) or a swap partition if you want to configure hibernation on your system as I have done for this laptop.
On the running system, you can set a value for the priority of your swap spaces to determine which one is going to be prioritized by the kernel. The priority for zram is 100 by default and for swap file or partition -2. The higher priority indicates which one is to be used first.