core/tests/components/frontend
J. Nick Koston 5b8591ec7e
Avoid reschedule churn in Storage.async_delay_save (#111091)
* Avoid circular import in Storage.async_delay_save

We call Storage.async_delay_save for every entity being added or removed
from the registry. The late import took more time than everything else
in the function.

* Avoid reschedule churn in Storage.async_delay_save

When we are adding or removing entities we will call async_delay_save
quite often which has to add and remove a TimerHandle on the event loop
which can add up when there are a lot of registry items changing.

If the timer handle still has 80% of the time remaining on it
we will avoid resceduling and let it fire at the time the
original async_delay_save call was made. This ensures we
do not force the event loop to rebuild its heapq because
too many timer handlers were cancelled at once

* div0

* add coverage for 0 since we had none

* fix bad conflict

* tweaks

* tweaks

* tweaks

* tweaks

* tweaks

* tweaks

* more test fixes

* mqtt tests rely on event loop overhead
2024-02-24 08:46:00 +01:00
..
__init__.py
test_init.py Avoid reschedule churn in Storage.async_delay_save (#111091) 2024-02-24 08:46:00 +01:00
test_storage.py