You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Ian Kallen <sp...@salon.com> on 2000/06/09 01:13:24 UTC

subprocess_env

I'm using a third party module that writes a bunch of variables to the
subprocess_env table to setup data for the request. It has us making
repeated class method calls like this (for our usage with Mason):
<% Blah::foo('bletch') %>

where foo is in the Blah package merely doing this:

sub foo {
    my($s) = @_;
    my($r) = Apache->request();
    return $r->subprocess_env('foo_' . $s);
}

I'm thinking of changing the behvior to 
<% $ENV{'foo_bletch'} %>
but foo_bletch isn't in the %ENV hash, so I'm looking at initializing
every request to do this:
$r->subprocess_env->do(
 sub { my($k,$v)=@_;
   $ENV{$k}=$v;
 1; 
 }
);
to eliminate repeated accesses of the subprocess_env table; one call
populates %ENV and that's it.

Now, I don't want to kick off a debate on the performance problems that
reading/writing to the environment incur; I didn't design this behavior
I just want to make the best of it since this is what the application
requires of us. I just need to optimize access to the environment by
turning the dozen or so calls per request to Blah::foo to just %ENV.  

Any ideas regarding the expense of mulitple $r->subprocess_env vs.
accessing %ENV?

--
Salon Internet 				http://www.salon.com/
  Manager, Software and Systems "Livin' La Vida Unix!"
Ian Kallen <id...@salon.com> / AIM: iankallen / Fax: (415) 354-3326

Re: subprocess_env

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 8 Jun 2000, Ian Kallen wrote:

> 
> I'm using a third party module that writes a bunch of variables to the
> subprocess_env table to setup data for the request. It has us making
> repeated class method calls like this (for our usage with Mason):
> <% Blah::foo('bletch') %>
> 
> where foo is in the Blah package merely doing this:
> 
> sub foo {
>     my($s) = @_;
>     my($r) = Apache->request();
>     return $r->subprocess_env('foo_' . $s);
> }
> 
> I'm thinking of changing the behvior to 
> <% $ENV{'foo_bletch'} %>
> but foo_bletch isn't in the %ENV hash, so I'm looking at initializing
> every request to do this:
> $r->subprocess_env->do(
>  sub { my($k,$v)=@_;
>    $ENV{$k}=$v;
>  1; 
>  }
> );
> to eliminate repeated accesses of the subprocess_env table; one call
> populates %ENV and that's it.
> 
> Now, I don't want to kick off a debate on the performance problems that
> reading/writing to the environment incur; I didn't design this behavior
> I just want to make the best of it since this is what the application
> requires of us. I just need to optimize access to the environment by
> turning the dozen or so calls per request to Blah::foo to just %ENV.  
> 
> Any ideas regarding the expense of mulitple $r->subprocess_env vs.
> accessing %ENV?

%ENV will probably be faster for lookups, since subprocess_env has the
overhead of calling a perl subroutine (pp_entersub).  it's the population
of %ENV that can be expensive.  you might be better off populating a
non-magic global, such as %Env.