core icon indicating copy to clipboard operation
core copied to clipboard

CPU utilization is higher and shows weird shapes after 19.7 upgrade

Open immanuelfodor opened this issue 7 years ago • 45 comments

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

[x] I have read the contributing guide lines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md

[x] I have searched the existing issues and I'm convinced that mine is new.

Describe the bug CPU utilization is noticeably higher after 19.1->19.7 upgrade than before, and the CPU graph shows weird triangles since then.

To Reproduce Upgrade from 19.1 to 19.7, look through the admin page to explore new features, leave the VM running for a day.

Expected behavior CPU utilization is constant and around the levels of 19.1.

Screenshots Grafana:
image

Relevant log files Running top shows extremely high python3.7 activity sometimes, for example once I saw this below but it's usually floating around 33-44%.

last pid: 70082;  load averages:  0.59,  0.55,  0.51                                                                                                                                                                 up 1+03:17:13  15:46:12
50 processes:  2 running, 48 sleeping
CPU: 49.6% user,  0.0% nice,  0.6% system,  0.0% interrupt, 49.8% idle
Mem: 33M Active, 628M Inact, 438M Wired, 277M Buf, 1859M Free
Swap: 

  PID USERNAME       THR PRI NICE   SIZE    RES   SWAP STATE   C   TIME    WCPU COMMAND
71938 root             1  84    0 26548K 22272K     0K CPU0    0  22:20  99.08% python3.7
15593 zabbix           1  20    0 18564K 10752K     0K select  1   0:25   0.11% zabbix_agentd
30415 root             1  21    0  1034M  3844K     0K CPU1    1   0:00   0.04% top
46820 root             1  20    0  1038M  7668K     0K select  0   0:00   0.02% sshd
37559 root             5  30    0  6912K  2356K     0K uwait   1   0:14   0.01% dpinger
94458 zabbix           1  20    0 18564K 10284K     0K nanslp  1   0:12   0.01% zabbix_agentd
84794 zabbix           1  20    0 18564K 10716K     0K nanslp  1   0:10   0.01% zabbix_agentd
33533 root             1  20    0  1039M  6344K     0K select  1   0:08   0.01% ntpd
65488 dhcpd            1  20    0 16588K  9260K     0K select  1   0:05   0.01% dhcpd
60544 root             1  20    0  1033M  2976K     0K bpf     0   0:07   0.00% filterlog
29313 root             1  20    0 17148K 11932K     0K kqread  1   0:08   0.00% lighttpd
92095 zabbix           1   4    0 18564K 10756K     0K select  1   0:25   0.00% zabbix_agentd
28141 zabbix           1  20    0 18564K 10760K     0K accept  1   0:25   0.00% zabbix_agentd
35656 root             1  52    0  1034M  3160K     0K wait    1   0:23   0.00% sh
80551 root             1  20    0 46964K 34700K     0K accept  1   0:15   0.00% python3.7
 9676 root             2  20    0 19876K 10916K     0K kqread  0   0:11   0.00% syslog-ng
...

Environment OPNsense 19.7 (amd64/OpenSSL) VM with 2 vcores and 3GB RAM running on Proxmox: pve-manager/5.4-11/6df3d8d0 (kernel: 4.15.18-18-pve) Network: Intel® I219-LM and I211

immanuelfodor avatar Jul 19 '19 13:07 immanuelfodor

I must say that OPNsense is working fine, there are no noticeable side effects of the CPU utilization changes, it just looks weird on the graph. If there is a good explanation why this is going to be the normal operation from now on, I'm all ears :)

immanuelfodor avatar Jul 19 '19 14:07 immanuelfodor

we refactored flowd_aggregate.py to parse the flowd binary files (/var/log/flowd.log) natively now and use python 3 in stead of python 2. I expect your top process is this one.

Generally it can process more flowd records in the same time than the old version, but will probably keep one core busy while doing so.

Is the machine also busy when there isn't a lot of traffic?

AdSchellevis avatar Jul 19 '19 14:07 AdSchellevis

I'm having high cpu usage as well.. I started a post on the forum https://forum.opnsense.org/index.php?topic=13507.0 I've attached a few screenshots and such seems like a few people are having similar issues, and it does seem that flowd_aggregate.py is the culprit.

mstrdraco avatar Jul 19 '19 14:07 mstrdraco

Same effect here, but I noticed it through my power meter, which normally shows 120W throughput idle (20mins after boot and everything settled) and now I have 170-180W in idle.

OPNsense runs under bhyve, on the host is powerdxx working.

From host:

load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 203%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 204%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 203%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 207%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 200%, current freq 3500 MHz ( 0), wanted freq 7000 MHz

