varenc 1 day ago

As others have said, macOS does this by default and it's quite impressive. I have a long running daemon with a memory leak. By its nature, the leaking memory is very repetitive and easily compressed. Right now this daemon has tried to claim 2.5GB of memory, but it's been compressed to a mere 450MB of actual memory! And because it's a memory leak, it never accesses this old stuff, so it never gets decompressed. Only 20MB of RAM is held that isn't compressed.

Of course, it would be far better to just not have the memory leak...but in the mean time, macOS memory compression is making the leak nearly a none issue.

  • trollbridge 1 day ago

    Wait until people find out about swapping.

    • Sharlin 1 day ago

      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.

      • qball 18 hours ago

        It's also something that Optane was basically purpose-built to solve, to the point of just shipping on DIMMs directly.

        A shame it's dead.

      • 8n4vidtmkvmk 15 hours ago

        Running out of VRAM and swapping to normal RAM still seems crazy expensive.

    • bayindirh 1 day ago

      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.

      • Lerc 1 day ago

        How long does a wear leveling SSD take to fail if it is set to constantly write at it's fastest possible bandwidth?

        • svnt 23 hours ago

          Two weeks to six months, depending on the drive design and the rate/size.

        • ksec 22 hours ago

          >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.

          • Lerc 21 hours ago

            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.

            I look forward to a crazy youtuber making one.

            • xarope 20 hours ago

              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

              • ssl-3 15 hours ago

                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.)

        • NekkoDroid 20 hours ago

          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 (with 8% health remaining). It is currentlly at 56k hours power on.

        • literalAardvark 14 hours ago

          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.

          Luckily the other half was more than plenty

      • AnthonBerg 13 hours ago

        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.

        • bayindirh 12 hours ago

          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.

      • trollbridge 8 hours ago

        That’s odd. Load averages usually aren’t high when swapping; swapping means the CPU isn’t busy.

        • bayindirh 8 hours ago

          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. (:

    • dotancohen 1 day ago

      Why the downvotes? I also was thinking that's a perfect candidate for swapping to disk.

    • varenc 2 hours ago

      In my case, the leaking compressed memory is almost certainly also being swapped to disk. I don't know this for sure, but I can observe that macOS makes very few reads to the swap file. So the swap file is storing memory that is very unlikely to be accessed anyway. It's almost like the other commenter's suggestion to free the leaking memory and crash the program if it tries to access it. But instead of freeing the memory, its puts it into the swap, but with pretty high confidence the memory will never be read.

  • davidkwast 1 day ago

    It's like having a room that shrinks everything to 1/5th of its size but you never come back to get anything. It will work until gets full.

    • AnthonBerg 13 hours ago

      I… this is a surprisingly accurate metaphoric abstraction for narcissism. Long story. I mean it though.

      Apologies for the off-topicness?

      —This is in earnest. The brain does operate according to information theory, certainly has memory, and does compress things.

  • 01HNNWZ0MV43FF 1 day ago

    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.

    Thus solving memory leaks forever...

    • bayindirh 1 day ago

      I believe one can create a kernel module called leaky_ram to make this possible. No?

      • kccqzy 1 day ago

        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.

        • JoshTriplett 17 hours ago

          If you actually do this, make sure no use of that system ever reports a bug on any software they use, ever.

  • cpeterso 1 day ago

    A new take on the OOM killer: if a long-running daemon hasn't touched some heap pages for a very long time, perhaps the OS could assume it is leaked and unmap the pages. If the daemon tries to access that memory, let it crash.

    • kevincox 1 day ago

      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.

      Sure, they will get restarted, but not great.

      • cxr 1 day ago

        It's a good example of perverse outcomes. Rather than simply following the contract and functioning correctly, we would be:

        going through extra effort to accommodate/enable buggy, poorly behaving programs, and meanwhile—

        punishing those (and the programmers of those) that are well-behaved and functioning exactly as intended but that now have to contend with evading some heuristic of badness.

        • tadfisher 23 hours ago

          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.

        • braiamp 19 hours ago

          "All means are fair except solving the problem"

      • onjectic 21 hours ago

        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 my sibling comment makes a good point though, that this encourages or permits buggy code.

        • cwillu 20 hours ago

          OOM triggers when memory pressure is critical; it's not practical to further defer addressing it at that point.

          • onjectic 2 hours ago

            Huh? Defer addressing? You are even more confused than the person I responded to. The memory would be reclaimed in this scenario, it is entirely “practical” in that sense, there is no contradiction.

            • cwillu 2 hours ago

              Defer /addressing/fixing/solving/ the problem.

              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

              • onjectic 2 hours ago

                No one said we were deferring fixing the problem. Memory is reclaimed. We would only be delaying or avoiding the part where the process is killed.

    • dotancohen 1 day ago

      Or swap it to a less expensive medium, such as the SSD.

      • TheSoftwareGuy 1 day ago

        That’s actually a very old idea, called paging or swapping. And it totally works

        • dotancohen 22 hours ago

          Yes, that is what I am referring to.

          • ChoGGi 7 hours ago

            Gonna party like it's 1969, I love AI!

            Not how I expected the next big optimization push, but I'll take it.

      • InsidiousWombat 23 hours ago

        I'd rather not have it waste write cycles

        ... but reading say libraries directly and only putting in RAM the parts often used, now we're talking

        • dotancohen 1 hour ago

          You could page to an HDD too. Or /dev/null

    • origini 23 hours ago

      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.

    • gpapilion 21 hours ago

      I thought this is what Meta ended up doing, as well as making it very aggressive to push data into compressed memory on servers.

    • varenc 19 hours ago

      I love it! especially if the OS didn't just do this to all recently untouched memory, and did something smart that accurately targeted memory leaks. Like in my case, it's a daemon constantly growing its memory usage at the same rate, and whose heap pages are repetitive and easily compressed. If you could confidently flag the memory as almost certainly a memory leak, I really love it. Honestly it sounds like a thing Apple would do. (and also keep records of the rare case leaked memory is misidentified and accessed later, to improve the process in the future)

    • throw0101d 7 hours ago

      > 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?

  • fl0ki 1 day ago

    The BackRAMs

  • jedbrooke 23 hours ago

    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

    0: https://learn.microsoft.com/en-us/archive/msdn-magazine/2009...

    • razster 20 hours ago

      But why? Curious as to the reason. Fascinating though.

      • jedbrooke 15 hours ago

        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.

    • varenc 1 hour ago

      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!

      APFS on-disk file compression is very mysterious, hard to observe, 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 good 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)

      edit: looks like `applesauce` is a more modern tool like `afsctool` that lets you use APFS transparent file compression: https://github.com/Dr-Emann/applesauce

  • oso2k 18 hours ago

    Zram also became default in Fedora 33.

  • surajrmal 5 hours ago

    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.

