News for hackers. Stuff that matters.
Re:Do not buy RAM, compress by cogman10 on Thursday November 19, 2026 @10:25AM (#50561314)
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-...

Re:Do not buy RAM, compress by ciupicri on Thursday November 19, 2026 @10:37AM (#50561505)
I've tried for running bsdiff and zswap was slower and spilled out data to the disk (which would wear an SSD).
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 01HNNWZ0MV43FF on Thursday November 19, 2026 @12:57PM (#50563519)
For today's 10,000, do `sudo apt-get install earlyoom` and thank me later
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 teo_zero on Saturday November 21, 2026 @03:11AM (#50587087)
> I want instant access to my rarely used pages > [...] > setting swappiness high enough (>100)

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.

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 mrob on Saturday November 21, 2026 @07:53PM (#50595144)
I'm going by the ArchWiki:

https://wiki.archlinux.org/title/Swap#Swappiness

"There is a common misconception that swappiness affects the memory threshold or prevents using swap space, but it only affects the preference for freeing up file pages over swap."

As I understand it, Linux does not preemptively evict idle pages, only as a response to memory pressure.

Re:Do not buy RAM, compress by imtringued on Friday November 20, 2026 @07:08AM (#50573610)
You've just started a fight against all read only statics inside of executables. I hope you're ready for that.
Re:Do not buy RAM, compress by InsidiousWombat on Thursday November 19, 2026 @03:58PM (#50566280)
wasting SSD writes for one. Especially if something leaks and it starts trashing
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 teravor on Thursday November 19, 2026 @12:43PM (#50563319)
> 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).

Re:Do not buy RAM, compress by __del__ on Thursday November 19, 2026 @11:06PM (#50570024)
that's right. zram with earlyoom is my current choice for a system with no swap.
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)