Archive:Optimize Load Time of Plugins with Persistence Scripts
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.