Lio 1 day ago

RAM compression sounds very useful but the thing I really need extra RAM for is local inference.

Since the models are effectively highly compressed data already my assumption is that RAM compression won't help improve that much (I'm assuming unified memory here as per the Framework Desktop). A bit like trying to compress a JPEG in a zip file.

Could anyone comment on that?

  • rft 1 day ago

    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.

    [1] https://github.com/zipnn/zipnn#results

  • kalcode 1 day ago

    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.

    • 0123456789ABCDE 1 day ago

      perhaps i'm not pilled enough for this conversation, but aren't you conflating two disparate concepts — model-weights and context-window?

      • kalcode 1 day ago

        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.

        So my mind on that.

  • matja 1 day ago

    > 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.

    • rft 1 day ago

      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.

      [1] https://github.com/zipnn/zipnn#results

  • strobe 1 day ago

    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?

  • throw-qqqqq 1 day ago

    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.

    https://en.wikipedia.org/wiki/Shannon%27s_source_coding_theo...

  • vlovich123 1 day ago

    You are correct, compression doesn’t help reduce 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.

    The other challenge with compressing weights of course is that you have to decompress them before you do math with them. Dequantizing weights is significantly cheaper and supports random access too (not that that matters too much but it helps in terms of leveraging SIMD techniques to do it in an embarrassingly parallel way)

    • Powdering7082 1 day ago

      > 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

      • vlovich123 14 hours ago

        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).

  • hobo123 1 day ago

    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.

    • RossBencina 1 day ago

      > I'm not too familiar with LLM memory access patterns

      Dense architectures hit every byte of the model for every token. It's the ultimate memory bandwidth nightmare.

      MoE models use subsections for each token and are more amenable to keeping parts in secondary storage, and indeed there are some local llm engines that do this.

    • origini 23 hours ago

      Compression and decompression of memory is potentially even beneficial for CPU as the memory bandwidth to the CPU is much slower than the CPU itself.

      • acchow 21 hours ago

        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.

