home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.03k stars 28.28k forks source link

Sluggish Performance On 2024.5 with statistics #116731

Closed dannytsang closed 1 week ago

dannytsang commented 2 weeks ago

The problem

I've noticed the performance since upgrading to 2024.5 has very poor compared to 2024.4.4. Symptoms I'm seeing include:

  1. Longer loading times from a browser
  2. Android mobile app taking longer to connect/load. At times, it times out or report SSL errors using nabu casa URL.
  3. Add-ons fail to load and shows a blank page like VSCode.

All the above I experience using Nabu casa, local IP and reverse proxy address.

When I reboot the VM, the performance seems to come back and then slows overtime. I don't see it hitting 100% CPU like #116650

What version of Home Assistant Core has the issue?

2024.5.0 and 2024.5.1

What was the last working version of Home Assistant Core?

2024.4.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

The behaviour is backed up uptime Kuma below. I upgraded on May 1st: image

dannytsang commented 2 weeks ago

I ran the profiler as well at the time it was slow. callgrind.out.1714732238247953.txt

joostlek commented 2 weeks ago

image

joostlek commented 2 weeks ago

Something is calling _exact_ratio a lot of times

dannytsang commented 2 weeks ago

Is it related to a statistics sensor? Any ideas how I can hunt it down?

joostlek commented 2 weeks ago

I recently learned how to read this, so this is everything I can pull out, furthermore I am not sure how to trace this back to anything sensible 😂

dannytsang commented 2 weeks ago

lol thanks for the assist and honesty @joostlek . Praying for @bdraco to chime in.

home-assistant[bot] commented 2 weeks ago

Hey there @thomdietrich, mind taking a look at this issue as it has been labeled with an integration (statistics) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `statistics` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign statistics` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


statistics documentation statistics source (message by IssueLinks)

bdraco commented 2 weeks ago

There are some prior issues https://github.com/home-assistant/core/issues/110433 https://github.com/home-assistant/core/issues/116650

bdraco commented 2 weeks ago

https://github.com/home-assistant/core/issues/116650 probably has the most information

ayavilevich commented 2 weeks ago

Something is calling _exact_ratio a lot of times

@dannytsang

Seems very similar to what I am experiencing with this version. See https://github.com/home-assistant/core/issues/116650#issuecomment-2093177277

Are you using MariaDB for your database or something else?

dannytsang commented 2 weeks ago

Something is calling _exact_ratio a lot of times

@dannytsang

Seems very similar to what I am experiencing with this version. See #116650 (comment)

Are you using MariaDB for your database or something else?

I am using MySQL.

ayavilevich commented 2 weeks ago

I am using MySQL.

So not the default SQLite, correct?

dannytsang commented 2 weeks ago

correct. I'm running MySQL 8.0.36

netmikey commented 1 week ago

I'm running the default SQLite and am experiencing the sluggish performance since 2024.5 as well. Running on an HA Blue.