Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[Suggestion/Workaround]: Add ZRAM-swap to Desktopify for smooth web browsing/video #57

Open
pseudofunizer opened this issue Sep 16, 2020 · 0 comments

Comments

@pseudofunizer
Copy link

pseudofunizer commented Sep 16, 2020

( @flexiondotorg - in addition to my other two fix suggestions -- see: #55 and #56 -- here's something to look into for an enhanced desktop experience, esp. in Xubuntu.)

I don't know if this is a de facto solution to the web video playback issue, but at least it's a helluva workaround to a majority of the video sluggishness experienced in i.e. Chromium and Firefox.

As suggested in this article in particular:

Raspberry Pi Performance: Add ZRAM and these Kernel Parameters

See: https://haydenjames.io/raspberry-pi-performance-add-zram-kernel-parameters/

(Also mentioned in Hackaday: https://hackaday.com/2020/05/20/zram-boosts-raspberry-pi-performance/ )

I have now tested this on two 4GB models of Raspberry Pi4B's, running on Desktopify along with a few of my own tweaks on Xubuntu (Xfce4) with great results. I think especially the higher RAM models would benefit significantly from a ZRAM type ram cache/swap.


I initially installed the zram-tools and zram-config via apt:

sudo apt install zram-tools zram-config

Then, after tweaking around for a while I fetched the zram-swap Git repo and ran the script, overriding the initial tests I had made.

git clone https://github.com/foundObjects/zram-swap.git cd zram-swap && sudo ./install.sh

Note -- as stated in the Hackaday article: if you do take it for a spin make sure you stop and disable zram-config before switching, the two scripts won’t play nicely together.

Then, added the recommended zram-swappiness parameters to /etc/sysctl.conf as in the instructions:

sudo echo 'vm.vfs_cache_pressure=500' >> /etc/sysctl.conf
sudo echo 'vm.swappiness=100' >> /etc/sysctl.conf
sudo echo 'vm.dirty_background_ratio=1' >> /etc/sysctl.conf
sudo echo 'vm.dirty_ratio=50' >> /etc/sysctl.conf

(For tweaking around with these settings, please refer to the article at https://haydenjames.io/raspberry-pi-performance-add-zram-kernel-parameters/ )


After adding ZRAM, all browsing and other desktop activity became lightning-fast in comparison to what it had been. CPU usage also drops extremely low when playing non-fullscreen browser videos (YouTube), especially when the FKMS has been applied and the h264ify browser add-on is in use in Firefox / Chromium.

Since the world is far from being perfect, and Raspberry Pi4B is still a work-in-progress on many frontiers, if none of my previous tips improve the performance enough, I'd encourage users to settle for a 720p display resolution -- with the FKMS v3d acceleration + ZRAM swap, there's next to no dropped frames (10-30 frames out of ~10000+ total when playing longer videos, according to Youtube's video stats), even if you force the output to 1080p, which then downscales it to your 720p resolution.

Some may find no need to lower the display output resolution, as the performance difference in Xubuntu is significant regardless of the display resolution, esp. when using the tweaks mentioned in #55 and #56 in conjunction with the above mentioned script to configure zram-swap.

The performance enhancement applies also on 1920x1080/60 and 1920x1200/60 resolutions/refresh rates that I've tested. But, on a 720p resolution things work basically seamlessly with Youtube and other web video sources alike, and Youtube's "Auto" selection often chooses 720p as the output resolution on the RPi4B anyway.

As a side note: I've usually had the h264ify browser add-on installed on both Chromium and Firefox and have been switching it on and off to try out what works best with the fkms-v3d driver enabled. Mostly I've found the h264ify browser add-on beneficial and recommend using it on both Chromium and Firefox + making sure that both of the check-boxes ([x] Enable h264ify, [x] Disable 60p video) are ticked.

I would contend that tweaking zram-swap or a similar RAM cache solution would help out a lot in browser video playback issues, as in addition to enhanced video playback, it also makes other web browsing functionality way more reponsive.

More info on what different types of RAM caching possibilities (Ubuntu) Linux has can be found from i.e.: https://askubuntu.com/questions/471912/zram-vs-zswap-vs-zcache-ultimate-guide-when-to-use-which-one

If anyone has any suggestions on how to prioritize web browsers (Chromium/Firefox) on both Linux's side and in zram-swap, that might be a suitable workaround (for now) for smoothing web video playback and/or browser responsiveness even further.

Happy tweaking! :o)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant