Re: a quick tangential question about sockets in perl ..

dwm@hotair.hobl.lucent.com
Fri, 24 Apr 1998 09:26:39 -0400 (EDT)


JP May wrote:
> 
> Say you write a small server that sits there and spits out, maybe the time or just a random sentence, let's say.  (No input, it just spits something out.)  Say you run it on port 2001 of your unix server to make it concrete.
> I have discovered the following:
> Say you then write a tiny client, in perl, which simply accesses that server, gets the output (the time or whatever) and prints it out.
> Of course, you could also just use telnet localhost 2001 to achieve the identical thing.
> Here is the question:
> no matter WHAT I try, I cannot write a Perl client that does this, as **FAST**, as "telnet localhost 2001' does it.
> At first I thought it was due to going 'via the internet', but I have tried writing the client totally internally to the box, ie only using PF_UNIX only not PF_INET protocol, as a socket, and it's the SAME delay.
> 
> The delay (maybe half a second? .. compared to instantaneous with telnet) is not related to perl overhead or what have you, there is definitely some sort of slow down in there.
> 

What makes you sure its "not related to perl overhead"?
The interpreter needs to parse and compile before execution. 
That could easily explain your perceived delay.

Quoting from the only PERL ref. I have handy at the moment:

" [the] compile does take time - it's inefficient to have a ... Perl program 
that does one small quick task...then exits, because the runtime for the 
program will be dwarfed by the compile time."
  p. 6 Llama book (Learning Perl 1st Ed.)

--
Doug Monroe
Lucent Technologies, Inc.