Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add zram support #6499

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

add zram support #6499

wants to merge 5 commits into from

Conversation

lrusak
Copy link
Member

@lrusak lrusak commented May 18, 2022

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.

CvH
CvH previously approved these changes May 19, 2022
@@ -0,0 +1,28 @@
# SPDX-License-Identifier: GPL-2.0-or-later
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-License-Identifier: GPL-2.0

@@ -4,7 +4,7 @@
PKG_NAME="image"
PKG_LICENSE="GPL"
PKG_SITE="https://libreelec.tv"
PKG_DEPENDS_TARGET="toolchain squashfs-tools:host dosfstools:host fakeroot:host kmod:host mtools:host populatefs:host libc gcc linux linux-drivers linux-firmware ${BOOTLOADER} busybox util-linux corefonts network misc-packages debug exfatprogs"
PKG_DEPENDS_TARGET="toolchain squashfs-tools:host dosfstools:host fakeroot:host kmod:host mtools:host populatefs:host libc gcc linux linux-drivers linux-firmware ${BOOTLOADER} busybox util-linux corefonts network misc-packages debug exfatprogs zram-swap"
Copy link
Member

@CvH CvH May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add it to the system-tools addons instead of shipping it by default ?

@CvH
Copy link
Member

CvH commented May 19, 2022

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 CvH self-requested a review May 21, 2022 07:51
@CvH CvH dismissed their stale review May 21, 2022 07:51

accidentally approved

@lrusak
Copy link
Member Author

lrusak commented May 27, 2022

@heitbaum heitbaum added LE 12.0 and removed LE 11.0 labels Jan 18, 2023
@g6094199
Copy link

g6094199 commented Aug 26, 2023

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.

@nomandera
Copy link
Contributor

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.

@rsalvaterra
Copy link

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.

@g6094199
Copy link

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).

@lrusak
Copy link
Member Author

lrusak commented Nov 16, 2023

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.

@HiassofT
Copy link
Member

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

@lrusak
Copy link
Member Author

lrusak commented Nov 18, 2023

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.

@CvH CvH added LE 13.0 and removed LE 12.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants