LibreELEC.tv icon indicating copy to clipboard operation
LibreELEC.tv copied to clipboard

add zram support

Open lrusak opened this issue 2 years ago • 9 comments

This add support for using zram in LibreELEC https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html

I decided to use the simple script here https://github.com/foundObjects/zram-swap It only needs zramctrl from util-linux (added in this PR) and mkswap from busybox (already included).

The default algorithm is LZ4 as it's less cpu heavy.

Testing was limited and I don't have any benchmarks.

I added the kernel_options that are required and adjusted the Generic and RPi4 kernel configs.

lrusak avatar May 18 '22 23:05 lrusak

I am not sure (I have no idea about zram) we want zram or not afaik @chewitt had some words about it.

Otherwise pls add the needed configs for the other devices too.

CvH avatar May 19 '22 10:05 CvH

https://haydenjames.io/linux-performance-almost-always-add-swap-part2-zram/

lrusak avatar May 27 '22 22:05 lrusak

in general its is a good idea to have zram (swap) on all low RAM units like all pi. so i vote for adding it (at least) to all low RAM units. i am using zram on all kinds of embedded os like openwrt, pfsense, small alpine vps, ....) and it serves well.

g6094199 avatar Aug 26 '23 12:08 g6094199

Coincidentally I have been researching zram support independently for another project and whilst there is surprisingly little in the way of case studies published what I have read appears to be unusually positive with no downsides.

Given our userbase is almost universally low in RAM resources I vote we pull this.

nomandera avatar Aug 31 '23 06:08 nomandera

This add support for using zram in LibreELEC https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html

Great! This is a really nice addition, thanks!

I decided to use the simple script here https://github.com/foundObjects/zram-swap It only needs zramctrl from util-linux (added in this PR) and mkswap from busybox (already included).

Note that zramctl is not needed at all. Zram can be configured exclusively thorugh sysfs. Of course, the script needs to be changed accordingly.

The default algorithm is LZ4 as it's less cpu heavy.

I'd personally choose zstd as the default, as it provides the best speed/ratio tradeoff. If lz4 is to be the default, please also make zstd available for those who prefer it.

rsalvaterra avatar Nov 16 '23 17:11 rsalvaterra

also a very good zram wiki page can be found at arch linux.

i also vote for a user chooseable compression algo and additionally zram size (50% of 1GB RAM [-> ~2GB compressable data with zstd -> 2,5GB usable RAM space in sum] is nice but up to 100% [and more is possible] depending on the platform you run on, see wiki article above).

g6094199 avatar Nov 16 '23 21:11 g6094199

LibreELEC isn't a general purpose distribution so configuration will likely be limited.

The purpose of support is to benefit all the projects as a whole.

Yes zstd is possibly a better choice than lz4.

lrusak avatar Nov 16 '23 22:11 lrusak

Yes zstd is possibly a better choice than lz4.

On beefyx86 hardware maybe, but likely not on low-end ARM - lz4 has faster compression speed than zstd and if people want to use it for swap (for whatever reason) this matters

HiassofT avatar Nov 16 '23 22:11 HiassofT

Yes zstd is possibly a better choice than lz4.

On beefyx86 hardware maybe, but likely not on low-end ARM - lz4 has faster compression speed than zstd and if people want to use it for swap (for whatever reason) this matters

That's probably why I chose lz4 in the first place.

I would actually prefer to use systemd-zram-generator but it's built in rust so would add a bit of build time to the overall build as the rust toolchain is required. That may be needed in the near future anyways as other rust components are added.

lrusak avatar Nov 18 '23 22:11 lrusak