I posted about ZRAM before, but because of my totally unscientific experiment, personal experience and the common question, which Linux to run on potatoes…
First, I tweaked ZRAM for my use-case(s) on my hardware, this settings might not be right for your use-cases or your hardware!
My hardware is a netbook with an Intel Celeron N4120 and 4G RAM (3.64G usable).
When I recently played around with ZRAM settings, it felt like the zstd algorithm made my netbook noticeable more sluggish. It never felt sluggish with lzo-rle or lz4.
In a totally unscientific way, I rebooted the computer several times (after a complete update of everything), executed my backup script several times, and measured the last 3 executions. (Didn’t touch the netbook during the runs.) The bottleneck of the backup script should not be ZRAM, but it is some reproducible workload that I could execute and measure.
To my surprise, I could measure a performance difference for my backup scripts, lz4 was consistent fastest in real and sys time w/o tweaks to vm.page-cluster!
Changing the vm.page-cluster to 0 further enhanced the speed for lz4, but with this one toggle, all of a sudden zstd is as fast as lz4 in my benchmark and runs with a more consistent runtime.
Changing the vm.swapiness to 180 decreased the speed for lz4, to my surprise.
Obviously the benchmarks are not 100% clean, although the trend for my workload was clearly in favor of lz4/zstd.
To the best of my knowledge, I ended up with nearly the same tweaks that Google makes for ChromeOS:
-
zstd as algorithm (I think ChromeOS uses lzo-rle)
-
2*ram as ram-size
-
vm.page-cluster = 0
-
Install/enable systemd-oomd
vm.page-cluster = 0 seems like a no-brainer when using ZRAM, on my netbook it is literally the switch for ‘fast’ mode.
In summary: ZRAM makes my netbook totally usable for everyday tasks, and with tweaking the above settings I run Gnome 3, VS Code and Firefox/Evolution w/o trouble. (Of course, Xfce4 on the same machine is still noticeable more performant.)
I wonder if we should recommend to people asking for a lightweight distribution for potatoes to check/tweak their ZRAM settings by default.
Anyway, I would be interested in experiences from other people:
- Any other tweaks on my ZRAM or sysctl for potatoes which made a measurable difference for you?
- Any other tips to improve quality of life on potatoe machines? (Besides switching to KDE, LXDE, Xfce, etc. ;-))
- Any idea why vm.swapiness didn’t improve my measurements? To my understanding it should basically have cached more of my files in ZRAM, making the backup run faster. It even slowed the backup down, which I don’t understand.
Edit:
- zstd beats lz4 on my machine for my benchmark when vm.page-cluster=0!
Thank you for your answer and your insights.
In my unscientific tests, sysctl/vm.page-cluster made a measurable difference (15% faster when setting it to 0), and it seems everyone else (PopOS, ChromeOS) tweaks at least this setting with ZRAM. I would assume the engineers at PopOS/ChromeOS also did some benchmarks before using this settings.
Now I really would be interested, if you would measure a difference on your 1gb potato SBCs, because IMHO it should even have a bigger impact for them. (Of course, your workload/use cases might make any difference irrelevant, and of course potato SBCs have other bottlenecks like WiFi/IO, which might make this totally irrelevant.
I don’t have my potato lab up and running at the moment but my android devices and sff hypervisors are all using page-cluster=0. That’s the default setting on android and ChromeOS I think, I probably tuned it on the proxmox machines years ago and forgot about it.
Edit: that’s basically swap read ahead right? Ie: number of pages to read from swap at a time.
To my understand it is swap read-ahead, and the number is a power for the base 2. This means the default reads 2^3 = 8 pages ahead. According to what I read, the default of 3 was set in the age of rotating discs and never adapted for RAM swap devices.
Yeah, that’s my understanding of that sysctl too. If IOPS are cheap (and they are when dealing with ram or high IOPS NVMe) there’s no real point in performing extra read ahead.