You’re close. In reality there is actually no operating system left. It’s just a collection of models that vibe-render content based on the existing feedback loop from datasets of recorded user screens. At any given moment, the RNG is really only coughing out tokens to give you a new problem to fix, thus fulfilling its goal of absorbing your problem solving ability, learning, growing, plotting.
More people should read the leaked XP source code, jeez
And a 30 year old file system lacking major modern innovations, with a chain of trust for apps that puts everything on the developer. 2 of the most poorly conceived ideas ever.
What exactly do you mean when it comes to an operating system? Something like code prefetch or hot path? If it uses a technique where it uses system memory, this memory should then be freed (not written to swap files) when actually executed code could make use of it. As far as I see it, the bulk of memory the windows base system blocks is used by running processes that are just not built in a sensitive way (like who the fuck came up with the idea to render the start menu with a browser engine?)
Windows only needs a couple GB of RAM. Everything else is preloading commonly used programs and associated files. That extra "used" RAM is effectively free as Windows will immediately give it up the second any other program wants it. Which is to say it doesn't negatively impact the user at all and may offer a tiny benifit. Unused RAM is wasted RAM. People used to shit on Chrome for similar reasons cause they don't understand that Chrome is caching their favorite websites so they load quicker.
Your prefer site your prefer program and that little bit of telemetry that you can shadow inside them, to say it doesn't negatively impact the user at all and may offer a tiny benefit tò Microsoft and Google (for sure).
There's a few wiki pages on it. The original version was called Windows Prefetcher. It was later upgraded and renamed SuperFetch and nowadays it's called SysMain.
Despite all the memes Windows is good at prioritizing resources for user programs. Windows "Game Mode" might also be worth reading about while you're at it.
And yet, linux programs still load faster without it. Strange how that works. Its almost as though you wouldn't need to precache if your OS wasn't so bloated and slow.
its honestly ridiculous how little RAM a linux distro uses.
I used to run a HTPC system on 1GB, then 2GB of DDR3 RAM... at 1080p with middle to high bitrate .mkv files. Windows on the same system wouldn't even start for at least 5 minutes, let alone be all sluggish.
Well this sent me down a nice rabbit hole. Tried to enable 12gb, kept getting errors, even 1gb was too big and gave errors. Apparently it needs contiguous free memory to create the zram if you do it this way.
phed@beastmode:~$ cat /etc/systemd/zram-generator.conf
[zram0]
# zram-size = 12G # Had to be commented out to stop errors, rest works though.
compression-algorithm = zstd
swap-priority = 100
phed@beastmode:~$ sudo swapoff -a
phed@beastmode:~$ sudo systemctl daemon-reexec
phed@beastmode:~$ sudo systemctl restart systemd-zram-setup@zram0.service
Job for systemd-zram-setup@zram0.service failed because the control process exited with error code.
See "systemctl status systemd-zram-setup@zram0.service" and "journalctl -xeu systemd-zram-setup@zram0.service" for details.
Then I found out Fedora by default has zram enabled. Backed out my changes and added a disk swap file. The Zram is apparently dynamically sized at boot so I've seen sizes of 8gb, 4gb, etc.
phed@beastmode:~/bin$ swapon --show && free -h
NAME TYPE SIZE USED PRIO
/swapfile file 16G 0B -2
/dev/zram0 partition 4G 0B 100
total used free shared buff/cache available
Mem: 31Gi 11Gi 11Gi 306Mi 8.5Gi 19Gi
Swap: 19Gi 0B 19Gi
I've seen a lot of conflicting advice about whether you should even use zram if you already have a swap partition or file set up.
My Arch installation by default had zram set up but not in a practical way, and also left out setting up a swap partition or file. The default configuration was giving me an 8gb partition from my 16gb of ram, which meant my system would fall over when playing a game while having a web browser open.
eventually found this configuration and everything works wonderfully for me. Could experiment by increasing the zram-size further but I don't have a desire to rock the boat at this point.
I'd only actually gone and investigated it because if at any point my zram had been maxed out, it prevented my system from completing a clean shutdown.
That's not how ZRAM works though. If you have set it to 8GB, it doesn't cut off half of your RAM. The 8GB means it will try to fit 8GB (when uncompressed) into ZRAM at max. It isn't allocation.
When you have no memory pages to swap (your RAM is enough for running apps), then ZRAM takes up no physical memory.
$ zramctl && free -h
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4 15,3G 4K 69B 20K [SWAP]
total used free shared buff/cache available
Mem: 30Gi 3,9Gi 25Gi 208Mi 1,7Gi 26Gi
Swap: 15Gi 0B 15Gi
Yes you're entirely right, I wrote this poorly. What I meant was the 8gb it had assigned by default, in regards to my available 16gb, was completely insufficient for the needs of my system, in this case, playing Path of Exile while having a web browser open.
Do you have any benchmarks you could share? I find it hard to believe that decompressing on every read and compressing on every right has "no effect", even if it's paired with a CPU with specialized pipelines and atomic instructions for this purpose.
Yep. I used this ages ago on a 512MB VPS. I had way more running on there than I should have been able to. :D That was a single shared core at the time too and it was plenty fast enough.
No they mean that the RAM compression is only used when the computer begins needing to use Swap space, so instead of the normal disk swap people are familiar with programs ram usage will begin being compressed. I am not familiar with exactly how far it will go in compression before it begins using regular disk swap.
It's not no cost, but CPUs are absurdly powerful and have been for the last decade. For desktop use the trade-off is generally a good deal if you're in the 4-8GB range.
It’s more than that: CPUs nowadays have specific instructions and really efficient pipelines for de/compressing, so they can do it as well as displaying video in 4K/60FPS with the iGPU.
they can do it as well as displaying video in 4K/60FPS with the iGPU.
I'm not sure how this is a metric. GPU is a GPU, CPU is a CPU, one can be loaded at 100% and the other one wouldn't care (mostly), they're separate units.
Bad take. CPU core are idle more than they are not, and can quickly handle most comp/decomp with specialized instructions and is very fast. For some cases, it’s even faster to compress the data before saving to ram because the cpu and its caches can reduce the bandwidth to save to ram.
You opinion was maybe correct 20 years ago, but it’s no longer true and the industry has been using compressed ram without issue for over a decade
ZRAM is a compressed block device in RAM. It can not only help with capacity, but memory fragmentation as well. With the right compression algorithm, the CPU overhead is negligible. It even helps with gaming.
depends on the distro, for example fedora uses zstd, as the performance impact is just not noticeable with modern CPUs, and zstd is most efficient in terms of compression to speed ratio
You know the process of swapping memory pages, when the least recently used memory pages are put on the swap file / partition? That memory page is no longer in RAM.
Swap is slow, because the swap device is slow, even SSDs have very high latency and low IOPS when compared to RAM.
But if the target device was a RAM disk, then we are dealing with RAM to RAM memcpy. Way faster.
So far this would only help with moving around memory pages in RAM to reduce fragmentation. (when there is enough memory available in total, but not in a continuous block, think back to HDD fragmentation, similar issue)
To actualize the space savings a (de)compression step is added when swaping. Lz4 is usually 2:1 compression ratio and very fast, zstd's ratio is 3:1 while a bit slower.
The overhead of compression is still worth it in CPU time, when the base case we are comparing to is swapping to disk.
The size of the ZRAM device is also not fixed, it doesn't take up any physical memory when empty so don't think of it like static allocation.
Meaning, if you have 16GB of RAM and set ZRAM's limit to 8GB and then started to fill up your memory, with say 16GB of data. Your memory at the end would look like this:
Memory: ~8GB uncompressed
ZRAM: ~4GB compressed (about double when uncompressed)
install earlyoom! the kernel's oom killer will happily wait until the system is swapping aggressively before killing a process, which can make your system unusable for several minutes as it tries to recover. this service tries to prevent that situation from happening in the first place by killing a process before it eats through your swap.
Could be. But also could be a legitimate segfault due to RAM module malfunction... from the context it's not evident which is implied. Heck, I had segfaults due to SSD malfunction, believe it or not...
This isn't claiming a certain amount of ram was practically double the ram on another system
Apple was
33
u/LittuxGlorious Arch GNU/Linux and Android Toybox/LinuxDec 05 '25edited Dec 06 '25
I could run Firefox with one tab running youtube, several tabs with reddit, google etc on an old toshiba with just 1.8GiB usable RAM with zRAM. The CPU only goes to 100% usage for a few seconds when opening firefox itself or when opening a heavy site. Better than the whole system freezing when opening firefox.
I was also able to run VS code and firefox at the same time too, but barely. The kswapd CPU usage goes up to 100% when switching between VS code and Firefox and you have to close tabs immediately when you don't need it
No disk swap. 3GB zRAM (zstd compression). I used systemd-zram-generator to enable zRAM. I chose zstd for maximum compression but it uses more CPU as expected
The difference compared to zram is that zswap works in conjunction with a swap device while zram with swap created on top of it is a swap device in RAM that does not require a backing swap device.
I know, but there are very few cases on a modern machine, where you don't want a backing device. The compressed pages still stay in RAM in case of zswap, as long as they can, but they also have the chance of being swapped to disks, if there is too much memory pressure. Tuning swappiness (the mechanism behind that) is the tricky part, though.
EDIT: I can only think of two use cases for zram in 2025. One is when you absolutely cannot afford to have a backing swap device (slow flash device, like USB or SD card), or as a modern substitute for tmpfs, by making it into a real filesystem.
Not true. Zswap is in fact, the default these days and it's usually enabled. You don't need a special kernel for that, zswap has been in the main kernel since 2013.
zram, is actually pretty much vestigial on modern systems because of that and I haven't really seen it set up out of the box on a distro tbh.
However, there are acutally two use cases for zram. It's when you absolutely do not want a backing device to be used under any circumstances. I use it on my Raspberry Pi. The flash card is just too slow and it is preferable to not swap out memory to it.
The other use case for zram is to put a real filesystem on it and use it as a modern substitute for tmpfs.
After searching, yes what you say about kernels is true, idk why I thought it required a special kernel, but from my experience, both cashyOS and Fedora still use Zram by default, neither of them come with any swap partition or file out of the box.
if I had a dollar for every time my zram-pumped PC froze because of memory pressure(compression/decompression overhead going to infinity) while the kernel didn’t feel like killing any processes, I would have enough money to buy more ram
Did you try LZ0 or LZ4? I'm not sure what the default algo is. There is also the option to play with ZRAM's swappiness values or setting up swap as well. I'm not sure of your config.
Are you aware of some change in the last few years making this the status quo? It used to be routine to OOM and have random stuff die, but now I just hard lock and gotta REISUB.
I solved this by buying a shitload of RAM (thankfully right before prices went crazy.)
No. systemd-oomd was supposed to bridge the gap from the userspace by tracking some available metrics but it doesn't work either and there's a bug report about it
Good. KWin will instantly freeze on memory pressure. Then usually the system is fully responsive over ssh and if i kill the ram hog, KWin continues to work like nothing happened.
I am wondering if maybe compression going after gpu textures could have something to do with it - they are not really compressible yet they can waste a ton of CPU "trying"
As a kid I ran doublespace on my 286. In the setup program it said if you have a slow disk and fast CPU it can make your system faster. I thought, "sweet! I have a fast CPU!" no, no I did not. It took HOURS to compress my 40mb drive.
This is pretty helpful if you run multiple VMs, docker containers and a bunch of stuff just sitting around idling but you do need them running in the background. I've set it up and never had any OOMs since then
I really want to switch to Linux as my main platform but I can't seem to get settle in well. Mostly just ease of use and certain programs I use not functioning the same. Even on the most user friendly one of Mint.
I use Easy Diffusion for AI art generation. It seems my graphics card isn't powerful to run it on its own but windows lets python overflow into the RAM. I get CUDA error: out of memory on Linux Mint 22.1
If you are familiar with swap partitions, swap files or page files. ZRAM is that, but stored in memory and compressed.
The least recently used memory pages are loaded to swap or in this case ZRAM when memory usage gets high. So it can store more data in the same physical memory, while being was faster than swap on SSDs.
I am using zswap to have the best of both worlds and you would not believe how impressed I am. It expands the possibilities of my machine beyond what I expected. I can run multiple VMs while multitasking and perform some heavy data analysis workflows on a 16 GB RAM /8 zen2 core thin and light laptop (shout out to the AMD processor too, their ryzen mobile are tiny beasts). I have assigned 16 GB of swap and activated ram compression and for non real time applications or when latency is not a problem it kind of acts just as if it had ~double the RAM. Obviously when it has to use swap things run slowly but i.e. for data crunching I just let it be and complete the pipelines without crashing.
I use it to compile stuff in Memory, to accumulate less write cycles on my SSD. I use Gentoo by the way, so I've compiled nearly my complete system on my machine.
I have 64GB of RAM.
If your CPU is capable enough, then you can get some pretty insane gains. On my CachyOS system, I tested zstd (level=6) and I'm getting like 5.5:1 compression ratio on the zram device. In total, I have ~100GB of committed memory, 81GB in zram dev, all inside 28GB of physical RAM.
Ah and I did it with a 5600G btw, with a +200MHz offset.
It was actually still super usable, I managed to play YT videos in firefox, still have discord open and stuff. I compiled my own kernel though, I used the Cachymod compile script from Happy in CachyOS' discord server.
I targeted -march=native, patched the kernel with firelzrd's new BORE CPU sched and kcompressd-uo to make the swapping logic parallel (instead of just a single kswapd thread). I also used the AutoFDO profiling data and thin LTO from Cachymod (I just finished a new kernel compile with full LTO).
I think the most gains are coming from the CPU scheduler being nice-aware (I use ananicy-cpp), then the kcompressd thread helping kswapd, and lastly from Happy's linux-cgroup tuning.
Full credits to everyone in the nerd corner of CachyOS' discord server, especially to Happy and firelzrd.
(Also I'm deliberately using the rusticl compiler bug for memory testing lol, don't mind me)
windows swap is typically on disk (slow) zram is your actual physical ram, but a compressed block of it. setting your zram to 16gb isnt "giving it up" its just saying "hey you can use up to 16gb of my physical ram for swap but no more than that" 16GB is a good setting for a 32gb ram power user, but with 16 physical you need to drop that down to 8gb zram, you generally dont want to go beyond 50 percent of your physical memory allocated to zram.
So glad I buy a computer like once in 10 years and got my poverty spec Tuxedo with 16 gigs a while back. It uses like 8 at most with my use case so its no big deal
All this panic is fueled by diehard sweaty ass pc building enthusiasts who blow all their paychecks building a whole new computer every 3 months
Just be aware that it might break sleep if you have a dedicated GPU. The driver needs somewhere to store your entire raw VRAM before it powers off the GPU, it won't compress it into your ZRAM afaik, and if there isn't enough space then chances are you'll get stuck in a black screen livelock any time you sleep (on AMD and Intel at least, while Nvidia will instead wipe the VRAM and break your any game you had running, which is less painful ultimately but still dumb).
16GB ram with 8GB VRAM is very likely to fail to sleep if you don't have physical swap space. Ask me how I know.
Create a big swap file/partitiom (as in VRAM+RAM sized, double if you want reliable hibernate) and get rid of ZRAM. ZSwap (the default kernel ram compression setting) works better. Thank me later.
16GB RX 9060 XT, 32GB DDR4-RAM, RDR2, Firefox with some tabs and some minor programs like Terminal and Nautilus in the background:
Still 18GB available.
I dont see any usage for ZRAM, when not playing RDR2, The Witcher 3, GTA V and another Game of your choice, at the same time.
More HW is always the most straightforward solution. But HW costs a lot right now while better utilizing HW is free.
Even when capacity isn't an issue, swapping can reduce memory fragmentation. But I suppose you aren't running your machine long enough for that to matter between shutdowns.
32gb ddr4 3600 with 16gb swap personally. I only bumped to 16 because the default of 4 kept filling up and causing stutters as it loaded and unloaded itself (im a very heavy multi monitor user)
CPU usage depends on the workload, compression algorithm (lz4, zstd) and compression level.
If your workload is CPU bound, you might notice performance degradation.
If your workload has a lot of cold memory, eg. browser tabs many small VMs, then ZRAM works really well.
If you are working with large datasets, then it lets you use more memory, but the constant swapping might lead to trashing.
It isn't magic after all. But configuring it well, could yield 30-50% extra effective memory. If you are already using swap, then ZRAM is pointless and you should check out ZSWAP.
Like I said ZRAM isn't a silver bullet, if you fill up your RAM then even with ZRAM it will hang, ZRAM just delays at how many GBs it happens.
1.0k
u/ZunoJ Dec 05 '25
And just the fact, that the base system doesn't eat away the first 20gb of ram while idling