frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Debunking Zswap and Zram Myths

https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-what.html
62•javierhonduco•3h ago

Comments

nephanth•1h ago
I used to put swap on zram when my laptop had one of those early ssds, that people would tell you not to put swap on for fear of wearing them out

Setup was tedious

patrakov•1h ago
User here, who also acts as a Level 2 support for storage.

The article contains some solid logic plus an assumption that I disagree with.

Solid logic: you should prefer zswap if you have a device that can be used for swap.

Solid logic: zram + other swap = bad due to LRU inversion (zram becomes a dead weight in memory).

Advice that matches my observations: zram works best when paired with a user-space OOM killer.

Bold assumption: everybody who has an SSD has a device that can be used for swap.

The assumption is simply false, and not due to the "SSD wear" argument. Many consumer SSDs, especially DRAMless ones (e.g., Apacer AS350 1TB, but also seen on Crucial SSDs), under synchronous writes, will regularly produce latency spikes of 10 seconds or more, due to the way they need to manage their cells. This is much worse than any HDD. If a DRAMless consumer SSD is all that you have, better use zram.

cdown•1h ago
Thank you for reading and your critique! What you're describing is definitely a real problem, but I'd challenge slightly and suggest the outcome is usually the inverse of what you might expect.

One of the counterintuitive things here is that _having_ disk swap can actually _decrease_ disk I/O. In fact this is so important to us on some storage tiers that it is essential to how we operate. Now, that sounds like patent nonsense, but hear me out :-)

With a zram-only setup, once zram is full, there is nowhere for anonymous pages to go. The kernel can't evict them to disk because there is no disk swap, so when it needs to free memory it has no choice but to reclaim file cache instead. If you don't allow the kernel to choose which page is colder across both anonymous and file-backed memory, and instead force it to only reclaim file caches, it is inevitable that you will eventually reclaim file caches that you actually needed to be resident to avoid disk activity, and those reads and writes hit the same slow DRAMless SSD you were trying to protect.

In the article I mentioned that in some cases enabling zswap reduced disk writes by up to 25% compared to having no swap at all. Of course, the exact numbers will vary across workloads, but the direction holds across most workloads that accumulate cold anonymous pages over time, and we've seen it hold on constrained environments like BMCs, servers, desktop, VR headsets, etc.

So, counter-intuitively, for your case, it may well be the case that zswap reduces disk I/O rather than increasing it with an appropriately sized swap device. If that's not the case that's exactly the kind of real-world data that helps us improve things on the mm side, and we'd love to hear about it :-)

patrakov•24m ago
1. Thanks for partially (in paragraph 4 but not paragraph 5) preempting the obvious objection. Distinguishing between disk reads and writes is very important for consumer SSDs, and you quoted exactly the right metric in paragraph 4: reduction of writes, almost regardless of the total I/O. Reads without writes are tolerable. Writes stall everything badly.

2. The comparison in paragraph 4 is between no-swap and zswap, and the results are plausible. But the relevant comparison here is a three-way one, between no-swap, zram, and zswap.

3. It's important to tune earlyoom "properly" when using zram as the only swap. Setting the "-m" argument too low causes earlyoom to miss obvious overloads that thrash the disk through page cache and memory-mapped files. On the other hand, with earlyoom, I could not find the right balance between unexpected OOM kills and missing the brownouts, simply because, with earlyoomd, the usage levels of RAM and zram-based swap are the only signals available for a decision. Perhaps systemd-oomd will fare better. The article does mention the need for tuning the userspace OOM killer to an uncomfortable degree.

I have already tried zswap with a swap file on a bad SSD, but, admittedly, not together with earlyoomd. With an SSD that cannot support even 10 MB/s of synchronous writes, it browns out, while zram + earlyoomd can be tuned not to brown out (at the expense of OOM kills on a subjectively perfectly well performing system). I will try backing-store-less zswap when it's ready.

And I agree that, on an enterprise SSD like Micron 7450 PRO, zswap is the way to go - and I doubt that Meta uses consumer SSDs.

bilegeek•5m ago
Counterargument: you can mostly disable zswap writeback, so it will only use the swap partition when hibernating[1].

[1]https://wiki.archlinux.org/title/Power_management/Suspend_an...

jitl•1h ago
thank goodness Kubernetes got support for swap; zswap has been a great boon for one of my workloads
adgjlsfhk1•1h ago
can you make a follow-up here for the best way to setup swap to support full disk encryption+hybernation?
guenthert•56m ago
So much polemic and no numbers? If it is a performance issue, show me the numbers!
cdown•27m ago
There are quite a few numbers in the article, although of course I'm happy to hear any more you'd like presented.

* A counterintuitive 25% reduction in disk writes at Instagram after enabling zswap

* Eventual ~5:1 compression ratio on Django workloads with zswap + zstd

* 20-30 minute OOM stalls at Cloudflare with the OOM killer never once firing under zram

The LRU inversion argument is just plain from the code presented and a logical consequence of how swap priority and zram's block device architecture interact, I'm not sure numbers would add much there.

Mashimo•6m ago
Is this advice also applicable to Desktops installations?

LiteLLM Python package compromised by supply-chain attack

https://github.com/BerriAI/litellm/issues/24512
159•theanonymousone•1h ago•68 comments

Missile Defense Is NP-Complete

https://smu160.github.io/posts/missile-defense-is-np-complete/
70•O3marchnative•1h ago•37 comments

Microsoft's "Fix" for Windows 11: Flowers After the Beating

https://www.sambent.com/microsofts-plan-to-fix-windows-11-is-gaslighting/
487•h0ek•4h ago•357 comments

Debunking Zswap and Zram Myths

https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-what.html
62•javierhonduco•3h ago•10 comments

curl > /dev/sda: How I made a Linux distro that runs wget | dd

https://astrid.tech/2026/03/24/0/curl-to-dev-sda/
61•astralbijection•3h ago•27 comments

Opera: Rewind The Web to 1996 (Opera at 30)

https://www.web-rewind.com
122•thushanfernando•6h ago•65 comments

Ripgrep is faster than grep, ag, git grep, ucg, pt, sift (2016)

https://burntsushi.net/ripgrep/
167•jxmorris12•7h ago•74 comments

Secure Domain Name System (DNS) Deployment 2026 Guide [pdf]

https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-81r3.pdf
13•XzetaU8•1h ago•0 comments

Box of Secrets: Discreetly modding an apartment intercom to work with Apple Home

https://www.jackhogan.me/blog/box-of-secrets/
209•jackhogan11•1d ago•68 comments

I Quit Editing Photos

https://jamesbaker.uk/i-quit-editing-photos/
9•speckx•3d ago•7 comments

Log File Viewer for the Terminal

https://lnav.org/
225•wiradikusuma•8h ago•28 comments

NanoClaw Adopts OneCLI Agent Vault

https://nanoclaw.dev/blog/nanoclaw-agent-vault/
41•turntable_pride•1h ago•5 comments

MSA: Memory Sparse Attention

https://github.com/EverMind-AI/MSA
44•chaosprint•2d ago•3 comments

No-build, no-NPM, SSR-first JavaScript framework if you hate React, love HTML

https://qitejs.qount25.dev
72•usrbinenv•5d ago•64 comments

iPhone 17 Pro Demonstrated Running a 400B LLM

https://twitter.com/anemll/status/2035901335984611412
658•anemll•23h ago•289 comments

Nanobrew: The fastest macOS package manager compatible with brew

https://nanobrew.trilok.ai/
10•syrusakbary•2h ago•2 comments

Autoresearch on an old research idea

https://ykumar.me/blog/eclip-autoresearch/
385•ykumards•19h ago•84 comments

BIO – The Bao I/O Co-Processor

https://www.crowdsupply.com/baochip/dabao/updates/bio-the-bao-i-o-co-processor
59•hasheddan•2d ago•13 comments

FCC updates covered list to include foreign-made consumer routers

https://www.fcc.gov/document/fcc-updates-covered-list-include-foreign-made-consumer-routers
371•moonka•16h ago•249 comments

A 6502 disassembler with a TUI: A modern take on Regenerator

https://github.com/ricardoquesada/regenerator2000
63•wslh•3d ago•7 comments

Show HN: Cq – Stack Overflow for AI coding agents

https://blog.mozilla.ai/cq-stack-overflow-for-agents/
177•peteski22•21h ago•73 comments

LLM Neuroanatomy II: Modern LLM Hacking and Hints of a Universal Language?

https://dnhkng.github.io/posts/rys-ii/
8•realberkeaslan•3h ago•2 comments

Claude Code Cheat Sheet

https://cc.storyfox.cz
499•phasE89•16h ago•160 comments

Dune3d: A parametric 3D CAD application

https://github.com/dune3d/dune3d
191•luu•2d ago•77 comments

Microservices and the First Law of Distributed Objects (2014)

https://martinfowler.com/articles/distributed-objects-microservices.html
34•pjmlp•3d ago•22 comments

The Resolv hack: How one compromised key printed $23M

https://www.chainalysis.com/blog/lessons-from-the-resolv-hack/
101•timbowhite•16h ago•142 comments

Pompeii's battle scars linked to an ancient 'machine gun'

https://phys.org/news/2026-03-pompeii-scars-linked-ancient-machine.html
93•pseudolus•4d ago•27 comments

Finding all regex matches has always been O(n²)

https://iev.ee/blog/the-quadratic-problem-nobody-fixed/
240•lalitmaganti•4d ago•63 comments

IRIX 3dfx Voodoo driver and glide2x IRIX port

https://sdz-mods.com/index.php/2026/03/23/irix-3dfx-voodoo-driver-glide2x-irix-port/
88•zdw•15h ago•18 comments

Abusing Customizable Selects

https://css-tricks.com/abusing-customizable-selects/
141•speckx•5d ago•7 comments