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

[dev] consider zram / zswap #12

Open
ihrapsa opened this issue Jun 24, 2021 · 2 comments
Open

[dev] consider zram / zswap #12

ihrapsa opened this issue Jun 24, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@ihrapsa
Copy link
Owner

ihrapsa commented Jun 24, 2021

This is a kind of swap that resides on RAM in a compressed form. It will make swapping and ram usage more efficient and it will increase the lifespan of the sd card as well.

Resources:
https://openwrt.org/packages/pkgdata/zram-swap
https://openwrt.org/packages/pkgdata/kmod-zram
https://forum.openwrt.org/t/retracted-compressed-memory-this-project-is-officially-retracted-take-note-about-its-future/49076
https://forum.openwrt.org/t/mounting-swap-on-zram-with-discard/48451
https://forum.openwrt.org/t/possible-to-use-zswap/8916/6
https://stackoverflow.com/questions/24467604/swapon-failed-trying-to-enable-zram

Interesting read:
https://haydenjames.io/linux-performance-almost-always-add-swap-part2-zram/
https://ikarus.sg/using-zram-to-get-more-out-of-your-raspberry-pi/

Building:
kmod-zram kmod-lib-lzo (this is selected by default) kmod-lib-lz4 kmod-lib-zstd
Kernel config:
zswap zbud z3fold

Enabling zswap:
either:
opkg install zram-swap - will allocate half of ram size to zram0
echo 1 > /sys/module/zswap/parameters/enabled; in /etc/rc.local (if not enabled by default in kernel)
or

##inside rc.local

swapoff /dev/zram0;
echo 1 > /sys/block/zram0/reset;
echo lzo > /sys/block/zram0/comp_algorithm              
echo 60M > /sys/block/zram0/disksize;
echo 1 > /sys/module/zswap/parameters/enabled;       #seems to be enabled by default
mkswap /dev/zram0;
swapon -p 5 /dev/zram0;

#echo lz4 > /sys/module/zswap/parameters/compressor;
#echo z3fold > /sys/module/zswap/parameters/zpool;
#echo 20 > /sys/module/zswap/parameters/max_pool_percent;
#echo 75 > /proc/sys/vm/swappiness;

@ihrapsa ihrapsa added the enhancement New feature or request label Jul 20, 2021
@thomsonOZ
Copy link
Contributor

Updated to my KlipperWRT, will review the performance in next few days.

@ihrapsa
Copy link
Owner Author

ihrapsa commented Sep 6, 2021

Updated to my KlipperWRT, will review the performance in next few days.

hmm... Thanks, but actually I configured KlipperWrt as default with zram-swap. I tried experimenting with different compression algorithms and ram sizes as well as zswap (which seems to be a more efficient way of using ram) but that zram-swap package/script configures everything depending on the amount of ram you have and I stuck with that. If you manage to get better performance with a different configuration please share 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants