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

Allow multiple whitespace-separated compression-algorithm=s, and give the ones after the first one to /recomp_algorithm

Open nabijaczleweli opened this issue 1 year ago • 1 comments

Ref: https://github.com/systemd/zram-generator/issues/178#issuecomment-2361314574

I've tested the error case, @OmegaSquad82 needs to test the "actually setting it" case.

A config like

compression-algorithm = a b c

was previously "compress with a b c" (naturally invalid) and is now "compress with a, recompress with b then c"

nabijaczleweli avatar Sep 20 '24 21:09 nabijaczleweli

Thank you so much I'll test it as soon as I can.

OmegaSquad82 avatar Oct 21 '24 16:10 OmegaSquad82

Rebased

nabijaczleweli avatar Nov 20 '24 15:11 nabijaczleweli

Sorry for the delay. I got the notification and then forgot to look at this.

Code-wise this looks good, but I'm not convinced that this is the right interface. The kernel allows additional parameters to be specified, for example type=huge_idle max_pages=42 algo=zstd. If we allow just a list of algorithm types to be specified, it will be awkward to attach any options to this.

I wonder if the interface shouldn't be inverted, allowing the user to list each "recompression level" separately, with a list of options. But I'm not sure how to express this concisely.

keszybz avatar Nov 20 '24 15:11 keszybz

I didn't really notice this because the interface is kinda iffy (/recomp_algorithm takes no options, /recompress takes options for the recompression subsystem or for a single algorithm, depending on the calling convention).

I can't think of a multi-key system that'd be any good. Maybe

compression-algorithm = a b(type=huge,threshold=1000) c (threshold=3000)

for

echo a > /sys/block/zram0/comp_algorithm

echo algo=b    priority=1 > /sys/block/zramX/recomp_algorithm
echo type=huge threshold=1000 priority=1 > /sys/block/zramX/recompress

echo algo=c    priority=2 > /sys/block/zramX/recomp_algorithm

echo threshold=3000       > /sys/block/zramX/recompress

?

nabijaczleweli avatar Nov 20 '24 16:11 nabijaczleweli

That seems pretty nice.

keszybz avatar Nov 20 '24 17:11 keszybz

Added

nabijaczleweli avatar Nov 20 '24 18:11 nabijaczleweli

As a side-effect we also support /algorithm_params (it was easier than not doing that). Needs to be tested by submitter.

nabijaczleweli avatar Nov 20 '24 18:11 nabijaczleweli

LGTM. Let's wait for feedback from the reporter.

keszybz avatar Nov 20 '24 21:11 keszybz

OK, let's do this. It'd be good to some testing on a real system, but we can do this later.

keszybz avatar Nov 21 '24 14:11 keszybz

LGTM, have tested few parameters. Seems to work as expected. Thank you both.

OmegaSquad82 avatar Nov 24 '24 05:11 OmegaSquad82