How to install Py spy on a HA OS instance, please instruct

hmm, dont think there’s a way for me to get all of those commands in terminal within 1 minute from restart…you’re right… cant do that in some predefined script can we?

ssh [email protected] -p 22222

docker exec -it homeassistant /bin/bash

Top (to get pid for homeassistant)

cd py_spy-0.3.12.data/scripts

./py-spy record --duration 120 --rate 100 --pid 61

Short of modifying the init script in the container I don’t have a good suggestion

new files sent/

Ive discovered an oddity in the Yaml checker:

using anchors in dashboard files has always worked nicely, especially when making a mistake… it would simply state things like ‘missing anchor’ or ‘anchor not defined’ Not exactly sure.

And, it did show the card yaml in a placeholder in the Dashboard view.

With the new yaml checker however, this turns into a cryptic:

which is simply not true, and an even odder:

the test card I use hasn’t even got a logbook card configured.

Is this something you recognize without anything further or would you need an issue for that?

probably related to: https://github.com/home-assistant/core/pull/73874 ?

update

wrote up an issue just to be sure.

Based on your new py-spy, the I/O performance fix for file was very effective as it disappeared from the profile.

1 Like

PR to speed this up here https://github.com/exxamalte/python-aio-georss-client/pull/32

Edit: The actual data didn’t match the test data so this won’t actually help.

1 Like

Unifi - JSON decoding overhead (would need a separate change to aiounifi after https://github.com/home-assistant/core/pull/72847https://github.com/Kane610/aiounifi/pull/145) :white_check_mark:

This should be in tonight’s nightly

just noticed these once more, not sure off we already took it off the list of possible optimizations:

2022-07-11 10:12:13.552 DEBUG (MainThread) [homeassistant.setup] Dependency template will wait for after dependencies ['group']
2022-07-11 10:12:13.563 INFO (MainThread) [homeassistant.setup] Setting up group
2022-07-11 10:12:13.897 DEBUG (MainThread) [homeassistant.setup] Dependency template will wait for after dependencies ['group']
2022-07-11 10:12:13.915 DEBUG (MainThread) [homeassistant.setup] Dependency template will wait for after dependencies ['group']
2022-07-11 10:12:13.915 DEBUG (MainThread) [homeassistant.setup] Dependency template will wait for after dependencies ['group']
2022-07-11 10:12:13.915 DEBUG (MainThread) [homeassistant.setup] Dependency template will wait for after dependencies ['group']
2022-07-11 10:12:13.923 DEBUG (MainThread) [homeassistant.setup] Dependency template will wait for after dependencies ['group']

happening midway startup…

even though group itself is not taking very long:

2022-07-11 10:12:16.091 INFO (MainThread) [homeassistant.setup] Setup of domain group took 2.5 seconds

Confirming the groups being of importance for those numbers in the integration startup list (btw. notice this is the first time an MQTT logging of below 100 secs happened):

HA core-2022.8.0.dev20220711

great you found your issue. always a worry when things like that happen :wink:

would it be too much to ask to edit this post (or even delete it), so the thread re mains fully on topic, and no further confusion will arise…
thanks!

Just an FYI you don’t actually have to set up host ssh for this task. If you install the ssh & web terminal addon and disable protection mode then you can access the docker cli and follow the rest of the steps from that.

Important: this is the ssh addon in the community addons repo, not the ssh addon in the official addons repo. You cannot access the docker cli from the ssh addon in the official addons repo.

Yes, I am aware, but as stated in above instructions: one can not copy&paste in the add-on.
Since these commands are a pain to type, I wanted to copy and paste them.

A terminal window allows us to do so.

In the config of both addons you can expose the ssh port on the host via the network options on the configuration tab. Then you can use it over ssh from a terminal on any machine. Just like with the host ssh.

I’ve never used the web UI of the ssh addon tbh, I always forget it exists

yes, but I am not sure why you say this now. Did I make a mistake above in the listing of actions required? I am using an external terminal to do all this, so no issue there.
sorry if I misunderstand what you’re saying Mike.

Well I noticed you linked it around discord and places. Which makes sense, it is a pretty complete guide. I was thinking if you are going to keep linking it you might want to update it to use the Community SSH addon approach instead of recommending setting up host SSH. Mostly since its significantly easier for others to do that. No formatting a USB drive and restarting required, just a few clicks from the UI.

thanks, you’re right, and consider that done, I added your suggestions.
See: How to install Py spy on a HA OS instance, please instruct - #44 by Mariusthvdb

@bdraco any chance you can look at my svg files and help me narrow down the issue? My pi4 usually has very minor load and sometimes could be after a day could be after a few hours it really spikes and stays high the only fix is to restart the HA container. There is nothing in the logs at that time either, so I am pretty stumped. I included py-spy svg snapshots for when I have good usage and bad. I suspected it was MQTT but reloading it didn’t solve the issue.
Thank you soo much!
bad cpu usage svg snapshot: https://secure.fabriceleven.com/g23hio+
good cpu usage svg snapshot: https://secure.fabriceleven.com/V8AQnu+

Nothing stands out as an obvious issue.

Can you get an strace -p <pid> -f -s4096 -o /config/spin.log ?

You may have to run apk install strace

Don’t post it though as it could happen to read a file with sensitive data when its logging. PM me and I’ll send you my dropbox or google address so you can share it securely.

Thank you! :heart: No problem. Already reloaded HA though… now we wait :slight_smile:
btw to install strace its
apk add strace

Mem: 3657596K used, 225460K free, 10448K shrd, 289212K buff, 1609196K cached
CPU:  35% usr  21% sys   0% nic  35% idle   0% io   0% irq   7% sirq
Load average: 4.47 4.44 4.60 5/1134 2261
  PID  PPID USER     STAT   VSZ %VSZ CPU %CPU COMMAND
   64    61 root     S     903m  24%   0   2% python3 -m homeassistant --config /config
  127    64 root     S     699m  18%   1   0% /config/rtsp2webrtc_v5_aarch64 {"server":{"http_port":"127.0.0.1:8083","ice_servers":["stun:stun.l.google.com:19302"]},"streams":{}}
  143    64 root     S     697m  18%   2   0% /config/rtsp2webrtc_v5_aarch64 {"server":{"http_port":"127.0.0.1:8084","ice_servers":["stun:stun.l.google.com:19302"]},"streams":{}}
  780     0 root     S     2788   0%   1   0% /bin/bash
 1656     0 root     S     2788   0%   0   0% /bin/bash
 2261  1656 root     R     1672   0%   2   0% top
   24     1 root     S      204   0%   0   0% s6-supervise s6rc-fdholder
   61     1 root     S      204   0%   2   0% s6-supervise home-assistant
   15     1 root     S      204   0%   1   0% s6-supervise s6-linux-init-shutdownd
   25     1 root     S      204   0%   3   0% s6-supervise s6rc-oneshot-runner
    1     0 root     S      200   0%   0   0% /package/admin/s6/command/s6-svscan -d4 -- /run/service
   17    15 root     S      192   0%   0   0% /package/admin/s6-linux-init/command/s6-linux-init-shutdownd -c /run/s6/basedir -g 3000 -C -B
   33    25 root     S      180   0%   2   0% /package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /package/admin/s6/comma
bash-5.1# py-spy top --pid 61
Error: Failed to find python version from target process
bash-5.1#

any help?

Hi
sure about the parameter for the PID? 61 is the PID of the parent process for homeassistant, you are likely trying to get information for PID 64 with py-spy?
py-spy top --pid 64

Edit: this worked for me too, uses pgrep to dynamically find the the pid for the “hass” process started by user “homeassistant” (if I recall correctly):
sudo py-spy top --pid $(pgrep -u homeassistant hass )
Armin

on the pid, check this guide I made how to get the correct one: Instructions to install Py-spy on HAOS

top (to get pid for homeassistant)

and just to be sure the guide was still accurate I dd test the exact same commands, and no errors appeared.

are you sure you have the correct pid, and file installed?
(I take it the docker exec went ok given the command prompt, and the folders are there too, given no cd error was displayed)