[BNE-PM] The Perl one-liner

David Bussenschutt d.bussenschutt at mailbox.gu.edu.au
Fri Sep 20 00:32:00 CDT 2002


Great comments Derek....   but as usual, I didn't properly explain my 
reasons for wanting to keep my overheads small..      Well, this is a 
component of a larger web-app/cgi program.  The web-app doesn't run in 
mod_perl or eqivalent, so it's the "warm-up"  that matters (and that takes 
a while) in this application.

In the time it takes for a client (real person) to visit my webpage, and 
have a page displayed, I have to (typically) open up between 6 and 12 
sockets to 2-4 different hosts, authenticate these connections securely, 
pull the relevant data through that I need from this remote server, close 
the connection, and go on to the next server...I can then analyse this 
data, and display the relevant info in the webpage.  Every once of speed I 
can get out of my app helps.   I expect that I will eventually run in 
mod_perl, but I haven't needed that yet (or figured it out either)   ;-)

David
--------------------------------------------------------------------
David Bussenschutt        Email: D.Bussenschutt at mailbox.gu.edu.au
Senior Computing Support Officer & Systems Administrator/Programmer
RedHat Certified Engineer. 
Member of Systems Administrators Guild of Australia.
Location: Griffith University. Information Technology Services
           Brisbane Qld. Aust.  (TEN bldg. rm 1.33) Ph: (07)38757079
--------------------------------------------------------------------




Derek Thomson <derek at wedgetail.com>
20/09/2002 03:00 PM

 
        To:     David Bussenschutt <d.bussenschutt at mailbox.gu.edu.au>
        cc:     brisbane-pm-list at happyfunball.pm.org
        Subject:        Re: [BNE-PM] The Perl one-liner


David Bussenschutt wrote:
> Speaking of filehandle identifiers, typeglobs and kludges.....
> 
> just the day before yesterday, I was funbling with this very same 
> "typeglob" issue, and how to pass this around into functions etc. 
EXCEPT, 
> mine wasn't a filehandle, so I couldn't use IO:File ... it was a Socket. 
 
> I didn't want to 'use IO:Socket' because it's got quite large overheads 
in 
> comparison to just 'use Socket'. 

They may be large, but are they really significant? I use IO::Socket 
throughout my Perl CORBA ORB, without a problem that I've noticed.

Remember, your average Java program running on a hotspot JVM (which is 
necessary to get anything approaching acceptable performance) is going 
to consume 40-50M by the time it "warms up", and gathers all that data 
and precompiles all that "hotspot" code. Compared to *that* even 1M or 
so on a 256M machine just isn't worth worrying about. The total size is 
still around 5M, so I still win by about 40M on average!

Also, I have IO::Socket set up as a dynamic library, so you only pay the 
price of that 1M *once* across all running Perl programs, so suddenly 
the effective overhead of IO::Socket can be divided by the count of all 
running Perl servers and clients.

> Of course, the other problem was that I was creating the socket inside a 

> ->new() object creation routine, and had to then save this newly created 

> socket/filehandle into the anonymous hash that the object uses for it's 
> object data. 
> I eventually figured out the following...
> ....
> below this is an extract showing the creation of the object/socket.  The 

> really important line is the use of Symbol::gensym() 

Didn't know that one. Very nice! But still, I'd only do it if there was 
a good reason to keep the size minimal, premature optimization being the 
root of all evil ...

--
D.







More information about the Brisbane-pm mailing list