mocaccinoOS / mocaccino

:musical_score: where magic happens
72 stars 7 forks source link

swap on Zram "by default" #64

Closed yusssufff closed 2 years ago

yusssufff commented 2 years ago

ISSUE: WITHOUT A DEFAULT "SWAP ON ZRAM", LIVE-USB OF MOCACCINO IS MORE HARD TO USE (NO SWAP), AND SLOWER ON LOW RAM SYSTHEMS AFTER INSTALL (SWAP ON DISK INSTEAD OF THE FASTER RAM)

There is a shift towards default " swap on zram " on many serious linux distributions these days: Fedora, EndlessOs, Calculate-Linux, AltLinux... There are various benefits for the company or home user. Mostly the system is much more reactive whenever starting to swap (swap on zram being much more reactive than swap on hdd or ssd).

What about joining the move, and enabling swap on zram " by default " in MocaccinoOS Desktop, like Calculate, Endless, Fedora, Alt...? It would be very helpful for the typical case of home users who have small RAM amounts available and experience regular swapping.

joostruis commented 2 years ago

please first define what you consider "LOW RAM" here. second, you can follow Gentoo documentation here : https://wiki.gentoo.org/wiki/Zram

yusssufff commented 2 years ago

Hi, Yes gentoo documentation can help. But as the aim is to offer something compiled 'out of the box', i think this could be included in Mocaccino... I think, from my experience with various machines, bellow 6GB RAM, zram comes-in very usefull. Under 4GB ram, zram is almost necessary for using GNOME.

joostruis commented 2 years ago

What you could do is investigate if you can make it to work at all as things are now. If something is missing let us know. Not sure if at this point there is a need to make this work "out of the box".

yusssufff commented 2 years ago

Well this usually works (see bellow). But i wonder if "outofbox" would be an option. This is what gentoo-based calculate-linux offers: vi /etc/systemd/system/zram.service [Unit] Description=Service ZRAM [Service] ExecStart=/usr/local/bin/zram-start ExecStop=/usr/local/bin/zram-stop Type=oneshot RemainAfterExit=true [Install] WantedBy=multi-user.target vi /usr/local/bin/zram-start #! /bin/bash # Charge le module modprobe zram # Compression ZSTD echo zstd > /sys/block/zram0/comp_algorithm # Taille 3Go echo 3221225472 > /sys/block/zram0/disksize # Création ZRAM mkswap -L zramswap /dev/zram0 # Activation ZRAM swapon -p 100 /dev/zram0 chmod +x /usr/local/bin/zram-start vi /usr/local/bin/zram-stop #! /bin/bash # Désactivation ZRAM swapoff /dev/zram0 # Reset du ZRAM echo 1 >/sys/block/zram0/reset # Suppression du module rmmod zram chmod +x /usr/local/bin/zram-stop systemctl --system daemon-reload systemctl enable zram systemctl start zram

yusssufff commented 2 years ago

https://www.linuxtricks.fr/wiki/zram-compresser-la-ram-au-lieu-de-swapper-sur-linux

yusssufff commented 2 years ago

following this process does work for me. but for Mocaccino to be able to be "out of the box" gentoo for regular users, that would be a great improvement to include it by default i think.

joostruis commented 2 years ago

I think if we add https://packages.gentoo.org/packages/sys-block/zram-init to layers/sys-fs users will also have the needed systemd service files available. That would at least make it a lot easier to configure it.

mudler commented 2 years ago

Hi, some work towards this has already started. At the moment we don't ship it by default, but you should be good to go to enable it by installing the zram profile and reboot:

luet install system-profile/zram

yusssufff commented 2 years ago

Its a very nice work. Very nice and easy to start! Maybe 32GB is a bit too much as default? Shouldnt we aim something more around 8GB?

joostruis commented 2 years ago

I just tested this on my old macbook and it works like a charm. I indeed notice I have 32GB swap. Perhaps we could tune this down to 8GB indeed!

joostruis commented 2 years ago

This is now fixed. After upgrade you must run etc-upgrade and reboot to apply this.

yusssufff commented 2 years ago

I think using zstd compression algorythm for zram would really be an improvement. Nearly same speed as the currently used lz4 (single thread), better speed with multi thread support and better compression ratio.