appdaemon icon indicating copy to clipboard operation
appdaemon copied to clipboard

CPU usage increases a lot after migrating from 4.4.2 to 4.5.8

Open lluisd opened this issue 6 months ago • 4 comments

What happened?

I moved from appdeamon from 4.4.2 to 4.5.8 and I was suprised this docker is the one with more CPU usage comparing with the rest. I filtered by that one and I get this increment of CPU and also Ram. But the big impact it's the CPU usage, I normally run about 60 typical dockers with a cpu usage of 4-5% and now it's about 10% becasue of that issue:

Also my dashboard is not oppening anymore: http://192.168.0.160:5050/ I get ERR_EMPTY_RESPONSE

Image

Version

4.5.8

Installation type

Home Assistant add-on

Relevant log output

Collecting babel (from -r /conf/requirements.txt (line 1))
  Downloading babel-2.17.0-py3-none-any.whl.metadata (2.0 kB)
Downloading babel-2.17.0-py3-none-any.whl (10.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.2/10.2 MB 23.3 MB/s eta 0:00:00
Installing collected packages: babel
Successfully installed babel-2.17.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
[notice] A new release of pip is available: 25.0.1 -> 25.1.1
[notice] To update, run: pip install --upgrade pip
2025-06-05 12:43:35.809873 INFO AppDaemon: ------------------------------------------------------------
2025-06-05 12:43:35.810827 INFO AppDaemon: AppDaemon Version 4.5.8 starting
2025-06-05 12:43:35.811079 INFO AppDaemon: ------------------------------------------------------------
2025-06-05 12:43:35.811248 INFO AppDaemon: Python version is 3.12.10
2025-06-05 12:43:35.811946 INFO AppDaemon: Configuration read from: /conf/appdaemon.yaml
2025-06-05 12:43:35.812465 INFO AppDaemon: Added log: AppDaemon
2025-06-05 12:43:35.812726 INFO AppDaemon: Added log: Error
2025-06-05 12:43:35.812875 INFO AppDaemon: Added log: Access
2025-06-05 12:43:35.813017 INFO AppDaemon: Added log: Diag
2025-06-05 12:43:35.814276 INFO AppDaemon: Using /conf/apps as app_dir
2025-06-05 12:43:35.816188 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module appdaemon.plugins.hass.hassplugin
2025-06-05 12:43:35.816714 INFO HASS: HASS Plugin initialization complete
2025-06-05 12:43:35.817135 INFO AppDaemon: Loading Plugin MQTT using class MqttPlugin from module appdaemon.plugins.mqtt.mqttplugin
2025-06-05 12:43:35.817466 INFO MQTT: MQTT Plugin Initializing
2025-06-05 12:43:35.817723 INFO MQTT: Using 'appdaemon/status' as birth topic with payload 'online'
2025-06-05 12:43:35.817959 INFO MQTT: Using 'appdaemon/status' as will topic with payload 'offline'
2025-06-05 12:43:35.829332 INFO AppDaemon: Initializing HTTP
2025-06-05 12:43:35.829811 INFO AppDaemon: Using 'ws' for event stream
2025-06-05 12:43:35.830304 INFO AppDaemon: HTTP Listening on port 5050
2025-06-05 12:43:35.834008 INFO AppDaemon: Starting API
2025-06-05 12:43:35.836717 INFO AppDaemon: Starting Admin Interface
2025-06-05 12:43:35.837135 INFO AppDaemon: Starting Dashboards
2025-06-05 12:43:35.846814 INFO HASS: Connected to Home Assistant 2025.5.3 with aiohttp websocket
2025-06-05 12:43:35.848159 INFO HASS: Authenticated to Home Assistant 2025.5.3
2025-06-05 12:43:35.850459 INFO HASS: Waiting for Home Assistant to start
2025-06-05 12:43:35.851881 INFO MQTT: Connected to MQTT broker at URL 192.168.0.160:1883 with paho-mqtt
2025-06-05 12:43:35.862216 INFO MQTT: MQTT Plugin initialization complete
2025-06-05 12:43:35.930247 INFO HASS: Completed initialization in 89.879ms
2025-06-05 12:43:36.053526 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2025-06-05 12:43:36.057168 INFO AppDaemon: Running on port 5050
2025-06-05 12:43:36.057464 INFO AppDaemon: Waiting for plugins to be ready
2025-06-05 12:43:36.058053 INFO AppDaemon: All plugins ready
2025-06-05 12:43:36.059970 INFO AppDaemon: Scheduler running in realtime
2025-06-05 12:43:36.556290 INFO AppDaemon: New app config: nspanel-1
2025-06-05 12:43:36.757304 INFO AppDaemon: Starting apps: {'nspanel-1'}
2025-06-05 12:43:36.764073 INFO AppDaemon: Calling initialize() for nspanel-1
2025-06-05 12:43:36.869176 INFO nspanel-1: Starting
2025-06-05 12:43:36.877000 INFO nspanel-1: Input config: {'panelRecvTopic': 'tele/tasmota_nspanel/RESULT', 'panelSendTopic': 'cmnd/tasmota_nspanel/CustomSend', 'model': 'eu', 'sleepTimeout': 20, 'screenBrightness': 50, 'sleepBrightness': [{'time': '8:00:00', 'value': 5}, {'time': '1:00:00', 'value': 0}], 'locale': 'es_ES', 'screensaver': {'type': 'screensaver2', 'key': 'screensaver', 'entities': [{'entity': 'weather.aemet'}, {'entity': 'sensor.aemet_temperature_feeling', 'icon': 'mdi:sun-thermometer'},  'sensor.weather_forecast_daily', 'sensor.weather_forecast_daily', 'sensor.temp_sensor_living_room_temperature', 'sensor.temperature_humidity_sensor_1971_humidity', 'switch.pc', 'switch.3d_printer', 'switch.camara', 'sensor.persons_at_home']
2025-06-05 12:43:36.958337 INFO nspanel-1: Started (v4.3.3)
2025-06-05 12:43:36.961670 INFO AppDaemon: App initialization complete
2025-06-05 12:43:37.153292 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"nlui_driver_version":"9"}'}
2025-06-05 12:43:37.155524 INFO nspanel-1: Update Pre-Check failed Tasmota Driver Version: 9 Panel Version: None
2025-06-05 12:43:37.174831 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"CustomRecv":"event,startup,53,eu"}'}
2025-06-05 12:43:37.176231 INFO nspanel-1: Received Message from Screen: event,startup,53,eu
2025-06-05 12:43:37.179444 INFO nspanel-1: Update Pre-Check failed Tasmota Driver Version: None Panel Version: 53
2025-06-05 12:43:37.180923 INFO nspanel-1: Startup Event
2025-06-05 12:43:37.586802 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"nlui_driver_version":"9"}'}
2025-06-05 12:43:37.588406 INFO nspanel-1: Update Pre-Check sucessful Tasmota Driver Version: 9 Panel Version: 53
2025-06-05 12:43:37.660859 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"CustomRecv":"event,renderCurrentPage"}'}
2025-06-05 12:43:37.662618 INFO nspanel-1: Received Message from Screen: event,renderCurrentPage
2025-06-05 12:44:08.073608 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"CustomRecv":"event,buttonPress2,screensaver,bExit,1"}'}
2025-06-05 12:44:08.075179 INFO nspanel-1: Received Message from Screen: event,buttonPress2,screensaver,bExit,1
2025-06-05 12:44:08.076721 INFO nspanel-1: Button Press Event; entity_id: screensaver; button_type: bExit; value: 1 
2025-06-05 12:44:08.081655 INFO nspanel-1: Searching for the following page as defaultPage: switches
2025-06-05 12:44:08.083312 INFO nspanel-1: Result for the following page as defaultPage: <luibackend.config.Card object at 0x7fd657ca20f0>
2025-06-05 12:44:08.338749 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"CustomRecv":"event,buttonPress2,screensaver,bExit,2"}'}
2025-06-05 12:44:08.340401 INFO nspanel-1: Received Message from Screen: event,buttonPress2,screensaver,bExit,2
2025-06-05 12:44:08.341925 INFO nspanel-1: Button Press Event; entity_id: screensaver; button_type: bExit; value: 2 
2025-06-05 12:44:08.346465 INFO nspanel-1: Searching for the following page as defaultPage: switches
2025-06-05 12:44:08.348118 INFO nspanel-1: Result for the following page as defaultPage: <luibackend.config.Card object at 0x7fd657ca20f0>
2025-06-05 12:44:09.075880 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"CustomRecv":"event,renderCurrentPage"}'}
2025-06-05 12:44:09.078137 INFO nspanel-1: Received Message from Screen: event,renderCurrentPage
2025-06-05 12:44:10.271473 INFO nspanel-1: MQTT callback for: {'topic': 'tele/tasmota_nspanel/RESULT', 'wildcard': None, 'payload': '{"CustomRecv":"event,buttonPress2,navigate.rollers_batteries,button"}'}
2025-06-05 12:44:10.275273 INFO nspanel-1: Received Message from Screen: event,buttonPress2,navigate.rollers_batteries,button

Relevant code in the app or config file that caused the issue

My docker compose

version: "3.5"
services:
  appdaemon:
    container_name: appdaemon
    image: acockburn/appdaemon:4.5.8
    environment:
      - HA_URL=http://192.168.0.160:8123
      - TOKEN="xxxx"
      - DASH_URL=http://localhost:5050
      - TIMEZONE=Europe/Madrid
    ports:
      - 5050:5050
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /volume1/docker/homeassistant/appdaemon:/conf
    restart: unless-stopped

Anything else?

No response

lluisd avatar Jun 05 '25 09:06 lluisd

fixed with setting production_mode: true in my appdaemon.yaml. But this didn't happen in my 4.4.2, it will be usefull to specify it more clear.

Image

lluisd avatar Jun 05 '25 11:06 lluisd

Yes, we are aware that non-production modes is responsible for most of the AppDaemon load and have plans to optimize it. Having said that, even with the rewrite it shouldn't have been significantly worse.

Thanks for reporting - I will move this to an enhancement for now, because your graphs make a useful data point.

acockburn avatar Jun 05 '25 11:06 acockburn

FWIW I have also seen this after upgrading to 4.5.8. I noticed my raspberry pi fan coming on more often than usual and my CPU charts show a similar increase following the upgrade. Something is definitely more aggressive with non-production mode in the new version

sjonez avatar Jun 17 '25 13:06 sjonez

This should be better in the next release

jsl12 avatar Jun 17 '25 14:06 jsl12