Small speed up to setting up integrations and config entries (#117278)

* Small speed up to setting up integration and config entries

When profiling tests, I noticed many calls to get_running_loop. In the places
where we are already in a coro, pass the existing loop so it does not have to
be looked up. I did not do this for places were we are not in a coro since there
is risk that an integration could be doing a non-thread-safe call and its better
that the code raises when trying to fetch the running loop vs the performance
improvement for these cases.

* fix merge

* missed some
This commit is contained in:
J. Nick Koston
2024-05-12 11:39:20 +09:00
committed by GitHub
parent 15825b9444
commit b061e7d1aa
5 changed files with 28 additions and 9 deletions

View File

@@ -427,7 +427,11 @@ async def async_from_config_dict(
if not all(
await asyncio.gather(
*(
create_eager_task(async_setup_component(hass, domain, config))
create_eager_task(
async_setup_component(hass, domain, config),
name=f"bootstrap setup {domain}",
loop=hass.loop,
)
for domain in CORE_INTEGRATIONS
)
)