hedgehog 1 day ago

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) and the defaults vary by distro. zstd is the right choice IMO unless you're in a situation where you know better.

  • taegee 23 hours ago

    Exactly. It defaults to lz4 but zstd gives quite a bit more compression.

    Unfortunately AFAIK there is no way to query the current compression level. You just write zstd(level=2) into some config file and hope for the best …

    • el_isma 21 hours ago

      sudo cat /sys/kernel/debug/zswap/stored_pages

      sudo cat /sys/kernel/debug/zswap/pool_total_size

      getconf PAGESIZE

      ratio = (stored pages * PAGESIZE) / pool total size

      I have 3.6 right now

      • taegee 2 hours ago

        I was talking about zram and I didn't mean the compression ratio but the compression level used by the algorithm (2 in my example).

        Sorry for the confusion.

  • seabrookmx 22 hours ago

    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.

  • deathanatos 20 hours ago

    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.)

    • hedgehog 3 hours ago

      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.

jakozaur 1 day ago

> 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.

  • jve 1 day ago

    Wait, Edge on windows automatically puts tabs to sleep when they are unused (https://explore.microsoft.com/en-us/edge/features/sleeping-t...). I think edge weren't even the first one, thus being kinda surprised I see chrome needs extension for that?

    • martheen 14 hours ago

      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.

  • evenfrost 1 day ago

    For Chrome I recommend The Marvellous Suspender, which can auto-suspend unused tabs. Has been a life-saver for me for quite a while.

    • jamesgeck0 1 day ago

      I thought suspend plugins became redundant when Chrome started shipping a built-in auto-suspend. Is there still a reason to use them?

      • kasabali 1 day ago

        They provide more granular options on when and what to suspend compared to crude heuristics of the built in feature.

  • aa-jv 1 day ago

    >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 ...

    • seanw444 22 hours ago

      Plus it makes an obvious time-for-space tradeoff, which isn't always desirable. That kind of thing is user preference.

  • benjiro29 1 day ago

    "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.

  • hobo123 1 day ago

    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.

cogman10 1 day ago

Don't use Zram, use Zswap. Especially if you want to swap to disk.

https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-...

  • ciupicri 1 day ago

    I've tried for running bsdiff and zswap was slower and spilled out data to the disk (which would wear an SSD).

  • mrob 1 day ago

    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.

    • dsp_person 1 day ago

      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.

    • 01HNNWZ0MV43FF 1 day ago

      For today's 10,000, do `sudo apt-get install earlyoom` and thank me later

    • quotemstr 1 day ago

      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?

      • mrob 1 day ago

        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.

        • quotemstr 1 day ago

          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.

          • mrob 23 hours ago

            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.

        • imtringued 8 hours ago

          You've just started a fight against all statics (.text) inside of executables. I hope you're ready for that.

          >If we knew how to identify those pages we could just avoid allocating them in the first place.

          It's called swap.

      • InsidiousWombat 23 hours ago

        wasting SSD writes for one. Especially if something leaks and it starts trashing

    • origini 23 hours ago

      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.

  • teravor 1 day ago

    > Especially if you want to swap to disk.

    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).

    • __del__ 16 hours ago

      that's right. zram with earlyoom is my current choice for a system with no swap.

  • jmakov 23 hours ago

    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.

    • cogman10 5 hours ago

      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.

  • yjftsjthsd-h 21 hours ago

    > 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)

