Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significantly increased CPU load produced by get entities node #1988

Closed
chrhen opened this issue Oct 31, 2024 · 2 comments
Closed

Significantly increased CPU load produced by get entities node #1988

chrhen opened this issue Oct 31, 2024 · 2 comments

Comments

@chrhen
Copy link

chrhen commented Oct 31, 2024

Problem/Motivation

I updated the addon from v18.0.5 to v18.1.1 on October 10. In Node-Red I am running a flow that involves polling entities via the get entities node at regular intervals (currently 5 s). I have around 1600 entities.

On v18.0.5 this did not produce a noticeable performance impact. However now the call on get entities produces up to 100% of load on one CPU core.

I was able to pin-point the issue to exactly this flow by disabling only this this flow. This took the CPU load of the node red addon back to 1-2% of CPU time.

Here you can see how CPU load changed once I upgraded from v18.0.5 to v18.1.1 on October 10. Bear in mind that these are by now average readings of the complete cores dedicated to HA. For reference I run HAOS within a VM on an Intel-based x86 NAS.

image

The flow in question:

image

image

Note: I have replaced the regex with string matching which hat no discernible effect.
Further note: I realize that this might not be the most performant modeling of that flow that I can do, but it's quite effective and allows me to evolve my HA setup without having to maintain something on top, such as labels, On v18.0.5 this approach had no measureable performance impact.

Expected behavior

CPU load of 1-2% when using get entities node to match through 1600 entities at 5 seconds intervals.

Actual behavior

CPU load of up to 100% on one core when using get entities node to match through 1600 entities at 5 seconds intervals.

Steps to reproduce

  1. Have/obtain a setup of around 1000 entities
  2. Create an inject node with an interval of 5 seconds
  3. Connect the inject node to a get entities node that iterates through all entities via entities.friendly_name and their state property
  4. Watch CPU load
  5. (To compare, do the same on v18.0.5)

Suspicion

I believe that the get entities node evolved with v18.1 and is now able to also comb through labels, floors, etc. Maybe this new implementation has introduced a side-effect or other drastic performance penalty?

@chrhen
Copy link
Author

chrhen commented Nov 1, 2024

Related to and apparently improved by zachowj/node-red-contrib-home-assistant-websocket#1656

@chrhen chrhen closed this as completed Nov 1, 2024
@chrhen chrhen reopened this Nov 1, 2024
@chrhen
Copy link
Author

chrhen commented Nov 1, 2024

Considered closed as package.json already references node-red-contrib-home-assistant-websocket 0.74.2 on main branch which should resolve the issue for the next release.

@chrhen chrhen closed this as completed Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant