* Signficantly reduce executor contention during bootstrap
At startup we have a thundering herd wanting to use the executor
to load manifiest.json. Since we know which integrations we are
about to load in each resolver step, group the manifest loads
into single executor jobs by calling async_get_integrations on
the deps of the integrations after they are resolved.
In practice this reduced the number of executor jobs
by 80% during bootstrap
* merge
* naming
* tweak
* tweak
* not enough contention to be worth it there
* refactor to avoid waiting
* refactor to avoid waiting
* tweaks
* tweaks
* tweak
* background is fine
* comment
* Reduce overhead to compile statistics
statistics uses LazyState for compatibility with State when pulling
data from the database.
After the previous round of refactoring to modern history, the setters
are never called and can be removed.
* reduce
Almost 99% of items that are put into the recorder queue are
Events. Avoid wrapping them in tasks since we have to unwrap
them right away and its must faster to check for both RecorderTask
and Events since events are the common case.
* Refactor translations to reduce dict lookups
All of our cache lookups used:
`cache[language][O(component)][category]`
The cache was designed as
`cache[language][component][category][flatted_key]`
The lookups are now
`cache[language][category][O(component)]`
The cache is now stored as
`cache[language][category][component][flatted_key]`
This allows the catch fetch to avoid looking up
the category each loop
* already a set, and we do not mutate
* Bump google-generativeai to 0.3.1
* Migrate to the new API and default to gemini-pro
* Add max output tokens option
* Add generate_content service
* Add tests
* additional checks
* async read_bytes
* Add tests for all errors
* Add support for the Spotify DJ playlist by mocking the playlist response
Add error handling for playlist lookup to ensure it doesn't break current playback state loading
* Run linters
Add exception type to playlist lookup error handling
* Fix typo in comment
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
---------
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
* remove removed locks
* move duplicated code to function
* remove entities by removing device
* add new locks automatically
* add locks from coordinator
* remove other PR stuff
* add pullspring lock to test for coverage
* requested changes