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

Speed up filter processing #476

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mrnerdhair
Copy link

Fixes #379.

Filtering and sorting didn't scale well; area and device processing in particular was O(n^2). In my environment, with ~3000 entities and ~200 devices, displaying a handful of rooms involved 30-second load times.

I've approached the problem by breaking the filter and sort functions down into sections to allow re-use of various intermediate results. I've also added an improved caching infrastructure to prevent multiple loads of the areas/devices/entities/labels lists being triggered by a flurry of initial cache misses.

These changes bring my ~30sec case down to ~200ms.

@Mattie432
Copy link

Mattie432 commented Nov 29, 2024

Holy! This has made such an improvement to my dashboard!

I was at the point of sacking off all the auto-entities i'd written across mutliple dashboards & replace them with fixed lists again. This has made a massive difference to responsiveness, especially on mobile devices with lower compute.

@thomasloven please consider this MR. Until this is rolled in & released, I will be using the forked version.

@mrnerdhair
Copy link
Author

FWIW, I eventually went to writing my own dashboard strategy... not because of shortcomings here as much as the pain of trying to shove everything specific I wanted to do into nothing but templates & yaml. (Also because working on this PR taught me enough to make me more confident in writing my own HA-flavored frontend JS.)

Anyhow, if you find any issues with my PR please LMK and I'll try to fix them up!

@thomasloven
Copy link
Owner

This looks very interesting.
Unfortunately, the PR is full of unrelated code formatting changes, which makes it very hard for me to review.

Could you try to clean those out?

@mrnerdhair
Copy link
Author

Huh. Not intentional, will try to fix that.

@mrnerdhair mrnerdhair force-pushed the improve-filter-performance branch from 83ee40c to 67b79b5 Compare December 6, 2024 19:33
@mrnerdhair
Copy link
Author

Whoops! Looks like I accidentally reset my VS Code formatting defaults to Deno a while back. Here's a better breakdown. I've pinned a specific version of prettier (as they recommend) and normalized the formatting to that.

It's still a pretty big changeset, but at least it's more readable now.

babel({
exclude: "node_modules/**",
babelHelpers: "bundled",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the previous behavior; specifying it explicitly prevents a build-time warning.

@bobbravo2
Copy link

bobbravo2 commented Dec 24, 2024

@mrnerdhair tested out your branch on HA locally, performance looks a lot better!

FWIW -- testing steps -- I had to create a new build of the hass-custom-devcontainer, forked here: https://github.com/bobbravo2/hass-custom-devcontainer

That and the auto-entities.js had to be added manually to the UI via the dashboards -> resources, with the path http://localhost:8123/local/workspace/auto-entities.js

Once that was done, I was able to test your branch:
Zight 2024-12-23 at 20 43 18 jpg

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.

Using a device filter slows down a performance
4 participants