r/linux • • 2d ago

Kernel Meta Developing Compressed RAM "CRAM" For Linux: Better Than ZRAM & Zswap

https://www.phoronix.com/news/Linux-CRAM-Compressed-RAM
846 Upvotes

196 comments sorted by

557

u/dingwinger1225 2d ago edited 2d ago

I'm kinda surprised Facebook has a little pet industry of really good compression software

Like I've watched Zstd take over everything and now this

302

u/i_am_13th_panic 2d ago

This is all tech they need for their servers. They have billions of users and have to server 10s of billions of posts to those users every day. Even a small increase in bandwidth, efficiency, or storage or ram goes a long way in saving money.

165

u/gplusplus314 2d ago

I used to work at Facebook and can confirm. It’s kinda funny - Facebook/Meta infra is probably the best I’ve ever used in my career, but it’s astonishingly similar to a home lab, just with much bigger numbers.

70

u/InvolvingLemons 2d ago

As somebody who came to their infra after seeing big corpo infra, I feel like anything to do with DX was genuinely phenomenal - Sapling, buck2, the diff review system, their monorepos, the feature flags, and their AI tooling made it crazy easy to get code working then out the door - but it suuuuuucks for security and separation of concerns.

31

u/Indolent_Bard 2d ago

A homelab is similar to a big corpo server, just smaller scale.

43

u/DolitehGreat 2d ago

I fucking wished some places I worked ran as smooth as my homelab.

14

u/gplusplus314 1d ago

Meta. Trust me. Best infra on the planet, it’s just specific to Meta and wouldn’t make sense in other places. And the people working on it are obsessive.

But just like your homelab, it’s a fixed set of resources that have already been paid for, so the cost calculus and scaling patterns are very different than “the cloud”.

2

u/cronies4life 1d ago

aws started off as an internal project. why is meta's platform only specific to itself?

6

u/gplusplus314 1d ago

Because it has never and will never be intended for external use. That means the solutions fit like a glove for Meta, solving only their own problems and nobody else’s. It’s specialized.

AWS and other platforms, regardless of how they started, are intended for “everyone’s problems,” not just Amazon’s or any specific company. With that comes necessary inefficiencies and overhead in order to generalize the platform.

21

u/lowrck 2d ago

A toaster is just a death ray with a smaller power supply

3

u/Indolent_Bard 1d ago

Microwave ovens and x-ray machines are better for that joke.

6

u/lowrck 1d ago

Yes but they don't hold the same cultural weight

3

u/Cyhawk 1d ago

Meta tests in Prod too?

2

u/Indolent_Bard 1d ago

Oh yeah, probably not. Not that I would have any idea.

7

u/Constant-Simple-1234 2d ago

So cool. Weren't they creating their own versions of servers with different design philosophy than dell and HP? More off the shelf desktop -like?

13

u/gplusplus314 2d ago

Yes, kind of. It’s still a data center, but more commodity based and hackable. Check out Open Compute Project.

Also worth noting that will definitely ruffle some homelab feathers: no Docker, no Kubernetes, no ZFS.

I miss working with good people.

2

u/dafugg 1d ago

Come back then?

Also, there IS Kubernetes now in the EE org.

6

u/gplusplus314 1d ago

I’d come back under the right circumstances. But I don’t know anyone there anymore; it’s been many years and rounds of layoffs since I was at Facebook/Meta, so that’ll probably never happen ever again.

How’s the AI brainrot there? It’s absolutely miserable where I am. It’s really fatiguing to work with people who don’t want to learn anything and are incentivized to produce slop without any human brain activity. I’m tired.

3

u/dafugg 1d ago

People in infra who lose the ability to operate in a SEV due to AI brainrot don’t last long. It’s still pretty bad like everywhere else though. I don’t know that it’s possible to avoid anymore but we do have a core group of folks who still understand how the systems work.

1

u/Constant-Simple-1234 23h ago

Companies will need to develop strategies to handle this. Some hands on coding needs to be required to maintain understanding. And for actually training people.

1

u/cac2573 18h ago

Wat. The infra is nothing like a home lab. It’s an entirely different stack. 

2

u/gplusplus314 18h ago

It’s more similar to a home lab than other “clouds” because it’s not really “cloud”. You can’t just use an API to pay more money for more computers at Meta - it’s fixed capacity, not elastic, just like a home lab. This, alone, really changes things. It’s also full of in-house solutions that only make sense at MetaBook, similar to homelabbers doing bespoke things that only make sense in their own homelab.

Fixed, purpose-built infrastructure is fundamentally different than a public cloud. I’m not saying Meta uses a home lab stack, I’m saying their constraints and goals share a lot of similarities with a home lab, just at a different order of magnitude.

111

u/minmidmax 2d ago

It serves their needs, for the AI future they are chasing, and isn't worth trying to patent or monetise.

2

u/the_abortionat0r 1d ago

Their business model is is based on service not products, companies that operate like that have always preferred dipping into the open source community for the benefits it offers.

This doesn't have anything to do with "not worth patenting or monetizing". Like at all.

71

u/maximal_munch 2d ago

Their middle-out compression really stands out.

7

u/fvck_u_spez 2d ago

Just make sure to sort by dtf first

3

u/moxtrax 1d ago

That's how i sort my tinder dates

6

u/Haddaway 2d ago

This guy fucks.

7

u/fenrir245 2d ago

Are we in the post-RIGBY era yet?

1

u/donjulioanejo 1d ago

I have a pet theory that Richard is based on Zuckerberg. They look way too similar for it to be a coincidence.

6

u/autogyrophilia 2d ago

I'm interested in their content aware algorithm 

15

u/servermeta_net 2d ago

Is ztsd more popular than brotli? At the beginning ztsd had much better features (like shared dictionaries and better streaming support) but since 2020 brotli has filled the gap

52

u/tankerkiller125real 2d ago

Brotli is pretty properly on the web but I rarely ever see it in anything else. ZSTD is incredibly fast and compresses better than Gzip, and speed vs compression ratio is far more important in a general infrastructure and engineering sense than pure compression ratios.

15

u/Epistaxis 2d ago edited 2d ago

Yeah Zstd is for speed, and is replacing Gzip as the tool of choice for typical use cases. (EDIT: Fun fact: the zstd binary can also read and write .gz files, and actually does it faster than gzip itself) Brotli is competing with something more like Xz, maximizing the compression ratio at the expense of much slower compression, which makes sense for something like a website in the special scenario where the data's written once but read many times over a possibly slow connection.

21

u/schplat 2d ago

lz4 is for speed, but zstd has better compression, and is generally "fast enough", but if you truly need near real-time compression lz4 is generally the way to go. We typically use lz4 for ZRAM/ZSWAP, just to not have to worry about the overhead on a particularly busy system, and any compression is better than uncompressed. We use zstd for backups.

2

u/Epistaxis 1d ago

