Defer esphome persistent storage writes until after startup#42600
Defer esphome persistent storage writes until after startup#42600balloob merged 1 commit intohome-assistant:devfrom
Conversation
|
Hey there @OttoWinter, mind taking a look at this pull request as its been labeled with an integration ( |
1ae34ff to
f83de92
Compare
There was a problem hiding this comment.
Nice one.
We should find all the async_save and make them delays unless it's auth related (user/config entry).
There was a problem hiding this comment.
I'll audit what else is done at startup and adjust since these are the ones we except to be I/O bound since they are competing with loading the .py files from disk.
Avoid disk I/O during startup as it can cause delays when a user has many esphome devices.
f83de92 to
1445ca3
Compare
|
|
||
| DATA_KEY = "esphome" | ||
|
|
||
| SAVE_DELAY = 120 |
There was a problem hiding this comment.
Is this going to be okay? If there never will be 2 minutes of no data, it will never save until HA is shut down.
There was a problem hiding this comment.
Should be fine since it only needs the data to re-setup the config entries with the last state before its able to make the connection to the device.
There was a problem hiding this comment.
For other use cases, we could consider adding a max_wait to delay_save to make sure it's written eventually (besides on shutdown).
Noticed because I have 35+ esphome devices.
Proposed change
Defer esphome persistent storage writes until after startup
Avoid disk I/O during startup as it can cause delays when
a user has many esphome devices.
Type of change
Example entry for
configuration.yaml:# Example configuration.yamlAdditional 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: