-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
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
Cache the response from config/entity_registry/list #74443
Conversation
This reverts commit 810b2a2.
Reverts home-assistant#74378 and replaces this with a cache instead
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( |
We should probably resolve the symlink and stat the files in the executor. It might make the request a bit slower though. The upside is that if you open the UI during startup when the system is IO bound it won't block the event loop waiting to be able to run the readlink/stat syscslls |
Actually for the frontend files if we aren't in dev mode it might make more sense to cache the filepath lookup |
Same as home-assistant#74443 for the device registry
This one should be good to go. #74474 takes care of the existing I/O in the event loop |
This is part of an optimization cycle to improve the responsiveness of the UI during first pickup and startup
Proposed change
Reverts #74378 and replaces this with a cache instead.
When doing additional testing, the list comp was still
slow on my RPI 32bit test platform, and we still had
the json encode overhead (while its much better with
orjson, its still not trivial).
This reduces the CPU spike
when everything reconnects at startup. The device
registry does show up on the profile still, and while its
small for one device reconnecting, it could have an impact
if they have 5-6 and the system is cpu bound during startup
so we might want to do that one as well in the future
but addressing the static files path is probably time
better spent.
Flame graph of an initial websocket connect
on cache hit its below the sampling threshold.
And yes it does look like static files call pathlib which is doing
I/O in the event loop but that seems to be copied from
aiohttp so I'm not sure if it should or not
Similar strategy as
core/homeassistant/components/websocket_api/messages.py
Line 70 in ebc8fba
event itself
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
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: