Skip to content

Conversation

dbuezas
Copy link
Owner

@dbuezas dbuezas commented Nov 15, 2022

Plotting multiple attributes or statistics of the same entity resulted in duplicated requests to home assistant.
This problem will be exacerbated with the inclusion of offsets.

This PR addresses this by:

  • Caching the raw fetched data before picking an attribute (e.g current_temperature, target_temperature,...) or statistic (min, max, ...)
  • Making multiple requests for the same entity in sequence (currently superfluous, but relevant for offsets), so the ranges subtraction logic avoids fetching overlapping intervals
  • Delaying the decision of what attribute/statistic to pick from until plotting time

The performance improvement is exactly proportional to the amount of traces on the same entity. E.g, when plotting max, min and mean, it is 3x faster

@dbuezas dbuezas force-pushed the perf/avoid-redundant-fetches branch from 2b0dc82 to e7c63ea Compare November 15, 2022 20:20
@dbuezas dbuezas merged commit 59c04f9 into master Nov 15, 2022
@dbuezas dbuezas deleted the perf/avoid-redundant-fetches branch November 15, 2022 21:10
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

Successfully merging this pull request may close these issues.

1 participant