Hi everyone,
I've been happily converting over a bunch of scripts to use mod_perl
since we recently solved my Apache::SSI issues.
My main reason for migrating to mod_perl from standard CGI scripts
is to improve performance on our Web server. Many scripts take several
seconds to run, but switching to mod_perl cuts the that time to tenths
of a second.
However, I've noticed that scripts that generate lot of output take
substantially longer to run than their CGI counterparts.
As an example, here's the timing on a CGI script (listed first) and
the timing on a mod_perl aware script (listed second):
[113]> time lynx -dump -mime-header
http://www.hort.net/cgi-bin/gallery/photographer/lindsey > /dev/null
0.010u 0.030s 0:01.59 2.5% 0+0k 0+0io 393pf+0w
[114]> time lynx -dump -mime-header
http://www.hort.net/perlssi/gallery/photographer/lindsey > /dev/null
0.010u 0.000s 0:03.38 0.2% 0+0k 0+0io 393pf+0w
The CGI script took 1.59 seconds to run, whereas the mod_perl version
took 3.38 seconds. It generates about 321K of output.
When the same script runs in another mode that generates less output,
the mod_perl version is faster. Again, CGI first, mod_perl second:
[136]> time lynx -dump -mime-header
http://www.hort.net/cgi-bin/gallery/photographer > /dev/null
0.010u 0.010s 0:01.12 1.7% 0+0k 0+0io 436pf+0w
[137]> time lynx -dump -mime-header
http://www.hort.net/perlssi/gallery/photographer > /dev/null
0.020u 0.000s 0:00.16 12.5% 0+0k 0+0io 431pf+0w
This time the CGI script takes 1.12 seconds, but the mod_perl version is
only .16 seconds.
Why does this happen? My handlers are set up like
PerlSetVar Filter On
PerlModule Apache::Filter Apache::RegistryFilter Apache::SSI
PerlHandler Apache::RegistryFilter Apache::SSI
I'm guessing that it's because Apache::Filter loads the output of
each filter into memory before passing it on.
Can anyone confirm this? Is there a way around it?
Thanks,
Chris
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html