Hi all,

I'm researching some performance problems with one of our Web sites and
stumbled across some legacy code that's getting pulled into our system.
This code uses $` and $' variables with regular expression matches.
>From the perlre docs (emphasis mine):

WARNING: Once Perl sees that you need one of "$&", "$`", or "$'"
*anywhere in the program*, it has to provide them for every pattern
match. This may substantially slow your program.

In fact, in tests that I've run, it appears that the mere existence of
these variables will trigger this behavior, regardless of whether or
not the code that accesses them will be executed. Removing these
variables seems to consistently get me a ten percent bump in regex
performance.

Since mod_perl is a persistent Perl interpreter embedded in the Web
server, it seems to me that any reference to these variables will
impact all regex matches in a mod_perl environment, regardless of
whether or not my code actually uses those variables. Is this the case?
I don't know enough about benchmarking snippets in a mod_perl
environment to easily verify this.

Cheers,
Ovid

=====
Silence is Evil            http://users.easystreet.com/ovid/philosophy/indexdecency.htm
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html

Reply via email to