You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Torsten Foertsch <to...@gmx.net> on 2007/02/28 11:04:14 UTC
Interpreter scope
Hi,
the default interpreter scope is request. That means a certain interpreter is
locked during the whole request cycle. I use modperl mostly in the
pre-response phases plus sometimes as an output filter. But I use pnotes to
pass data between the phases. If I understand it correctly this forbids a
handler interpreter scope. Now I'd like to release the interpreter in most
cases just before the response phase. So it can be reused by another request
while the current request sends its data over a possibly slow network.
Is that reasonable?
Is there something like $r->release_interp_after_this_phase()?
If not what is the right place to start looking/patching? And what pitfalls
are there to watch out?
Torsten
Re: Interpreter scope
Posted by Frank Wiles <fr...@wiles.org>.
On Wed, 28 Feb 2007 11:04:14 +0100
Torsten Foertsch <to...@gmx.net> wrote:
> Hi,
>
> the default interpreter scope is request. That means a certain
> interpreter is locked during the whole request cycle. I use modperl
> mostly in the pre-response phases plus sometimes as an output filter.
> But I use pnotes to pass data between the phases. If I understand it
> correctly this forbids a handler interpreter scope. Now I'd like to
> release the interpreter in most cases just before the response phase.
> So it can be reused by another request while the current request
> sends its data over a possibly slow network.
>
> Is that reasonable?
>
> Is there something like $r->release_interp_after_this_phase()?
>
> If not what is the right place to start looking/patching? And what
> pitfalls are there to watch out?
Have you looked into using a lightweight front end setup to handle
this? I've had great success with the more traditional light/heavy
Apache setup with mod_proxy, perlbal is awesome, and know
many people who use things like lighttpd or pound.
---------------------------------
Frank Wiles <fr...@wiles.org>
http://www.wiles.org
---------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: Interpreter scope
Posted by Perrin Harkins <pe...@elem.com>.
Torsten Foertsch wrote:
> I use pnotes to
> pass data between the phases. If I understand it correctly this forbids a
> handler interpreter scope.
You might try using notes() instead, since I don't think it cares about
which interpreter is used. You can use Storable to stuff things into it
if your data is more than just a string.
- Perrin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: Interpreter scope
Posted by Torsten Foertsch <to...@gmx.net>.
On Monday 23 April 2007 07:08, Philippe M. Chiasson wrote:
> > Is there something like $r->release_interp_after_this_phase()?
>
> Nope, but writing one would be very simple, all that's needed is
> to call
>
> MpInterpPUTBACK_On(interp)
>
apr_pool_cleanup_kill(r->pool, r, modperl_config_req_cleanup);
modperl_interp_pool_set(r->pool, NULL, 0);
interp->request=r;
MpInterpPUTBACK_On(interp);
MpReqCLEANUP_REGISTERED_On(rcfg);
I think this turns a per-request interpreter into a per-handler one. I have
attached a first version of an Apache2::Interpreter module that implements
$r->interpreter->release.
The most tricky part for me was to find the correct interp. Could you please
have a look at that? Maybe it could be done much simpler.
Also, the cleanup stuff is buggy as it is with scope==handler.
$r->pool->cleanup_register works by locking the interp until pool cleanup. It
thus blocks the interp from being reused. PerlCleanupHandler does not work at
all.
Torsten
Re: Interpreter scope
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
On 28-Feb-07, at 2:04 AM, Torsten Foertsch wrote:
> Hi,
>
> the default interpreter scope is request. That means a certain
> interpreter is
> locked during the whole request cycle.
That's correct.
> I use modperl mostly in the
> pre-response phases plus sometimes as an output filter. But I use
> pnotes to
> pass data between the phases. If I understand it correctly this
> forbids a
> handler interpreter scope.
Yes, but you could use $r->notes() instead, as that's Perl agnostic,
as long
as what you need to pass around can be serialized as a string, you
should be
okay.
> Now I'd like to release the interpreter in most
> cases just before the response phase. So it can be reused by
> another request
> while the current request sends its data over a possibly slow network.
>
> Is that reasonable?
It's certainly not unreasonable ;-) If you know what you are doing,
it should
be perfectly fine to have a mechanism to release the current
interpreter, and
in the worst-case scenario, it might just need to be re-acquired.
> Is there something like $r->release_interp_after_this_phase()?
Nope, but writing one would be very simple, all that's needed is
to call
MpInterpPUTBACK_On(interp)
> If not what is the right place to start looking/patching? And what
> pitfalls
> are there to watch out?
The tricky case will be what happens if you release the interpreter, but
by some mistake, there is a handler that needs Perl again later during
the request phase, you'd have to handle that gracefully somewhat.
------------------------------------------------------------------------
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/