Just to reiterate what everyone else has said... Thanks!

With this new stash, I noticed an overall improvement in runtime of
approximately 10-15%.  That's application-wide, not just templating.  
Nice.  Here are my latest profiling results, which highlight a couple of
routines which might also be candidates for XSing... possibly in v3?

Total Elapsed Time = 9649.115 Seconds
  User+System Time = 8187.315 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c  Name
 0.06   4.705 67.230  15016   0.0003 0.0045  Template::Provider::__ANON__
 0.03   2.727 10.496  70016   0.0000 0.0001  Template::Stash::XS::get
 0.03   2.572 50.012  14448   0.0002 0.0035  Template::Context::include
 0.02   1.639  1.559  14732   0.0001 0.0001  Template::Stash::clone
 0.02   1.405  2.703   1181   0.0012 0.0023  Petsmart::DBO::Product::lo...
 0.01   1.129  1.040  16297   0.0001 0.0001  Template::Iterator::get_next
 0.01   1.109  1.096   2462   0.0005 0.0004  DBI::st::execute
 0.01   0.749  0.747   1417   0.0005 0.0005  Template::Provider::load
 0.01   0.719  1.121  15300   0.0000 0.0001  Template::Context::template
 0.01   0.627  1.285   2820   0.0002 0.0005  Petsmart::Akamaizer::creat...
 0.01   0.598  2.078   2820   0.0002 0.0007  Petsmart::Akamaizer::urlToArl
 0.01   0.580  0.565   2740   0.0002 0.0002  DBI::st::fetch
 0.00   0.399  0.417    283   0.0014 0.0015  main::printPage
 0.00   0.390  0.278  20420   0.0000 0.0000  Template::Stash::XS::set

++t

On Mon, 20 Aug 2001, Doug Steinwand wrote:

> Hello All,
> 
>  I've recently developed an XS module for Template Toolkit that should
> help improve performance.  I started with Andy's work from last year and
> rewrote it to work with Template Toolkit version 2.04.  Amazingly, it
> passes all tests in the ''make test'' suite.  Under ideal conditions,
> it's about twice as fast as the original, pure-perl version.
> 
>  Attached you will find a tarball with the changes.  I've successfully
> compiled it on FreeBSD 4.3 and RH Linux 6.2 using gcc 2.95.3 with the
> ''-O -Wall -ansi'' options; your mileage may vary.
> 
>  I want to thank TicketMaster, Inc. for giving me the opportunity to
> develop, test and then release this code to the community.
> 
>  - doug
> 
> 
> Template-Toolkit-2.04/xs/README
> 
> ----------------------------------------------------------------------
>  Template::Stash::XS                                      August 2001
> ----------------------------------------------------------------------
> 
> Introduction:
> 
>  * This is an XS implementation of the Template::Stash module, based
>    in part upon work that Andy Wardley did late last year.  It is
>    an alternative version of the core Template::Stash methods ''get'' 
>    and ''set'' (the ones that should benefit most from a speedy C 
>    implementation), along with some virtual methods (like first, last,
>    reverse, etc.)
> 
> 
> How to Build:
> 
>  1) Fetch and extract the Template-Toolkit-2.04.tar.gz and
>     TT-2.04-XS.tar.gz tarballs:
> 
>         # mkdir work
>         # cd work
>         # tar zxf Template-Toolkit-2.04.tar.gz
>         # tar zxf TT-2.04-XS.tar.gz
> 
> 
>  2) Build Template Toolkit as usual, and answer ''yes'' to the XS 
>     Stash questions. Note: Unless you answer ''yes' to the second 
>     question, the ''make test'' step will not actually be testing the 
>     XS version.  If so desired, use the PREFIX= option to install in 
>     an alternative directory.  Also, you'll need a recent version of 
>     File::Spec to pass all the tests -- see this link:
>     http://search.cpan.org/search?dist=File-Spec
> 
>         # cd Template-Toolkit-2.04
>         # perl Makefile.PL PREFIX=/somplace/else
> 
>           ... Do you want to build the XS Stash module? 
>           ... Do you want to use the XS Stash for all Templates?
> 
>         # make
>         # make test
> 
> 
>  3) Run the additional test script ''tt-bench.pl'' to see the 
>     improvement in speed. You may need to install the BSD::Resource
>     module -- see http://search.cpan.org/search?dist=BSD-Resource
> 
>         # perl tt-bench.pl
> 
> 
>  4) Optionally, install the new Template Toolkit:
> 
>         # make install
> 
> 
> Additional Notes:
> 
>  * Depending upon the size and content of a template, this version
>    has about twice the speed of the original Template::Stash.
> 
> 
>  * When a virtual method (like pop, push, nsort, sort etc.) has not
>    been implemented in XS, it uses these hashrefs in Template::Stash
>    package -- $HASH_OPS, $LIST_OPS, and $SCALAR_OPS -- to call perl
>    subroutines that can do the work.
> 
> 
>  * Using the ''reference'' feature of Template Toolkit -- like
>    [% a = \foo %] -- leaks a large amount of memory. Enable the
>    template code at the end of ''tt-bench.pl'' for a demonstration.
>    (Note: This is a problem in the pure-perl version, too.  Also,
>    you'll need a platform that fully supports getrusage() -- FreeBSD
>    and IRIX are two that should work. Otherwise, use a utility like
>    ''top''. )
> 
> 
>  * Although it passes all the tests that I've thrown at it, there may
>    still be some problems and/or bugs.  My primary goal was to mirror
>    the behavior of the pure-perl version using XS.
> 
> 
>  * Profiling code can be enabled with ''#define TT_PERF_ENABLE'' in
>    the Stash.xs source, but doing so hurts performance a bit.  The
>    results can be displayed by adding the line:
> 
>           print Template::Stash::XS::performance(1);
> 
>    to your code. Use a 0 instead of 1 for a more compact display.
> 
> 
>  * If you make changes to Stash.xs, simply run ''make'' and optionally
>    ''make install'' in the Template-Toolkit-2.04 directory.
>    Furthermore, there's no need to try crazy compiler optimizations on
>    this code, because a majority of time is spent inside Perl's
>    functions.
> 
> 
>  * Here's the manifest for the TT-2.04-XS.tar.gz package:
> 
>         Template-Toolkit-2.04/Makefile.PL
>         Template-Toolkit-2.04/tt-bench.pl
>         Template-Toolkit-2.04/lib/Template/Stash/XS.pm
>         Template-Toolkit-2.04/t/stash-xs.t
>         Template-Toolkit-2.04/xs/MANIFEST
>         Template-Toolkit-2.04/xs/Makefile.PL
>         Template-Toolkit-2.04/xs/README
>         Template-Toolkit-2.04/xs/Stash.xs

Tony Payne  :  Sr. Software Engineer  :  PETsMART.com  :  626-817-7151




Reply via email to