You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Geoffrey Young <gy...@laserlink.net> on 2000/06/06 17:10:18 UTC

RE: [benchmark] DBI/preload (was Re: [RFC] improving memory mappi ng thru code exercising)


> -----Original Message-----
> From: Jason Terry [mailto:jter@g-web.net]
> Sent: Tuesday, June 06, 2000 10:52 AM
> To: modperl@apache.org
> Subject: Re: [benchmark] DBI/preload (was Re: [RFC] improving memory
> mapping thru code exercising)
> 
> 
> I just wanted to thank you guys for sending this to the mailing list.
> 
> I added these lines to my startup script....
> use Carp;
> CGI->compile(qw(my_common_functions));
> DBI->install_driver('mysql');
> 
> Please note that these were already existing in my startup script.
> use CGI();
> use DBI();
> 
> And after testing, and running the server with the new 
> settings all night long, it seems that I am saving ~2M of RAM 
> for each apache
> process.  Again thank you.
> 
> However, this has made me curious, and left me wondering...   
> I have 3 scripts that I pre-load in my startup file, would any of my
> self-made modules, or other CPAN modules, benefit from 
> including directly in the startup script... as opposed to 
> being loaded only
> in the pre-loaded scripts themselves?

yes - you should preload any modules you plan to use frequently in your
startup.pl so that the code can be shared among the child processes.

see
http://perl.apache.org/guide/config.html#What_Modules_You_Should_Add_to_t
ff for additional specifics...

HTH

--Geoff

> 
> Again, thank you for this thread it has saved me 20-80M of 
> RAM depending on my current load.
>     -Jason
> 
> ----- Original Message -----
> From: "Stas Bekman" <sb...@stason.org>
> To: "Tim Bunce" <Ti...@ig.co.uk>
> Cc: "mod_perl list" <mo...@apache.org>
> Sent: Sunday, June 04, 2000 1:50 PM
> Subject: Re: [benchmark] DBI/preload (was Re: [RFC] improving 
> memory mapping thru code exercising)
> 
> 
> > On Sun, 4 Jun 2000, Tim Bunce wrote:
> >
> > > On Sat, Jun 03, 2000 at 02:49:47AM +0300, Stas Bekman wrote:
> > > > On Fri, 2 Jun 2000, Perrin Harkins wrote:
> > > >
> > > > > On Sat, 3 Jun 2000, Stas Bekman wrote:
> > > > > > * install_driver  (2):
> > > > > >   DBI->install_driver("mysql");
> > > > >
> > > > > I've never seen that before,
> > > >
> > > > There is always a first time :)
> > > >
> > > > > and it isn't in the DBI perldoc.
> > > >
> > > > Where do you think I've found it :) It is mentioned in 
> DBI manpage:
> > > >
> > > >            DBI->connect automatically installs the driver if it
> > > >            has not been installed yet. Driver 
> installation always
> > > >            returns a valid driver handle or it dies 
> with an error
> > > >            message which includes the string 
> 'install_driver' and
> > > >            the underlying problem. So, DBI->connect 
> will die on a
> > > >            driver installation failure and will only 
> return undef
> > > >            on a connect failure, for which $DBI::errstr 
> will hold
> > > >            the error.
> > >
> > > I've been meaning to document it properly for the last couple of
> > > years, since I knew people were using it for mod_perl.
> >
> > I guess most of the mod_perl folks don't use it, since they don't
> > know about it. I have discovered it following the Vivek's reply.
> >
> > > > but actualy it's the DBD:: method.
> > >
> > > Nope. A DBI->method.
> >
> > Ok
> >
> > > > > Is it safer than "use DBD::mysql;"?
> > > >
> > > > "safer" is the wrong question. It's always used by DBI, 
> but when you call
> > > > it at the server startup you get a few more K shared, 
> compared with only
> > > > preloading of DBD::mysql.
> > >
> > > Yes, and the semantics of install_driver are that it'll 
> die if the driver
> > > can't be installed, just like 'use'.
> > >
> > > >  Apache::DBI->connect_on_init('DBI:mysql:test::localhost', [...]
> > > >  or DBI->disconnect("Cannot connect to database: 
> $DBI::errstr\n");
> > >
> > > There's no such method as DBI->disconnect.
> >
> > Ouch, you are right. But the first part has never failed 
> for me, so I copy
> > and paste this old error for years :) Thanks for telling me!
> >
> > 
> _____________________________________________________________________
> > Stas Bekman              JAm_pH     --   Just Another 
> mod_perl Hacker
> > http://stason.org/       mod_perl Guide  
http://perl.apache.org/guide
> mailto:stas@stason.org   http://perl.org     http://stason.org/TULARC
> http://singlesheaven.com http://perlmonth.com http://sourcegarden.org