Living with the Office 2016 interface ►
◄ Project Zebra: We are not shipping your machine! (Xubuntu testing)
This entry is part of my Project Zebra series covering migration to Linux for personal computing use.
This entry is mainly going to be about memory usage. The TL;DR version is it seems AdBlock Plus was sucking up an unreasonable amount of it, but that doesn't mean it isn't worth reviewing other settings and tweaks relating to hibernation, swap usage and monitoring. It could very much be.
I've got 8GB of RAM in my 2013 era desktop, which isn't a huge amount by current standards, but systems with less are still common. I like to hibernate rather than shut down, so writing that RAM to disk isn't amazingly fast (and I'd like to use the tuxonice kernel patches, which don't flush caches and allow a system to resume with everything restored, but previous experiences with this involved instability). It looks very unlikely that it'll ever get merged into the mainstream kernel, unfortunately – https://github.com/NigelCunningham/tuxonice-kernel/issues/39
Mostly for my own future reference, my /etc/uswsusp.conf is a fairly standard
snapshot device = /dev/snapshot resume device = /dev/disk/by-uuid/[uuid goes here] image size = 10737418240 compress = y threads = y shutdown method = platform early writeout = y RSA key file = /etc/uswsusp.key #splash = y #encrypt = y #compute checksum = y #suspend loglevel = 2
Note from the future: although I had uwsusp installed, it wasn't being used by systemd. In order to use uswsusp and s2disk with systemd you need to edit systemd-hibernate.service. Personally I've decided to try to work with the normal kernel swsusp functionally and create a .conf file for systemd to use 'shutdown' mode.
I'd also noticed (after turning on the System Load Monitor panel item to monitor) that after a few hours I was quite often hitting swap with relatively few browser tabs open, which then caused things to become unresponsive when called upon. It's possible to flush swap by turning it off and back on again (sudo swapoff -a && sudo swapon -a) but very slow.
Ubuntu doesn't ship with swap usage minimised in order to adequately support a range of hardware, so it's worth reducing the "swappiness" setting and on modern systems you can use a value of 1 to mean "minimum" rather than 0 since that actually means "turn swap off" these days. I'd already set it to 15 in October, but figured it was worth setting to the minimum.
https://askubuntu.com/questions/103915/how-do-i-configure-swappiness
More importantly, use efficient software that doesn't hog memory in the first place. So the biggest part of my efficiency drive was ditching AdBlock Plus in all browsers and using uBlock Origin instead, which made a huge difference (and seems faster!) Before, closing all open tabs after using Chromium for a while could easily leave it using a gig of RAM.\
Third party testing seems to bear out the memory usage, though doesn't comment on the freeing; https://www.raymond.cc/blog/10-ad-blocking-extensions-tested-for-best-performance/view-all/
I'd agree on the roughly double usage difference, as my system is hovering at 40% in use now versus a previously consistent 80% plus. Like I say, it's a huge difference.
The other big win came from googling some stuff on rolling distros and stumbling upon configuration tips for disk caching. Under default settings if you, the user, do something that's very file I/O intensive then Linux will give priority to it. But actually if you're running backups you can probably stand to have them perform a bit slower but leave more resources for those web browser tabs, email client and other software you've got open.
In /etc/sysctl.d/99-sysctl.conf set vm.vfs_cache_pressure=50 then reboot or use sysctl -p
I was wondering if this would make FreeFileSync batch jobs leave the system more responsive. Apparently yes. Lots. It makes such a big difference that it's disappointing Ubuntu and derivatives don't (as far as I know) either default to an all uses desktop-friendly setting or ask during install. I suppose some people might not run into it with regular and/or large copy or file access operations, but letting those monopolise system resources should at least be subject to whether users are logged into a desktop environment with an interactive session, shouldn't it?
Running with those changes for a month or so, performance is very nice indeed. To keep an eye on how nice, I wanted a panel widget indicator. Now, the default ones for Xfce don't seem to show the current percentage of memory occupied (bars yes, as text no) but there is a Generic Monitor widget that lets you put the output of a script onto the panel. It's a bit of a shame you can't specify a command to run when clicking on the widget, but it's fine for the purpose of displaying info. (Memo to self – this might make a good "first coding project" on Linux).
With a simple tweak, Arne's script there will give a percentage rather than just the figures:
#!/bin/sh meminfo=`free -m | grep 'Mem:'` used=`echo $meminfo | cut -d" " -f3` total=`echo $meminfo | cut -d" " -f2` cached=`echo $meminfo | cut -d" " -f7` really_used=`expr $used - $cached` percent=$(echo "($used / $total * 100)" | bc -l ) show=$(echo "(($percent+0.5)/1)+1" | bc) echo "$show%"
A comment on the above: bash isn't itself a fully featured coding language and doesn't do floating point arithmetic, which is a weird concept coming from the languages I use the most, so a workaround is needed to round the percentage up. The -l parameter means we use bc's math library to get a float result, whereas it isn't needed for the rounding up bit.
https://askubuntu.com/questions/179898/how-to-round-decimals-using-bc-in-bash
Rounding up seems to mirror the approach taken by Xfce's task manager.
💬 Comments are off, but you can use the mail form to contact or see the about page for social media links.