375
ZRAM is insane (www.kernel.org)
submitted 1 year ago* (last edited 1 year ago) by wolf@lemmy.zip to c/linux@lemmy.ml

I got a cheap netbook style laptop for traveling some weeks ago (HP Stream 11" with 4 GB of RAM and a N4120). Didn't expect much more from this hardware than opening a few browser tabs and doing some retro gaming via Steam.

Shared RAM with graphics card means that 3.64 GB of RAM are effectively usable for the OS. This was even too little RAM to open a handful of tabs w/o having tabs being unresponsive for seconds sometimes in a very annoying way. Another thing which made trouble was the Wifi - I guess it went into power saving, was swapped and didn't load fast enough to provide a good experience. (Of course I wasted an hour checking for Wifi drivers/support.)

In short: Even for my low expectations for this laptop it was an underwhelming experience.

First step was to look at my vm.swappiness and set it to 10, which already helped, but still the machine had hiccups and annoying timeouts.

In a last, desperate effort I enabled ZRAM on the laptop... and literally WTF: Saying it is a night and day difference doesn't do the experience justice. Typing this words now on the Stream, which I use exactly the same way as my much more beefy other machines (my next worst computer has 8G of RAM and an Intel Core i3), browsing with 10 open tabs, e-mail client open on another virtual desktop... it is crazy, it makes the Stream fun to use and I use it at home for everything which isn't heavily CPU/IO bound.

What surprised me the most: No hiccups, no timeouts and it even fixed the Wifi issues on this little machine. Didn't expect this would be possible, especially with a N4120 and 3.64 GB of RAM.

In short, my laptop changed from not even reaching my low/realistic expectations to being my favorite technical purchase of the last years, thanks to ZRAM.

Besides making this a ZRAM appreciation post, I really want to spread the word about it. Especially for old hardware and limited RAM situations, IMHO it should be the first thing which comes to mind/is recommended.

Fedora and PopOS use it by default, so it is well tested and should IMHO again, be a default at least for desktop setups.

Give it a try - supposedly it even improved the experience on much more beefy computers for gaming etc.

you are viewing a single comment's thread
view the rest of the comments
[-] Rescuer6394@feddit.nl 8 points 1 year ago* (last edited 1 year ago)

Isn't zswap enabled by default?

having zram + swap on disk isn't the same as having zswap + swap on disk? the difference should be only that zram show as a swap device while zswap does not.

having only zram, you are still confined by the total ram you have. idk how the average compression ratio is, but you can gain 1.5x ram max. to get more, you need a physical swap device.

is there an advantage of using zram instead of zwap? when you still have a physical swap with lower priority.

bonus question: What if I use all 3 of them? would this just be redundant?

[-] TheWoozy@lemmy.dbzer0.com 7 points 1 year ago

I used zram + swap for years. I dedicated 25% of my memory to zram. The problem is that zram would get filled with infrequently used data, and disk swap would get the frequently used data. Once that happens everything slows down.

Zswap tries to fix that be creating a compressed swap buffer in memory. Older/less used data will get written to disk, but fresh/frequently used data will stay in the compressed ram buffer. That's my understanding, at least. I don't remember how to query Zswap usage stats.

[-] wolf@lemmy.zip 5 points 1 year ago

I am using Debian 12 and I am pretty sure zswap is not enabled by default.

With zstd the compression ratio is better than 3 in all experiments I saw. (Of course you won't get this numbers for random/encrypted data). Right now I have 12MB compressed to 2MB via ZRAM (fresh reboot) which is a factor of 6.

So, taking 3 as factor learned from others and my experience, with 1.8 GB of ZRAM I can store 5.4 GB of memory, adding the 1.8 GB of usual RAM, I end up with 7.2 GB of RAM which is double my 3.6 GB RAM I started with. (All this is backed by 4 GB of physical SWAP.)

Sorry, I cannot really answer your questions concerning zswap vs ZRAM, I just follow the herd and trust that the Fedora people usually have good reasons for their technical choices and are deploying ZRAM by default for several years now.

[-] spiffeeroo@programming.dev 4 points 1 year ago

Arch and RHEL enable zswap by default. Regular x86_64 Ubuntu and Debian do not have zswap nor zram enabled by default.

[-] secret301@sh.itjust.works 2 points 1 year ago

For me zram made my system more responsive but the oomd didn't really count it as more ram so sometimes things would get killed earlier than I'd want. ZRAM + regular swap fixed this unless an application was getting really greedy. I kinda wanna try all three now

[-] Rescuer6394@feddit.nl 5 points 1 year ago* (last edited 1 year ago)

check if zswap is already enabled:

zgrep CONFIG_ZSWAP_DEFAULT_ON /proc/config.gz

https://wiki.archlinux.org/title/zswap

this post was submitted on 02 Sep 2023
375 points (100.0% liked)

Linux

48687 readers
254 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS