[Templates] Performance and caching

Nigel Metheringham Nigel.Metheringham@dev.intechnology.co.uk
Thu, 18 May 2006 14:25:17 +0100


The Catalyst docs suggest that the following settings are used to
improve performance (in a ::View::TT):-

__PACKAGE__->config(
    {
       ...
        #
        # performance tweaks
        COMPILE_DIR        => dir(MyApp->config->{home},
                                  'tmp'),
        STASH              => Template::Stash::XS->new,
    }
);


Now the Template::Stash::XS recommendation make sense, and presumably
benefits all apps.  

However the TT documentation implies to me that setting COMPILE_DIR is
only of use when a process is restarted - so a long lived FastCGI or
mod_perl process would gain little benefit (and potentially take a hit
if it stats the cached files).

In the docs for Template::Provider is the section:-
CACHE_SIZE
        The Template::Provider module caches compiled templates to avoid
        the need to re-parse template files or blocks each time they are
        used. The CACHE_SIZE option is used to limit the number of
        compiled templates that the module should cache.
        
        By default, the CACHE_SIZE is undefined and all compiled
        templates are cached. When set to any positive value, the cache
        will be limited to storing no more than that number of compiled
        templates. When a new template is loaded and compiled and the
        cache is full (i.e. the number of entries == CACHE_SIZE), the
        least recently used compiled template is discarded to make room
        for the new one.
        
        The CACHE_SIZE can be set to 0 to disable caching altogether.
        

To me this implies that *by default* TT in a long lived process will
cache all the compiled templates, and so caching them on disk is only
useful for restarting a process.

Am I right in this or just deluded as usual?

	Nigel.
-- 
[ Nigel Metheringham           Nigel.Metheringham@InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]