Over the past few weeks, the RAM (or system memory) usage on my workstation has increased due to a heavier workload across multiple workspaces. Largely due to an increased number of open web browser tabs as well as other applications spread across 8 other workspaces. With 16 GB of RAM on my system, lately I’ve… continue reading.
Over the past few weeks, the RAM (or system memory) usage on my workstation has increased due to a heavier workload across multiple workspaces. Largely due to an increased number of open web browser tabs as well as other applications spread across 8 other workspaces. With 16 GB of RAM on my system, lately I’ve… continue reading.
I’d love to hear how Zram works for you, especially if you’re trying it for the first time! For those who’ve already been using it, feel free to share your setup, tweaks, tips, and screenshots.
One thing I didn’t mention in the article was the dual-channel compromise when adding more RAM. My B550 has 4 RAM slots and I have 2×8GB running in dual-channel at, 3600MHz. If I add just 1 more 8 GB, my system will go into mixed dual/single-channel mode where the first 16 GB will be in dual-channel and the extra 8 GB will be in single-channel and potentially lose some performance.
To keep full dual-channel, the best approach would be to add 2 more 8 GB to make 32 GB (4×8GB) and keep the 3600MHz. But when you populate all 4 slots some boards will downclock the RAM to make it more stable, including mine, from reading they will drop to 3200Mhz, then there’s the Infinity Fabric Clock (FCLK) which I have set at 1800MHz.
In any case, before next reboot I will adjust my Zram config to use 25% (4 GB RAM) instead of 50%. I’ve been working on this article for the past week, during which I noticed that 8 GB of Zram was overkill. So instead, 12 GB RAM will be untouched, and 4 GB will be used for Zram swap.
EDIT (additional thoughts on this topic)
Regarding swappiness
The Arch Wiki recommends vm.swappiness=180 - I understand it, given how much faster Zram is compared to disk-based swap. However, I think a lower setting (< 100) also acknowledges the reality that Zram is still significantly slower than RAM itself.
While Zram offers a major speed advantage over traditional swap, it still introduces compression and decompression and CPU overhead, making it far from a perfect replacement for direct memory access.
I’ve also been experimenting with different values. Setting vm.swappiness=200
caused swap to Zram to kick in at ~85% memory usage.
At swappiness=10
, swap didn’t start until ~95% memory usage, which closer to the behavior I prefer.
This reinforces my preference for a low swappiness (10 - 50), keeping RAM usage prioritized before swapping. That said, I can see higher values (< 100) being useful for systems that struggle with memory pressure. Especially if there’s less than 8 GB of RAM installed.
100+ swappiness still seems a bit aggressive, to me, but it’s worth testing different values based on your workload.
What about Zswap?
Feature | ZRAM | Zswap |
---|---|---|
Best for | Desktop, many apps and browser tabs | Servers, gradual swap usage |
Visible in swapon ? |
Yes | No (hidden inside RAM) |
Acts as swap device? | Yes | No, compresses and sends to swap |
Prevents OOM Killer? | ![]() |
![]() |
Works without disk swap? | ![]() |
![]() |
Compression Savings | ![]() |
![]() |
Performance on Chrome Tabs | ![]() |
![]() |
Zswap is a swap cache, not a swap device.
– It only compresses memory when swap is actually needed.
– Zram always reserves memory upfront, Zswap only uses memory dynamically as swap pages are created.
– For systems with fast SSDs or NVMe, Zswap can reduce disk swap writes while still letting the SSD handle overflow.
Zram on the other hand, creates a compressed swap space in RAM as a compressed block device.
– Some RAM is “reserved” for Zram, so less RAM is available for applications.
– However, because of compression (e.g. Zstd 3:1 or 4:1), you can store more data than the default allocated RAM.
– If you allocate 4GB to Zram, you don’t “lose” 4GB, you get extra up to 12GB extra.
Consider trying out vm.page-cluster=0 too, reference: “new zram tuning benchmarks” on the fedora Reddit, can’t post links here, yet.
Thanks, @stereomato Added that link for you. Also see: Trust Level System (Guide).
This morning, I’ve been benchmarking RAM vs. Zram vs. disk swap (NVMe).
I tried this out. I’m not really sure how well I’ll notice if this improves my machine’s performance but I enjoy learning about ‘tweaking’ and improving performance through configuration and similar methods.
Hopefully this info isn’t too sensitive but this is what I’m working with.
And here are my results. At least here are the outputs of the same commands in the original post!
My disk is a HDD. It can sometimes feel slow, it might take 8-10 seconds to load google chrome when I launch that and I can hear the disk spinning as data is retrieved. But that being said its not horrible. I can run minecraft Java, I tried some shaders and they ran very laggy (the game ran fine but the image was jumpy so maybe lag isn’t correct), I tweaked a lot of the performance video settings very low and It ran very smoothly but at that point, why even try to use shaders. So after I did that I thought, maybe this has more to do with my GPU than working memory anyways and also I do not know if I would need to allocate more RAM for minecraft after doing the zram/zswap tweaks for those to be able to take affect.
If this topic went way over my head and I’m confusing anyone, apologies! I at least appreciated this post and enjoyed the process of trying it out.
Nice! You probably won’t notice any improvement until you have exhausted memory and started swapping to Zram.
Since you are using a HDD there are some suggested kernel tweaks for your setup:
Change the Zram size to 2 GB instead of 4. (25% instead of 50%) Then make sure ALGO=zstd
because the higher compression is better. This will mean 6 GB RAM untouched, 2 GB that can store ~ 6 GB of in-memory zram swap. So the net effect will be 12 GB stored in memory before needing to swap to HDD.
Then tweak these:
vm.dirty_background_ratio = 5
vm.dirty_ratio = 10
vm.swappiness = 10
vm.vfs_cache_pressure = 100 #(default)
vm.dirty_expire_centisecs = 1500
vm.dirty_writeback_centisecs = 1500
vm.page-cluster = 0
vm.dirty_expire_centisecs
& vm.dirty_writeback_centisecs
Reduces large sudden writes by flushing dirty pages more frequently (15 seconds) in smaller batches, preventing big I/O spikes.
vm.page-cluster=0
Ensures that when swap is needed, pages are read in smaller chunks. (default 3, higher means more I/O)
These help to reduce large sudden writes by spreading them out more evenly, which is especially useful for HDDs to avoid I/O bottlenecks.
Also apply advice here:
Reduce logs they write frequently, etc. Be careful. Apply all of these at your own risk and responsibility.
I’ve been following the zram discussion for a while now. Never used zram, does it really do that much for everyday use or rather for special use cases (e.g. VMs)?
If you use more than 90% of installed RAM or, if you have non-zero value for swap “used” it’s worth checking out. If you have slowdowns and freezing during high swap “used” then it will improve that. Check the table above.
Okay, changes made. Advice appreciated, thank you. I will be giving the other article some time soon. It looks like there is some information there about nvmes and other resources, I think it will work out for me to test out these tweaks on this machine with the HDD. I think I can see how tweaks like this could help my other machine using nvme. I currently have 16G RAM on that machine, but I need to use as much as I can for a VM. After experimenting with this so far it made me think, I can maybe utilize this to maximize efficiency on my other machine since I want to use RAM as heavily as possible.