Scale ZRAM to Full Memory Size
Fedora 33 enabled zram by default. The size of the virtual swap devices was set so that the amount of memory used for compressed swap pages was limited to a quarter of physical memory in typical scenarios. That size is now increased to half of physical memory (
zram-fraction becomes 1.0,
max-zram-size becomes 8 GiB). This allows systems with small amounts to successfully launch the Anaconda installer and other programs.
- Targeted release: Fedora 34
- Last updated: 2021-01-27
- FESCo issue: #2554
- Tracker bug: #1921084
- Release notes tracker: #644
When ZRAM was enabled by default in Fedora 33, the size of the device (before compression) was limited to fraction 0.5 of RAM or 4 GiB, whichever is less. The reason to limit the fraction to less than 1.0 is that with only incompressible data in memory, whole RAM would be filled by the "compressed" pages, leaving no RAM for normal use. But this concern seems to have been overblown, and there have been no reports of compressed swap taking up too much memory. In real use, we will have at least a few hundred MiB of code in memory, which compresses quite well, so some compression will occur even when working with incompressible data. In typical usage scenarios, we get effective compression of 2:1 or 3:1, which means that the compressed pages use at most between 1/4th and 1/6th of RAM. By increasing the fraction to 1.0, we expect to consign up to half of RAM for compressed pages.
Increasing the size of the device is important for small devices. For devices with 1GB of RAM, sizing ZRAM to 1 GiB allows successful installation with Anaconda. In general, it is expected that having more compressed swap will make the device more functional after installation too. This increase is the most important for devices with small amounts of memory (< 1 GiB), but will be beneficial to systems with slightly larger systems (1–8 GiB).
Technically, this change is completely trivial, amounting to two lines of configuration. Nevertheless, there is some potential for problems with incompressible workloads. The experience with ZRAM so far makes the Change authors optimistic that no issues will be encountered, but users and other developers should be aware of the change.
Benefit to Fedora
Fedora works better on devices with low RAM. In particular, the installer can function.
- Proposal owners: change the defaults in
- Other developers: N/A (not a System Wide Change)
- Release engineering: #Releng issue number (a check of an impact with Release Engineering is needed)
- Policies and guidelines: N/A (not a System Wide Change)
- Trademark approval: N/A (not needed for this Change)
- Alignment with Objectives:
Default configuration is changed. Systems with local configuration will not be affected. Systems which had zram-generator disabled will not be affected.
How To Test
Install the new version of the
zram-generator-defaults package, execute
sudo systemctl daemon-reload && sudo systemctl restart swap-create@zram0, use
zramctl to check that the device has the expected size. After some use, check that pages are compressed at least with ration 2:1:
$ zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 lzo-rle 7.6G 4K 74B 12K 4 [SWAP] ^ ^ ^ | \____\_______ the ratio of those values should be more than 2:1 | `------ this should be approx the size of RAM
(Note that the compressed swap device is destroyed and recreated during restart. This means that all pages will be "swapped in", i.e. decompressed. When making a zram configuration change on machines with low memory, instead of
sudo systemctl restart, rebooting might be a better option.)
Not user visible.
- Contingency mechanism: Revert default configuration to previous values.
- Contingency deadline: Final freeze, any time really.
- Blocks release? No
- Blocks product? No
The default size of compressed zram devices (
/dev/zram0) has been increased to 1.0 fraction of RAM, or 8 GiB, whichever is smaller.