Article Summary:
By default Fedora uses zram that is whichever of these is smaller: the system RAM or 8GB.
This should work fine, but we probably want to use a bigger zRAM on systems with a lot of RAM, likely always the same as system RAM, while at it we can take a look into compression (the default seems to be lzo-rle, but zstd is an option) and swappiness.
The use cases most likely to benefit from this are gaming, some types of development (e.g. Java ecosystem being memory hungry), web browsing (if we are pessimistic about browser memory usage) and virtualization.
Article Description:
By default Fedora ships a /usr/lib/systemd/zram-generator.conf with the folowing contents:
$ cat /usr/lib/systemd/zram-generator.conf
This config file enables a /dev/zram0 device with the default settings:
— size — same as available RAM or 8GB, 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-size = min(ram, 8192)
Resulting in:
$ zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle 8G <snip> <snip> <snip> [SWAP]
From the .conf file man page:
• zram-size=
Sets the size of the zram device as a function of MemTotal, available as the ram variable. Additional variables may be provided by DIRECTIVES.
Arithmetic operators (^%/\*-+), e, π, SI suffixes, log(), int(), ceil(), floor(), round(), abs(), min(), max(), and trigonometric functions are supported.
Defaults to min(ram / 2, 4096).
We effectively can chose either max(ram / 2, 8192) or max(ram, 8192) depending on how much the user trusts zRAM won’t eat their normal RAM.
There’s research on compression for zram, but we can analyze the available research and choose whether to recommend zstd by default or whether some other options make sense.
Apparently there’s the swappiness recommendations that PopOS uses, we can look into those as well.
Note: We can potentially later create a Docs page with more information, Fedora Magazine just will bring more visibility for this. Generally every single time I had to figure out how to optimize zram I rely on the Arch wiki.
I have read and understand the Ai-Assisted Contributions Policy
For Editor Use Only
Editor:
Image Editor:
Publication Date:
Preview Link: