Recommended ZRAM setting for very limited ram Xiaomi R4A Gigabit device with memory shortage

I am wondering what would be the best possible zram settings for Xiaomi R4a Gigabit router that comes with 16MBFlash and 128MB RAM.

Since the flash size of the mentioned router is very limited I installed a couple of ipk into the RAM of the device.

That said the overview of the device memory is as follows

I am wondering what would be the optimal zram compression method and zram size for the current memory allocation and usage of the of the router.

Is there any advantage among the zstd,lzo,lz4 over other compression algorithms? (Router v23.05.2)
Based on the provided information on the image what would be the recommended ZRAM size?

Thanks

1 Like

Let's approach this from another angle...

128MB RAM is sufficient for many use cases. What are you running on your router that is consuming so much of your RAM?

Also, it looks like you've enabled swap... where does that map (internal flash memory, SD card/USB stick, SSD/HDD, etc)?

2.5 MB for proxy app that gets installed on the RAM.
OpenVPN process soon will consume more memory too.

Is that the space it requires in RAM, or the size of the binary/package? 2.5MB doesn't sound like all that much.

This will still fit... although you might consider WireGuard if your remote endpoint can support it (commercial VPN, work VPN, or road-warrior config).

You can run quite a bit in 128MB RAM. It's things like AGH and such that can take up massive amounts of memory... if you're not running those things, you shouldn't need to worry too much.

It's not quite clear what you're looking for, the r4a doesn't have USB-, sdhc ports or anything else to extend the main storage. As such, it really isn't a good device for a proxy (caching files to disk). The internal 16 MB flash leave you ~14 MB at your disposal, which is sufficient but not splendid for larger packages - and the 128 MB RAM put a cap on the extensibility from that angle as well...

While you can get quite far with this device for 'normal use', I fear you're asking a bit too much from it - yes, zram might help a little, but what you 'win' by installing proxy packages to RAM, you lose in RAM available for actually running your programs - and I don't really imagine the fun whenever you reboot the router. Maybe you should consider a hardware upgrade - or reduce your expectations in line with the abilities of your current router.

OpenWrt can be configured in quite convoluted ways (extrom, zram, nfs, hardware mods to replace flash/ RAM, etc.), but that doesn't mean you should use those options, as they all come with their own complications as well. For the most part those are more a relict of old times (when 4 MB flash and 16 MB RAM were common and nothing beyond 4/32 even on the market), but these days a device with 'sufficient' system resources (and USB) doesn't need to be expensive - but it makes your life considerably easier.

1 Like

You have 8 MB of files on the RAM disk (/var or /tmp), which is an unusually large amount: those subtract directly from available RAM.

The "cached" 30 MB is not committed RAM, it is merely buffered files from the disk. It will be immediately freed by the kernel if needed for something important.

Overall this does not look like RAM space is a problem.

The country that I am now high-end routers such as Linksys, ASUS, or latest routers are rarity and considered as luxury options with bloated prices, I mean one have to pay up to 3 or four times of the equal retail USD price to obtain one here if he could find one.

A year ago I purchased an outdated refurbished imported linksys secondhand model made 2017 for 2 times of its USD equivalent price of the similar refurbished prices sold on the ebay.

I remember once I bricked physically one of my Xiaomi R4AG routers and then all my tries to find a memory chip replacement for it has failed.

For the moment I have to stick with this low-end model until I could find a better capable device with reasonable price regardless of its condition whether it is new or second hand.