Do not buy RAM, compress

Ecno92 276 points 225 comments November 19, 2026
curiousbits.nl · View on Hacker News

Discussion Highlights (20 comments)

Ecno92

Since I am using Claude with parallel sessions in different workspaces I started to run out of RAM. Instead of buying more RAM, which meant that I should replace my device, I decided to implement zram. This compresses memory. Now I can do more with the same hardware. In many cloud environments compression is not enabled. I am curious to see if the same gains can be made in such environment.

roosgit

MacOS has been doing this for quite a while now. I was a bit surprised this wasn’t the default for most Linux distros, although I think Pop!_OS (what a name!) has had zram enabled for a few years already. I turned it on on one of my servers (1GB RAM) and it works fine.

messe

Use zswap not zram if you have a backing device: https://linuxblog.io/zswap-better-than-zram/ https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-...

mzhaase

Zram vs Zswap: https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-... > If in doubt, prefer to use zswap. Only use zram if you have a highly specific reason to. > In terms of architecture: > zswap sits in front of your disk swap, compresses pages in RAM, and automatically tiers cold data to disk. It integrates directly with the kernel's memory management and distributes pressure gracefully. > zram is a compressed RAM block device with a hard capacity limit. When you put swap on it and it fills up, there is no automatic eviction, and the kernel has very little leverage to do anything about the situation. The system either OOMs or falls back to lower-priority swap, causing LRU inversion (see below). It only really makes sense for extremely memory-constrained embedded systems, diskless setups, or cases with specific security requirements around keeping private data off persistent storage. Swap on zram is also increasingly unsupported upstream.

sammatilda

I just discovered zram thanks to claude after installing fedora on a new computer and man I was blown away by both zram and fedora. Fedora amongst the linux distributions for some reasons has really got everything that an end user needs and the whole experience is just way smoother than anything I have used in 25 years on linux. I am hoping to switch my dad from ubuntu to fedora in a month or so because he has 16 GB ram and this seems like something most people dont know.

ChrisRR

> Compressing memory does not come with downsides. It takes a little bit more from your CPU and adds latency to some processes It sounds like those are downsides

Lio

RAM compression sounds very useful but the thing I really need extra RAM for is local inference. Since the models are effectively highly compressed data already my assumption is that RAM compression won't help improve that much (I'm assuming unified memory here as per the Framework Desktop). A bit like trying to compress a JPEG in a zip file. Could anyone comment on that?

yummybear

"Compressing memory does not come with downsides. It takes a little bit more from your CPU and adds latency to some processes" Which one is it?

DeathArrow

I have built my PC with core i7 14700K, RTX 3090,128 GB DDR3, 2TB SSD, 8TB HDD about 3 years ago. Still perfectly usable and I won't upgrade until prices come down. Even used prices are terrible now.

jakozaur

> Memory compression is not new. If you have a Windows or Mac device you are already using it. Yes, macOS has had it enabled by default since OS X Mavericks 10.9, released in October 2013. I’m surprised some desktop Linux distributions still require manual configuration to enable it. For browser tabs, though, I think a better solution is automatic tab closing, using something like the Tab Wrangler extension for Chrome. Collecting tabs comes naturally; we’re much worse at closing them.

kiicia

nice try Ram Altman

jauntywundrkind

In many systems, adding compression makes not just storage better but increases the io you get from a system too. Here's Valkey 9.2 compression figures showing that: https://www.phoronix.com/news/Valkey-9.2 That's for RDB persistence. https://valkey.io/topics/persistence/ I wonder if there's any similar wins with ram? That some workloads would see net wins from compression. Some cost of cpu, but increasing net throughput significantly.

certyfreak

I switched to Fedora some time ago and only recently learned about zram. I was hitting full system memory(16GB) during normal use, and after increasing my zram to 16GB, I was blown away. I had initially planned to buy additional ram.

dist-epoch

> If you have a Windows or Mac device you are already using it Technically yes, practically on Windows memory compression is not used. I have Windows 11, 128 GB RAM, and my memory stats show: 42 GB in use, 380 MB compressed.

rustyhancock

I've used zswap on most of my systems and generally find it beneficial especially as (de)compression can be very fast these days. What's interesting to note is that I've occasionally wondered why isn't the swap partition compressed. If you have it on an NVMe drive it probably is as is all data! The controller usually transparently does it as it writes to/from NAND. So the kernel sees uncompressed fixed block pages and the speed boosts happen with data arriving faster when read or written to flash.

baud9600

You’d hope with these amazing GPUs today, that some cycles can be used to compress RAM very efficiently. So many parallel cores, surely we can get even better compression from this latent hardware?

LoganDark

Windows doesn't do memory compression if the page file is not enabled. I never particularly saw the point of the page file because I don't enjoy swapping, but it appears that the memory management system disproportionately depends on it to the point where it simply refuses to work properly with it off. So make sure that's turned on if you want memory compression. (Do not let it auto-size or it will happily fill up your whole drive, set it to something reasonable)

cubefox

So why is zswap (basically zram+swap) not enabled by default everywhere?

nukanse

For a programmer, on many cases, it pays to compress the data, to improve RAM IO, because the alu may already be doing nothing meanwhile waiting for the data from ram, so you can use that time to decompress, process, compress, and store the result. A lot of code today is bottlenecked by IO. You spend a lot of effort optimizing with SIMD, processing the data super fast, and then the speed it's wssted because there is not enough bandwidth to even send the result to ram. Modern cpu should include more hardware support for memory compression

hinkley

Okay, Johnny Mnemonic.

Semantic search powered by Rivestack pgvector
13,334 stories · 126,150 chunks indexed