What's new

zram and merlin

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

HRearden

Occasional Visitor
Is it possible to get zram working with this firmware as a way to not wear out a flash drive and squeeze a bit more out of and into the memory?

rearden
 
No, zram doesn't exist in the kernel used on these devices.
 
Kernel there - I'd have to check - but I think it does support ZRAM if built... used to be referred to as compcache.. Look at kernel config - it's a boolean if present.

Challenge is that RAM is so limited here, so putting swap into RAM might not be a good thing.
 
It was merged in mainline with 3.14.
 
Thank you for your reply.
If this would be effective on this device, It would be useful to having the required modules compiled in considered in a future release.
rearden
 
If this would be effective on this device, It would be useful to having the required modules compiled in considered in a future release.
It seems unlikely this would be of any benefit. If I understand correctly it is primarily used for performance reasons on systems that place a swap file on disk or flash storage. AFAIK Merlin's firmware doesn't use any swap space, and when users add it themselves they place it on an external flash drive. The performance gains would come at the expense of reducing the amount of available RAM and increasing the CPU load, on devices that are already hampered by a lack of both.

Just my 2 cents.:)
 
Last edited:
ZRAM can have a performance impact on memory limited devices - the primary benefit is to reduce write pressure on flash, but that benefit does come at a cost.

I'd say the most common low-end use-case for ZRAM (along with KSM) is Android on the low-end phones..
 
ZRAM is a trade between RAM size and CPU performance, which is quite useless on weak embedded CPUs in most cases.
ZRAM can have a performance impact on memory limited devices - the primary benefit is to reduce write pressure on flash, but that benefit does come at a cost.
There's an idea to use some small "cloud storage" (file container?) on USB-less devices, so ZRAM was implemented on some local brand recently.

I'll let you know how ZRAM works after couple of months.
 
Last edited:
Google had decent luck with their Project Svelte where ZRAM/KMS was used with dual core and 512MB of RAM and still had decent performance. They use a similar approach with ChromeOS.

There are limits, as mm has to scan pages to find candidates to page out to the compressed RAM disk, and there's the obvious overhead of compressing/expanding the data to the page file..

That being said - I've done this on dual/quad cortex A53's, but also working with more RAM to start with (1GB) - goal there was basically to keep swap from hammering flash (eMMC in production, SDcard on dev platforms).

It's easy enough to play around with on RPi's Raspbian... here's a short shell script to enable ZRAM

(this is a bash script, so need to add the shebang bash -- can't add it here as cloudflare gets upset) - do this as a privileged user (root or sudo) - this script enables the ZRAM kernel mod, and sets up the params for a 512MB ZRAM page file.

Code:
# Raspberry Pi ZRAM script
# Tuned for quad core, 1 GB RAM models
# put me in /etc/init.d/zram.sh and make me executable
# then run "sudo update-rc.d zram.sh defaults"

modprobe zram
echo 3 >/sys/devices/virtual/block/zram0/max_comp_streams
echo lz4 >/sys/devices/virtual/block/zram0/comp_algorithm
echo 268435456 >/sys/devices/virtual/block/zram0/mem_limit
echo 536870912 >/sys/devices/virtual/block/zram0/disksize
mkswap /dev/zram0
swapon -p 0 /dev/zram0
sysctl vm.swappiness=10
 
ZRAM can have a performance impact on memory limited devices - the primary benefit is to reduce write pressure on flash, but that benefit does come at a cost.
I played around with it on my desktop computer, for the very same reason you describe - to reduce wear and tear on my new SSD.

The cost compared to when not using zswap/zram was freezes and stuttering when using swapspace, and a long freeze when purging non-used swapspace. This occured even when using lzo or lz4.

These are the only benchmarks I could find: http://www.hecticgeek.com/2013/11/zswap-responsiveness-ubuntu/

I'd be very interested if someone could present any benchmark numbers on a scenario where it's actually useful.
 
Zswap by itself might be hitting the on-disk swapfile - it compresses the pages there...

Nice writeup here on Zram/Zswap/Zcache and how they affect each other...

https://askubuntu.com/questions/471912/zram-vs-zswap-vs-zcache-ultimate-guide-when-to-use-which-one

FWIW - with Ubuntu 14.04/16.04 - zram-config is in the package repos - so just install it, and it'll make some rational defaults.

And with vm - there's some sysctl values that can impact - vm.swappiness set too aggressive can lead to excessive swapping... I would start with 10, which only swaps if absolutely needed.

Where Zram can be handy - if one has a lot of ram to start with...
 
An interesting discussion. My goal is to reduce wear on the usb flash drive and to "bump up" the effective memory before the fairly slow and limited life flash drive enters into the swap game, given a reasonable cpu cost.
 
An interesting discussion. My goal is to reduce wear on the usb flash drive and to "bump up" the effective memory before the fairly slow and limited life flash drive enters into the swap game, given a reasonable cpu cost.

Two problems however...

Already confirmed that the kernel included in the GPL drop that is used in the current RMerlin-ASUSWRT builds does not have the needed code to enable Zram, and the other is that one needs a fair amount of memory to start with - 256MB probably would not benefit from Zram.

Outside of running entware/optware packages, the supplied memory is usually sufficient - as it should be - engineering/development there has sized things based on performance and applications, and to keep costs down, put in just enough.

Going back to the performance impact concerns - the Raspian folks were fairly resistant to enabling ZRam - it works ok on the quad core RPi2 and 3, but the same codebase has to support the older Pi1's, some of which only have 256MB of RAM... and performance issues were noted during high levels of use - such as running the Kodi media player for playback...

For those concerned about excessive writing to NAND/SD/USB Flash - one can always query the stats to see.

And just as a point of reference... this is with ZRam enabled - see script above.

Raspian Jessie on Pi3 - VNC'ed into the Pixel Desktop with Chromium Browser running...

Code:
SW Rev => 4.9.28-v7+ #998 SMP Mon May 15 16:55:39 BST 2017
FW Rev => May 15 2017 16:57:15
Copyright (c) 2012 Broadcom
version 9469ea3706e34c4de62f38a5008f69a429b4b43e (clean) (release)
===============
ARM Mem => arm=880M
GPU Mem => gpu=128M
===============
top - 15:41:40 up  5:17,  2 users,  load average: 0.63, 0.16, 0.09
Tasks: 167 total,   1 running, 166 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:    880556 total,   614112 used,   266444 free,    24220 buffers
KiB Swap:   626680 total,        0 used,   626680 free.   387116 cached Mem
 
Last edited:

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top