-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
Add support for caching entity properties #100601
Conversation
The PR description needs to be corrected. It's talking about the wrong attribute. |
This comment was marked as outdated.
This comment was marked as outdated.
0127573
to
76faf85
Compare
76faf85
to
06b20d7
Compare
What is the amount of time as an example? It also matters if it's already slow or very fast. |
I updated the PR description with this information. |
Will test this later today. At first glance it looks like it will take care of some of the heavy hitters we see with a large number of polling integrations. |
With previous testing the hot platforms where in order:
These are the places where the cost is much higher where I expect this will really ✨ |
Looks like |
This sounds incorrect. |
Yeah, the numbers were swapped, fixed now. |
Proposed change
Add support for caching entity properties
The implementation in this PR is essentially the same as in #95315 but:
Entity._attr_*
are caught and cause the corresponding property's cache to be invalidatedEntity._attr_*
attribute are cachedWith the simple test below, the time needed for calculating state is decreased by around 1/3 on my development machine, from ~3.3 µs / iteration to ~1.8 µs / iteration:
If this PR is accepted, base classes for entity domains should be modified in the same way in follow-up PRs
Needs:
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: