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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid importing MQTT into core for ServiceInfo dataclass #74418
Avoid importing MQTT into core for ServiceInfo dataclass #74418
Conversation
Hey there @emontnemery, mind taking a look at this pull request as it has been labeled with an integration ( |
Hey there @emontnemery, mind taking a look at this pull request as it has been labeled with an integration ( |
d7e685c
to
76f3433
Compare
76f3433
to
e248488
Compare
Its still going to hit |
This still takes 8s on my spinning disk system
|
I think we need to relo all these dataclasses into their own area |
Was on the fence on if this was worth the churn but after #75183 I'm not on the fence anymore and will move this foward and do followups for bluetooth, and the others. |
Proposed change
Which ever integration triggered the first discovery flow would trigger the python code for mqtt to be loaded. Since most flows would wait until after startup since we queue them until the started event if they come from discovery, this meant that the
rpi_power
integration which is triggered from theraspberry_pi
hardware integration would cause this to happen a lot sooner on RPI platforms. MQTT python code loading would happen at an unexpected time which is a blocking operation since the python files have to be loaded from disk. This caused warnings since everything was waiting for MQTT code load (which takes 8s on my x86_64 spinning disk machine and likely longer on RPi3b+s with an sd card)Likely fixes #73863
A nice side effect is that if you aren't using MQTT, this saves ~20MiB of RAM on 64bit platforms
I will move the rest of them in a followup PR but I didn't want to do that now since this one should go into beta since they will already be loaded anyways if they are enabled and don't have this issue, but its better to be consistant and have them all in one place in case we add more in the future.
MQTT was getting loaded via config flow since it was needed to type
async_step_mqtt
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: