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
Fix mobile app dispatcher performance #99647
Conversation
The mobile_app would setup a dispatcher to listener for updates on every entity and reject the ones that were not for the unique id that it was intrested in. Instead we now register for a signal per unique id since we were previously generating O(entities*sensors*devices) callbacks which was causing the event loop to stall when there were a large number of mobile app users.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
This causes enough callbacks to generate an asyncio debug warning so I tagged it |
I've been looking for this one a for a long time but was just lucky enough for it to happen when I was profiling today |
Nice catch! |
Fix mobile app thundering heard The mobile_app would setup a dispatcher to listener for updates on every entity and reject the ones that were not for the unique id that it was intrested in. Instead we now register for a signal per unique id since we were previously generating O(entities*sensors*devices) callbacks which was causing the event loop to stall when there were a large number of mobile app users.
Proposed change
The mobile_app would set up a dispatcher to listen for updates on every entity and reject the ones that were not for the unique id that it was interested in. This generated
O(n*devices)
callbacks which meant each new mobile app integration made the performance significantly worse which was causing the event loop to stall when there were a large number of mobile app users.Instead we now register for a signal per unique id which generates
O(1)
callback per sensor update.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: