Archive:Optimize Load Time of Plugins with Persistence Scripts

From Official Kodi Wiki
Revision as of 00:04, 25 March 2009 by >Alexpoet (Initial commit.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Plugins are powerful and easy to write, but that convenience can come with a severe performance cost, particularly in the form of long load times between menus. These load times occur because plugins lack persistence. Every time a user launches a plugin or chooses a menu entry within the plugin, XBMC runs the plugin from scratch, draws the new menu, and then closes the script. Global or class variables used throughout the plugin (often on multiple screens) have to be re-initialized over and over again.

To take full advantage of the plugin design, you should optimize your plugin with this in mind, loading only the information you need on each pass. In some cases (such as plugins that rely on large custom databases), your plugin will require a repeated initialization that costs several seconds every time the user selects a menu item. In such cases, you can significantly speed up navigation by running a Persistence server script in the background, and accessing it from the plugin when you need it.


Overview

Theory

The Client/Server Architecture

Implementation

Installation

Setting Up the Persistence Server

Designing Your Persistent Class

Providing Module Paths to ClassHandler

Updating and Saving Changes with ClassHandler

Known Issues