flowerlad 1 day ago

In the 1990s there was a third-party add-on for Windows called SoftRAM95 [1] that doubled your RAM using compression. That one turned out to be a scam though [2].

[1] https://en.wikipedia.org/wiki/SoftRAM

[2] https://devblogs.microsoft.com/oldnewthing/20211111-00/?p=10...

  • origini 23 hours ago

    My Windows 98 had a feature were you can convert a floppy disk to compressed floppy disk or so? It showed 1.4mb before and 7mb after.

    Apparently it was called DriveSpace: https://de.wikipedia.org/wiki/DriveSpace

    • ssl-3 14 hours ago

      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.

    • lproven 10 hours ago

      > 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, with a much better disk-repair tool called SCANDISK.

      Stac noticed the stolen code in Doublespace. It sued. It won.

      https://msversus.org/archive/stac.html

      It something like $250M or so in damages. Knowing that bigger disks would soon make disk compression irrelevant -- and as the tech was now built in, there would be no more sales -- it got into remote control tech-support apps instead by acquiring a R/C vendor, "Reachout." It also bought a vendor of server image-based backups, "Replica". The dot-com crash nearly killed it, and everyone was bundling this tech by 2002, so the management sold up and wound up the company and returned the cash to shareholders. A rare honourable company in the PC industry, screwed over by Microsoft.

      Do not trust Microsoft.

      Microsoft issued another "update" to DOS 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

  • ErroneousBosh 20 hours ago

    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!

sammatilda 1 day ago

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.

  • nico 1 day ago

    Wow, very cool. Is this like the old "RAM doubler" for Mac OS (or like Johnny Mnemonic's "Pemex MemDoubler")? :)

    • lproven 10 hours ago

      Only extremely loosely, but kinda sorta ish yes.

  • Lio 1 day ago

    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 I update using the UI updater.

    It's better using the dnf command but it still felt a bit lumpy compared to apt.

    • mritzmann 1 day ago

      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.

      • ErroneousBosh 20 hours ago

        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.

    • nosrepa 1 day ago

      You can turn that off in the settings for discover.

  • speed_spread 1 day ago

    I like Fedora too but I'm pretty sure Ubuntu also has zram. You just need to enable it.

  • amelius 1 day ago

    Could this be one of the tricks the M-series cpus are pulling behind the scenes to make them look faster?

    • jrmg 1 day ago

      It’s definitely one of the tricks the Neo is pulling behind the scenes to make 8Gb be ‘enough’.

    • swiftcoder 1 day ago

      It's nothing to do with the CPUs. Apple implemented this OS-wide back in the 2010s, long before the M-series was on anyone's radar.

      • aldonius 19 hours ago

        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.

  • mkesper 1 day ago

    zram has inherent problems and is superseded by zswap. https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-...

    • anthk 1 day ago

      Not in my case. Both a NUC with 8GB of RAM and a netbook with 1. Zram ran better. The least you touch the disk, the better.

    • kasabali 1 day ago

      superseded when? both have inherent problems and their usecases and I got sick of this meme of pushing zswap as the superior solution.

      • quotemstr 1 day ago

        Doesn't seem like a "meme" as much as a well-argued technical position. What's the problem?

    • hofiflo 1 day ago

      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 :)

      • adgjlsfhk1 1 day ago

        zswap+earlyoom/systemd-oomd is the optimal combo. Unfortunately, very few desktops ship this/configure it correctly.

        • hofiflo 1 day ago

          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!

          • MayeulC 14 hours ago

            You can also try the following to let the system detect thrashing and fire up its OOM killer: echo 1000 > /sys/kernel/mm/lru_gen/min_ttl_ms

            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.

      • anthk 22 hours ago

        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...

    • shakow 23 hours ago

      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.

      • Izkata 2 hours ago

        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.

        > and it's better to let the OOM killer do its job

        For most users this is the worst outcome, causing them to lose work.

  • hobo123 1 day ago

    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.

    • taegee 23 hours ago

      What's wrong with current packages? And the major version upgrades every six months is just a click on the update button.

      For my parents (or any other non-techie person), I'd just take Fedora Kinoite and set it to auto-update.

      • hobo123 15 hours ago

        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.

        • taegee 2 hours ago

          Then you should have a look at the mentioned atomic desktop spins. They guarantee you a bootable system.

          I hopefully never have to touch GNOME ever again in my life though. :D

          KDE is like night and day to me.

    • martinald 19 hours ago

      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.

  • InsidiousWombat 23 hours ago

    Fedora is beta test environment for RedHat, I wouldn't use it for work machine.

