2015-03-23, 13:44
Hi All,
What is this topic about:
I wanted to make this topic because i am having issues with very slow Kodi + MySQL performance and i think there are more people that run into this issue, maybe without even knowing it could and should perform much better.
What is slow exactly?
Users are reporting slow browsing of the Kodi library since Kodi upgrade. Most noticably; widgets are very slow to populate on Kodi start up.
XBMC13.2 vs Kodi14 example: https://www.youtube.com/watch?v=x6XWqUD7aHc
What can be done?
Lets start by optimizing our MySQL server. (Thanks to forum users for some of the optimizations)
1: Kodi should create your database InnoDB format by default. Check if this is the case as MyISAM is less optimal.
2: add "skip-name-resolve" to my.ini/my.cnf config file.
3: Enable and optimize query caching. Add following to my.ini/my.cnf config file.
query_cache_type = 1
query_cache_size = 15728640
query_cache_limit = 1048576
4: Add table indexes (Possibly useless as its default since XBMC12)
ALTER TABLE movie ADD INDEX ix_idFile(idFile);
ALTER TABLE movie ADD INDEX idMovie(idMovie);
ALTER TABLE movie ADD INDEX idFile(idFile);
5: Clean your Database/Cache. Take a look at this topic: http://forum.kodi.tv/showthread.php?tid=158373
Still slow? Join the club
Even after these optimzations, Kodi is still slow. Let's compare Kodi to XBMC some more. Lets talk about MySQL utilization during XBMC/Kodi startup.
Top = Kodi
Bottom = XBMC
Comparing the two, we see that Kodi is a little bit more agressive on the query side. This might be explained by XBMC grabbing content one at a time and Kodi seems to have a more "grab it all at once" plan of attack.
Kodi seems to be grabbing a little more content but not really seeing any issues here.
Let's continue to disk utilization. I happen to use Apache Webdav as my source content which gives me easy content access logging.
XBMC startup:
Yeah..., Nothing. Everything is grabbed from local cache. This is how we like it.
Kodi startup:
So.. Yeah.. On startup, disk was accessed more then 320 times. Worst of all, these files don't even exist (404) (FYI: All my image/metadata content is local and was scanned local)
I checked if these banners or posters are referenced anywhere (nfo file) but no trace. Something is just guessing these content paths and possibly taking a long time to do it.
Everytime when entering a menu in the library (Movies or TV-Shows), the above disk access is repeated. Causing a major slowdown in library browsing.
My guess is that we have to start looking at the content grabbers. Grab Fanart plugin or the Library Data Provider plugin?
These plugins seem to be doing their job less then optimal since recent updates or they are bieng called in a different way
Grab Fanart Plugin versions:
XBMC: 0.13.2
Kodi: 0.14.0
Libary Data Provider versions:
XBMC: 0.0.8
Kodi: 0.0.8
Jeroen, the ReFocus skin creator was so kind to create a different IncludesHome.xml file for me where he changed the way content it called.
From:
To:
This has changed the widget population time from 30 to ~10seconds but still way under the XBMC13.2 of barely 2 seconds.
At this moment my knowledge becomes a bit limited as i am not a programmer/skinner. Maybe someone else may be able to give some input?
What is this topic about:
I wanted to make this topic because i am having issues with very slow Kodi + MySQL performance and i think there are more people that run into this issue, maybe without even knowing it could and should perform much better.
What is slow exactly?
Users are reporting slow browsing of the Kodi library since Kodi upgrade. Most noticably; widgets are very slow to populate on Kodi start up.
XBMC13.2 vs Kodi14 example: https://www.youtube.com/watch?v=x6XWqUD7aHc
What can be done?
Lets start by optimizing our MySQL server. (Thanks to forum users for some of the optimizations)
1: Kodi should create your database InnoDB format by default. Check if this is the case as MyISAM is less optimal.
2: add "skip-name-resolve" to my.ini/my.cnf config file.
3: Enable and optimize query caching. Add following to my.ini/my.cnf config file.
query_cache_type = 1
query_cache_size = 15728640
query_cache_limit = 1048576
4: Add table indexes (Possibly useless as its default since XBMC12)
ALTER TABLE movie ADD INDEX ix_idFile(idFile);
ALTER TABLE movie ADD INDEX idMovie(idMovie);
ALTER TABLE movie ADD INDEX idFile(idFile);
5: Clean your Database/Cache. Take a look at this topic: http://forum.kodi.tv/showthread.php?tid=158373
Still slow? Join the club
Even after these optimzations, Kodi is still slow. Let's compare Kodi to XBMC some more. Lets talk about MySQL utilization during XBMC/Kodi startup.
Top = Kodi
Bottom = XBMC
Comparing the two, we see that Kodi is a little bit more agressive on the query side. This might be explained by XBMC grabbing content one at a time and Kodi seems to have a more "grab it all at once" plan of attack.
Kodi seems to be grabbing a little more content but not really seeing any issues here.
Let's continue to disk utilization. I happen to use Apache Webdav as my source content which gives me easy content access logging.
XBMC startup:
Code:
tail -f /var/log/httpd-access.log
Yeah..., Nothing. Everything is grabbed from local cache. This is how we like it.
Kodi startup:
Code:
tail -f /var/log/httpd-access.log
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/The.Imitation.Game.2014/The.Imitation.Game.2014-banner.png HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Birdman.2014/Birdman.2014-banner.jpg HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Birdman.2014/Birdman.2014-banner.png HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Laggies.2014/Laggies.2014-banner.jpg HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Laggies.2014/Laggies.2014-banner.png HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Wild.2014/Wild.2014-banner.jpg HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Wild.2014/Wild.2014-banner.png HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Interstellar.2014/Interstellar.2014-banner.jpg HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies/Interstellar.2014/Interstellar.2014-banner.png HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies_archive/Caligula.1979/Caligula.1979-banner.jpg HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies_archive/Caligula.1979/Caligula.1979-banner.png HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies_archive/A.Beautiful.Mind.2001/A.Beautiful.Mind.2001-banner.jpg HTTP/1.1" 200 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies_archive/The.Girl.With.The.Dragon.Tattoo.2011/The.Girl.With.The.Dragon.Tattoo.2011-banner.jpg HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies_archive/The.Girl.With.The.Dragon.Tattoo.2011/The.Girl.With.The.Dragon.Tattoo.2011-banner.png HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies_archive/Hot.Tub.Time.Machine.2010/Hot.Tub.Time.Machine.2010-banner.jpg HTTP/1.1" 404 -
10.10.10.50 - Access [23/Mar/2015:12:06:29 +0100] "HEAD /datastore1/Movies_archive/Hot.Tub.Time.Machine.2010/Hot.Tub.Time.Machine.2010-banner.png HTTP/1.1" 404 -
Add 300 more lines
So.. Yeah.. On startup, disk was accessed more then 320 times. Worst of all, these files don't even exist (404) (FYI: All my image/metadata content is local and was scanned local)
I checked if these banners or posters are referenced anywhere (nfo file) but no trace. Something is just guessing these content paths and possibly taking a long time to do it.
Everytime when entering a menu in the library (Movies or TV-Shows), the above disk access is repeated. Causing a major slowdown in library browsing.
My guess is that we have to start looking at the content grabbers. Grab Fanart plugin or the Library Data Provider plugin?
These plugins seem to be doing their job less then optimal since recent updates or they are bieng called in a different way
Grab Fanart Plugin versions:
XBMC: 0.13.2
Kodi: 0.14.0
Libary Data Provider versions:
XBMC: 0.0.8
Kodi: 0.0.8
Jeroen, the ReFocus skin creator was so kind to create a different IncludesHome.xml file for me where he changed the way content it called.
From:
Code:
<content limit="25" target="video">plugin://service.library.data.provider?type=recentmovies&reload=$INFO[Window(10000).Property(
recentmovies)]</content>
Code:
<content target="video">videodb://recentlyaddedmovies/</content>
This has changed the widget population time from 30 to ~10seconds but still way under the XBMC13.2 of barely 2 seconds.
At this moment my knowledge becomes a bit limited as i am not a programmer/skinner. Maybe someone else may be able to give some input?