Python3 high CPU Usage

I was still having this issue on 110.4. Do you mean you’re having the issue if you add the container to multiple networks? Or the actual host machine?

Yes if my host machine is in multiple networks, homeassistant goes crazy with CPU usage. I tried it several times, and as soon as I add an aditional VLAN the CPU usage goes up substantially.

This problem can be caused by any misbehaving integration so posting a py-spy is the best way to help narrow it down.

If its a zeroconf issue, hopefully it should be sorted out in https://github.com/home-assistant/core/pull/36277 which should be in 0.111 next week

Can you get an strace -f -p <pid> -s 4096 and look for mdns traffic?

Hi all,
i’m currently having the same issue: HA runs ok for about 13 hour and then become unresponsive and very very slow.
Htop shows 100+ usage on python3 home assistant.

Tried to disable all the plugins and integrations without success. Default_config is not present in my config.yaml

I runned a py-spy and this is the result:

Can anyone help me to read the data on the image?

I’m running hassio in docker on a ubuntu server machine hosted in a vmware esxi server.
I’m using hassio in a VLAN IOT but i’m passing the IOT VLAN as untegged one to the ubuntu VM, so only one LAN.

Thanks

1 Like

Can you run another py-spy with a duration of 360 seconds?

Also please open an issue report with aiohomekit about the zeroconf call here https://github.com/Jc2k/aiohomekit/issues/new

Hi, thanks for the reply.
Here the profile for 360 seconds. Note that now the home assistan is working, after i disabled some homekit in the configuration yaml. cpu usage still very high

exatly what is the problem?

Thank you for posting the 360 second recording. I’m working on a PR to fix it here https://github.com/home-assistant/core/pull/37691

Sorry for the question but you found the problem? How I solve it? What is exactly my issue?

The issue seen on the recording you posted should be resolved in 0.113

I’m having the same issue with, after 12 hours (with 0.113.2) now after 1 hour with (0.113.3) Any help?

Please post a py-spy.

Also if you have the spotcast custom integration installs, be sure to upgrade.

There is no py-spy for arm devices right?

You can install via cargo if you are using the latest home assistant images, and enter the docker container via https://developers.home-assistant.io/docs/operating-system/debugging/

apk add cargo
cargo install py-spy
mkdir /config/www
/root/.cargo/bin/py-spy record --pid 227 --duration 120 --output /config/www/pi.svg

You’ll need to use top or something else to find the correct pid

2 Likes

EDIT: I was able to compile using pip instead of cargo, but had to use the instructions at this GitHub issue: https://github.com/benfred/py-spy/issues/23

I’m getting the following error trying to install py-spy:

error: could not find native static library `unwind`, perhaps an -L flag is missing?

error: aborting due to previous error

error: could not compile `remoteprocess`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `py-spy v0.3.3`, intermediate artifacts can be found at `/tmp/cargo-installtigzV2`

Caused by:
  build failed

I’m running Home Assistant as a VM on Proxmox.

Are you using the latest image with python 3.8.3?

The cargo install will only work on the newer images with the newer rust.

Edit: I see you got it working by other means :+1:

Yes, I am on .113.3 with the latest supervisor and OS as well, so not sure what the issue was there but going the pip route was fine once I found the other hoop to jump through. :slight_smile:

Hello, I also have a problem with high cpu for several versions. From reboot it grows from 2% to about 35% (RPI4 Docker Supervised currently at 0.114).
Thank you for any tips.


Py-Spy for 2 top PIDs (120s):