Addon performance
#1
I have a video addon where i am looking at some performance tuning for displaying list items.  I have seen the caching / offscreen thread but I have a specific question about performance with adding context menu additions to list items. 

Here's the specific code I am using:

                    if playcount == 0:
                        li.addContextMenuItems([ (addon.getLocalizedString(30347), 'Container.Refresh'),            \
                        (addon.getLocalizedString(30346), 'Action(ParentDir)'), (addon.getLocalizedString(30372),   \
                        'RunScript(plugin.video.mezzmo, {},{}, {}, {}, {}, {}, {}, {})'.format(pctitle, itemurl,    \
                        season_text, episode_text, playcount, pcseries, pcdbfile, contenturl)) ])
                    elif playcount > 0:
                        li.addContextMenuItems([ (addon.getLocalizedString(30347), 'Container.Refresh'),            \
                        (addon.getLocalizedString(30346), 'Action(ParentDir)'), (addon.getLocalizedString(30373),   \
                        'RunScript(plugin.video.mezzmo, {},{}, {}, {}, {}, {}, {}, {})'.format(pctitle,itemurl,    \
                        season_text, episode_text, playcount, pcseries, pcdbfile, contenturl)) ])  

This is called each time a list item is added / displayed.  My question is the overhead of addon.getLocalizedString function being called each time vs. calling them once before the list item population loop ?
For example:

contextitem1 = addon.getLocalizedString(30346)
contextitem2 = addon.getLocalizedString(30347)
contextitem3 = addon.getLocalizedString(30372)
contextitem4 = addon.getLocalizedString(30373)

add list item loop:

                    if playcount == 0:
                        li.addContextMenuItems([ (contextitem2, 'Container.Refresh'),            \
                        (contextitem1, 'Action(ParentDir)'), (contextitem3,   \
                        'RunScript(plugin.video.mezzmo, {},{}, {}, {}, {}, {}, {}, {})'.format(pctitle, itemurl,    \
                        season_text, episode_text, playcount, pcseries, pcdbfile, contenturl)) ])
                    elif playcount > 0:
                        li.addContextMenuItems([ (contextitem2, 'Container.Refresh'),            \
                        contextitem1, 'Action(ParentDir)'), (contextitem4,   \
                        'RunScript(plugin.video.mezzmo, {},{}, {}, {}, {}, {}, {}, {})'.format(pctitle,itemurl,    \
                        season_text, episode_text, playcount, pcseries, pcdbfile, contenturl)) ])  

Is one vs. the other recommended and is there a lot of overhead with the addon.getLocalizedString(30346) types of calls for each list item ?


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#2
There shouldn't be much overhead in getting the localized string. I'd be more concerned about that fact that you're calling RunScript for every list item. There is significant (well, relative to just calling a method) overhead in running a script, so if there's some way you can avoid that, you're likely to see better performance than with tweaking the localized string call.
Reply
#3
(2020-10-09, 23:59)pkscout Wrote: There shouldn't be much overhead in getting the localized string. I'd be more concerned about that fact that you're calling RunScript for every list item. There is significant (well, relative to just calling a method) overhead in running a script, so if there's some way you can avoid that, you're likely to see better performance than with tweaking the localized string call.

Thanks for the feedback.  The script doesn't run every time a list item is added, it is just what is called if a user clicks on the new context menu item.  Ronnie and I had a lengthy dialog about this in another thread.  It does seem like on some platforms, mostly lower end ARM processors, that there is overhead with the context RunScript menu additions.   I am not seeing it on Intel NUCs, Windows PCs, Raspberry Pi 4s etc.  It also appears to run faster under Matrix than Kodi 18 so I may not spend much time trying to optimize it.

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#4
(2020-10-10, 01:49)jbinkley60 Wrote:
(2020-10-09, 23:59)pkscout Wrote: There shouldn't be much overhead in getting the localized string. I'd be more concerned about that fact that you're calling RunScript for every list item. There is significant (well, relative to just calling a method) overhead in running a script, so if there's some way you can avoid that, you're likely to see better performance than with tweaking the localized string call.

Thanks for the feedback.  The script doesn't run every time a list item is added, it is just what is called if a user clicks on the new context menu item.  Ronnie and I had a lengthy dialog about this in another thread.  It does seem like on some platforms, mostly lower end ARM processors, that there is overhead with the context RunScript menu additions.   I am not seeing it on Intel NUCs, Windows PCs, Raspberry Pi 4s etc.  It also appears to run faster under Matrix than Kodi 18 so I may not spend much time trying to optimize it.

Jeff

I've gotten to the bottom of the slowness issue loading large playlists and adding the context menu items above.  I was seeing the problem most pronounced on the Vero 4K+ units running OSMC / Kodi.  In my testing I saw the load times for a 150 item playlist go from less than 3 seconds to over 14 seconds after I added the context menu items code above.  The root cause was the order in which I added the list item to the playlist and the context menu items. 

If I added the list item first and then the associated context menu items I would see the extreme slowness.  I reversed the order adding the context menu items first and then the list item addition the load times went back to less than 3 seconds.  I wasn't seeing the issue on Windows, LibreElec on Intel, LibreElec on Raspberry Pi and other platforms running the addon. 

I don't have an explanation for why this was happening but wanted to share what I found.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#5
Maybe OSMC specific kodi patches?
Reply

Logout Mark Read Team Forum Stats Members Help
Addon performance0