nukanse 1 day ago

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

Juvination 1 day ago

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.

roosgit 1 day ago

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.

  • kachnuv_ocasek 1 day ago

    Fedora has had zram on by default for at least five years now.

    • ChocolateGod 1 day ago

      zram relies on the swap subsystem, macOS memory compression does not rely on pages being swapped.

      • anthk 1 day ago

        You can enforce the swappiness to 100 and virtually work in the same way.

        • mrob 1 day ago

          Maximum swappiness is 200. Setting it higher than 100 is possibly a good idea when using zram.

certyfreak 1 day ago

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.

Waterluvian 19 hours ago

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.

aktenlage 1 day ago

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.

noodlesUK 1 day ago

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.

jmakov 1 day ago

Looking at the solution AMD bought, looks like Linux has a lot of room to improve regarding moving (compressed) inactive pages to disk: https://www.amd.com/en/products/software/mext.html.

If my understanding is correct, both ZRAM and ZSWAP write uncompressed pages to disk. And both don't pack the pages together meaning even if we'd write compressed pages (let's say they compress 5:1), we'd still write the original size to disk. This is crazy.

  • zamalek 1 day ago

    > If my understanding is correct, both ZRAM and ZSWAP write uncompressed pages to disk.

    ZRAM added compressed_writeback in 7.0, it needs to be explicitly enabled.

    • jmakov 1 day ago

      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.

      • mrheosuper 16 hours ago

        Do they map ram page 1:1 to disk block ? I imagine if this is done by CPU, you can compress multiple ram page into single disk block.

myrandomcomment 1 day ago

MacOS does this by default for inactive pages. On my current system with 18GB of RAM I show 4.80GB for Apps, 3.16GB Wired and 5.06GB Compressed.

Lerc 1 day ago

I have to wonder if the better solution would be for browsers (and apps that are effectively broswers) to compress their data proactively.

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.

  • anthk 1 day ago

    Browsers can just suspend tabs. If they are separate processes, just send a SIGSTOP except for the actual active tab and run SIGCONT upon switching.

  • isthatafact 23 hours ago

    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.

  • aldonius 19 hours ago

    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.

trelliumD 21 hours ago
  • sleepytimetea 21 hours ago

    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.

  • flexagoon 21 hours ago

    It seems like it's something still in development and not in the kernel yet?

  • Self-Perfection 6 hours ago

    This technology is in development yet and targeted for special hardware that handles compression.

    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.

rustyhancock 1 day ago

I've used zswap on most of my systems and generally find it beneficial especially as (de)compression can be very fast these days.

What's interesting to note is that I've occasionally wondered why isn't the swap partition compressed.

If you have it on an NVMe drive it probably is as is all data! The controller usually transparently does it as it writes to/from NAND.

So the kernel sees uncompressed fixed block pages and the speed boosts happen with data arriving faster when read or written to flash.

  • close04 1 day ago

    > 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 measure the benefit. Does it benefit machines with low amounts of RAM and wimpy CPU (like a RPi3)?

    > The controller usually transparently does it as it writes to/from NAND.

    In the consumer SSD space the last controllers I know did 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

  • mkesper 1 day ago

    Where did you get that info? Sounds suspicious.

    • deltoidmaximus 1 day ago

      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.

manbash 16 hours ago

We've gone full circle. We kept swap partitions to minimal because RAM kept getting bigger and affordable. Now we're back.

2001zhaozhao 1 day ago

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.

zamalek 1 day ago

> 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.

72deluxe 1 day ago

Having viewed that page, I cannot fathom how Firefox is using 27GB of RAM in his screenshot?!

  • alpaca128 1 day ago

    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.

  • Sopel 1 day ago

    from my experience it would require roughly 100 active youtube tabs

altcognito 1 day ago

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

  • martheen 13 hours ago

    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.

cyh555 15 hours ago

Only if you use SSD because the operation involve will read from disks as well, not just decompressing the compressed RAM. It's very slow on HDD

bullish-bearr 1 day ago

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

pyaamb 1 day ago

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

Ecno92 1 day ago

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.

  • XYen0n 1 day ago

    You can enable it yourself, for example using https://github.com/systemd/zram-generator.

    • Ecno92 1 day ago

      I did! I am actually the author of the post! ;-)

      • aa-jv 1 day ago

        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...

