[xbmc:master] Texture (poster/fanart) loading way too slow
#1
Hello,

today I builded current xbmc:master and found that texture loading is way too slow.
My use case is quite simple. Go to TV show library (1642 entries), press Shift+Z to go to end and now I must wait 12-15sec before poster and fanart appears.
I made debug log, but there is nothing suspicious. I guess following two lines marks start and end of loading process

Code:
22:42:14 T:4428  NOTICE: Thread Background Loader start, auto delete: false
...
22:42:28 T:4428   DEBUG: Thread Background Loader 4428 terminating

It takes 14secs. Problem is that it doesn't happen only one times when I start application and go library for first time, but always when I return to library (from home, from playback, etc.).
From observer point of view it looks like texture list is always loaded from the start and not from selected position.

I'm aware of pull request #918, but from description and comments I'm not sure if it still WIP and I should wait or if it's bug (in builds before this pull request I got textures almost instantly everywhere in the list).

Thx

Reply
#2
Nice - someone with 1642 shows - never short of something to watch, eh?

It's unfortunately hard to tell exactly what is going on from the log. How many of these actually have art associated? Do they all have both thumbs and fanart available? The thumbloader thread is currently completely unoptimised, so it doesn't really surprise me that it takes an age, though ofcourse it shouldn't take that long - a second at most.

The next step is figuring out whether the bg loader has actually done it's thing yet (i.e. all art URLs have been discovered for your shows) - you can check this with a query on your database:

Code:
select idShow from tvshow where idShow not in (select distinct media_id from art where media_type='tvshow');

That should show you the id's of any show that doesn't have art stored in the art table. You could refine it for thumb or fanart:

Code:
select idShow from tvshow where idShow not in (select distinct media_id from art where media_type='tvshow' and type='thumb');

Once we know that, we can explore further. Can you build yourself by any chance?

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
(2012-05-16, 00:26)jmarshall Wrote: Nice - someone with 1642 shows - never short of something to watch, eh?
Smile

(2012-05-16, 00:26)jmarshall Wrote: It's unfortunately hard to tell exactly what is going on from the log. How many of these actually have art associated? Do they all have both thumbs and fanart available? The thumbloader thread is currently completely unoptimised, so it doesn't really surprise me that it takes an age, though ofcourse it shouldn't take that long - a second at most.
All have thumb and only 135 doesn't have fanart.

(2012-05-16, 00:26)jmarshall Wrote: The next step is figuring out whether the bg loader has actually done it's thing yet (i.e. all art URLs have been discovered for your shows) - you can check this with a query on your database:

Code:
select idShow from tvshow where idShow not in (select distinct media_id from art where media_type='tvshow');
...
This select returned me few entries even when they got correctly showed thumbs/fanarts in XBMC. These was shows which have duplicate entries in tvshow table for some reason (scraped from two sources or from two directories under same show name), so I tried to remove duplicates and see if it isn't source of problems. It isn't, it's still ~13sec Smile. Anyway I'm not sure if these "orphaned" entries can't cause problems elsewhere.

(2012-05-16, 00:26)jmarshall Wrote: Once we know that, we can explore further. Can you build yourself by any chance?
Yes, it's my build. I can help with testing, I'll only need help with git because I'm not so familiar with it and don't want to mess my own repo Smile

Cheers
Bambi
Reply
#4
That's fine then, you can do some tests without messing around too much with git. Let's start by making some changes to xbmc/ThumbLoader.cpp - see CVideoThumbLoader::LoadItem().

Start by commenting out the blocks for resume, fanart, thumbnails, and streamdetails, leaving the block that does FillLibraryArt() - basically all you want in CVideoThumbLoader::LoadItem() is the block that does FillLibraryArt().

See what sort of speedup you get from that and we'll go from there. I'll prepare a patch in the meantime that speeds things up in other ways.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
Original
14073ms, 13990ms, 13847ms

Without Resume point
7950ms, 7955ms, 7798ms

Without Resume point, Fanart
7074ms, 6973ms, 7031ms

Without Resume point, Fanart, Thumbnails
7000ms, 7008ms, 7042ms

Without Resume point, Fanart, Thumbnails, Flag extraction
7069ms, 6993ms, 7039ms

So looks like slowest is that resume point (one by one) loading from DB, Fanart section add almost second too, rest is under measurable threshold.
Hope it'll help. Unfortunatelly it looks like we are in completelly oposite timezone so I'm leaving to bed Smile

Cheers
Bambi
Reply
#6
Thanks - most useful. I'll do up a patch that will take care of resumepoint (which at least atm doesn't apply to tvshows) and also takes care of the constant load/unload of the db.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
Ok, I've pushed a fix to master instead. You'll want 625736ad or higher.

There's some slight room for further speedup, mostly around skipping the items that don't have art available so they don't check for art on disk until all other items are done, but we'll see if that's needed before looking at it (it won't actually speed it up all that much further I suspect).

Lastly, assuming this still isn't good enough, we'll have to denormalise the database. This is something I don't want to do, however, as I'd prefer that major changes to the database occurred in tandem with a rewrite, which I just don't have time for at the moment.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#8
It's much better now
3036ms, 2610ms, 2539ms