That's full load on 2 cores, which should'nt be under idle system.

mr44er avatar Jul 19 '19 15:07 mr44er

flowd_aggregate.py can only use one core....

AdSchellevis avatar Jul 19 '19 15:07 AdSchellevis

Yes, I only wanted to say this load is much higher than before and normally the cpu would go down (and so the power) with the freq -> dev.hwpstate.0.freq_settings: 3500/-1 3300/-1 3100/-1 2800/-1 2200/-1 1600/-1

mr44er avatar Jul 19 '19 15:07 mr44er

The question is how much flow records the machine is producing (traffic), if the machine is busy without network load, we might have an issue finding the tail of the flowd.log file. In which case it might help to rotate more often or wait more time in between cycles.

It could be that the script itself can utilise a core better, which would lead to higher load (on one core).

AdSchellevis avatar Jul 19 '19 15:07 AdSchellevis

The question is how much flow records the machine is producing (traffic), if the machine is busy without network load, we might have an issue finding the tail of the flowd.log file. In which case it might help to rotate more often or wait more time in between cycles.

It could be that the script itself can utilise a core better, which would lead to higher load (on one core).

The flowd.log is not showing any data, I see it growing but when trying to read it via clog or other methods it produces no output. Is this expected behavior?

pyrodex avatar Jul 19 '19 15:07 pyrodex

if the machine is busy without network load, we might have an issue finding the tail of the flowd.log file.

No traffic today, machine is out of production.

I stopped it for now.

Host (120W now again) :

load 15%, current freq 3500 MHz ( 0), wanted freq 6569 MHz load 30%, current freq 3500 MHz ( 0), wanted freq 6569 MHz load 40%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 24%, current freq 3500 MHz ( 0), wanted freq 6781 MHz load 21%, current freq 3500 MHz ( 0), wanted freq 6569 MHz load 16%, current freq 3500 MHz ( 0), wanted freq 6363 MHz load 31%, current freq 3500 MHz ( 0), wanted freq 6363 MHz load 28%, current freq 3500 MHz ( 0), wanted freq 6363 MHz load 12%, current freq 3500 MHz ( 0), wanted freq 6164 MHz load 19%, current freq 3500 MHz ( 0), wanted freq 5971 MHz load 40%, current freq 3500 MHz ( 0), wanted freq 6369 MHz load 40%, current freq 3500 MHz ( 0), wanted freq 6793 MHz load 13%, current freq 3500 MHz ( 0), wanted freq 6580 MHz load 14%, current freq 3500 MHz ( 0), wanted freq 6374 MHz load 20%, current freq 1600 MHz ( 5), wanted freq 6174 MHz changing clock speed from 1600 MHz to 3500 MHz load 26%, current freq 1600 MHz ( 5), wanted freq 6174 MHz changing clock speed from 1600 MHz to 3500 MHz load 12%, current freq 3500 MHz ( 0), wanted freq 5981 MHz load 22%, current freq 3500 MHz ( 0), wanted freq 5794 MHz load 41%, current freq 3500 MHz ( 0), wanted freq 6334 MHz load 36%, current freq 3500 MHz ( 0), wanted freq 6334 MHz load 22%, current freq 3500 MHz ( 0), wanted freq 6136 MHz load 26%, current freq 3500 MHz ( 0), wanted freq 6136 MHz load 46%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 30%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 25%, current freq 3500 MHz ( 0), wanted freq 7000 MHz

mr44er avatar Jul 19 '19 15:07 mr44er

flowd-reader /var/log/flowd.log

to read the binary file.

AdSchellevis avatar Jul 19 '19 15:07 AdSchellevis

flowd-reader /var/log/flowd.log open(/var/log/flowd.log): No such file or directory

Whoops?

mr44er avatar Jul 19 '19 15:07 mr44er

https://github.com/opnsense/core/commit/fabaef0a4329709582521c5f37fbe59edd6d0289 reduces the load a bit while seeking the end of the file.

opnsense-patch fabaef0a
service flowd_aggregate restart

@mr44er ls -aslh /var/log/flowd.log*

AdSchellevis avatar Jul 19 '19 15:07 AdSchellevis

ls -aslh /var/log/flowd.log* ls: No match. opnsense-patch fabaef0a ... All patches have been applied successfully. Have a nice day.

powerd -v powerd: unable to determine AC line status load 41%, current freq 1600 MHz ( 5), wanted freq 1749 MHz changing clock speed from 1600 MHz to 2200 MHz load 22%, current freq 1600 MHz ( 5), wanted freq 1694 MHz changing clock speed from 1600 MHz to 2200 MHz load 22%, current freq 2200 MHz ( 4), wanted freq 1641 MHz load 19%, current freq 2200 MHz ( 4), wanted freq 1600 MHz changing clock speed from 2200 MHz to 1600 MHz load 37%, current freq 1600 MHz ( 5), wanted freq 1600 MHz load 29%, current freq 1600 MHz ( 5), wanted freq 1600 MHz load 44%, current freq 1600 MHz ( 5), wanted freq 1877 MHz changing clock speed from 1600 MHz to 2200 MHz load 27%, current freq 1600 MHz ( 5), wanted freq 1877 MHz changing clock speed from 1600 MHz to 2200 MHz load 22%, current freq 2200 MHz ( 4), wanted freq 1818 MHz load 25%, current freq 2200 MHz ( 4), wanted freq 1818 MHz load 29%, current freq 2200 MHz ( 4), wanted freq 1818 MHz load 27%, current freq 2200 MHz ( 4), wanted freq 1818 MHz load 36%, current freq 2200 MHz ( 4), wanted freq 1818 MHz load 14%, current freq 2200 MHz ( 4), wanted freq 1761 MHz load 106%, current freq 2200 MHz ( 4), wanted freq 7000 MHz changing clock speed from 2200 MHz to 3500 MHz load 4%, current freq 3500 MHz ( 0), wanted freq 6781 MHz load 8%, current freq 3500 MHz ( 0), wanted freq 6569 MHz load 7%, current freq 3500 MHz ( 0), wanted freq 6363 MHz load 48%, current freq 3500 MHz ( 0), wanted freq 7000 MHz load 11%, current freq 3500 MHz ( 0), wanted freq 6781 MHz load 34%, current freq 3500 MHz ( 0), wanted freq 6781 MHz load 16%, current freq 3500 MHz ( 0), wanted freq 6569 MHz load 32%, current freq 3500 MHz ( 0), wanted freq 6569 MHz load 24%, current freq 3500 MHz ( 0), wanted freq 6363 MHz load 40%, current freq 3500 MHz ( 0), wanted freq 6787 MHz load 32%, current freq 3500 MHz ( 0), wanted freq 6787 MHz

Looks good so far.

flowd-reader /var/log/flowd.log

Shows data now...do you need something from it? Won't just c&p because of ips. ;)

Edit: cpugraph on dashboard is now flat again and everything is snappier so far. :)

graph

mr44er avatar Jul 19 '19 16:07 mr44er

Seems the patch made mine way worse.. IMG_20190719_121630

mstrdraco avatar Jul 19 '19 16:07 mstrdraco

the dashboard consumes cycles as well, worse is practically not possible (it's doing less or the same amount of work).

If the script reads the file it can use one core for 100%. The old version sometimes had difficulties keeping up, likely because there was latency between the flowd library and the python process.

Previously we always waited 15 seconds between polls, with https://github.com/opnsense/core/commit/6b1f3e60b97a4fcfb0bc6fdaf50fd02d8bfc52b1 we wait max 60 seconds (minus the time spend last time).

On top of the other one:

opnsense-patch 6b1f3e60
service flowd_aggregate restart

We might consider lowering the max files size (10MB now), since every poll it has to read the file to know where it ended last time (which is the same as previously by the way).

AdSchellevis avatar Jul 19 '19 16:07 AdSchellevis

I've added the second patch as well.. my CPU is currently getting an extreme workout it's flapping from 100% to 26% and running about 15 degrees warmer then it did on 19.1. My max cpu load before would flap between 10% and at max 50% before on 19.1 as well. My Cpu is - Intel(R) Xeon(R) CPU X3430 @ 2.40GHz (4 cores) with 12gb of Ram.

mstrdraco avatar Jul 19 '19 16:07 mstrdraco

Wow, this thread has skyrocketed since I was away :grinning: To your first question @AdSchellevis : I only have minimal traffic from a few clients, nothing serious. I'm eager to help by applying the two patches, but if I do so, will the next 19.7.1 update go smoothly or I'm about create a headache for myself. I've never used the opnsense-patch utility before.

immanuelfodor avatar Jul 19 '19 16:07 immanuelfodor

It doesn't sound good, @mstrdraco, I'll do a vzdump backup of the VM before applying the patches then, just to make sure.

immanuelfodor avatar Jul 19 '19 16:07 immanuelfodor

from System/Diag

image

mstrdraco avatar Jul 19 '19 16:07 mstrdraco

This is the from top command, so maybe the GUI isn't displaying properly? Not sure image

mstrdraco avatar Jul 19 '19 16:07 mstrdraco