You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ryan Thompson <ry...@sasknow.com> on 2001/12/31 00:17:30 UTC

Template-Toolkit performance tuning

Hello again,

Thanks for all the good replies on the template issue. I had forgotten
how much of a powder-keg that subject was... lucky nobody lit a match
:-)

Anyways, I've re-written one of my modules using TT to try it out, but
I am less than satisfied with the performance... To the point where I
think I may have missed an important step. Here's the details:

The template I'm testing uses about 10
	[% IF variable %]Do something with $variable[% END %]
type of blocks. Nothing horribly complex.

With my previous template system, with the same logic, I could serve
on the order of 50 requests per second on the same system. Doing a
straight conversion, I'm seeing only 7.5 requests per second under TT
for the same content. Ugh! Help!

Here's a snipped of what I've done:

	use Template;

	my %vars;

	$var{foo} = "bar";   # About 30 scalars like this
	.
	.

	my $tt = new Template({INTERPOLATE => 1});
	$tt->process($file, \%vars);

Everything displays fine, and no errors/warnings show up... It's just
horribly slow. At ~150ms per request, the delay is noticeable on our
local LAN.

Without delving deeper than I already have into the documentation, I
suspect that the template files are not being cached, resulting in a
disk hit on every request. Not good! There must be a way around this.

Any thoughts?

Thanks,
- Ryan

-- 
  Ryan Thompson <ry...@sasknow.com>
  Network Administrator, Accounts

  SaskNow Technologies - http://www.sasknow.com
  #106-380 3120 8th St E - Saskatoon, SK - S7H 0W2

        Tel: 306-664-3600   Fax: 306-664-1161   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America


Re: Template-Toolkit performance tuning

Posted by Bill Moseley <mo...@hank.org>.
At 05:17 PM 12/30/01 -0600, Ryan Thompson wrote:
>	use Template;
>
>	my %vars;
>
>	$var{foo} = "bar";   # About 30 scalars like this
>	.
>	.
>
>	my $tt = new Template({INTERPOLATE => 1});

Cache your template object between requests.


-- 
Bill Moseley
mailto:moseley@hank.org