On Tue, Sep 23, 2008 at 11:34 PM, Andy Wardley <[EMAIL PROTECTED]> wrote:
> Unless you're doing something computationally expensive (in which case, > you're better off writing it as a Perl subroutine or plugin) then it's > unlikely (but not impossible) that the template rendering is a problem > by itself. About 8 minutes for the template on my dev system. The production system is taking between 8 and 20 minutes (and sometimes over 40 minutes) to render the template. > There's an overhead to accessing variables which will make > it slower than pure Perl, but unless you're accessing lots and lots of > variables (e.g. deeply nested loops with lots of calculation) then you > shouldn't really notice any performance problems. The data structure I am passing it includes a list of hashrefs, each hashref has a 2d array. So there are three nesting of loops and probably about 20k-40k entries in the 2d arrays total (each row in the 2d array represents an invoice, and each invoice has, I think 4 pieces of data associated with it). I moved most of the arithmetic out, as I noticed that was approx 50x slower than in pure Perl. The areas I am currently suspicious of include blocks which generate inputs (since there are approx 5k inputs on the page when this occurs), and the use of the following tag which gets executed probably 10k times: <?lsmb FILTER format('%15.2f') ?> > >> I have a template which is taking forever to render > > Roughly how long is "taking forever"? My first complaint from my customer was "after 40 minutes I give up and stop loading the page." However, this is intermittent and probably a system issue. However, it never takes less than 6-8 minutes. . > > It's more likely that something you're pulling into the template is taking > a long time to access. Are you making repeated database connections that > could be taking a while to setup? Nope. One db connection, something like 4 queries in quick succession and a commit. Total db time is not great (about 15 sec) but only a tiny part of the execution time on the script. This all happens before the template is generated. > Or perhaps accessing files on a slow > network filesystem? If you're talking to a database then you should check > how long those queries take from the command line. Already done as that was my first thought. However, top shows the Perl script running forever, and with a little prodding we were able to determine that the template rendering was the vast majority of the time. My 6-8 min. on my laptop involves very little db activity as the main queries are replaced with cached data. > It could be something > as simple as needing to add an index or two to the database (or looking > into replication/sharding if your database is being swamped by multiple > client connections and/or lengthy queries). I think I know why there is the variation in production (it may be a concurrency issue with the web app, but not the db), however, if I am right, cutting it down a bit (maybe down to 4-min. to render in my laptop) might help significantly. Best Wishes, Chris Travers _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates