Tracing what causes CPU spikes

Hello, my current Network is an OpenWrt router acting as a SoftEther server + Asterisk aside for phone calls ( no transcoding )

what happens is during the first 3-4 minutes of a call, everything is amazing. CPU usage is ~ 0.00. THEN it starts spiking, goes down then spikes again till it reaches 2+ usage. i need to track what causes that usage. top doesn't show anything useful for me because the cpu usage per process is almost consistent YET it jumps.

i'm running Extroot + SWAP to an SDcard.

that's during the beginning of a call :

image_2021-12-10_234804

that's when it started spiking :
image_2021-12-10_234613

is there any "tool" or command that i can use to pinpoint where the problem is ? any ideas ? thank you so much in advance !

EDIT : it spiked literally the next "top" refresh :

image_2021-12-10_235114

Install the package sysstat.

Run pidstat -T TASK 2 (which snapshots every 2 seconds)

I see 20MB memory, which router is this?
ubus call system board

it's the TL-MR3220 with 32mb ram and 500MB swap

gonna give it a try. Thanks !

but i just wanna know what causes the sudden spike, is it a problem with USB ? or just kernel module that i don't need/use ?

The last available OpenWRT version for that device is 17.01.5, which is no longer supported.

With only a 400 Mhz CPU, it's not surprising it's struggling.

Time for a new router.

3 Likes

The most likely cause would actually be running out of RAM, followed by swapping over USB (at write speeds of around 5 MByte/s) - and from there on it's game over.

5 Likes

that's the spike from the pidstat cmd and top at the same time

i know it's old but it's 9000 Miles away right now :frowning: so i have nothing to do about it for the time being. i'm just trying to figure out if i can do anything about the spike to at least not make it go 1.00+ usage when on calls.

As @slh mentioned, memory may be the bigger issue...

Run pidstat -r -p ALL 2 and see what's happening.

1 Like

but shouldn't it reflect on the %io ? since it's using usb ? or at least kswapd would have the highest usage ?

( i'm not questioning you, just trying to learn how to narrow things down, how to track usage and what corresponds to them )

wow... usage is 0.10 and maxes out at 0.15.. i left a call on for 5 minutes and nothing till now.. is that like quantum physics in terms of when you look at it, it disappears or something ? :face_with_raised_eyebrow:

At the time of the snapshot, asterisk and vpnserver (2 PID's) were using a total of 12.62% of memory.

okay, is that alot in my situation ? because the router doesn't do any actual routing for the network. i'm using it as a softether + asterisk only, no NAT nor masquerading. even uhttpd is disabled so...

Well, the warning on the wiki for 4/32 devices states...

Devices with ≤4MB Flash and/or ≤32MB RAM (so-called “4/32 devices”) may be made to work but they will be very limited (usually you won't be able to install or run additional packages) because they have low RAM and Flash space. Consider this when choosing a device to buy, or when deciding to flash OpenWrt on your device because it is listed as supported.

You're bumping up against the law of "firmware physics".

1 Like

well, i wanted it to at least get it stable enough... because if it's not gonna work then i will have to "throw it away" and to be honest i didn't want to because it works and it's not awful, it just needs tweaking since it has Extroot and SWAP ( i know they aren't the lifesavers but at least hopefully it does the job )

Tweaking is not going to change the 4/32 limitation (which is just to run a basic OpenWRT install/config).

i know, i Resoldered a 16MB ROM and added swap so at least i can bypass it ( + Extroot )

You have not one but two big applications trying to run in 32M RAM. USB swap is a very poor substitute. If you control both ends of the VPN, could you change from softether to wireguard?

2 Likes

it's blocked :frowning: at first i had OpenVPN but it's also blocked so i disabled it altogether. then i tried L2TP ( also blocked ) and not even port blocking, it's literally protocol block over any port ( even 53 ). That's when i tried softether. this and SSTP they are the only working protocols

i think wireguard is also blocked, i haven't tried it but if i can find a portable server for windows to give it a try before deploying it on the router would be awesome