Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve library listings in smaller chunks #347

Closed
marcelveldt opened this issue Jun 15, 2022 · 5 comments
Closed

Retrieve library listings in smaller chunks #347

marcelveldt opened this issue Jun 15, 2022 · 5 comments
Labels
enhancement Improvements of existing functionality
Milestone

Comments

@marcelveldt
Copy link
Member

The library items are retrieved by the frontend when you open the panel all-at-once.
So all Artists are loaded in one batch, All Albums etc.

For people with larger collections this comes with a performance penalty:

  1. There's a real large chunk of data being moved from db --> MA --> HA --> websocket --> frontend
  2. It takes a while before the frontend is useable, you have to wait until the data is precached into the "store" of the frontend.
  3. The HA executor is busy creating large chunks of data, I believe @bdraco has recently seen a profiler report showing this.

Solution here would be to move the item listings around as smaller chunks.
Like prefetch the first 250 items and request more if you scroll around the listings (or slowly prefetch them if you are navigating)

Not a very large job to adjust but needs to be done properly. Too much to make it into the 2022.6 release tomorrow.
This task is a reminder.

There are several issues reported directly or more indirect belonging to this issue.

@marcelveldt marcelveldt added the enhancement Improvements of existing functionality label Jun 15, 2022
@bdraco
Copy link

bdraco commented Jun 15, 2022

Here are some call graphs of the two major performance hotspots

from_db_row
async_get_mass_func

@marcelveldt
Copy link
Member Author

@bdraco thanks, very helpful! Just as I suspected the load is in getting the library items all at once (e.g. tracks, albums etc).
this is also going to have a huge performance benefit of your orjson project ;-)

@bdraco
Copy link

bdraco commented Jun 15, 2022

Excellent home-assistant/core#72847 is hopefully unblocked soon ... https://twitter.com/pvizeli/status/1537093332500979714

@marcelveldt marcelveldt added this to the 2022.6.0 milestone Jun 16, 2022
@erkr
Copy link
Contributor

erkr commented Jun 16, 2022

This is really working much better in beta 7 👍
I believe this issue can be closed

@erkr erkr added the Completed label Jun 16, 2022
@marcelveldt
Copy link
Member Author

This is now implemented. Only small chunks at once are grabbed. This will save a huge performance hit and it will be even better once the orjson support hits HA core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements of existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants