Re:Do not buy RAM, compress
by Ecno92 on Thursday November 19, 2026 @03:56AM
(#50557662)
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.
Re:Do not buy RAM, compress
by aa-jv on Thursday November 19, 2026 @07:15AM
(#50559122)
Great article, thanks for sharing the details .. only thing I'd add is that you should put a bit of emphasis on the fact that this is not a one-size fits-all setting - users should very much apply it when appropriate to their latency budgets...
Re:Do not buy RAM, compress
by roosgit on Thursday November 19, 2026 @04:23AM
(#50557847)
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.
Re:Do not buy RAM, compress
by speed_spread on Thursday November 19, 2026 @06:34AM
(#50558821)
What if I loathe swap? The I/O hit of hitting swap, even with SSD, always mean a severely degraded desktop experience. I often end up closing applications to free up RAM or would just order more RAM back when it didn't involve taking a third mortgage.
I would rather have the system tell me there's not enough memory than try to pretend there's an infinite amount of it and then slow to a crawl without apparent reason. Unix memory allocation is daft. Desktop swap to block never worked, never will.
Re:Do not buy RAM, compress
by adgjlsfhk1 on Thursday November 19, 2026 @01:34PM
(#50564143)
You still want swap, The part you're missing is a good oom strategy. Your system slowing a ton has to do with needing to access swapped memory. Swap is still very useful when you have background tasks that aren't running, but are still using a bunch of RAM. The trick is that if you suddenly start reading a lot of that data repeatedly while being in that sate, you need to oom something quickly.
Re:Do not buy RAM, compress
by sammatilda on Thursday November 19, 2026 @05:39AM
(#50558400)
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.
Re:Do not buy RAM, compress
by Lio on Thursday November 19, 2026 @05:51AM
(#50558481)
It's funny, I switch from Fedora back to Ubuntu last year.
I really like Fedora in that it seems very up to date package wise but I found it requires a reboot every time did a package update using the UI updater.
It's better using the dnf command but it still felt a bit lumpy compared to apt.
Re:Do not buy RAM, compress
by mritzmann on Thursday November 19, 2026 @06:25AM
(#50558742)
Install "needrestart", and you'll see that a reboot would be useful in Ubuntu, too. Many running programs still use the old version of a shared library even after it has been updated. With so many security updates these days, it almost always makes sense to reboot.
Re:Do not buy RAM, compress
by ErroneousBosh on Thursday November 19, 2026 @07:08PM
(#50568413)
For me Ubuntu these days seems to give a list of what things might benefit from a restart, often things running in docker containers that themselves might do with a bit of an update.
Re:Do not buy RAM, compress
by aldonius on Thursday November 19, 2026 @07:53PM
(#50568777)
Also useful on mobile. Apple's always been precious about RAM usage on iOS and it's helped them keep device RAM sizes a bit lower (compared to Android flagships). They've even got that offloading mechanism so they can keep on-device models relatively small too.
Re:Do not buy RAM, compress
by hofiflo on Thursday November 19, 2026 @12:29PM
(#50563130)
I have a laptop with soldered RAM, a whole whopping 16GB of it. Without zswap or zram, it’s borderline unusable with web browsing, a bunch of terminals, mail client, etc. open. Maybe it’s a skill issue on my side, but only zram makes it work properly without hickups due to the OOM killer taking too long to kick in. Since switching from zswap to zram, I basically don’t encounter OOM situations and corresponding lockups anymore at all. Just my personal anecdote :)
Re:Do not buy RAM, compress
by hofiflo on Thursday November 19, 2026 @03:12PM
(#50565655)
I guess that’s where the skill issue is coming in! That’s what I tried but probably my configuration wasn’t ideal. Maybe I should give it another shot!
Re:Do not buy RAM, compress
by anthk on Thursday November 19, 2026 @05:34PM
(#50567462)
Man my notebook has 2GB of RAM and I used either UBo + ZRAM or bundled adblocking from Waterfox just fine. The NUC with 8GB and ZRAM flies. WIth 16GB you shouldn't need ZRAM at all...
Re:Do not buy RAM, compress
by shakow on Thursday November 19, 2026 @04:38PM
(#50566802)
I would argue this article has its conclusion in reverse: for 99.9% of end users, zram is better, as hitting a disk swap means that something went very wrong anyway, and it's better to let the OOM killer do its job (a shame that the default one sucks hard).
Using zswap only makes sense in a server context, where very long-running processes, relative expendability of SSDs and very high concurrency completely change the optimal.
But now, people just parrot this article and paste it everywhere without taking time to stop and think about how it applies to different use cases.
Re:Do not buy RAM, compress
by Izkata on Friday November 20, 2026 @01:23PM
(#50579426)
From what I'm reading, zswap does the same thing as zram, except when it hits its limits and actually needs to swap to disk it has extra information about what's actually being accessed so it can push the least-recently-used memory to disk. Where when zram hits that point the kernel doesn't distinguish it from disk swap so your recent stuff gets pushed to disk and things you want fast end up slow.
Re:Do not buy RAM, compress
by 2001zhaozhao on Friday November 20, 2026 @10:44PM
(#50585696)
I had Claude test zram vs zswap on a machine with 32gb RAM and 4 sticks of Intel 16gb Optane as swap, and zram was substantially faster. Just one data point though. zswap is generally the superior option.
Re:Do not buy RAM, compress
by hobo123 on Thursday November 19, 2026 @03:16PM
(#50565718)
Not hating on Fedora, but do you really want your dad on a distro that switches to new packages (or tries new stuff) very eagerly, and that basically requires you to update to the new version every time? Also, 16GB on Linux go a long way, unless you do mem intensive stuff.
Re:Do not buy RAM, compress
by hobo123 on Friday November 20, 2026 @12:25AM
(#50570505)
Nothing wrong, it's why I tried Fedora a long time ago. What turned me off was constant half done replacements (I think once the login screen didn't work well, and stuff like that).
I think by now Gnome is super stable (feature wise) and most systems around it, so if you want the latest, it's probably great.
Re:Do not buy RAM, compress
by martinald on Thursday November 19, 2026 @08:44PM
(#50569120)
I thought this before using Fedora, but actually it's great. It turns out that so many issues I had with desktop Linux were caused by a multitude of outdated packages.
For example, Ubuntu 24.04's GNOME doesn't support fractional scaling, which is a complete dealbreaker for me.
Re:Do not buy RAM, compress
by xxs on Thursday November 19, 2026 @06:19AM
(#50558683)
That's a terrible statement. Perhaps it can apply to certain setups where compression (and decompression) shows decent results, in lots of applications it'd be a massive downgrade.
Re:Do not buy RAM, compress
by aa-jv on Thursday November 19, 2026 @07:12AM
(#50559100)
The distinction is in the distribution - is the Linux bootable for an end user or is it for a rack-mount industrial application - since anyway the kernel configuration has to be involved to have zswap effectively applied at kernel runtime.
Re:Do not buy RAM, compress
by Rohansi on Thursday November 19, 2026 @06:20AM
(#50558693)
It's basically in-memory swap. If you have swap then you already have the added latency (but worse) and I/O usage instead of CPU. Like swap, the downsides only come into play under high memory pressure.
Re:Do not buy RAM, compress
by aa-jv on Thursday November 19, 2026 @07:11AM
(#50559091)
They are downsides in cases where an application has to escalate a critical fault as quickly as possible - indeed where every nanosecond counts - and a process waiting for page restoration is going to be delayed even an intolerable amount.
It should be a user switch and probably will become one in most Linux desktop distributations, I would wager. However, I would not enable it - I run Ubuntu Studio for every last little bit of latency it gives me in a realtime audio-capture application, and on those systems were it to become default-on by way of distro update, I'd be kinda miffed.
Re:Do not buy RAM, compress
by Lio on Thursday November 19, 2026 @05:54AM
(#50558511)
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).
Re:Do not buy RAM, compress
by rft on Thursday November 19, 2026 @06:11AM
(#50558617)
I haven't tried it in RAM, but your reasoning matches what I saw when I looked at compressing weights for archiving them. The weights don't compress nicely with standard, especially fast, algorithms. Some more background in this repo [1] including example compression ratios. I would also worry about decompression speed, that gives you a hard bound on the throughput. If the numbers in this repo are accurate, you likely hit the throughput limit of decompression way before you hit the memory limit, even considering the space savings and thus higher effective throughput.
Re:Do not buy RAM, compress
by kalcode on Thursday November 19, 2026 @06:34AM
(#50558817)
I don't know at all. But I've been playing with oMlx and Splash. Using Pi there are compression extensions like the billion-context. I suspect your right.
But all seem to have massive issue boards. What I did see was oMlx release clustering so you can string 3 macs and have 3 times the memory or use one for prefilling accelerating.
Which I thought was neat and what I'll likely poke at instead of getting more ran.
Re:Do not buy RAM, compress
by kalcode on Thursday November 19, 2026 @10:49AM
(#50561671)
Yah I think I am conflating it. I was thinking using the ram more effectively to begin to squeeze more, one of those is context size. Less VRAM the less context you can handle, so there always a lot of tuning to find that sweet spot.
Re:Do not buy RAM, compress
by matja on Thursday November 19, 2026 @07:45AM
(#50559382)
> A bit like trying to compress a JPEG in a zip file
Interesting comparison, I wonder if there are loss-less compression schemes that are "weight-aware", about the statistical properties of model weights.
Back to that line - because (Huffman coded) JPEG images can be lossless recoded using arithmetic coding, which makes them smaller than if they were compressed with the best general-purpose compression algorithms/tools (e.g. `jpegtran -arithmetic < input.jpg > output.jpg` beats `xz -9 < input.jpg > output.jpg`). AC takes advantage of the properties of the image coding better than general-purpose compression tools on the output of the Huffman coding.
Re:Do not buy RAM, compress
by rft on Thursday November 19, 2026 @08:44AM
(#50560021)
The library I use for archiving compressed raw LLM weights ([1] , posted in my other comment) afaik at least reorders the weights to more easily compress them. They also have a paper linked, which I admittedly didn't read, that might have more background and tradeoffs. Likely they will have discussed methods to take advantage of the structure of weights.
Re:Do not buy RAM, compress
by strobe on Thursday November 19, 2026 @10:45AM
(#50561617)
it interesting because usually on workstation the browser & electron apps it's that holding much of the memory hostage (it's very common to see that browser consuming 20-30gb on 64gb system), so may be if it will be significant compression win on that side it leads to more memory for model but how much performance penalty would be for inference in that case?
Re:Do not buy RAM, compress
by throw-qqqqq on Thursday November 19, 2026 @10:55AM
(#50561750)
The max theoretical ratio of (byte-independent) compression can be approximated using the Shannon entropy.
Most quantized GGUFs have a very high Shannon entropy, so are almost perfectly compressed already. A Q4_K_M quantization is often around +7.90 bits/byte and so is virtually incompressible.
Unquantized models (F16) are often around +7bits/byte for comparison.
Re:Do not buy RAM, compress
by vlovich123 on Thursday November 19, 2026 @11:13AM
(#50561996)
You are correct, compression doesn’t help a model. That’s why quantization is inherently a lossy operation although there’s tricks to limit the perceived loss. That’s the only way to further compress the data.
One way to think about it is that if the weights were compressible, it’s a clear signal that better training could make the model smarter as there’s redundant information in the structure that could be used to store other meaning.
Re:Do not buy RAM, compress
by Powdering7082 on Thursday November 19, 2026 @12:17PM
(#50562945)
> redundant information in the structure that could be used to store other meaning.
Consider the induction heads, their W_O are generally expected to be the identity matrix and it is useful to have many of them at many layers (e.g. if you only had one induction head in the whole network you'd only be able to perform one induction circuit per token emitted)
That being said the attention heads are a small portion of the total network size
Re:Do not buy RAM, compress
by vlovich123 on Friday November 20, 2026 @01:16AM
(#50570821)
Just to nitpick, it’s W_V * W_O and the “identity” matrix is not a literal identity matrix (not square and not strictly 1s and 0s) so it’s still generally not compressible.
But yes, there’s weight pruning techniques for W_O and W_V, LoRA to reduce the size of weights through approximations, and MQA, GQA, MLA to remove redundancies in the KV projection weights (and also shrink the size of the kv cache while we’re at it).
Re:Do not buy RAM, compress
by hobo123 on Thursday November 19, 2026 @03:03PM
(#50565519)
Since you need to apply CPU time to compress memory, and also CPU before you can map pages back into process memory (by uncompressing), this is only useful for not frequently used memory, like swap only a bit faster.
I'm not too familiar with LLM memory access patterns, but since the model files are stored on disk, you wouldn't ever keep them in memory anyway (except caching) and just reread them on demand.
Re:Do not buy RAM, compress
by acchow on Thursday November 19, 2026 @06:04PM
(#50567817)
I'm learning about this now. Apparently it's not as simple as comparing decompression speeds vs memory bandwidth.
Compression happens in 16KB pages. But memory reads can be 64-byte or 128-byte lines. So from a compressed page, the CPU cannot directly read a line from memory.
So to read even a single 8-byte line, the kernel will page fault, allocate a fresh 16KB page, decompress the entire 16KB page into it, update the page tables, flush the TLB, then resume execution.
Re:Do not buy RAM, compress
by jakozaur on Thursday November 19, 2026 @06:16AM
(#50558651)
> 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.
Re:Do not buy RAM, compress
by martheen on Friday November 20, 2026 @01:42AM
(#50570976)
Tab Wrangler is more about closing the tabs entirely so they're not cluttering the UI. Apparently, Edge introduced Sleeping Tabs in early 2021, while Chrome only had it in late 2022. I suspect this kind of behavior is how Microsoft, for a while, boasted that their browser was using less battery before Chrome implemented it too.
Much earlier, before Covid, Chromium and Firefox already have automatic unloading (discarded entirely from RAM, the page will reload when you open it again) but it's only triggered on low RAM situation. I'm perfectly aware of that behavior because every time another app is hogging the RAM, I'd notice it from the constant reloading when I'm browsing.
Re:Do not buy RAM, compress
by aa-jv on Thursday November 19, 2026 @07:06AM
(#50559047)
>I’m surprised some desktop Linux distributions still require manual configuration to enable it.
Its a user choice and should be a user-facing knob because there are times it is inappropriate for use, such as in safety-critical circumstances, certain realtime realities, and so on. It should probably be on by default for desktop Linux, but off by default for every other application a distribution may be targeting ...
Re:Do not buy RAM, compress
by benjiro29 on Thursday November 19, 2026 @11:27AM
(#50562224)
"For browser tabs, though, I think a better solution is automatic tab closing" ... the better solution is to actually offload tabs. The issue with Chrome/Edge/... is not your tabs itself but the huge amount of memory loaded for GPU operations.
Do Shift+Esc and watch how large the GPU memory usage is. Often 2/3 to 50% of your actual tab usage.
Ironically, its not the closing of tabs that bothers me, but the fact that tab order changes, what slows my productivity/muscle memory down. And its the same reason for a lot of people why they keep tabs open.
I never understood why we do not have a basic snapshot / sleep that offloads a tabs memory on disk (and dumps the GPU memory), aka a ghost tab. And fast loads when you view the tab. Sure, there may be a small delay but it can save so much memory, while people can keep their tabs open/organized.
Some extensions try to mimic that but its often a crude solution because they do not have deeper access to the webview2 engine.
Re:Do not buy RAM, compress
by hobo123 on Thursday November 19, 2026 @03:08PM
(#50565608)
Brave on Mac (but not Linux IIRC) does this, you can choose how eagerly it will suspend background tabs, although this is somewhat erratic - I've seen it suspend a paused YT video that has been idle for maybe an hour (and not much memory pressure on the system), and then sometimes it takes its time.
In Firefox there's about:unloads where you can suspend tabs in I believe LRU order. I'd really like to see this as a default option (like: only keep N tabs active). Maybe there's an extension for that.
Re:Do not buy RAM, compress
by jauntywundrkind on Thursday November 19, 2026 @06:20AM
(#50558705)
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
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.
Re:Do not buy RAM, compress
by certyfreak on Thursday November 19, 2026 @06:21AM
(#50558716)
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.
Re:Do not buy RAM, compress
by close04 on Thursday November 19, 2026 @10:27AM
(#50561351)
> I've used zswap on most of my systems and generally find it beneficial
I started using zswap recently but didn't have the time yet to benchmark and measure the benefit. Does it benefit machines with low amounts of RAM like 1GB (small headless servers) or better not bother?
> If you have it on an NVMe drive it probably is as is all data!
In the consumer SSD space the last controllers I know to do on the fly compression were SandForce [1], probably 15 years ago, when minimizing writes and saving the little capacity available was imperative. I don't think any other desktop SSDs do this now. A bit more common in enterprise models like ScaleFlux CSD.
Re:Do not buy RAM, compress
by deltoidmaximus on Thursday November 19, 2026 @01:20PM
(#50563894)
I didn't think controllers generally did any compression but I remember once that on old sandforce controllers if you did something like write all zeros it wouldn't actually overwrite anything instead just mapping to another block of zeros. Which sounded more like on device dedupping than compression.
Re:Do not buy RAM, compress
by baud9600 on Thursday November 19, 2026 @06:49AM
(#50558931)
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?
Re:Do not buy RAM, compress
by LoganDark on Thursday November 19, 2026 @06:54AM
(#50558966)
Windows doesn't do memory compression if your pagefile is not enabled. I never particularly saw the point of the pagefile as it's a dated optimization for systems that don't have enough memory, 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. (Do not let it auto size or it will happily fill up your whole drive, set it to something reasonable)
Re:Do not buy RAM, compress
by LoganDark on Thursday November 19, 2026 @03:19PM
(#50565771)
I thought the point of memory compression was fitting more pages into the same memory, by compressing their contents when they're not being used. It doesn't make sense that you would still need to have memory for every page, as that prevents you from getting more out of the same memory, doesn't it?
SSDs make swapping less of an issue, but it's still something I'd rather not allow to ever happen, as it's difficult to get swapped-out pages back into memory without exercising every single application on the system.
I thought memory compression was a replacement for swapping entirely, because you don't need to evict from memory, you can just compress it.
Re:Do not buy RAM, compress
by aa-jv on Thursday November 19, 2026 @07:08AM
(#50559070)
Because it is a user choice, and there are applications where it is inappropriate. For desktop Linux it should probably be on, as long as its clear to the user - but yeah, for many other Linux use cases its inappropriate.
Re:Do not buy RAM, compress
by cestith on Thursday November 19, 2026 @10:24AM
(#50561300)
Maybe it should be generally on for desktop-focused distros and generally off for server-focused ones. The distros that focus on doing both well might want to recommend it in the installer when told it's primarily a desktop installation and explain the tradeoffs.
For a server, it really depends on what kind of service you're providing whether it would be helpful. We might want to let server admins, SREs, production engineers, or platform engineers to make an active decision about it.
Re:Do not buy RAM, compress
by cestith on Thursday November 19, 2026 @12:12PM
(#50562867)
In most cases you'll really want zswap rather than zram anyway.
There are plenty of scenarios in which servers are run with only nominal swap sizes or none at all and systems don't run out of RAM.
Let me size my hypervisor cluster to demand and let the system decide where to place the guests. If the hypervisors are crashing due to full RAM, that's down to planning or budget issues and not a reason to put additional unpredictable latency underneath the guests.
Let me size my SDI to UDP TS video streaming servers to the number and size of streams they'll service. There's not much in their memory pages that's going to ever be idle enough to compress, so why boot the kernel configured to do that? It's just risking extra packet IAT for buying not much benefit.
But in general, yes, zswap would be a good thing compared to swapping to a drive, unless you are mostly swapping things that are really truly idle a long time. Default swappiness on a lot of distros is around 60 by the way, and on servers it's often set closer to 10 or 15.
Re:Do not buy RAM, compress
by nukanse on Thursday November 19, 2026 @07:06AM
(#50559048)
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
Re:Do not buy RAM, compress
by aktenlage on Thursday November 19, 2026 @07:34AM
(#50559287)
So, if it is used as swap, that means to use the data, it first needs to go to the CPU, then back to regular RAM, then back to the CPU.
Isn't that wasteful? The CPU's caches may help a bit, but I would guess first a huge block is going through the decompression, so only the last bits are still in the cache, when the actual usage starts.
Re:Do not buy RAM, compress
by alpaca128 on Thursday November 19, 2026 @10:54AM
(#50561731)
I've seen a single YouTube browser process use 8GB on my desktop, so I'm not that surprised. YT eats up whatever is available if you leave some tabs open for long enough, fortunately about:processes exists.
Re:Do not buy RAM, compress
by mrob on Thursday November 19, 2026 @11:43AM
(#50562465)
I never want to swap to disk. If I'm ever in that situation, it means I did something wrong, so I want my userspace OOM killer to trigger and inform me of my mistake immediately instead of wasting time and SSD endurance delaying the inevitable. But zram with lz4 compression is effectively free RAM in most circumstances, so there's little reason not to enable it.
Re:Do not buy RAM, compress
by dsp_person on Thursday November 19, 2026 @12:33PM
(#50563190)
Good point, dumping to SSD isn't ideal. I think I'm gonna start trying to set memory limits on programs with systemd-run so they can self-limit themselves.
Re:Do not buy RAM, compress
by quotemstr on Thursday November 19, 2026 @02:51PM
(#50565331)
You absolutely do want to swap to disk. There are lots of non-file-backed cold pages that are pointless to keep in RAM forever. You could argue that these pages shouldn't exist, but they do, so why not shove them to a disk?
Re:Do not buy RAM, compress
by mrob on Thursday November 19, 2026 @03:15PM
(#50565705)
I want instant access to my rarely used pages just as much as my frequently used pages. It's only pointless to keep in RAM if it's literally never used. If we knew how to identify those pages we could just avoid allocating them in the first place.
Re:Do not buy RAM, compress
by quotemstr on Thursday November 19, 2026 @03:37PM
(#50566007)
Your system is still swapping all your file-backed pages (e.g. .so files) unless you're mlockall()-ing everything. If you pin non-file-backed pages in RAM by running without a swap file, the system has a harder time keeping your frequently-accessed file-backed pages in RAM and can't do as good a job as optimizing your usage patterns.
All you're doing by running without swap is pessimizing yourself.
Re:Do not buy RAM, compress
by mrob on Thursday November 19, 2026 @04:25PM
(#50566605)
I think this problem is avoided with swap on zram by setting swappiness high enough (>100). Theoretically, 200 would be best, although I'm reluctant to set it to an extreme value because I don't know how well tested that is. I was previously running swappiness=160. I increased it to 180 and I'll see if I notice any difference.
Re:Do not buy RAM, compress
by mrob on Saturday November 21, 2026 @08:11AM
(#50588875)
As I understand it, swappiness controls priority for evicting anonymous vs. file-backed pages. Both are equally effective at reducing memory pressure, and both are effectively "swapping". But if I'm using swap on zram then reading file-backed pages from files is slower than swapping from compressed ram.
Re:Do not buy RAM, compress
by teo_zero on Saturday November 21, 2026 @07:25PM
(#50595000)
> reading file-backed pages from files is slower than swapping from compressed ram
Which, in turn, is slower than not swapping at all. To avoid swapping unless absolutely needed, you set swappiness to 0. On the opposite side, to swap as soon as the kernel sees an opportunity, you tune swappiness to 200.
Re:Do not buy RAM, compress
by origini on Thursday November 19, 2026 @04:14PM
(#50566471)
If you configure it and don't need it, it doesn't cost you anythning.
If you need it, it allows you to choose what to kill or gives you time to save.
It also allows you to utilize your available memory better (which didn't matter for a long time, fair enough but it matters on cloud were memory was always expensive and it might matter today again).
Plenty of things are loaded into memroy and are never touched again. Plenty of daemons doing something in the background but just not eveyr second of it.
You are not running a real time system with calculated memory usage. You run a bunch of random stuff.
Re:Do not buy RAM, compress
by jmakov on Thursday November 19, 2026 @04:13PM
(#50566454)
I'm working with time series data. Compresses 5:1 with ZSTD-1. If I want to load 512GiB of the data, having 128GiB physical RAM, ZRAM handles it. My understanding is that if I'd want to use ZSWAP, I'd need min 384GB swapfile taking up my disk space even if it will not be touched at all.
Re:Do not buy RAM, compress
by cogman10 on Friday November 20, 2026 @10:23AM
(#50575993)
Zswap compresses in memory just like Zram does. You can even configure the percentage of ram you want. You need the same amount of disk space as you would with zram. The benefit of zswap is that compressed pages get written to disk if they are eventually swapped there.
Re:Do not buy RAM, compress
by yjftsjthsd-h on Thursday November 19, 2026 @06:12PM
(#50567905)
> Especially if you want to swap to disk.
Exclusively if you want to swap to disk, no? I'm using zram precisely because I don't want any swap to disk. (Or sometimes because it's not an option; if you use ZFS and don't preallocate a swap partition then there's really nowhere to swap to)
Re:Do not buy RAM, compress
by isthatafact on Thursday November 19, 2026 @04:07PM
(#50566372)
First, it seems like browsers should have some kind of setting similar to "do not try to use all of the RAM on the system because that will either crash the browser or crash or severely retard the system if it decides to start swapping" -- maybe limit usage to XGB or X% of total ram.
Re:Do not buy RAM, compress
by aldonius on Thursday November 19, 2026 @07:57PM
(#50568800)
I think of memory compression as being like swap or pre-emptive multitasking. The OS should manage it by default and then the problem is solved for almost everything on the system.
And then if you're literally Postgres or something like that you can opt out and DIY.
Re:Do not buy RAM, compress
by Juvination on Thursday November 19, 2026 @10:36AM
(#50561483)
What a fun loop through time. I remember downloading programs to free up ram in the early 2000's, then as RAM became more ubiqutous and programs were still small you could run them directly on RAMDisk. (I did this with Path of Exile about 10 years ago to avoid lag.) Now we are working back to getting the most out of our ram.
Re:Do not buy RAM, compress
by Sharlin on Thursday November 19, 2026 @12:35PM
(#50563224)
Paging to disk has also become vastly more transparent, and less of a last resort, with M.2 SSDs. No more things slowing down 10x and endless HD noise when out of RAM.
Re:Do not buy RAM, compress
by _carbyau_ on Thursday November 19, 2026 @07:42PM
(#50568673)
Is that transparency good though?
I was there man. I heard the constant HDD stuttering away.
And it was a clear signal I had to go hunting for memory hogs.
If it happens in perfect silence and also doesn't slow your computer much then.. you wonder if some essential process is talking back and forth to the internet while your SSD wears down possibly for days on end?!?
Re:Do not buy RAM, compress
by bayindirh on Thursday November 19, 2026 @01:15PM
(#50563802)
Oh we found out about it. In the old days, a machine with a load of 57380 (probably not the highest number I have seen) means the machine has run out of memory and started swapping heavily.
Fun days.
Now, we find out when the SSD wears out, in the worst case.
Re:Do not buy RAM, compress
by ksec on Thursday November 19, 2026 @05:04PM
(#50567104)
>constantly write at it's fastest possible bandwidth?
Not very long especially on modern consumer SSD. Depending on Drive size, at that speed we are talking about full drive write in ~5 to 10 min. On a 5-year warranty SSD that is about 1 - 2 weeks. We have tested Consumer SSD to last beyond their warranty. But even doubling that would only give you 2 - 4 weeks max.
Re:Do not buy RAM, compress
by Lerc on Thursday November 19, 2026 @06:10PM
(#50567871)
Ouch. Seems like there's a market for something between RAM and Flash in terms of price per bit and dynamic usage.
Volatile memory that was significantly slower than RAM but could be parallelised to wide pipes for wide bandwidth.
Maybe just more flash to allow for more redundancy. Even if flash only lasted a week it's only two or three orders of magnitude to allow for practically usable lifetimes.
A rather amusing idea would be to have a box containing 1024 MicroSDs with a 512 byte block write. Wire them in parallel and you could do a swap drive with 512k blocks with rather impressive bandwidth. Setting them to actively use 0.1% of their data space and wear level across the whole thing they should last a fair few years at full usage. If you were treating them purely as swap you could tune your data size and consider the flash as a consumable. A quick google suggests that RAM is 100x flash, and that micro-SD and SSDs are roughly comparable now at price per bit. Maybe the sweet spot is around 10x redundancy in storage capacity. Then for the price of RAM you could get 10x that in swap with a really big pipe. 10x and cleverness might be ok (reads dominating in real world usage, even for swap, error correction might be able to squeeze quite a lot out with redundancy space.
Re:Do not buy RAM, compress
by xarope on Thursday November 19, 2026 @06:55PM
(#50568322)
an intel optane card will solve this for you, I'm still waiting to see if I should get one for an slog, but my home lab isn't write heavy enough for this
Re:Do not buy RAM, compress
by ssl-3 on Friday November 20, 2026 @12:45AM
(#50570622)
Optane is a fine choice for SLOG, but SLOG only helps with performance for synchronous writes.
And even then: It doesn't reduce RAM use. Sync writes that are ultimately bound for spiny-rust-disk still reside in RAM (in TXG) until they lands on rust.
SLOG is thus mostly write-only in practice.
The performance boost is that it returns as soon a sync write successfully is recorded on the SLOG device (but before it lands on rust), which can improve performance for things that are limited by sync write speed.
On reboot or remount or whatever, SLOG gets reviewed and outstanding sync writes (if any) are permanently committed to the pool. That's really the only time it gets read.
---
Should a person play around with SLOG for performance? Yeah, sure, especially if they've got processes that are being held back by bursty sync writes.
Small-ish Optane devices are still available inexpensively, so as far as tweaky homelab computer tricks go in 2026: It's a cheap way to play with something new.
And small can be fine. It depends on the workload.
(Double-extra bonus point for using a redundant pair of them, though.)
Re:Do not buy RAM, compress
by ksec on Saturday November 21, 2026 @05:12AM
(#50587746)
I mean unless there are some specific needs or bugs, most consumer usage simply dont blown out SSD in their life time. Even in cases with 8GB memory and Safari being still appalling with memory management on many tabs, you are at worst doing 100 - 200GB write per day. On a modern Mac with 16GB base memory, you could be doing 20 - 50GB write per day. Your SSD would easily last 10+ years.
Re:Do not buy RAM, compress
by NekkoDroid on Thursday November 19, 2026 @07:38PM
(#50568649)
I recently looked at my SSD health with crystal disk info and one of my SATA SSDs is rated for 150TBW and is currently at ~350TBW. It is currentlly at 56k hours power on.
One of my less proud moments was blowing half the life of a new datacenter ssd by forgetting to set limits on the burn in test and assuming it'd be fine like any other drive I ever tested.
Came back the next morning and was happy to find that the tests hadn't failed, unfortunately they had also gone far quicker than I had anticipated and had something silly like 2PB written.
Re:Do not buy RAM, compress
by AnthonBerg on Friday November 20, 2026 @02:14AM
(#50571196)
SSD has been retconned to stand for "Storage. Speedy. and… Disposable".
Kidding/not kidding.
I've come to regard SSDs as ephemeral. I stripe-RAID them in my workstation to sum their speed as well as their failure rate. (Which actually also distributes the wear, so…)
And then I use the combined speed and terror to kindle the motivational fire of getting a proper backup solution underneath it.
Re:Do not buy RAM, compress
by bayindirh on Friday November 20, 2026 @03:00AM
(#50571534)
It depends. I have seen consumer SSDs die in weeks, write oriented SSDs (Specifically designed to be LOG disks of Sun ZFS storage units) run for years under heavy load.
Currently we run some datacenter SSDs which handle constant load just fine, despite being TLCs.
I believe they really put some magic smoke in these chips, because the endurance numbers are just black art at this point. Even my system SSD, which is an EVO860 256GB shows its wear level at 33% after 44K hours.
My /home disk, a 980 Pro 2TB, shows 1% wear after 835 hours. That machine is on 24/7.
Re:Do not buy RAM, compress
by bayindirh on Friday November 20, 2026 @07:38AM
(#50573853)
Try swapping a couple of high performance and multi-core jobs which makes tons of random read & write from RAM to a couple of SATA drives (you can use a good RAID adapter as well), and you'll have nice IOWAIT values pinned to 99%.
Give it some time and you'll see numbers you believe was impossible to display on the output of uptime command. (:
If you want to check out whether your system has zswap enabled, you can look at /sys/module/zswap/parameters/enabled, which will be 0 if zswap isn't enabled and 1 or Y if it is. You can look at the kernel docs (<https://docs.kernel.org/admin-guide/mm/zswap.html>) for more.
Re:Do not buy RAM, compress
by 01HNNWZ0MV43FF on Thursday November 19, 2026 @12:56PM
(#50563504)
If the user was feeling stochastic, the OS could theoretically just drop pages that haven't been accessed in, say, 2 days, and send the process a segfault if it tries to access them.
Re:Do not buy RAM, compress
by kccqzy on Thursday November 19, 2026 @03:52PM
(#50566193)
No need for a kernel module. Create a FUSE filesystem in user space on which to create a swap file. Once any written block is more than 2 days old just discard it. When they are accessed give EIO. This IIRC translates to a SIGBUS signal in the process.
Re:Do not buy RAM, compress
by kevincox on Thursday November 19, 2026 @01:41PM
(#50564264)
This sounds like a bad idea. No one has logged in via SSH for a while so the daemon hasn't touched any pages (or only pre-auth relevant pages) then when you log in it gets killed. Or if someone sends a rarely used request to an HTTP server then it crashes accessing some data unique to that request.
Re:Do not buy RAM, compress
by tadfisher on Thursday November 19, 2026 @04:27PM
(#50566630)
You have described the current state of Android development if you want your app to stay alive and be useful without its GUI in the foreground. It is an insidious process that has essentially broken the OS more with each release, and broken apps that were mindful of battery usage but didn't pull the correct magical levers.
Re:Do not buy RAM, compress
by onjectic on Thursday November 19, 2026 @05:58PM
(#50567756)
I think what they are saying is if OOM was going to kill the process anyways, it can defer this a bit and only fault on read or write on the rarely used memory.
So don’t change the OOM descision making, just the action taken.
I think the person below makes a good point though, that this encourages or permits buggy code.
Re:Do not buy RAM, compress
by origini on Thursday November 19, 2026 @04:06PM
(#50566364)
I thought about something similiar but more in context of applications like JVM based or go based tools which are loaded in memory and then do not touch certain memroy pages for ages anymore.
Apparently though, tracking pages and access and stuff would be very slow.
I continued thinking about it on how to structure go or jvm apps that you split it in processes so they are more bound to when they are needed and you unload parts of your tool/programm by just handing over the results from one process to the other and kill it.
Re:Do not buy RAM, compress
by chmod775 on Thursday November 19, 2026 @11:33PM
(#50570211)
That would break about a billion kinds of daemons. For example it might take down dbus and various system daemons when you open your settings, because some stuff is only accessed then. It would likely also trivially crash cron, various audio daemons when rare functionality is accessed by a program or you switch the output, etc.
I have trouble thinking of a daemon this wouldn't break. It might break even a simple clipboard manager when you go back through the history.
Re:Do not buy RAM, compress
by throw0101d on Friday November 20, 2026 @07:59AM
(#50574091)
> If the daemon tries to access that memory, let it crash.
Why not just change Linux's vm.overcommit_memory to not allow overcommitting, so that when a daemon/process does a malloc() an error is returned and it can be handled right away?
Re:Do not buy RAM, compress
by jedbrooke on Thursday November 19, 2026 @04:52PM
(#50566967)
I discovered something similar when I tried to recreate a rudimentary version of the Billion Laughs Attack[0] on my macbook. It just compressed all the “ha”s so the 10 GB string only ever took a few MB
Re:Do not buy RAM, compress
by jedbrooke on Friday November 20, 2026 @12:25AM
(#50570502)
oh hah, I’m not a security researcher or anything. I was just a high schooler messing around with computers. The rudimentary version I tried was just doing something like this in the python repl
a = “ha”
b = 10 * a
c = 10 * b
and so on and watching the memory climb in the activity viewer. I was surprised when the 10GB or even 100GB one (confirmed with len() ) didnt crash my 8GB laptop or even cause it to swap.
Interestingly I tried the python version just now on modern macos, currently activity monitor shows 192GB ram used, 184GB compressed, on a machine with 36GB physical.
Actually something really weird happened, zsh killed the python proc, activity monitor shows it still alive, but the physical ram value is bugged and showing 0 bytes physical and 1.7 GB swap. So compressing RAM does have some limitations.
Re:Do not buy RAM, compress
by varenc on Friday November 20, 2026 @02:30PM
(#50580541)
I had a similar experience, but with Apple's APFS on-disk file compression! I accidentally generated a log file that just contains 300+ million lines of the same message repeated constantly. The log file was supposedly over 100GB in size, but I hadn't noticed my disk filling up. I investigate more, and discovered that APFS had compressed the file on my disk!
Apple's on-disk file compression is very mysterious, hard look up, and harder to intentionally trigger. The only clue in the Finder GUI is comparing the file size vs size on disk. Using the 3rd party `afsctool` you can tell APFS to compress a file on disk manually, but I believe there's no native macOS way to do this. The official way is that macOS decides for mysterious reasons when to compress a file on disk and it rarely does. But apparently generating a 100GB log file with million of repeated lines is enough to convince macOS to use APFS compression. (and having a disk that's nearly full probably)
Re:Do not buy RAM, compress
by surajrmal on Friday November 20, 2026 @10:22AM
(#50575963)
Apple chips have hardware offload for compression that allows for higher compression ratios without paying a substantial latency or power penalty. Android also does this, but with a less optimal compression ratio due to having to do it via CPU instructions.
Re:Do not buy RAM, compress
by pyaamb on Thursday November 19, 2026 @11:19AM
(#50562081)
I wonder what the theoretical limits are of semantic compression for LLM input/output (eg. "Can you please send me the final report by Friday?" -> "Send final report by Friday." -> sr(FINAL, DEADLINE=FRIDAY)) that can still be recovered back to English
Tried porting it to swift, was hoping it would make mobile local models more useful for a project I was working on but it was hurting the accuracy too much. Can be very task dependent on how much you can compress. https://github.com/nburns/llmlingua-swift
Re:Do not buy RAM, compress
by altcognito on Thursday November 19, 2026 @11:25AM
(#50562174)
It's funny that MS didn't integrate memory compression until 2015. From ye olden days, we used "RAM doublers" in MSDOS, which were a bit of a different beast and took a performance hit due to simpler implementation, so some of us aren't "excited" by the cost of packing things in with compression. It is a bandaid for processes that lie somewhere between being needed and not (otherwise it would goto swap right?)
If it avoids hitting the disk I get it, but to some of us, that just means it's time to buy more RAM
Re:Do not buy RAM, compress
by martheen on Friday November 20, 2026 @01:58AM
(#50571077)
Microsoft, Linux and Apple do it in subsequent years. Probably just the sweet spot of multiple cores sitting around while app devs dump everything into Electron.
Re:Do not buy RAM, compress
by IronWolve on Thursday November 19, 2026 @11:40AM
(#50562410)
I remember the compression rage back on my amiga, had both ram and file compression, since you had to get as much room as you could with limited ram and a floppy.
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 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.
Re:Do not buy RAM, compress
by flowerlad on Thursday November 19, 2026 @12:48PM
(#50563398)
In the 1990s there was a third-party add-on for Windows called SoftRAM95 that doubled your RAM using compression. That one turned out to be a scam though [1].
Re:Do not buy RAM, compress
by ssl-3 on Friday November 20, 2026 @01:06AM
(#50570765)
That's disk compression, not RAM compression. It's been variously demonized over the years but it can be pretty great to have.
I was using transparent disk compression ~35 years ago on an 8088 running MS-DOS and Stacker, to eek a bit more storage into a 20-megabyte MFM ST-225 hard drive.
It's been a built-in for many systems for decades. Windows can do it. I'm using it today with ZFS, where it's essentially free on modern-ish hardware.
Re:Do not buy RAM, compress
by lproven on Friday November 20, 2026 @05:46AM
(#50572859)
> Apparently it was called DriveSpace
This was a built in feature of DOS, not Windows.
It was introduced in MS-DOS 6.0 -- in fact it was the major feature.
It rivalled DR-DOS 6 which bundled a 3rd party disk compression program called SuperStore, which DR licensed in.
Microsoft invited other disk-compression vendors to send in their code for MS to look at and maybe license. STAC gave them the source code to the industry #1, Stacker.
(Stacker even worked on OS/2 2, a major technological feat. I ran Stacker in DOS + OS/2 dual-boot. I really recommend nobody ever tries this -- it was a nightmare.)
MS being MS it just stole the code. It took some of the core Stacker algorithm, and the driver architecture from another rival product ("DoubleDisk" from Vertisoft), and built it into MS-DOS 6 and called it DoubleSpace.
Never trust Microsoft. I don't care what your SLA says.
MS-DOS 6 was buggy AF. MS issued an update, MS-DOS 6.20.
Re:Do not buy RAM, compress
by ErroneousBosh on Thursday November 19, 2026 @07:07PM
(#50568406)
I have a vague recollection of a manager at a web dev studio I worked at in the very early 2000s insisting everyone install a bit of software called (something like) "Appcelerator Pro Turbo Gold" or something, the only bit I clearly remember is "Appcelerator".
Anyway I don't know what it did but it was supposed to make your RAM 50% more efficient. I suspect it just dicked about with Windows 95/98's cacheing or something, to make stuff load faster.
What it did do, though, and this eventually was what triggered the mutiny, was every time you started up any application it would play a really loud sample of a dragster starting up and driving off, for about 30 seconds.
With a dozen PCs in the room, you can imagine this got pretty fucking annoying.
Not as annoying as constantly getting hauled up about not using this miracle of computer science, though, because my PC was for video editing, ran Windows 2000 which this didn't work on, and had a whopping 512MB of RAM anyway!
Re:Do not buy RAM, compress
by quotemstr on Thursday November 19, 2026 @02:53PM
(#50565360)
FWIW, DAMON (https://docs.kernel.org/mm/damon/design.html#operation-actio...) has supported explicit control over Linux working sets for a while now. For whatever reason, ISTM few people know about it, but it's a nice subsystem with a lot of policy flexibility.
Re:Do not buy RAM, compress
by jmakov on Thursday November 19, 2026 @03:03PM
(#50565522)
Yes, but if a 4k page compresses to 1k, a 4k block on the disk still gets used - 1k + 3k of zero padding. Meaning if 100GB of data compresses 5:1, 100GB needs to be written to the disk instead of 20GB.
Re:Do not buy RAM, compress
by noodlesUK on Thursday November 19, 2026 @02:52PM
(#50565357)
I think it's a great shame that kubernetes really doesn't like systems with any kind of swap on (including zswap). If memory compression were more commonly used I think many workloads could survive on smaller systems.
Re:Do not buy RAM, compress
by zamalek on Thursday November 19, 2026 @02:56PM
(#50565412)
> Compressing memory does come with small, but not really noticeable, downsides. It takes a little bit more from your CPU and adds latency to some processes.
I recall reading an article around the time the Windows team added it (back when I still used the OS). Their compression algorithm was typically faster than the latency to the prevailing disk type at the time (SATA SSD, most likely) - at the time it had zero downsides. I'm not sure if that still holds true.
On Linux it generally doesn't: off-the-shelf compression is used, which do not outpace storage access latency.
Re:Do not buy RAM, compress
by tonymet on Thursday November 19, 2026 @02:57PM
(#50565422)
I was load testing micro VMs with zswap and i was blown away by how much capacity the machine could have. forking thousands of processes, using 2.5x the available ram, and the server still hums along, albeit a bit sluggish. but no timeouts or lockups. still very accessible.
It's a remarkable tech that deserves more attention. Swap is back in style!
Re:Do not buy RAM, compress
by 2001zhaozhao on Thursday November 19, 2026 @03:16PM
(#50565713)
I do this and also buy old used 16GB Optane sticks to use as swap. These are $7 a pop on ebay. They're way lower latency than normal swap and you can swap data as much as you like without worrying about wear.
Re:Do not buy RAM, compress
by bullish-bearr on Thursday November 19, 2026 @03:25PM
(#50565859)
Doesn't this only work if you have a bunch of stuff you do not need to access frequently in RAM? i wonder what kind of algorithm optimization goes behind the scenes to make sure pages that least recently used get compressed with other pages
Re:Do not buy RAM, compress
by djha-skin on Thursday November 19, 2026 @03:33PM
(#50565956)
This guy already had 32GB RAM. I know that's "standard" or whatever but it's surprisingly difficult to afford when you already have an 8GB laptop at home that still works on Linux. Would be interesting to see someone trick out a low-powered 4GB one, I would find that very interesting.
Re:Do not buy RAM, compress
by larodi on Thursday November 19, 2026 @04:45PM
(#50566893)
Whatever could've been compressed reasonably by the open models, was already done by quantization, and guys sure know how to crunch data while it still matters.
Re:Do not buy RAM, compress
by dmitrygr on Thursday November 19, 2026 @05:16PM
(#50567244)
macOS has been doing this a while and this is the root of why users report 8GB macs easily handle more applications than 8GB Windows boxen. Since quite a long time ago, apple silicon even has hardware for this. Literally cpu instructions that do ram compression: https://asahilinux.org/docs/hw/cpu/apple-instructions/
Re:Do not buy RAM, compress
by sleepytimetea on Thursday November 19, 2026 @06:38PM
(#50568160)
CRAM seems to be on its way to the mainline kernel, pending some MM major infra changes that need to merge. So, currently, it is out-of-tree experimental kernel support only.
Sounds interesting though - the 452X read speedup because of avoiding the whole page fault zswap path is really great, which degrades to about a 5X speedup if there are 20% writes mixed with the reads, still worth the move.
Assuming a long running server eventually settles into a steady state with a large amount of read-only pages that are constantly referred to, and are highly compressible, the compressed ram reads using zstd would allow a server to effectively quadruple (4:1 ratio) its RAM without the zswap performance hits.
Re:Do not buy RAM, compress
by Waterluvian on Thursday November 19, 2026 @08:46PM
(#50569139)
I have fond memories of being 8 or 9 and turning on RAM Doubler so that some of my Macintosh games would actually run. They were sluggish but they at least started.
Re:Do not buy RAM, compress
by angst on Thursday November 19, 2026 @09:16PM
(#50569349)
for Windows run (Get-MMAgent).MemoryCompression in Windows PowerShell (needs admin rights). It's usually True, but you can run Enable-MMAgent -MemoryCompression if not.
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.
I would rather have the system tell me there's not enough memory than try to pretend there's an infinite amount of it and then slow to a crawl without apparent reason. Unix memory allocation is daft. Desktop swap to block never worked, never will.
We use it heavily in our cloud env and it works great:
( https://news.ycombinator.com/item?id=47500746 )
It’s long and more satisfying than this In These AI Times wrapper.
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.
I really like Fedora in that it seems very up to date package wise but I found it requires a reboot every time did a package update using the UI updater.
It's better using the dnf command but it still felt a bit lumpy compared to apt.
Docs: https://www.kernel.org/doc/html/latest/admin-guide/mm/multig...
In practice I think you may still want a userspace OOM killer that knows a bit more about what processes are preferable to kill.
Using zswap only makes sense in a server context, where very long-running processes, relative expendability of SSDs and very high concurrency completely change the optimal.
But now, people just parrot this article and paste it everywhere without taking time to stop and think about how it applies to different use cases.
For my parents (or any other non-techie person), I'd just take Fedora Kinoite and set it to auto-update.
I think by now Gnome is super stable (feature wise) and most systems around it, so if you want the latest, it's probably great.
I hopefully never have to touch GNOME ever again in my life.
For example, Ubuntu 24.04's GNOME doesn't support fractional scaling, which is a complete dealbreaker for me.
It sounds like those are downsides
It’s like saying that in order to breathe you have to use your nose or mouth. Which is bad if you want to retain the oxygen that is inside your lungs.
There are always scenario’s where memory compression is an outright bad idea. Just like trying to breathe under water.
I did not really notice a large performance impact.
Unless you are in an environment where compute performance is critical, I think this is something interesting to try.
It should be a user switch and probably will become one in most Linux desktop distributations, I would wager. However, I would not enable it - I run Ubuntu Studio for every last little bit of latency it gives me in a realtime audio-capture application, and on those systems were it to become default-on by way of distro update, I'd be kinda miffed.
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).
Could anyone comment on that?
[1] https://github.com/zipnn/zipnn#results
But all seem to have massive issue boards. What I did see was oMlx release clustering so you can string 3 macs and have 3 times the memory or use one for prefilling accelerating.
Which I thought was neat and what I'll likely poke at instead of getting more ran.
So my mind on that.
Interesting comparison, I wonder if there are loss-less compression schemes that are "weight-aware", about the statistical properties of model weights.
Back to that line - because (Huffman coded) JPEG images can be lossless recoded using arithmetic coding, which makes them smaller than if they were compressed with the best general-purpose compression algorithms/tools (e.g. `jpegtran -arithmetic < input.jpg > output.jpg` beats `xz -9 < input.jpg > output.jpg`). AC takes advantage of the properties of the image coding better than general-purpose compression tools on the output of the Huffman coding.
[1] https://github.com/zipnn/zipnn#results
Most quantized GGUFs have a very high Shannon entropy, so are almost perfectly compressed already. A Q4_K_M quantization is often around +7.90 bits/byte and so is virtually incompressible.
Unquantized models (F16) are often around +7bits/byte for comparison.
https://en.wikipedia.org/wiki/Shannon%27s_source_coding_theo...
One way to think about it is that if the weights were compressible, it’s a clear signal that better training could make the model smarter as there’s redundant information in the structure that could be used to store other meaning.
Consider the induction heads, their W_O are generally expected to be the identity matrix and it is useful to have many of them at many layers (e.g. if you only had one induction head in the whole network you'd only be able to perform one induction circuit per token emitted)
That being said the attention heads are a small portion of the total network size
But yes, there’s weight pruning techniques for W_O and W_V, LoRA to reduce the size of weights through approximations, and MQA, GQA, MLA to remove redundancies in the KV projection weights (and also shrink the size of the kv cache while we’re at it).
I'm not too familiar with LLM memory access patterns, but since the model files are stored on disk, you wouldn't ever keep them in memory anyway (except caching) and just reread them on demand.
Compression happens in 16KB pages. But memory reads can be 64-byte or 128-byte lines. So from a compressed page, the CPU cannot directly read a line from memory.
So to read even a single 8-byte line, the kernel will page fault, allocate a fresh 16KB page, decompress the entire 16KB page into it, update the page tables, flush the TLB, then resume execution.
Which one is it?
Still perfectly usable and I won't upgrade until prices come down. Even used prices are terrible now.
Typo DDR5?
The main thing I regret is not maxing out the memory on my server. At first 32Gi seemed more than I'd ever need, but now it's feeling quite anaemic.
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.
Much earlier, before Covid, Chromium and Firefox already have automatic unloading (discarded entirely from RAM, the page will reload when you open it again) but it's only triggered on low RAM situation. I'm perfectly aware of that behavior because every time another app is hogging the RAM, I'd notice it from the constant reloading when I'm browsing.
Its a user choice and should be a user-facing knob because there are times it is inappropriate for use, such as in safety-critical circumstances, certain realtime realities, and so on. It should probably be on by default for desktop Linux, but off by default for every other application a distribution may be targeting ...
Do Shift+Esc and watch how large the GPU memory usage is. Often 2/3 to 50% of your actual tab usage.
Ironically, its not the closing of tabs that bothers me, but the fact that tab order changes, what slows my productivity/muscle memory down. And its the same reason for a lot of people why they keep tabs open.
I never understood why we do not have a basic snapshot / sleep that offloads a tabs memory on disk (and dumps the GPU memory), aka a ghost tab. And fast loads when you view the tab. Sure, there may be a small delay but it can save so much memory, while people can keep their tabs open/organized.
Some extensions try to mimic that but its often a crude solution because they do not have deeper access to the webview2 engine.
In Firefox there's about:unloads where you can suspend tabs in I believe LRU order. I'd really like to see this as a default option (like: only keep N tabs active). Maybe there's an extension for that.
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.
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.
I'm a Linux user myself, but I think it would start compressing it when there would be less than 25% free
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.
I started using zswap recently but didn't have the time yet to benchmark and measure the benefit. Does it benefit machines with low amounts of RAM like 1GB (small headless servers) or better not bother?
> If you have it on an NVMe drive it probably is as is all data!
In the consumer SSD space the last controllers I know to do on the fly compression were SandForce [1], probably 15 years ago, when minimizing writes and saving the little capacity available was imperative. I don't think any other desktop SSDs do this now. A bit more common in enterprise models like ScaleFlux CSD.
[1] https://en.wikipedia.org/wiki/SandForce#Products
There might be gains by having the GPU recompress with a higher compression level in the background though.
So shouldn’t disable pagefile, unless it’s a disk space issue. Windows probably won’t use it much anyways if you have enough RAM.
SSDs make swapping less of an issue, but it's still something I'd rather not allow to ever happen, as it's difficult to get swapped-out pages back into memory without exercising every single application on the system.
I thought memory compression was a replacement for swapping entirely, because you don't need to evict from memory, you can just compress it.
For a server, it really depends on what kind of service you're providing whether it would be helpful. We might want to let server admins, SREs, production engineers, or platform engineers to make an active decision about it.
There are plenty of scenarios in which servers are run with only nominal swap sizes or none at all and systems don't run out of RAM.
Let me size my hypervisor cluster to demand and let the system decide where to place the guests. If the hypervisors are crashing due to full RAM, that's down to planning or budget issues and not a reason to put additional unpredictable latency underneath the guests.
Let me size my SDI to UDP TS video streaming servers to the number and size of streams they'll service. There's not much in their memory pages that's going to ever be idle enough to compress, so why boot the kernel configured to do that? It's just risking extra packet IAT for buying not much benefit.
But in general, yes, zswap would be a good thing compared to swapping to a drive, unless you are mostly swapping things that are really truly idle a long time. Default swappiness on a lot of distros is around 60 by the way, and on servers it's often set closer to 10 or 15.
That’s true of everything. Default setups make those choices.
Isn't that wasteful? The CPU's caches may help a bit, but I would guess first a huge block is going through the decompression, so only the last bits are still in the cache, when the actual usage starts.
https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-...
All you're doing by running without swap is pessimizing yourself.
I can't follow your reasoning. On the one hand you want the fastest access, on the other you advocate for high swappiness.
I think you should want swappiness=0, then the swap device can be whatever: it will be hardly ever used.
Which, in turn, is slower than not swapping at all. To avoid swapping unless absolutely needed, you set swappiness to 0. On the opposite side, to swap as soon as the kernel sees an opportunity, you tune swappiness to 200.
If you need it, it allows you to choose what to kill or gives you time to save.
It also allows you to utilize your available memory better (which didn't matter for a long time, fair enough but it matters on cloud were memory was always expensive and it might matter today again).
Plenty of things are loaded into memroy and are never touched again. Plenty of daemons doing something in the background but just not eveyr second of it.
You are not running a real time system with calculated memory usage. You run a bunch of random stuff.
if you don't want to swap to disk you should NOT use zswap.
zram is ideal in that scenario, though it may complicate OOM killer considerations (you may want a userspace one).
Exclusively if you want to swap to disk, no? I'm using zram precisely because I don't want any swap to disk. (Or sometimes because it's not an option; if you use ZFS and don't preallocate a swap partition then there's really nowhere to swap to)
DiskDoubler, Stacker, SuperStor, DoubleDisk...
I find that the ratio of browserish memory use to that of other programs is enough to render the latter insignificant most of the time.
And then if you're literally Postgres or something like that you can opt out and DIY.
I was there man. I heard the constant HDD stuttering away. And it was a clear signal I had to go hunting for memory hogs.
If it happens in perfect silence and also doesn't slow your computer much then.. you wonder if some essential process is talking back and forth to the internet while your SSD wears down possibly for days on end?!?
A shame it's dead.
Fun days.
Now, we find out when the SSD wears out, in the worst case.
Not very long especially on modern consumer SSD. Depending on Drive size, at that speed we are talking about full drive write in ~5 to 10 min. On a 5-year warranty SSD that is about 1 - 2 weeks. We have tested Consumer SSD to last beyond their warranty. But even doubling that would only give you 2 - 4 weeks max.
Volatile memory that was significantly slower than RAM but could be parallelised to wide pipes for wide bandwidth.
Maybe just more flash to allow for more redundancy. Even if flash only lasted a week it's only two or three orders of magnitude to allow for practically usable lifetimes.
A rather amusing idea would be to have a box containing 1024 MicroSDs with a 512 byte block write. Wire them in parallel and you could do a swap drive with 512k blocks with rather impressive bandwidth. Setting them to actively use 0.1% of their data space and wear level across the whole thing they should last a fair few years at full usage. If you were treating them purely as swap you could tune your data size and consider the flash as a consumable. A quick google suggests that RAM is 100x flash, and that micro-SD and SSDs are roughly comparable now at price per bit. Maybe the sweet spot is around 10x redundancy in storage capacity. Then for the price of RAM you could get 10x that in swap with a really big pipe. 10x and cleverness might be ok (reads dominating in real world usage, even for swap, error correction might be able to squeeze quite a lot out with redundancy space.
I look forward to a crazy youtuber making one.
And even then: It doesn't reduce RAM use. Sync writes that are ultimately bound for spiny-rust-disk still reside in RAM (in TXG) until they lands on rust.
SLOG is thus mostly write-only in practice.
The performance boost is that it returns as soon a sync write successfully is recorded on the SLOG device (but before it lands on rust), which can improve performance for things that are limited by sync write speed.
On reboot or remount or whatever, SLOG gets reviewed and outstanding sync writes (if any) are permanently committed to the pool. That's really the only time it gets read.
---
Should a person play around with SLOG for performance? Yeah, sure, especially if they've got processes that are being held back by bursty sync writes.
Small-ish Optane devices are still available inexpensively, so as far as tweaky homelab computer tricks go in 2026: It's a cheap way to play with something new.
And small can be fine. It depends on the workload.
(Double-extra bonus point for using a redundant pair of them, though.)
Came back the next morning and was happy to find that the tests hadn't failed, unfortunately they had also gone far quicker than I had anticipated and had something silly like 2PB written.
Luckily the other half was more than plenty
Kidding/not kidding.
I've come to regard SSDs as ephemeral. I stripe-RAID them in my workstation to sum their speed as well as their failure rate. (Which actually also distributes the wear, so…)
And then I use the combined speed and terror to kindle the motivational fire of getting a proper backup solution underneath it.
Currently we run some datacenter SSDs which handle constant load just fine, despite being TLCs.
I believe they really put some magic smoke in these chips, because the endurance numbers are just black art at this point. Even my system SSD, which is an EVO860 256GB shows its wear level at 33% after 44K hours.
My /home disk, a 980 Pro 2TB, shows 1% wear after 835 hours. That machine is on 24/7.
Give it some time and you'll see numbers you believe was impossible to display on the output of uptime command. (:
If you want to check out whether your system has zswap enabled, you can look at /sys/module/zswap/parameters/enabled, which will be 0 if zswap isn't enabled and 1 or Y if it is. You can look at the kernel docs (<https://docs.kernel.org/admin-guide/mm/zswap.html>) for more.
I tried to summarise hows and whys here, in case it helps:
https://www.theregister.com/on-prem/2026/03/13/ram-is-gettin...
Apologies for the off-topicness?
—This is in earnest. The brain does operate according to information theory, certainly has memory, and does compress things.
Thus solving memory leaks forever...
Sure, they will get restarted, but not great.
So don’t change the OOM descision making, just the action taken.
I think the person below makes a good point though, that this encourages or permits buggy code.
If the oomkiller is running, it's too late to wait and see: some process or kernel thread needs memory that the kernel can't currently provide
Not how I expected the next big optimization push, but I'll take it.
... but reading say libraries directly and only putting in RAM the parts often used, now we're talking
Apparently though, tracking pages and access and stuff would be very slow.
I continued thinking about it on how to structure go or jvm apps that you split it in processes so they are more bound to when they are needed and you unload parts of your tool/programm by just handing over the results from one process to the other and kill it.
I have trouble thinking of a daemon this wouldn't break. It might break even a simple clipboard manager when you go back through the history.
Why not just change Linux's vm.overcommit_memory to not allow overcommitting, so that when a daemon/process does a malloc() an error is returned and it can be handled right away?
0: https://learn.microsoft.com/en-us/archive/msdn-magazine/2009...
Interestingly I tried the python version just now on modern macos, currently activity monitor shows 192GB ram used, 184GB compressed, on a machine with 36GB physical.
Actually something really weird happened, zsh killed the python proc, activity monitor shows it still alive, but the physical ram value is bugged and showing 0 bytes physical and 1.7 GB swap. So compressing RAM does have some limitations.
Apple's on-disk file compression is very mysterious, hard look up, and harder to intentionally trigger. The only clue in the Finder GUI is comparing the file size vs size on disk. Using the 3rd party `afsctool` you can tell APFS to compress a file on disk manually, but I believe there's no native macOS way to do this. The official way is that macOS decides for mysterious reasons when to compress a file on disk and it rarely does. But apparently generating a 100GB log file with million of repeated lines is enough to convince macOS to use APFS compression. (and having a disk that's nearly full probably)
Tried porting it to swift, was hoping it would make mobile local models more useful for a project I was working on but it was hurting the accuracy too much. Can be very task dependent on how much you can compress. https://github.com/nburns/llmlingua-swift
If it avoids hitting the disk I get it, but to some of us, that just means it's time to buy more RAM
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/pool_total_size
getconf PAGESIZE
ratio = (stored pages * PAGESIZE) / pool total size
I have 3.6 right now
Sorry for the confusion.
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.
(¹on disk. A lot of these "z[foo]" projects are compressed memory.)
As usual, working class is being told to tighten the belts whilst the rich get insanely richer.
Fuck that.
https://www.youtube.com/watch?v=4icQwducz68
https://www.youtube.com/watch?v=IXkX2ojrKZQ
[1] https://devblogs.microsoft.com/oldnewthing/20211111-00/?p=10...
Apparently it was called DriveSpace: https://de.wikipedia.org/wiki/DriveSpace
I was using transparent disk compression ~35 years ago on an 8088 running MS-DOS and Stacker, to eek a bit more storage into a 20-megabyte MFM ST-225 hard drive.
It's been a built-in for many systems for decades. Windows can do it. I'm using it today with ZFS, where it's essentially free on modern-ish hardware.
This was a built in feature of DOS, not Windows.
It was introduced in MS-DOS 6.0 -- in fact it was the major feature.
It rivalled DR-DOS 6 which bundled a 3rd party disk compression program called SuperStore, which DR licensed in.
Microsoft invited other disk-compression vendors to send in their code for MS to look at and maybe license. STAC gave them the source code to the industry #1, Stacker.
(Stacker even worked on OS/2 2, a major technological feat. I ran Stacker in DOS + OS/2 dual-boot. I really recommend nobody ever tries this -- it was a nightmare.)
MS being MS it just stole the code. It took some of the core Stacker algorithm, and the driver architecture from another rival product ("DoubleDisk" from Vertisoft), and built it into MS-DOS 6 and called it DoubleSpace.
Never trust Microsoft. I don't care what your SLA says.
MS-DOS 6 was buggy AF. MS issued an update, MS-DOS 6.20.
Stac noticed the stolen code. It sued. It won.
https://msversus.org/archive/stac.html
Microsoft issued an "update" called MS-DOS 6.21 without DoubleSpace.
It rewrote the offending code and issued MS-DOS 6.22 with DriveSpace instead.
It's the same system with some lines changed.
Reminder: Never trust Microsoft.
Windows 95 and 98 just inherited DriveSpace from MS-DOS 6.22.
https://en.wikipedia.org/wiki/DriveSpace
Anyway I don't know what it did but it was supposed to make your RAM 50% more efficient. I suspect it just dicked about with Windows 95/98's cacheing or something, to make stuff load faster.
What it did do, though, and this eventually was what triggered the mutiny, was every time you started up any application it would play a really loud sample of a dragster starting up and driving off, for about 30 seconds.
With a dozen PCs in the room, you can imagine this got pretty fucking annoying.
Not as annoying as constantly getting hauled up about not using this miracle of computer science, though, because my PC was for video editing, ran Windows 2000 which this didn't work on, and had a whopping 512MB of RAM anyway!
ZRAM added compressed_writeback in 7.0, it needs to be explicitly enabled.
I recall reading an article around the time the Windows team added it (back when I still used the OS). Their compression algorithm was typically faster than the latency to the prevailing disk type at the time (SATA SSD, most likely) - at the time it had zero downsides. I'm not sure if that still holds true.
On Linux it generally doesn't: off-the-shelf compression is used, which do not outpace storage access latency.
It's a remarkable tech that deserves more attention. Swap is back in style!
Assuming a long running server eventually settles into a steady state with a large amount of read-only pages that are constantly referred to, and are highly compressible, the compressed ram reads using zstd would allow a server to effectively quadruple (4:1 ratio) its RAM without the zswap performance hits.
It is not clear how much of a difference switching to software only CRAM implementation will give over using zram and will it be available at all.
As a teenager, a company called Stacker that made a "RAM doubler" for DOS hired him to write their compression algorithms.
Hearing him talk, I felt like he was some sort of wizard - I wanted to be in that club.
He inspired a 30 year career in software development.
Zram is better _if and only if_ you do not have fixed permanent storage to swap onto. E.g. a Raspberry Pi running off just a microSD card.
Zswap is better _if and only if_ you do have fast storage for a swap file or partition. E.g. a PC with an SSD or HDD.