From: Boris Z. <bz...@2b...> - 2004-09-14 09:14:33
|
Hi Vlad, Am 13.09.2004 um 16:54 schrieb Vlad: > Boris, > > I've installed last version of PgKit-TT you have posted here on my > local server and came to a disappointing performance issues. I don't > know is it tied to PageKit in general and not to TT extension (cause I > didn't play with pgkit + native html templates), but here is the > numbers: > > 1) page kit "homepage" showed me 35 requests per second > > 2) simple pure mod_perl handler that loads and expands TT template > (with 2 included files and one simple cycle) - 330 rps > Thats slow, but the pagekit homepage use already a database and a lot of logic. It is not only expanding some stuff. First try to compare a real page or at least the same ;-). In the Config/Config.xml change reload = 'yes' to reload='no'. That speedup the application a bit. But now you can not change Config entries for the pages without restarting the server. Also the Cache is not checked for updated files ( this is not needed if your application is ready, but for develop you bertter leave it to 'yes'. Now remove as much as possible from Common::pkit_common_code. Or remove the whole sub. > I was considering PageKit as framework for my application, but those > numbers, frankly, keeping me off... I understand that it's not valid > to compare page expanded via pagekit with page expanded purely by TT, > because there is a lot going on "behind the scene" in pagekit, but it > still way too much - 10 times... On my Powerbook G4 1.5 a TT pagekit page *outpreforms* a native TT handler that delivers the same page! I do not have access to another test computer currently. .=--------+------=. | toolkit | con | |=--------+------=| | pkit | 84 | | tt | 28 | | ht | 95 | '=--------+------=' Here the results from a native TT handler: Concurrency Level: 10 Time taken for tests: 55.120 seconds Complete requests: 1500 Failed requests: 0 Broken pipe errors: 0 Total transferred: 5220000 bytes HTML transferred: 4905000 bytes Requests per second: 27.21 [#/sec] (mean) Time per request: 367.47 [ms] (mean) Time per request: 36.75 [ms] (mean, across all concurrent requests) Transfer rate: 94.70 [Kbytes/sec] received and here the same _with_ PageKit: Concurrency Level: 10 Time taken for tests: 17.885 seconds Complete requests: 1500 Failed requests: 0 Broken pipe errors: 0 Total transferred: 5202928 bytes HTML transferred: 4839444 bytes Requests per second: 83.87 [#/sec] (mean) Time per request: 119.23 [ms] (mean) Time per request: 11.92 [ms] (mean, across all concurrent requests) Transfer rate: 290.91 [Kbytes/sec] received ~ the same handler with HTML::Template Concurrency Level: 10 Time taken for tests: 15.753 seconds Complete requests: 1500 Failed requests: 0 Broken pipe errors: 0 Total transferred: 5200500 bytes HTML transferred: 4885500 bytes Requests per second: 95.22 [#/sec] (mean) Time per request: 105.02 [ms] (mean) Time per request: 10.50 [ms] (mean, across all concurrent requests) Transfer rate: 330.13 [Kbytes/sec] received this is the HTML::Template handler. sub ht : method { my $class = shift; my $r = shift; my $text = <<ENDE; <html> <body> <tmpl_include NAME="/tmp/template.tmpl"> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_var HOME> <tmpl_var path> <tmpl_include NAME="/tmp/template.tmpl"> </body> </html> ENDE my $pkit_root = '/Users/borisz/src/c/aq/Apache-PageKit-2.14_09-tt/eg'; my $dbh = DBI->connect_cached( "dbi:SQLite:dbname=$pkit_root/dbfile", "", "" ) || die "$DBI::errstr"; my $template = HTML::Template->new( scalarref => \$text ); $template->param( HOME => $ENV{HOME} ); $template->param( PATH => $ENV{PATH} ); print "Content-Type: text/html\n\n", $template->output; return Apache::OK; } I have tested with apaches ab 1.3 inside the same server as pagekit live with this handler. The file template.tt2 holds ########## template.tt2 ######### [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] ############################# <Perl> sub tt : method { my $class = shift; my $r = shift; my $text = <<ENDE; <html> <body> Template<br> [% INCLUDE template.tt2 %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% HOME %] [% PATH %] [% INCLUDE template.tt2 %] </body> </html> ENDE # open the html template my $template = Template->new( INCLUDE_PATH => '/tmp' ); my $o = ''; $template->process( \$text, { HOME => $ENV{HOME}, PATH => $ENV{PATH} }, \$o ) || die $template->error(); # send the obligatory Content-Type and print the template output print "Content-Type: text/html\n\n", $o; return Apache::OK; } </Perl> <Location /test/tt> SetHandler perl-script PerlHandler MyTest::Handler->tt </Location> > also, something that I dind't quite understand is presence of PgKit > tags which looks quite not like default TT tags in the code of your > templates (taken from pgkit TT edition)... it looked to me like you > are doing some "double" scans over each template, expanding internal > page-kit related stuff and then giving the result to TT... if I > guessed that correctly, perhaps this is the source of such "slowness"? No, at least not at all, most often the database access is the slowest part. General the best you can do is put as much as possible into components and content. That is as fast as directly typed into the page. Use a fast database. DBD::SQLite in a recent version is a lot faster on concurent access so use the lastest. But keep in mind that recently DBD::SQLite switch from version 2 to 3 and both are incompatible. So update only if your data is on a backup. For larger datasets and more SQL futures I recommend postgres. > Perhaps, this pre-parsing of a template it worth giving down to TT? > The templates are in a real precached format, faster as generated from tt so until there is no error in the code, that part is faster than tt itself. Watch them in the pkit_cache directory with strings View/pkit_cache/somefile. > > thank you! > > p.s. btw, what are the changes in this last > Apache-PageKit-2.14_09-tt.tar.gz compared to what you gave us to > download several of week ago? > the file eg/dbfile is not in the Apache-PageKit-2.14_09-tt.tar.gz tarfile, since this is in the old DBD::SQLite format and you get some errors if you use a version 3 format. The fix is to delete the file. And more important mod_perl and libapreq2 have changed again. This version work _only_ with the newer mod_perl. -- Boris |