Re:Do not buy RAM, compress
by hedgehog on Thursday November 19, 2026 @11:44AM
(#50562483)
As others have noted zswap is usually a better choice than zram, additionally depending on your situation it may be worth checking which algorithm it's using as there are a few choices (zstd, lz4, etc). zstd is the right choice IMO unless you're in a situation where you know better.
[ Parent
| on HN ]
Exactly. It defaults to lz4 but zstd gives quite a bit more compression.
Unfortunately AFAIK there is no way to query the current settings. You just write zstd(level=2) into some config file and hope for the best …
sudo cat /sys/kernel/debug/zswap/stored_pages
sudo cat /sys/kernel/debug/zswap/pool_total_size
getconf PAGESIZE
ratio = (stored pages * PAGESIZE) / pool total size
I have 3.6 right now
I was talking about zram and I didn't mean the compression ratio but the compression level used by the algorithm (2 in my example).
Sorry for the confusion.
I was talking about zram.
Re:Do not buy RAM, compress
by seabrookmx on Thursday November 19, 2026 @05:17PM
(#50567248)
I have a Framework 13 (AMD, 16GB) running Ubuntu. After some struggles with heavy multitasking, I bumped the default swapfile from 4->16GB and enabled zswap with zstd. I basically don't think about RAM usage anymore. It's been working flawlessly.
zswap actually compresses the memory _in RAM_ (just like zram) first before swapping it, so you actually get more runway out of it before it hits the disk. But you still can spill over to the disk when necessary.
Re:Do not buy RAM, compress
by deathanatos on Thursday November 19, 2026 @07:51PM
(#50568760)
My frustration with zswap is that, when content is spilled to disk-based swap, it gets decompressed. There is, AFAICT, no way to have compressed swap¹ on Linux.
(¹on disk. A lot of these "z[foo]" projects are compressed memory.)
Yeah I have wondered about that but I don't understand Linux well enough to know how to implement it. Having an additional tier of compressed storage for less-warm pages (including general disk cache) seems like it would be a performance win. I'm guessing there are some subtleties to doing the disk storage in a way that has acceptable page-in latency, doesn't cause excessive write amplification on flash, etc.