Optimising CPU usage on OpenWrt router
My OpenWrt adventures began with the ASUS RT-AC56U router. It was a fairly good, cheap router with a dual-core Broadcom BCM4708A0 processor clocked at 800MHz. It also had 128MB of flash memory and 256MB of RAM.
Appetite grows with eating, as the saying goes.
While I didn’t complain about the processor, I quickly ran out of space for more of these applications. So I decided to replace it with a Linksys WRT3200ACM, which I later changed to a Linksys WRT32x.
WRT3200ACM (WRT32x) is a very solid machine, we still use this type of router at work. While I was pleased with its performance, the WiFi network did not work out very well.
The signal strength left much to be desired, and cooperation with other routers or access points was not without problems. All because of the wireless chip from Marvell used in it.
Additionally, the lack of support for DFS channels in WiFi in the 5GHz frequency further limited its use. Also, forget about WPA3 encryption introduced by default in the OpenWrt 21.02 series (WPA3 can be turned on, but WiFi and the entire router quickly stop working).
In my search for a better router, I came across the Linksys MR8300. It had 3 Qualcomm Atheros radios. One was for the 2.4GHz frequency and the other two for 5GHz, the first for channels up to 60 and the second for above 100 (with DFS support).
While the router performed well, it was clear to see that it was much slower, especially when installing software.
The WRT3200ACM (WRT32x) had a dual-core 1866MHz processor, while the MR8300 had a quad-core 717MHz.
Theoretically, performance should have been similar due to the larger number of cores, but it wasn’t.
While my internet speed increased from 100/10Mbps to 200/20Mbps I additionally noticed that the router started to choke, especially when it had internet link optimization enabled using SQM QoS.
SQM QoS did not perform above 100Mbps and after disabling it, 200Mbps could be achieved without any problems.
Unfortunately, enabling Packet Steering in Network > Interfaces > Global network options did not help.
Packet Steering allows packets to be managed using all available processors in the system, in this case cores (of which the MR8300 has four).
I was forced to disable SQM QoS until I find a solution to this problem. I suspect I will be checking this out when the stable OpenWrt 22.03 version is released, where Firewall 4 will be introduced.
However, I decided to delve deeper into the aspect of using the computing power inherent in the four cores of the Linksys MR8300.
In my searches I came across a command that shows how our processor and its cores are being used.
tail /proc/interrupts -n 100
This allowed me to see that the first core was working overtime while the other three were slacking off.
I decided to do something about it.
While browsing the official OpenWrt website I came across the Irqbalance package.
The purpose of this package is, literally translated, “distribute interrupts across multiple logical processors (cores)”. In short, distribute commands from the main core to all available ones.
Irqbalance is a Linux daemon that distributes interrupts over multiple logical CPUs. This may result in improved overall performance and even reduced power consumption.
This package is not available by default in the system and its installation does not automatically enable it. This is dictated by the fact that in the case of devices up to two cores, the performance increase is minimal or causes its deterioration.
In the case of the Linksys MR8300, which has four cores, it is worth trying.
I updated the packages and installed irqbalance
opkg update
opkg install irqbalance
By editing the configuration file, I enabled its automatic start
nano /etc/config/irqbalance
option enabled '1'
Then I started it manually
/etc/init.d/irqbalance start
After a while it was obvious that the 3 lazy cores had started working for bread.
tail /proc/interrupts -n 100
After performing several tests, including downloading files from torrents (see how to add a torrent client to a router with OpenWrt), which in the initial stage always caused the router to slow down, I saw a slight improvement.
Load Average 1.44, 0.83, 0.50
It’s not great, but it’s always better than nothing.
I still had to forget about SQM QoS, but at least I can see that the router’s CPU is being utilized to a higher extent than before the change.
The ideal would be to have a Linksys WRT3200ACM (WRT32x) processor and a MR8300 wireless network card.
If you are interested in using OpenWrt for more advanced purposes, then it is worth considering creating a router using Raspberry Pi 4 and separate WiFi points.
If only the Askey RT4230W REV6 / RAC2V1K (not SAC2V1K) were available to play around with on this side of the globe, then we might have an affordable powerful alternative to the WRT3200ACM (WRT32x) or MR8300, which is supposed to be officially supported in OpenWrt 22.03.
I took the plunge and bought from the US via eBay UK Askey RT4230W REV6 / RAC2V1K. I flashed OpenWrt without having to open the case and everything works beautifully.
Regards.
Comments & Reactions