Re: Documentation for Apache::exit()?

2002-09-26 Thread Francisco Corella

Hi Ged,

> > Thanks for replying.  I hope you had a good time in my old country :-)
>
> You probably saw the reports on the news about roads being washed away
> by the rain in Sevilla.  I went on a motor-cycle.  Camping.

Mmm... Doesn't sound like the perfect vacation.  I'm glad you made it back
:-)

> > > If you're writing new code then I would recommend writing handlers and
> > > avoiding Apache::Registry altogether.
> >
> > Why do you recommend avoiding Apache::Registry?
>
> Apache::Registry is essentially just to get you going with mod_perl
> and your old CGI scripts.  See for example mod_perl_traps.pod which deals
> with some of the 'gotchas' that you can run into.  You can make better
> use of the Perl API using handlers.  (Of course you might not need to.:)
>
> > Is there a performance penalty for using it?
>
> Handlers can be faster, yes, but since you get such a big performance
> boost from mod_perl to begin with it's not usually serious.  Read the
> the Eagle Book, the mod_perl Guide and the mod_perl CookBook.  (That
> will take you most of the rest of the year...:)  The details are on
> the mod_perl home page.

Thanks for the pointers.  I've read the Eagle Book already, and I check the
Guide as needed, but I wasn't aware of the mod_perl CookBook.  I've checked
the table of contents on Amazon and ordered it.

Francisco

---
Francisco Corella
[EMAIL PROTECTED]




Re: Documentation for Apache::exit()?

2002-09-26 Thread Francisco Corella

Hi Kyle,

> There are a few performance penalties when using Apache::Registry:
>
> * Scripts are compiled at first request instead of server start unless you
> use something like Apache::RegistryLoader.  So, the first request per
child
> will be a little bit slower and you don't get to share memory between
httpd
> children.  (Memory sharing can be a big problem.)
>
> * Every request runs through Apache::Registry::handler before your script
> gets called which has overhead including some setup code, an extra stat(),
> and a chdir().  (PerlRun and RegistryNG uses $r->finfo but Registry does
an
> extra stat() -- not sure if there's a reason for that.)

Thanks a lot.  I hadn't thought of the memory problem.  It seems that I'll
have to bite the proverbial bullet and not use Apache::Registry.

Francisco




Re: Documentation for Apache::exit()?

2002-09-26 Thread Lupe Christoph

On Wednesday, 2002-09-25 at 10:41:19 -0400, valerian wrote:

> BTW, anyone know if Perl 6 will free unused memory?  From what I
> understand, right now it just allocates as needed, but never gives any
> back to the OS when it's done... (ie, when some function ends)

Even if Parrot (the perl 6 engine) free()'s unused memory, all malloc
implementations I know will not return memory to the OS. If the
implementation uses brk() or sbrk(), it can only grow or shrink the data
segment, not deallocate arbitrary parts of it. Only if it mmap()'s from
/dev/null it can do that.

Add to this mess that free()'d memory tends to be non-contiguous, you
have a nice SMOP. Lots of overhead for little gain.

Lupe Christoph
-- 
| [EMAIL PROTECTED]   |   http://www.lupe-christoph.de/ |
| Big Misunderstandings #6398: The Titanic was not supposed to be|
| unsinkable. The designer had a speech impediment. He said: "I have |
| thith great unthinkable conthept ..."  |



RE: Documentation for Apache::exit()?

2002-09-25 Thread Kyle Oppenheim

> > There are a few performance penalties when using Apache::Registry:
> >
> > * Scripts are compiled at first request instead of server start
> unless you
> > use something like Apache::RegistryLoader.  So, the first
> request per child
> > will be a little bit slower and you don't get to share memory
> between httpd
> > children.  (Memory sharing can be a big problem.)
>
> But it still shares all the modules you pre-load in the http.conf,
> right?  So how much memory is wasted depends on the size of the script
> in question, or more accurately on how big its data structures are?
> (including imported variables)

Correct -- if you preload modules in httpd.conf, you will most likely use
shared memory for those modules.  Of course, the memory page will be copied
to the child process if it is modified after forking.  This could happen
because the module allocates some memory, something else that shares the
memory page is modified, etc.  However, with Apache::Registry scripts, you
are loading code in the child process directly (with the exception of using
Apache::RegistryLoader) -- so there's no chance for any memory sharing.

- Kyle




Re: Documentation for Apache::exit()?

2002-09-25 Thread valerian

On Tue, Sep 24, 2002 at 08:03:56PM -0700, Kyle Oppenheim wrote:
> There are a few performance penalties when using Apache::Registry:
> 
> * Scripts are compiled at first request instead of server start unless you
> use something like Apache::RegistryLoader.  So, the first request per child
> will be a little bit slower and you don't get to share memory between httpd
> children.  (Memory sharing can be a big problem.)

But it still shares all the modules you pre-load in the http.conf,
right?  So how much memory is wasted depends on the size of the script
in question, or more accurately on how big its data structures are?
(including imported variables)

BTW, anyone know if Perl 6 will free unused memory?  From what I
understand, right now it just allocates as needed, but never gives any
back to the OS when it's done... (ie, when some function ends)



RE: Documentation for Apache::exit()?

2002-09-24 Thread Kyle Oppenheim

> > If you're writing new code then I would recommend writing handlers and
> > avoiding Apache::Registry altogether.
>
> I had been thinking about whether to do this.  Why do you
> recommend avoiding
> Apache::Registry?  Is there a performance penalty for using it?

We sometimes use Apache::Registry scripts to implement a simple MVC model
(look back in the archives for about a thousand different implementations of
MVC using mod_perl!).  Perl modules are the model, the Apache::Registry
scripts are the controller, and a template provides the view.  It keeps our
configuration brain-dead since there are no PerlModule directives other than
Apache::Registry.

There are a few performance penalties when using Apache::Registry:

* Scripts are compiled at first request instead of server start unless you
use something like Apache::RegistryLoader.  So, the first request per child
will be a little bit slower and you don't get to share memory between httpd
children.  (Memory sharing can be a big problem.)

* Every request runs through Apache::Registry::handler before your script
gets called which has overhead including some setup code, an extra stat(),
and a chdir().  (PerlRun and RegistryNG uses $r->finfo but Registry does an
extra stat() -- not sure if there's a reason for that.)

- Kyle




Re: Documentation for Apache::exit()?

2002-09-24 Thread Ged Haywood

Hi Francisco,

On Tue, 24 Sep 2002, Francisco Corella wrote:

> Thanks for replying.  I hope you had a good time in my old country :-)

You probably saw the reports on the news about roads being washed away
by the rain in Sevilla.  I went on a motor-cycle.  Camping.

> > If you're writing new code then I would recommend writing handlers and
> > avoiding Apache::Registry altogether.
> 
> Why do you recommend avoiding Apache::Registry?

Apache::Registry is essentially just to get you going with mod_perl
and your old CGI scripts.  See for example mod_perl_traps.pod which deals
with some of the 'gotchas' that you can run into.  You can make better
use of the Perl API using handlers.  (Of course you might not need to.:)

> Is there a performance penalty for using it?

Handlers can be faster, yes, but since you get such a big performance
boost from mod_perl to begin with it's not usually serious.  Read the
the Eagle Book, the mod_perl Guide and the mod_perl CookBook.  (That
will take you most of the rest of the year...:)  The details are on
the mod_perl home page.

73,
Ged.




Re: Documentation for Apache::exit()?

2002-09-24 Thread Francisco Corella

Hi Ged,

> Sorry it took a long time to reply.  Been to Spain.

Thanks for replying.  I hope you had a good time in my old country :-)

> If you're writing new code then I would recommend writing handlers and
> avoiding Apache::Registry altogether.

I had been thinking about whether to do this.  Why do you recommend avoiding
Apache::Registry?  Is there a performance penalty for using it?

Thanks,

Francisco

---
Francisco Corella
[EMAIL PROTECTED]




Re: Documentation for Apache::exit()?

2002-09-21 Thread Ged Haywood

Hi Francisco,

Sorry it took a long time to reply.  Been to Spain.

On Fri, 13 Sep 2002, Francisco Corella wrote:

> I believe calling Apache::exit doesn't prevent the log phase from
> being run for the request, does it?

That's the way I understand it.

> You recommend using 'return' rather than 'exit', but that's easier said than
> done.  I'm using Apache::Registry and I'm reusing code that was originally
> part of CGI scripts.  You can't just change 'exit' to 'return' if 'exit' is
> buried under many levels of procedure calls.

I don't think I quite did that, I meant that you can return a value
from a mod_perl script to Apache to tell it what you want.  If you're
using Apache::Registry you can use the $r->status method to return the
value, for example
  $r->status(NOT_FOUND); 
before exiting your Registry script.

Apache::Registry attempts to simulate a CGI environment.  If your code
is reasonably well-formed then you shouldn't have to make a lot of
changes.  I think most CGI scripts will work under Apache::registry,
or can be made to work by relatively painless modifications.

> And one is not supposed to call return in a script handled by
> Apache::Registry, am I right?

I'm sure you can, but I think Apache::Registry will ignore it and still
return OK to Apache unless you do something like $r->status(NOT_FOUND);
before you return.

> Even when I'm writing new code, I'd like to use Apache::exit as an
> exception-raising mechanism.  (I believe Apache::Registry does an eval{}
> that catches the exception.)  Is this a bad idea?

If you're writing new code then I would recommend writing handlers and
avoiding Apache::Registry altogether.

73,
Ged.




Re: Documentation for Apache::exit()?

2002-09-12 Thread Ged Haywood

Hi there,

On Wed, 11 Sep 2002, Francisco Corella wrote:

> The Modules book by Lincoln Stein and Doug MacEachern (pp.464-465)
> says that Apache::exit() can be used to halt script execution
> without terminating the process and without logging an error.

Ask yourself why you want to call an exit() function.  Do you really
want to terminate the process?  If you were to call exit() within the
Apache/mod_perl process, things would fall over rather badly from the
perspective of the user of a browser, and maybe elsewhere too.

Perhaps you really want to stop handling the request, so all you need
to do is to tell Apache that you're done.  To do that, usually you'd
return a value like OK or DECLINED to Apache.  Then it can do all the
cleaning up that has to be done.

> The User Guide at http://perl.apache.org/docs/1.0/guide/index.html

Huge, isn't it?  :)

> However, the Apache documentation itself does not mention an exit()
> function. Neither "perldoc Apache" nor the documentation at
> http://perl.apache.org/docs/1.0/api/Apache.html contain the word
> "exit".  Am I looking in the wrong place?

Maybe you're asking the wrong question.  If you must, have a look in
Apache.xs - (but don't say I didn't warn you...:)

73,
Ged.