News for hackers. Stuff that matters.
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.
Re:Do not buy RAM, compress by taegee on Thursday November 19, 2026 @04:17PM (#50566510)
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 …

Re:Do not buy RAM, compress by el_isma on Thursday November 19, 2026 @06:13PM (#50567918)
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

Re:Do not buy RAM, compress by taegee on Friday November 20, 2026 @01:08PM (#50579202)
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.

Re:Do not buy RAM, compress by impact123 on Friday November 20, 2026 @05:15AM (#50572619)
Re:Do not buy RAM, compress by taegee on Friday November 20, 2026 @01:07PM (#50579175)
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.)

Re:Do not buy RAM, compress by hedgehog on Friday November 20, 2026 @12:14PM (#50578236)
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.