Gehinnn 21 hours ago

Waiting for the day that an OS ships an LLM to optimize instructions globally, compresses RAM even smarter and fixes bugs/leaks on the fly.

arianvanp 10 hours ago

use zswap. not zram. it's superior imo

  • lproven 10 hours ago

    It is not as simple as A is better than B.

    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.

IronWolve 1 day ago

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.

baud9600 1 day ago

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?

  • BenjiWiebe 1 day ago

    I'm under the impression that GPU latency is the problem here for on-the-fly de/compression.

    There might be gains by having the GPU recompress with a higher compression level in the background though.

grandlimelabs 1 day ago

Make sure to stress-test compression and decompression for whatever you're doing before you go jumping into relying on it, though.

angst 18 hours ago

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.

ChrisRR 1 day ago

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

It sounds like those are downsides

  • MadameMinty 1 day ago

    "does not come without downsides" + "does come with downsides" race condition

  • xxs 1 day ago

    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.

    • Rohansi 1 day ago

      zram does not compress all of your RAM. It only compresses inactive blocks of memory that would be eligible for swap, if you had swap enabled.

    • aa-jv 1 day ago

      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.

  • Rohansi 1 day ago

    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.

  • Stitch4223 1 day ago

    They are not selling it well.

    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.

  • Ecno92 1 day ago

    I believe I have written this not in the best way. (I have uploaded a slightly improved version)

    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.

  • aa-jv 1 day ago

    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.

djha-skin 1 day ago

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.

yummybear 1 day ago

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

Which one is it?

kiicia 1 day ago

nice try Ram Altman

larodi 23 hours ago

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.

vjvjvjvjghv 1 day ago

Looks like I need to find my old SoftRAM floppy disk. Maybe somebody can come up with something that saves memory that's not used much to disk?

distantsounds 1 day ago

Hilarious ending to the article. You expect some implementation details with a Getting Started section, instead you get a "check the arch wiki" link.

  • nchmy 1 day ago

    Yeah that was disappointing

sharts 11 hours ago

It’s the 90s again. Compress!

bismanawaz 1 day ago

I was wondering if its the agents itself or the browsers that they open fill up the RAM?

1023bytes 1 day ago

Do not buy RAM, download more RAM

po1nt 22 hours ago

How did we allow websites to get this big anyway is beyond me.

tooheavy 1 day ago

Compression is fine as long as the CPU doesn't become the bottleneck.

claytongulick 18 hours ago

This made me think of the mid 90's and a friend of mine named Scott who was one of the smartest guys I'd ever met.

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.

