[BNE-PM] The Perl one-liner
Derek Thomson
derek at wedgetail.com
Fri Sep 20 00:00:42 CDT 2002
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