LibreELEC.tv
LibreELEC.tv copied to clipboard
add zram support
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.
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.
https://haydenjames.io/linux-performance-almost-always-add-swap-part2-zram/
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.
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.
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.
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).
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.
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
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.