zram-generator icon indicating copy to clipboard operation
zram-generator copied to clipboard

RFE: default settings for all zram devices

Open Mek101 opened this issue 3 years ago • 11 comments

Having to specify a [zramN] section for each CPU core can extremely redundant on machines with many cores. Would it be possible to add a [default] section, to set the configuration of all devices, unless it's specifically overridden by the section of the single device?

Mek101 avatar Oct 22 '21 09:10 Mek101

Not too much related to the issue itself, but I'm curious…

section for each CPU core

What's the reason for this?

ignatenkobrain avatar Oct 22 '21 12:10 ignatenkobrain

I think they're referring to old versions of Zram that didn't do multi core (fixad as of 3.15). docs.

vilgotf avatar Oct 22 '21 15:10 vilgotf

I'm talking about the structure of zram-generator config file

Mek101 avatar Oct 22 '21 15:10 Mek101

Sure, but beside the RFE (which I find rather superfluous, seeing as printf '[zram%d]\nzram-fraction = 0.017\n\n' $(seq $(nproc)) > /etc/systemd/zram-generator.conf works), why do you want to generate 112 zram devices instead of, like, just one 112 times as large?

nabijaczleweli avatar Oct 22 '21 15:10 nabijaczleweli

What


Sorry mobile formatting made everything illegible

Mek101 avatar Oct 22 '21 15:10 Mek101

(which I find rather superfluous, seeing as printf '[zram%d]\nzram-fraction = 0.017\n\n' $(seq $(nproc)) > /etc/systemd/zram-generator.conf works

Works until you have to update something and you have 1 or 2 devices with a different configuration, then you have to copy those different configs away, generate a new file file and repatch it

why do you want to generate 112 zram devices instead of, like, just one 112 times as large?

Parallelism

Mek101 avatar Oct 22 '21 19:10 Mek101

Is this, like, measurable? I don't really believe you're gonna get more/better/faster processing by doing smaller batches.

nabijaczleweli avatar Oct 23 '21 14:10 nabijaczleweli

From the kernel docs quoted by @vilgotf:

Regardless of the value passed to this attribute, ZRAM will always allocate multiple compression streams - one per online CPU - thus allowing several concurrent compression operations.

keszybz avatar Oct 24 '21 09:10 keszybz

To summarize: the original motivation was apparently to have multiple devices to allow parallellization, which actually is implemented internally in the kernel. Nevertheless, the approach to have default settings could be useful to some extent, e.g. for mount points. But I would like to see some actual use case before adding new functionality.

keszybz avatar Nov 02 '21 11:11 keszybz

I hijack this issue with a related thing.

I'm quite lazy and stupid, so I just copied mount-point = /var/tmp from the README when I specified mount-point in my zram-generator.conf. I suspect that this caused illegal permissions to be set to /var/tmp. It broke my flatpak (and probably many other things). Later I realized that the high quality hack actually applied to me. I don't know much about systemd and generators (nor am I eager to learn), I just wanted to get zram up and running ASAP and zram-generator seemed easy to use, plus I like Rust.

It might be wise to specify some different mount-point in the README. Why is /var/tmp being used? I bet I'm not the only one being lazy and stupid.

610th avatar Jan 07 '22 11:01 610th

This is a very good point (and /var/tmp is (supposed to be :v) guaranteed-persistent across boots). I've updated the README to point at /var/compressed instead of /var/tmp in the referenced commit.

nabijaczleweli avatar Jan 07 '22 14:01 nabijaczleweli