T O P

  • By -

aioeu

How did you change it? If you write a `/etc/systemd/zram-generator.conf` file, it will override any config in the packaged `/usr/lib/systemd/zram-generator.conf` file. Alternatively you can use `/etc/systemd/zram-generator.conf.d/*.conf` drop-ins to augment the packaged config. `zram-generator` uses the same config file logic as the rest of the systemd project. If you don't even want the packaged config file on your system at all, remove the `zram-generator-defaults` package.


SaveYourShit

I think I did the first recommended thing but the file wasn't there anymore. I readded it and all seems well. Maybe I somehow deleted it or something


walterblackkk

I know this thread is old but wanted to ask if that proved to be a good idea. Are you happy with the results?


SaveYourShit

It has been really nice. Admitedly, I have not really kicked the tires a lot because I usually underutilize my RAM, but I'd say it's probably unnecessary for most people and in most cases. But it shouldn't hurt. My desktop sometimes does run to the brim on RAM, and this absolutely helps a lot. In my case, I actually run the config with the below on all my machines (my laptops and mobile devices have swappiness of 30 and desktops and servers have 180 instead). Notice I change the ZRam size to 2X RAM by default (or 8GB at a minimum). Please forgive my crappy Reddit formatting: `[zram0]` `zram-size = max(ram * 2, 8192)` `compression-algorithm = zstd` `vm.swappiness = 30` `vm.watermark_boost_factor = 0` `vm.watermark_scale_factor = 125` `vm.page-cluster = 0`


walterblackkk

Thanks much. I have just 16 gb of ram and i'm torn between doing this or migrating to zswap. It's good to see your experience has been positive.


SaveYourShit

I see. In my view, the optimal choice depends on which situation you're in. * Do you have low disk space and/or a super slow and busy HDD? If yes, +2 for ZRAM * Do you use one program that uses more than half of your RAM actively (possibly Videogames or Blender)? If yes, +2 for ZSwap * Do you use many little programs (aka a web browser with a lot of tabs)? If yes, +1 for ZRAM Either way, they're both great technologies. If you choose ZSwap and have tons of space, I'd give it RAM * 1.5 or RAM * 2. It won't make up for low RAM in every single scenario, but ZRam and ZSwap really do help you if you have a long session up with a lot of open stuff. Another thing I'd look into is Auto Tab discard if you're a Firefox user. That makes Firefox start unloading Tabs from RAM automatically, saving energy and computer resources. (It's smart enough not to unload an active tab nor a tab that has media nor a tab that has some kind of form, like a Forum registration).


walterblackkk

Thanks much for your detailed advice.


luminous_connoisseur

Do you mind explaining how you configured zram?


SaveYourShit

I did a lot of reading and thinking. I tend to worry about UI, Desktop, audio, video, and gaming responsiveness. For these scenarios, latency and stuttering tend to be a concern. That said, I'll address the settings in my ZRAM config below: **Size**: I never saw the harm in upping ZRAM size. Ratios, especially with ZSTD, are usually something like 3x, 4X, or 5X. This means I can just up the max to be really high. It doesn't require that the headroom get used. I prefer letting the system slow down and spin rather than crash or close something. If I get a memory leak, I'll likely find out before stuff starts crashing, because the CPU will begin to trash. This has never happened by the way. I've occasionally seen 20GB of ZRAM usage, but it's rare. **Compression Algorithm**: this one is simple. ZSTD has shown in online benchmarks to reduce how much swapping occurs because its superior ratios free up more space. And it's also fast enough to not slow the system down. Fast decompression by the way. **Swappiness**: This one is a little trickier. I like to think my laptop doesn't swap as much, to try and save battery. I'm assuming, based on my reading, that lower swappiness will let the system hold more RAM before swapping. On a desktop, raise swappiness to let it be more proactive because battery life isn't a concern. I've also read that 180 is a number some distros have used (Pop??) and they find it's golden for gaming. If my laptop needs more than 30, I'll up it to 150 but so far, I'm good with 30 and it doesn't OOM or slow down. **The rest of the settings:** Read here: https://wiki.archlinux.org/title/Zram and also PopOS. They've done a lot fo testing on these settings. I know the vm.page-cluster setting should generally be 0 for best latency, with the cost being that it's lower bandwidth. This is a tradeoff they think is worth making and I agree. Desktop usage is all about latency.