I was wrong! zswap IS better than zram

This article hopefully serves to balance the recommendation between both ZRAM and Zswap. At the very least, remove some of my previous bias. :grimacing:

The community discussion this was based on can be followed here:

As well as the related forum topics below the comments.


Quick reference for the settings and outcomes when using Zram and Zswap:

Metric (System with 16 GB or RAM) 1.5:1 2:1 3:1
Likely algorithm(s) at this ratio LZ4 LZO Zstd
ZRAM — 4 GB
Max zram disksize (GB) 4.00 4.00 4.00
Max uncompressed stored in zram (GB) 4.00 4.00 4.00
Approx. RAM used by zram when full (GB) 2.67 2.00 1.33
Resident RAM left for everything else (GB) 13.33 14.00 14.67
Max uncompressed working set before any disk swap (GB) 17.33 18.00 18.67

ZSWAP — pool cap 20% of RAM = 3.20 GB
zswap pool cap (GB) @ 20% 3.20 3.20 3.20
Max uncompressed cached in zswap (GB) 4.80 6.40 9.60
Approx RAM used by zswap at cap (GB) 3.20 3.20 3.20
Resident RAM left for everything else at cap (GB) 12.80 12.80 12.80
Max uncompressed working set before any disk swap (GB) 17.60 19.20 22.40

Notes
• ZRAM has a fixed uncompressed cap equal to its disksize. Actual RAM used by zram is allocated dynamically as pages are compressed and swapped out, not all at once when the device is initialized.
• ZSWAP also grows on demand up to its pool cap. When full, it starts evicting to the backing swap device.

1 Like