perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: [mp2] Making Apache::ASP optimized for mod_perl 2
Date Wed, 07 May 2003 01:30:20 GMT
Josh Chamas wrote:
> Stas Bekman wrote:
>>> Thanks for the tip.  The $ModPerl2 in this case is calculated
>>> at module load time, so I think the effect is the same, its just
>>> not a constant.
>> The effect is very different, that's the whole point of using 
>> constants. By using a constant the parser will optimize the code and 
>> throw away the branches that won't be executed.
> I have done benchmarks of constants vs. scalars, and have not seen much
> of a difference before ... 

It could be insignificant, but those things add up. I believe it also saves 
some memory if the branches include big chunks of code.

> I hesitate to start using constants in CPAN
> modules as I do not know how far back they go with older perls
> ( do they work for perl 5.005 ?? ), perl 5.005 would be the earliest perl
> I would support at this point if someone asked me to do so.  I gave up
> on perl 5.004_04 a year to 2 back, so I am clearly slow to upgrade :)

No problem with 5.005_03:
perl-5.00503 -wle 'use constant FOO => 1; print FOO ? "OK" : "OK TOO"'

>> I believe, very quickly this common thing will grow, as different 
>> people have different needs and it's going to be hard to find a golden 
>> middle. For example if I don't use HTTP handlers, but use mp2 to write 
>> protocol modules, my common list wouldn't include any of the 
>> Apache::Request* modules.
> How about then an Apache::CommonMP1, or some such just to ease the
> compatibility thing, without the full Apache::compat, or rather an
> Apache::compat_lite ???  The very big difference being that Apache::compat
> is strong advised to not have CPAN authors use, but an Apache::CommonMP1
> might not have such an advisory.  The name doesn't matter, but the effect
> does, that module authors have a nice module to load that gets them most
> of the functions that they have grown accustomed to over the years.

I like your idea in the other reply, let's discuss it there.

>> Very quickly you will find all the modules that Apache::ASP needs to 
>> load and you will move on to deal with other problems. It's not like 
>> you say *argh* every few minutes for the next few years to come, 
>> because every time some module wasn't loaded.
> Right, I do not make these suggestions for myself, but for those who
> will do the same as I have done, that is port larger modules
> to mp2.  That was the only point of my sharing, as I have already
> solved the problem as you say.  I just picture the next thousand
> people saying *argh* and thinking there might be an improvement.

I agree with you. And thanks for trying to make other developers' lives 
better. I'm just trying to ensure that we give away guns which allow people 
shoot themselves in their own feet only, and hopefully not wound hordes of 

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message