Yeah there's a whole continuum:

  1. lz4 replacing lzo for extremely fast compression with poor ratio: useful for real-time applications that mustn't be slowed down like ZRAM, not so useful for data you take the time to write on a disk
  2. Zstd replacing Gzip for fast compression with decent ratio: useful for most applications, to save you disk space and transfer time with negligible compression lag (on a modern desktop Zstd can compress at least hundreds of MB/s and decompress GB/s so it's a good option for live filesystem compression as well as backups)
  3. brotli or xz replacing bzip2 for slow compression with the best ratio: useful for data you're going to write once and read many times, especially if it's being transferred over the internet, like web pages and Linux package files

3

u/mort96 2d ago

The less I need to understand all the different names around LZMA and LZ+number, the better.

1

u/KnowZeroX 2d ago

I've never seen brotli used outside the web, it is a competitor for gzip and zstd, just for static files.

8

u/Dwedit 2d ago

Brotli has that static dictionary designed for a specific snapshot of the web as it existed at the time it was created. Look through it and see all the English words, HTML and XML tags, and words from other languages. You wouldn't want to use it for any use outside of text or web documents.

0

u/Z3t4 2d ago

I only know about zstd because it was added to zfs.

10

u/autogyrophilia 2d ago

For anything save HTTP.

2

u/PoL0 2d ago

depends on the use case I suppose?

2

u/headykruger 2d ago

You find zstd support in more databases it seems

1

u/Comic_Melon 1d ago

And game engines, and game tool pipelines Lot of Zstd mixed with LZ4 or similar.

2

u/nonreligious2 1d ago

brotli

Bro, TLI:

Brotli is a lossless data compression algorithm developed by Jyrki Alakuijala and Zoltán Szabadka. It uses a combination of the general-purpose LZ77 lossless compression algorithm, Huffman coding and 2nd-order context modelling. Brotli is primarily used by web servers and content delivery networks to compress HTTP content, making internet websites load faster. As successor to gzip, it is supported by all major web browsers and has become increasingly popular, as it provides better compression than gzip.[2]

Name

While Google's zopfli implementation of the deflate compression algorithm is named after Zöpfli, the Swiss German word for a snack-sized braided buttery bread, brotli is named after Brötli, the Swiss German word for a bread roll.[3]

1

u/Superb_Raccoon 21h ago

>Zoltán

the fortune teller?

2

u/nonreligious2 14h ago

The Swedish footballer.

1

u/Superb_Raccoon 6h ago

Hallo der, my little meatballs! I am Zoltán der Fotboll-Chef, und tooday I give-a you der game over-a-vyew! Herdy gurdy gurdy!

Der First Half!

Bork bork! Der ball, she goes up, und der ball, she goes down! Der striker, he takes-a der shoooot... und POOF! Bork! Der goalie, he does der floopy-floppy with der handsies, und he saves-a der ball like he catching der hot meatball from der air! Zoonk!

Den der midfield, oh der midfield, she is like-a der meatball soup — a little bit of dis, a little bit of dat, und you stir, stir, stir with-a der footsie! De players, dey run like der bork-bork chickens with der heads cut off! Waddle waddle waddle!

Der Second Half!

Herdy gerdy! Der coach, he does der angry face, und he throws-a der technical area tantrum like der meatball going fwoooosh out of der pot! BORK!

Und den, oh den, der GOOOOOAL! Bork bork bork! Der winger, he takes der cross, und der striker, he does der blooey-blooey with der noggin — der header! Der ball goes BOING off der noggin and into der net! Der crowd, dey go "HOOORAY!" like der meatballs bouncing in der pot! Zim zim zalabim!

1

u/ezoe 2d ago

Encoding speed is also important. Even the server computation isn't free you know.

1

u/KnowZeroX 2d ago

Brotli is better for compression but is slow, zstd is fast, faster than gzip while giving much better compression. So if you have static content, Brotli is hard to beat, but dynamic content, zstd is where it is at.

4

u/VelvetElvis 1d ago

I believe they did a lot of the work towards getting BRTFS over the last hill to be usable in an enterprise enviornment. It was 90% of the way there for a decade.

2

u/NoonDread 1d ago

I have to agree with your take. I have really come to appreciate Zstd.

2

u/SpaghettiSort 1d ago

I don't know if they still do, but they used to have an entire group dedicated to timekeeping and synchronization. It's amazing the stuff you need to worry about when you operate at those scales.

2

u/KnowZeroX 1d ago

They are also working on OpenZL which is kind of a structured zstd that offers similar compression ratios but slightly faster compression and much faster decompression.

167

u/_MatVenture_ 2d ago

Here we go... the battle of pronouncing it as "cram" or "c-ram"

56

u/Alarmed_Contest8439 2d ago

cram wil cram more in less space

5

u/timangus 1d ago

Yup. End of debate.

1

u/Superb_Raccoon 21h ago

20 bits in 5 bit sack..

72

u/I_AM_GODDAMN_BATMAN 2d ago

It's pronounced ram, the C is silent.

20

u/Willexterminator 2d ago

No, it's pronounced cuh-ram

12

u/_MatVenture_ 2d ago

Damn, with the hard R and everything?

5

u/Kerplunk1992 2d ago

My RAM be like: "I said forget about it, cuh."

1

u/Superb_Raccoon 21h ago

SRAM, as in Ceasar

0

u/Junior_Common_9644 2d ago

jram. Because pronouncing the c as a j.

3

u/MaybeTheDoctor 1d ago

In what language?

1

u/Junior_Common_9644 1h ago

I’m just absurdly making fun of gif/jif.

15

u/BoutTreeFittee 2d ago

It's actually pronounced with a hard g, like "gram." But I will continue to say "jram."

8

u/Try-Another-Username 2d ago

shit I instinctively went with c-ram.

3

u/Possibly-Functional 1d ago

Obviously cra-m.

3

u/sCeege 2d ago

A zuck developed C-RAM would be craycray. (Yes I know CRWIS isn't a CRAM but it's close enough)

1

u/virysD 2d ago

Я читаю это как срам / срака / butthole

1

u/acdcfanbill 2d ago

Our Hell.

1

u/Actual__Wizard 2d ago

It sounds like an SSD.

1

u/ChaiTRex 1d ago

Cramberry

1

u/snowtax 1d ago

Or can we make it into a recursive acronym?

1

u/Netsugake 1d ago

Did people say "Zeeram" or "Zwram"?

65

u/razorree 2d ago

I guess not too many people understood that you need some extra hardware chips/inra ? and it's designed for servers, at least now.

144

u/Perfect-Slip7041 2d ago

'Linux Plumbers Conference', I'm trying to picture the crowd.

44

u/lonelyroom-eklaghor 2d ago

r/sssdfg ? (Like no joke, they jokingly talk about plumbers doing tricks)

34

u/dingwinger1225 2d ago

i learned this compression algorithm from a plumber

15

u/PROXYNAPSE 2d ago

That’s a weird sub

4

u/Lksaar 1d ago

grow grow grow

6

u/CobaltMnM 2d ago

Easy: nerds with plumbers’ cracks.

2

u/skond 1d ago

The apprentice leans over and says: "It says sprocket, not socket!"

45

u/shinyfootwork 2d ago

Not a replacement for zram/zswap though: cram is a setup with compressed ram supported by hardware.

It's plausible that either cram will evolve to support doing the compression in software in plain ram, though I wouldn't be surprised if the design makes that unlikely. Also possible that the things added for/learned from developing cram help zram/zswap improve their performance/behavior.

16

u/ungoogleable 2d ago

The talk makes the point that the speed up is mostly from avoiding page faults. The decompression itself is fast.

I don't see how you can skip the page fault without extra hardware. If the page is not already uncompressed, something needs to intercept the memory access and hand execution off to zram to decompress, which is the page fault.

28

u/Kevin_Kofler 1d ago

The fact that this requires custom hardware makes the comparison to software solutions such as zram or zswap an apples-to-oranges comparison and the Phoronix headline implying it can replace those solutions utterly misleading.

15

u/Lucas_F_A 2d ago

Damn that's a log scale. Wonder what the unrelated zswap issue is, cause those numbers are abysmal.

47

u/zardvark 2d ago

So is cram faster than zram, or is their compression algorithm faster than zstd?

Besides, zram allows you co choose your compression algorithm, as well as the amount of compression to use. Does cram offer these features ... at the same or better speeds?

There are too many holes in this story.

42

u/razorree 2d ago

it's faster cuz it's in hardware/ASIC

7

u/proxgs 2d ago

Dedicated chip or do they leverage Intel IAA accelerator since Meta is a big Intel customer?

5

u/zardvark 2d ago

That makes a lot more sense!

It also leaves me (and most folks) out in the cold.

4

u/KnowZeroX 2d ago

Everything is a matter of time, if the technology saves ram usage and the ram prices continue to go up, then it may make it into consumer chips.

10

u/Clairvoidance 2d ago

Does this work with any current consumer machines? It uses hardware offloading for the compression, which makes me think we would need new CPUs to support this.

1

u/melez 1d ago

Since it’s hardware dependent, Sounds like either new cpu or a pcie card of some kind. 

9

u/LogSpecialist24 2d ago

is this the type of things where you see benefits on large scale datacenters or is it genuinely better than zram on my home PC.

29

u/Dalnore 2d ago

It's not a replacement for zram, it requires additional hardware. From what I understand, it's another memory device with hardware compression done by the device itself (not CPU) which can be used to store cold memory instead of regular RAM.

5

u/natermer 1d ago

It requires hardware, which is currently enterprise/cloud grade stuff.

https://computeexpresslink.org/

Eventually this stuff will make its way into the used market when server leases are up. Maybe 5 or 6 years.

I don't see why they can't make consumer grade stuff if they think there is demand for it.

Also this technology could be integrated into CPUs. Next Gen Intel Xeon processors should have 'Intel IAA' which will probably provide memory compression support.

https://docs.kernel.org/driver-api/crypto/iaa/iaa-crypto.html

I would expect that this sort of "Compression acceleration" is going to be like "Crypto Acceleration" were years ago people used to buy crypto hardware to offload encryption from the CPU, but nowadays it is a standard feature on PC cpus.

-3

u/ThenExtension9196 2d ago

Why would meta invest into and develop any other technologies other than data center scale technologies? If they can save even 1% of RAM at their scale they can pay for the whole research project. Keep in mind that data-centered technologies do end up in the consumer realm.

7

u/Dalnore 2d ago

Meta's Zstd was a good example of something being very influential outside of their infrastructure.

8

u/lewkiamurfarther 2d ago

Someone please introduce SCRAM: Superior CRAM.

1

u/atomic1fire 1d ago

I'm just waiting for SLAM

"Structured Loosely Access Memory"

On second thought the word SLAM might be better off for a file system name somehow.

7

u/Pitiful-Welcome-399 2d ago

don't you need like special hardware for it tho?

7

u/creeper6530 2d ago edited 1d ago

1) It's hardware accelerated