anizan 22 hours ago

Here we go with the softram remix

anizan 22 hours ago

Here we go with softram remix

fernandogrd 1 day ago

Things I did: - Zswap instead of zram. - Unload browser tabs (my own private extension. - Force idle cli AI agents to go to disk swap earlier.

pshirshov 1 day ago

Vectors do not compress.

cubefox 1 day ago

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

  • aa-jv 1 day ago

    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.

    • cubefox 1 day ago

      Maybe it should generally be on and and only switched off when it is inappropriate.

      • cestith 1 day ago

        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.

        • cubefox 1 day ago

          I have a hard time imagining cases where swapping or running out of RAM is preferable to RAM compression.

          • cestith 1 day ago

            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.

    • jrmg 1 day ago

      “Because it is a user choice”

      That’s true of everything. Default setups make those choices.

  • ChocolateGod 1 day ago

    zswap works very differently to zram.

tonymet 1 day ago

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!

UltraSane 1 day ago

IBM Power systems have hardware RAM compression.

LoganDark 1 day ago

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

  • vardump 1 day ago

    Windows needs to have a backing store for every page allocated.

    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.

    • LoganDark 1 day ago

      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.

dist-epoch 1 day ago

> If you have a Windows or Mac device you are already using it

Technically yes, practically on Windows memory compression is not used.

I have Windows 11, 128 GB RAM, and my memory stats show: 42 GB in use, 380 MB compressed.

  • sheo 1 day ago

    You have plenty of RAM free. Compressing at that point is increasing latency for no good reason. Unused RAM is wasted RAM

    I'm a Linux user myself, but I think it would start compressing it when there would be less than 25% free

jauntywundrkind 1 day ago

In many systems, adding compression makes not just storage better but increases the io you get from a system too. Here's Valkey 9.2 compression figures showing that: https://www.phoronix.com/news/Valkey-9.2

That's for RDB persistence. https://valkey.io/topics/persistence/

I wonder if there's any similar wins with ram? That some workloads would see net wins from compression. Some cost of cpu, but increasing net throughput significantly.

dmitrygr 22 hours ago

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/

hinkley 1 day ago

Okay, Johnny Mnemonic.

varispeed 1 day ago

Do not eat, drink water.

As usual, working class is being told to tighten the belts whilst the rich get insanely richer.

Fuck that.

  • ifloop 1 day ago

    just download more RAM

DeathArrow 1 day ago

I have built my PC with core i7 14700K, RTX 3090,128 GB DDR3, 2TB SSD, 8TB HDD about 3 years ago.

Still perfectly usable and I won't upgrade until prices come down. Even used prices are terrible now.

  • globular-toast 1 day ago

    Mine is an i7 4790K with 32GB of RAM and it's more than usable, I find it quite nippy.

    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.

mzhaase 1 day ago

Zram vs Zswap: https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-...

> If in doubt, prefer to use zswap. Only use zram if you have a highly specific reason to.

> In terms of architecture:

> zswap sits in front of your disk swap, compresses pages in RAM, and automatically tiers cold data to disk. It integrates directly with the kernel's memory management and distributes pressure gracefully.

> zram is a compressed RAM block device with a hard capacity limit. When you put swap on it and it fills up, there is no automatic eviction, and the kernel has very little leverage to do anything about the situation. The system either OOMs or falls back to lower-priority swap, causing LRU inversion (see below). It only really makes sense for extremely memory-constrained embedded systems, diskless setups, or cases with specific security requirements around keeping private data off persistent storage. Swap on zram is also increasingly unsupported upstream.

  • speed_spread 1 day ago

    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.

    • izacus 1 day ago

      You seem to be fundamentally misunderstanding what zswap is and are instead griping about something unrelated.

    • mrob 1 day ago

      Agreed. IMO, zswap is the one that requires a "highly specific reason", while zram (with lz4) should be enabled by default.

    • adgjlsfhk1 1 day ago

      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.