Tags:
create new tag
, view all tags
Most template toolkits (like TemplateToolkit) have some way of precompiling templates to improve performance.

I'm not advocating going as far as TemplateToolkit, but it does occur to me that the current templates are rather inefficient; statis values are expanded every time the templates are instantiated, and they almost all contain includes of other template files.

A possible option would be a small script to statically compile templates - or at least, statically expand all the includes into flat template files. This could be done to generate a "cache" of template files used by the running TWiki.

For example, we ship the current templates dir, which will work fine; an administrator can run tools/compile_templates.pl to generate a templates_cache dir, that could then be used instead of templates if it exists.

The script would be fairly trivial to write.

-- CrawfordCurrie - 17 Jan 2005

Test implementation

I want to simplify the tmpl's needed in the Css zen garden Skin, so i wan to compile them, then refactor the result.

instead of writing a tool, I added a simple hack to TWiki::Template to save the compiled tmpl to a template_cache dir, and to get it form there if it exists. (see attached)

it would be nice to know which tmpl files are entry points and which are supporting libraries though - otherwise its extremely difficult to write a tools/compile_templates.pl . it may even be implossible without a TAG signalling that, as plugins can add any number of top level tmpl's

While the Cache part is not the initial reason for writing the code, I will ammend that patch to make the cache implementation pluggable (ie, make it a call to TWiki::Cache::readFromCache($key).

Kenneth - is there any chance you could benchmark this patch for me? You where rather helpful wrt the users work i did last time.

-- SvenDowideit - 08 Dec 2006

Sven. Naturally I will help with that.

I have once tried to hand compile the view.pattern.tmpl into one flat file. I was so sure I would get min. 100 ms but I ended up saving nothing to my big surprise. But maybe this is a false result. Maybe when you have high traffic and many Apache threads - the template files will not all be in cache RAM but will have to be re-read and then it may make a huge difference. Trying with ab -c 10 or something could be interesting with and without a compiled template.

But my test machine is always available for a benchmark. Just let me know and I will make the tests.

-- KennethLavrsen - 08 Dec 2006

TWiki's skins need a renovation - CssZengardenSkin makes a start shows some results gathered by a more detailed version of this change -

And also the Simplification of twiki the default skins that I'd like to get into the next release.

Kenneth, I'll make a few changes to this patch (its got a bug wrt the TMPL:P context switch stuff), and then get you to test it - I'm in Zurich, and have no access to the servers I have at home to make a repeatable benchmark :/

Thanks smile

-- SvenDowideit - 12 Dec 2006

Not sure what there is to take to a release meeting on this one.

-- KennethLavrsen - 08 Apr 2007

Agreed with Sven that this is really not a proposal as such but more a study with a positive result that can be used as part as already accepted TWikiCache proposal as applicable.

-- KennethLavrsen - 08 Apr 2007

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatEXT Template_cache_patch r1 manage 2.2 K 2006-12-08 - 13:33 SvenDowideit quick optimistic template_cache generator
Unknown file formatEXT Template_debug_patch r1 manage 4.5 K 2006-12-11 - 18:22 SvenDowideit  
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2007-04-08 - KennethLavrsen
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.