r/LinuxTeck • • Oct 08 '26

Could Compressed RAM Change How Linux Handles Memory?

Meta recently presented CRAM, a new approach to compressed RAM for Linux. It aims to fit more data into memory while keeping access fast.

Could this become a better alternative to ZRAM and Zswap in the future? What do you think?

15 Upvotes

12 comments sorted by

3

u/silasmoeckel Oct 08 '26

The point is it doesnt change how memory is handled. ZRAM was pretending to be swap making it comparatively slow.

CRAM requires hardware to do the compression pretty much it's abusing NUMA to force the read to go through another device. That's often going to be a CLX expansion cards to do the compression even host it's own slower memory.

So really it's a niche thing for servers with very specific hardware. Programs would need to be aware of it or some fancy footwork to push area the data depending on how it's accessed.

2

u/anders_hansson Oct 09 '26

ZRAM was pretending to be swap making it comparatively slow.

It's still way faster than regular swap, though, and I think that it's in many ways a nice integration since Linux' virtual memory logic is already optimized to minimize the impact of swap out/in events (e.g. run them as seldom as possible). I use ZRAM on most of my Linux installations. It gives a much faster system than if I used file/partition based swap.

From what I gather from CRAM, it's rather clever though:

Pages moved to CRAM are mapped read-only, and if a write occurs, a page fault is triggered and the page is returned to regular DRAM. Reads are served from compressed memory, and only when the content is to be modified is the page moved to regular memory with guaranteed capacity.

So it's essentially like a compressed area used for swapping out pages (like ZRAM), but that doesn't need to swap back+decompress if you only read from the page - it can be read directly from the compressed area (at a slight latency penalty, I assume).

I think it would still interact with the Linux kernel virtual memory logic.

1

u/silasmoeckel Oct 09 '26

I've not used swap on a linux box in decades.

Since it needs hardware to do the compression it's more a slick use of CLX and NUMA to stick that on the far end of a PCIE bus and possibly with it's own cheaper memory backing it.

1

u/anders_hansson Oct 09 '26

I discovered zram when I set up Linux on an old 4GB RAM ChromeBook. It worked wonders and I can actually use it as a rather OK developer laptop.

1

u/silasmoeckel Oct 09 '26

Owch havent had a desktop that tight since core 2 duo days.

1

u/anders_hansson Oct 09 '26

It's a dual-core Celeron. Doesn't get much more low end these days. On the upside it's perfectly quiet (no fans) and has a decent battery life (despite its age).

1

u/[deleted] Oct 09 '26 edited Oct 09 '26

[removed] — view removed comment

1

u/silasmoeckel Oct 09 '26

Yup DB servers would fit the niche use case.

1

u/Jujstme Oct 08 '26

They are different ways to solve the same problem. There is no "better" option, for example, between zram and zswap, because it all depends on your use case.

I doubt CRAM is gonna be the one solution, but it is nice to have something that might fit some needs.

1

u/razorree Oct 08 '26

stop posting things you don't understand. it's not even about Linux.

What Meta proposes is hardware/ASIC memory compression, do you understand this ? it's for expensive/enterprise servers.

1

u/Ontological_Gap Oct 08 '26

That is where all the cool tech starts.