but still slow for regular usage, it's still visible on my dev PC (C2D 3.6GHz, 8GB, 7200rpm HDD - nothing fast but a lot of HTPCs is far worse Smile).
I have no time for further investigation now, but will check you changes later.

Cheers
Bambi
Reply
#9
Much better. I suspect it's now pretty equivalent to what it was before - before it used to stat() (on thread) every bit of art - local would have been pretty quick, but over the network would have been pretty slow. i.e. the art before was incorporated as part of the directory fetch, so the fetch itself would have been slower, but thumbs would have appeared "instantly" after that.

Try commenting out the fetch for fanart+thumbs like you did before (the resume thing has been taken care of) and see if that helps.

With a query per item, there's not a lot we can do at this point to speed things up without denormalising the database, which I really don't want to have to do (but will if it's the only option).

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#10
(2012-05-17, 08:18)jmarshall Wrote: With a query per item, there's not a lot we can do at this point to speed things up without denormalising the database, which I really don't want to have to do (but will if it's the only option).

May I ask what's a resume point? Is that for items that are in progress?

If it is, it seems unnecessary to fetch it in MyVideoNav.xml as it may be faster to use partially watched overlay for: watched, unwatched and unwatched items that are in progress (playcount=0; playcount>0; play count>0 + bookmarksize>0).

More detailed info on resume point (progress status) could be saved for DialogVideoInfo.xml to improve performance.

Just a thought.
My skins:

Amber
Quartz

Reply
#11
The patch has improved the speed considerably... It is now usable. Smile

Thanks!
Reply
#12
@pecinko: Resume point is available in the listing (a wee play icon is available next to items in confluence IIRC).
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#13
So I tried again comment out code blocks inside of LoadItem() and deltas are almost same like last time
- fanart substracts 800-1000ms
- resume point another 200-300ms
- thumbs and flag extraction nothing measurable

With all these parts commented out I got down to ~1850ms. It's much better than at the start, but I can't share your and vicbitter optimism. It's still far from seamless experience what i had with such big library before.
If I understand your process description correctly this time was part of directory/library loading (not sure about that, never noticed any long delay) and then it showed thumbs/fanarts almost instantly. With current version I always see empty thumb frame for some time everywhere after 1/3 of list, even worse is that it happen everytime i return to the list. Imho from common user point of view it's much worse.
To not only criticise, I have some ideas so I'll study code and experiment little bit over weekend Smile
Reply
#14
Thanks for the measurements.

Resume point for tvshows (which I presume is what you're measuring) should not make any difference whatsoever, as the fileid is empty there. All you're saving is a function call and comparison, which should be microseconds if anything.

Fanart is the big one, as for your shows that have no fanart available (local or remote) we hit the disk to look for it. That could potentially be looked for after we've retrieved the information that's already cached (essentially we'd move the FillLibraryArt() block into CVideoThumbLoader::OnLoaderStart()).

And yes, the previous directory fetch time was slower, particularly if you were using pathsubstitution. This applied to the first fetch primarily, as it counted in the "this directory fetch is slow -> cache the results logic, which is now likely no longer being hit". Note that the directory fetch time for other content (movies for example) can be made faster still, as we could remove the streamdetails fetch there (which is a synchronous query per-item), so you may not see quite as much difference there with dir fetch time. One idea to improve things here is to cache the results of the thumbloader thread in OnLoaderFinish() (and load them in OnLoaderStart, if available). IIRC the picture info loader does this.

For 1600 items, though, 1800ms sounds about right: After all, 1600 queries over the network would be expected to be of that order of magnitude I should think. The only way to speed that up is to use a single query in it's place, but that is non-trivial as we have arbitrary amounts of art per item to retrieve, so simply joining the tables will just create multiple rows per item to parse. One possible solution here is to denormalise the art data so that it is available as a single entry per item, with the disadvantage of added complexity of maintaining that data.

Yet another option is to move the additional information handling to the item level rather than having it handled at the window level: i.e. when information is required for a particular listitem, if the info is not available (and hasn't been looked for in the past) we fire off a handler for that. This means that things still won't be instant, ofcourse, but will be pretty close to instant, as the very first time the item appears in the UI the handler will run. The trick here is that the item needs to be aware of its loader function.

Note that there's always a tradeoff: Either you get a slow listing (which could be cached, which could become stale) with all data available immediately, or you get information available very quickly, with additional information not critical to the initial listing available shortly after.

Personally, I think that for the most part it's probably good enough once we add caching on top of it. Once we have caching, we could fill from the cache synchronously, which would essentially give you the best of both worlds: No long waits for initial listings (with art + extras loaded shortly after) and then fast listings after that.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#15
Agreed... there is still a minor lag (initially) but it is now within usable limits. I have compared against Eden (with path substitution) and I am experiencing much better performance once the list is fully loaded.

If further optimisation can be done then this would be great and I like the caching option. Happy to help test out any code as I have quite a large library (800+). If it helps, I can compile code, etc so could make/apply any suggested mods locally before they need to be committed to master.

Thanks for this fantastic new functionality!

Reply

Logout Mark Read Team Forum Stats Members Help
[xbmc:master] Texture (poster/fanart) loading way too slow0