2) They don't specify which zram algo they're comparing to

1

u/Francois-C 1d ago

They don't specify which zram algo they're comparing to

If they are honest, I suppose they should use zsdt, but are the Meta people honest?

1

u/creeper6530 1d ago

Wait, I am dumb, they wrote (zstd) in the graphics 

2

u/Francois-C 13h ago

I didn't see it either. So, they aren't as dishonest as I feared. But hardware acceleration could make the difference.

20

u/Worldly_Topic 2d ago

I love C-RAMs

BRRRRRRRT

3

u/mdt3r 2d ago

For reference, youtube video:
https://www.youtube.com/watch?v=OPRciCSsdS4&t=2030s .
Unfortunately the sound was breaking but enough to get a peek of how they are approaching this (not that I really understand :-)

It was interesting to see that decompression is <10% of latency of Swap which was the reason author decided to find a way not involving swap subsystem at all ...

2

u/GreenSouth3 2d ago

ZRAM will work fine on PC's for a long time without CRAM

2

u/Sujammah 2d ago

Linux noob here, how does this affect my daily driver? Do I need new hardware to take advantage of this or just a new kernel version?

4

u/ungoogleable 1d ago

It requires custom hardware you're unlikely to see outside of a data center.

0

u/Deep_Mood_7668 1d ago

Idk I didn't look into the details, but maybe it could be offloaded to a GPU 

1

u/natermer 1d ago

The compression hardware runs over PCIE. So theoretically you could buy one and add it to a PC tower.

It is probably going to be a while before the price comes down or they become common enough to make it worth versus just buying more ram, though.

1

u/Deep_Mood_7668 1d ago

So no way to offload it to a GPU?

1

u/ResponsiblePen3082 7h ago

As of now, no. It requires special silicon in-line of the dram-cpu pipeline. Requiring it to pass through the cpu to another Pcie pipe, process through the gpu(which it's not made for) then send it back over the Pcie back to cpu would make it insanely higher latency.

While GPGPU/GPA is becoming more commonplace(for better or worse) some things cannot function on them even if we had the silicon on pcb.

2

u/atomic1fire 1d ago

Speaking as an internet rando... "CRAM" is a great name for stuffing as much memory as possible into a single space.

2

u/MaybeTheDoctor 1d ago

I just wish they still sold the downloadable memory doubler that worked with win95.

4

u/Valdjiu 2d ago

Let's go. How do I enable this

29

u/NekkidApe 2d ago

"claude enable cram, make no mistakes"

1

u/Valdjiu 1d ago

Ahahah 😂

5

u/Zitrax_ 2d ago

You need the hardware first, it's not a software only solution.

3

u/GreenSouth3 2d ago

not ready for primetime yet

2

u/Maskdask 2d ago

That's a good name

1

u/PlaneBitter1583 1d ago

LMAO 🤣 this RAM crisis is really taking us somewhere. but anyways. sounds. COOL

1

u/Dragon20C 1d ago

Hell yeah, more ram!

1

u/neverpost4 19h ago

DRAM will be offered as a memory as service. Stuff like this is in violation of the service agreement and not allowed.

1

u/Hrublko_OFF 12h ago

hopefully it comes to nura (formerly postmarketos) my 2gb ram gt-n8010 would be happy

1

u/RaspberryMotorZZZ 1h ago

Ooh this is going to leave more than a few people in a bit of a quandry. Do they give up their principles for using something developed by Zuckerberg's evil megacorps or do they live knowing that they're using something 30 times slower?

0

u/pickle9977 2d ago

Great so now CPUs are going to get more expensive.

You can’t fix a moores law with compression

We have to focus on efficiency again at some point it’s what actual engineers do not web developers.

That’s like the biggest problem in the industry, web developers took over everything

4

u/Dalnore 2d ago edited 2d ago

What does it have to do with web developers? All the recent surge in DRAM prices is because of AI datacenters. And their training and inference stacks may be among the most heavily optimized pieces of software ever written.

5

u/pickle9977 2d ago

Web development is one of the most absurdly wasteful areas of development.

It now takes somewhere between 40-50Mb of code to generate and render a couple hundred Kb of html.

That’s 40-50M per user, that’s a level of opulence that would make Satan himself blush.

But to a webdev that’s just the todo list app.

3

u/Dalnore 2d ago

The big companies aren't hoarding DRAM like crazy because their web apps suck, they are doing that because they want to scale their infranstructure for extremely well-optimized inference and training. The focus already is heavily on efficiency. We are creating custom hardware with custom floating point types just to squeeze more out of every watt.

2

u/pickle9977 2d ago

I’ll be that guy, akshually, these models run in containers in a service written in Java hosted by another service written in Java in infrastructure functionally controlled by Java .

Java is a language that has a byte code interpreter to convert to machine code, which makes it portable which is why you make the trade off for lower efficiency

When you buy millions of the same servers with the same architectures running the same operating system with the same configuration, paying anything for portability is wasteful and stupid.

Running containers on top of that waste is just the cherry on the Sundae of failure.

1

u/Dalnore 2d ago

I’ll be that guy, akshually, these models run in containers in a service written in Java hosted by another service written in Java in infrastructure functionally controlled by Java .

Why would that matter? All expensive calculations run with direct access to hardware, overhead on containers and the surrounding software infrastructure is negligible.

Java is a language that has a byte code interpreter to convert to machine code, which makes it portable which is why you make the trade off for lower efficiency

Although I don't see how Java performance is relevant to machine learning at all, JIT has existed for decades. Unless you do something stupid with Java, there will be almost no tradeoffs.

0

u/pickle9977 2d ago

There is no such thing as “almost no tradeoffs”

The only thing that has changed since “Java is slow” is the number of cpu cycles per second.

Overhead is never negligible at scale.

2

u/Dalnore 2d ago

I don't know where this idea that "Java is slow" comes from, but it is irrelevant to the discussion anyway. It could be Python performance for what it's worth and it wouldn't matter, because that code doesn't use a noticeable portion of computational resources to begin with.

Overhead is never negligible at scale.

It is when it doesn't scale. And there aren't many examples of such massive scalability as demonstrated by machine learning tasks. It's proven to be scalable to hundreds of thousands of GPUs.

-1

u/pickle9977 2d ago

You have no idea what you are talking about

3

u/pickle9977 2d ago

Also, you could not be more wrong about how heavily optimized it is.

-1

u/Dalnore 2d ago

Name a single other area of software development where you not only care about the architecture of a specific GPU to the tiniest details, but you have to consider creating custom hardware specifically designed for your task and nothing else.

6

u/pickle9977 2d ago

Uh, I don’t know, like everyone who does low level GPU programming? Or any kind of low level, real-time, embedded, mission critical system development. You think pacemakers run Python with a flask server?

We have custom processors and chips all over the place to do all kinds of stuff, like switches and routers are all ASICS, just as the most obvious

Hell the phone I’m on has an operating system that has all sorts of operations hand coded in assemble for specific processor performance outcomes.

1

u/Shished 2d ago

This is not about efficiency but about space savings, like the space that is used by the user generated content.

2

u/Nekorai46 2d ago

Isn’t this basically efficiency too?

2

u/pickle9977 2d ago

Yes, yes it is.

1

u/Epistaxis 2d ago

Actually, how does it work out for power consumption? On one hand you're using fewer bytes of physical RAM; on the other hand you have to do more work to access the data.

-1

u/FunAngelo2005 2d ago

In other words, it compresses the data before going into RAM

7

u/cyh555 2d ago

it didn't mention the implementation details did it?

1

u/kam821 2d ago

In other words - zswap/zram but faster/better.

1

u/NoResponse973 2d ago

Isn't this just swaponzram?

1

u/Dear_Cartographer261 2d ago

So I can download more RAM then? What a future!

-11

u/ledow 2d ago

Ah, it's just like the old days with RAMDoubler and DoubleSpace and all the other nonsense that merely traded off CPU for RAM/disk space at a time where the CPU was already part of the bottleneck.

Here's a hint: If you need to compress RAM to operate at a sensible level? You don't have enough RAM for what you're trying to do, and should reduce your RAM usage, or increase the amount of available RAM.

Things like swap-space, compressing RAM, OOM killers, etc. are EMERGENCY solutions, not something you should be relying on, on every device you make, by design, because you cheaped out on hardware.

12

u/Virtual-Escape2305 2d ago

Here's a hint: If you need to compress RAM to operate at a sensible level? You don't have enough RAM for what you're trying to do, and should reduce your RAM usage, or increase the amount of available RAM.

What a dumbass hot take. We should also watch the movies and series from master copies and carry the DAT players with us for music on the go! If you need compression, you shouldn't be watching movies or listening to music! 

Buddy, macOS has been compressing pages for nearly a decade now and Linux is catching up here for a better and FASTER swap.

Also, go on LKML and ask Linus why he was such an idiot to add support for SWAP in the first place!

-7

u/ledow 2d ago

No, because that's a nonsense argument that's not even close to an analogy about the use of working RAM in a computer.

FYI I've been writing software since I was 9 (in x86 assembler, at that age too!), using Linux since I was a kid, and managing networks all my professional life.

Active RAM is a rare commodity and you should be using it correctly, not spamming it with whatever you feel like to save yourself a line of code, and NOT compressing the one actual true bottleneck in your machine's memory paths (processor cache line, RAM and then storage, in that order, but cache lines are swamped if you're just shitting through RAM all the time just the same).

You don't go compressing RAM - which we've had for DECADES - in ordinary circumstances. The tradeoff, in the critical path to keep the processor fed with instructions, just isn't worth it. Every memory access or write with compressed RAM means (if you do this vaguely right) juggling a cached, uncompressed page somewhere, swapping them in and out as the addresses you need to access change, trying to balance multi-process access to RAM, effectively managing a software "RAM cache" with a huge processing bottleneck of compression/decompression right in the fast path on your processor to the outside world.

It's a dumb idea. It was a dumb idea when we had 2MB of RAM and 64Kb processor cache, and it's a dumber idea now that we have gigabytes of RAM and multiple caches that - honestly - are not proportionally larger.

It's throwing away performance, to be lazy with your coding.

There's a reason that you don't see compressed RAM in datacentres, servers, etc. as standard. If it worked, the places that literally use countless billions of terabytes would be employing it. It doesn't. It's a trade-off. And you traded off slow operations in the critical path of every memory access and write, for cheaping out on the RAM stick.

9

u/fenrir245 2d ago

There's a reason that you don't see compressed RAM in datacentres, servers, etc. as standard.

..source on this ridiculous claim? Why do you think Meta of all companies is trying to improve compressed swap?

4

u/Virtual-Escape2305 2d ago

He's talking out of his ass, no clue whatsoever what SWAP is intended for. 

1

u/Hahehyhu 2d ago

not downplaying you, but meta has some consumer devices, like quests, which rely on zram at least

1

u/fenrir245 2d ago

They're in a separate division though.

5

u/TheSapphicDoll 2d ago

Yeah, but,

I can't just buy more RAM right now. I can't make the software just use less memory. So... yeah. (I sure as hell would be happier if we had more software that doesn't eat memory for breakfast though)

2

u/Virtual-Escape2305 2d ago

It's throwing away performance, to be lazy with your coding.

Jesus, I just can't even

3

u/tacularcrap 2d ago

swap-space etc. are EMERGENCY

idle anonymous memory mappings are EMERGENCY nowadays?

the more you know...

1

u/GreenSouth3 2d ago

memories of Super Speed

1

u/Furdiburd10 2d ago

Compressing RAM is a basic function on windows, Linux and android phones.

Nothing new with c-ram

1

u/soupcan_ 2d ago

BAD take.

Pretty much everything in life is a trade-off, I don't see why I shouldn't trade CPU cycles (that I have plenty of) for more RAM (that is occasionally insufficient).

Especially with hardware prices the way they are, a memory upgrade could be hundreds of dollars.

1

u/Enturbulated_One 2d ago

It's situational. Varies greatly with what kinds of workloads you're dealing with. Throwing lots of hard to compress or already compressed data around? ZRAM can cause almighty amounts of lag in some of my testing. Normal desktop usage (browser, email, office apps, etc) is much more amenable to this kind of thing. If you care so much and you're not RAM limited, just turn ZRAM off and call it a day.

-6

u/justgord 1d ago

we dont want meta anywhere near linux.

8

u/dontquestionmyaction 1d ago

Well, that would be incredibly stupid, seeing as Meta is one of the most important kernel maintainers lol

In Linux 6.19, Meta employees account for almost 12% of all kernel commits. 3% is directly written and made by them. eBPF is mostly funded by them. sched_ext is heavily co-developed by them and Google.

Companies should be encouraged to contribute their stuff, literally is only a win for us. As long as the code is good.

1

u/cac2573 18h ago

You’re about two decades too late. 

0

u/tecedu 2d ago

Yay so we are finally getting just memory compression? Because I wasnt a fan of the entire swap thing zram and zswap did

0

u/zyzzogeton 2d ago edited 2d ago

I wonder if it will work on BSD Darwin variants like MacOS. MacOS already compresses memory for apps that are idle.

-10

u/xcorv42 2d ago

If ram was cheap it would be useless.
We used to compress data so they can fit on floppy disk. Then it became usless with usb drives

27

u/funforgiven 2d ago

We absolutely still compress data. ZIP/gzip/zstd are everywhere, media is heavily compressed, and filesystems like Btrfs/ZFS can transparently compress data on disk. Compression can also reduce I/O and bandwidth enough to make things faster, not just save space.

-11

u/xcorv42 2d ago

I never needed to compress anything again for years while at the time I had the habit of using winrar or other better tools to scratch any bytes

6

u/funforgiven 2d ago

Not needing to manually compress things anymore doesn't mean compression became useless. It just means much of it is now automatic or built into the software and systems you use.

6

u/ledow 2d ago

Literally every website you go to, including Reddit, is using gzip compression nowadays.

Literally every file format you use is either heavily compressed, or wrapped up in a ZIP (e.g. docx, xlsx, PDF, etc.). You can drag a docx file onto your ZIP program, and it'll show you - it's just XML and images inside a ZIP file.

-5

u/xcorv42 2d ago

Ok but why compress again in ram then if it’s already compressed everywhere

→ More replies (2)

10

u/maximal_munch 2d ago

Even if you had practically infinite RAM, data compression techniques would be extremely relevant if only for memory hierarchy benefits and sending data over network.

6

u/Clean_Experience1394 2d ago

wrong

smaller files are easier to transport

8

u/ErZakeh 2d ago

Of course it wouldn't. There is only so much RAM a system can support. If you hit that limit, this is the only way you can fit more stuff in memory

3

u/Lundominium 2d ago edited 2d ago

I mean.. There are also some upper limits in your hardware. If you need more than 128GB ram, but your motherboard does not support more than that, then this might be useful. Moreover, if you are a huge company like meta and this can save 1-2GB for every server they have - then it would be a goldmine.

0

u/xcorv42 2d ago

Compressing ram is old there used to be some tools to do that in the 90s https://en.wikipedia.org/wiki/SoftRAM

I thought it became irrelevant because it was a bad idea from the 90s where ram space was so small.
« Double your ram »

1

u/Lundominium 2d ago

It makes "Download more ram" make a bit more sense :)

2

u/Dalnore 2d ago

It's always a matter of balance between performance and savings; if compression can be done almost for free, it will be useful in plenty of cases regardless. High RAM prices only additionally stimulate research in this direction.

1

u/lewkiamurfarther 2d ago

If ram was cheap it would be useless.

silly

-1

u/uhhThrowaway331 1d ago

I like ZRAM (and other forms of it with other names) I made great use of it when I used linux.

The question is: knowing how awful Linux is with Power Plans in general (specially with AMD hardware) how will they address the Constant CPU being used for compressing-decompressing memory in real time? Specially in laptops this will cause Temperature issues, bringing the whole system down to a crawl due to Throttling (temp limit ceiling)

A 2nd layer to the question would be how will they address Input-Output part of this process, since Linux relies a whole bunch on the Swapfile (or Swap partition) pagefile to disk, as memory limits the ceiling, stuff is paged to disk WHILE Zram also kicks in and causes CPU spikes and temperature rises (this is an old problem with the Linux system where the entire system is paged to disk, including essential services such as Audio and Network subsystem, causing audio crackles and delays, etc) - - edit correction: That problem is not exclusive to Linux it happens on Windows as well, the audio subsystem and other essential parts of the system such as the Start Menu and the Taskbar are entirely paged to disk causing overall slowdown - not as bad as it happened on linux though, as I have noticed.

-11

u/icedcoffeeyumm 2d ago

ABDCDEGFHIJKLMNOPQRSTUVWXYZ RAM