xbmc/xbmc — pull request #1462 by Montellese (2012-09-22 10:47:41+00:00)
Title: jsonrpc: only initialize the (Video|Music)ThumbLoader once when retrieving artwork for a list of items

These changes are a way to reduce the time it takes to retrieve big lists of items with their artwork (thumbnail and/or fanart). Currently we get a new instance of C(Video|Music)ThumbLoader for every item and open/close the connection to the database for every single item. On my system this results in a response time of a JSON-RPC request to AudioLibrary.GetSongs of ~14 seconds for 1500 songs. If I don't retrieve any artwork the response time is around 1s.

With these changes we only get a single instance of C(Video|Music)ThumbLoader and only open the connection to the database once for all the items which brings the response time of the request to AudioLibrary.GetSongs down to ~3.5 seconds. This is still quite a bit slower than the 1 second it takes when not retrieving artwork but it is a lot faster than the current 14 seconds.

This problem has been reported a lot in the JSON-RPC discussion thread and is present since the new implementation of the texture cache because it requires at least one additional SQL query for every item and artwork. Before the new texture cache we had 1 SQL query and now we have 1 + #items * #artwork so for 1500 songs with thumbnail and fanart that's 1 + 1500 * 2 = 3001 queries.