[Melbourne-pm] Perl Mongers in 2015...

Mathew Robertson mathew.blair.robertson at gmail.com
Thu Jan 8 14:43:58 PST 2015

> > And here is the crux of the mod-perl diversion...  the Tim Conners
> already
>                                                                  ^ bah
> Why does everyone do that? :)

Diverting conversation is a specialty that I attempt to excel at... and I
think most others on this list do too.  :-P

> > had existing code in the form of CGI::Fast.... So to get the code to run
> > faster, then a couple of lines of Apache config to setup mod_perl, would
> > solve the problem.
> From my very brief reading, doesn't mod_perl have the same problem that
> CGI::Fast has in that the brief running program you expected to set up a
> bunch of global variables, which then get discarded upon program exit, are
> all now sitting inside the scope of another loop, and now you have to port
> your code to make sure that all such traces of global variables are
> reinitialised every loop?

Depends on what you mean by global variables...

Often mod_perl will only speed up the initial perl-compilation bit -> the
module initialisation is performed on every invocation.
ie: it means that any module-scope variables which you do modify at
run-time, will be reset at every invocation.

... thus you code should just "drop in" with no changes [ and only say 3
lines of Apache config -> load mod-perl and configure
Apache/ModPerl::PerlRun/Registry etc  ].

For a decent percentage (aka: most, some, a little bit...) of code, a
global variable is initialised only on module startup, then used in
read-only context (aka treating them as global constants).
So with a few more lines of Apache config, you can pre-load modules which
have heavy module initialisation... this allows each invocation to inherit
the pre-loaded data.

> So there's no silver bullet drop in replacement for
> CGI::really_really_slow.  You'll be porting code one way or another.

No porting required.

It could be a silver bullet... but its sheen is sometimes a little off,
such as requiring manual restart of Apache whenever a module-file (xx.pm)
is changed.

> (my 5 ajax queries now take a fraction of a second total instead of
> bogging the pi down for more than 5 seconds.  Hopefully all my globals
> are reset each CGI::Fast loop

Does this mean you used mod-perl ?   Or some other technique?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20150109/1b3e044d/attachment.html>

More information about the Melbourne-pm mailing list