Skip to content
Tcl Source Code View Ticket
Login

View Ticket

fconfigure -peername very slow

Open533301ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 14 years ago
Descriptionplain2002-03-21 21:01:57
set socket [socket $host $port]
fconfigure -peername ;# or fconfigure
# long delay, network specific- 5 seconds on mine much longer (minutes) on others.

I also tried this with ver.8.0.
davygrvyplain2002-03-26 16:53:06
Logged In: YES 
user_id=7549

It's related to DNS reverse lookup, I think.
rkarenplain2002-03-31 08:31:47
Logged In: YES 
user_id=489489

Yes, I figured that, but it would be nice if it timed out.
I sent code to someone that slowed a 30 second process
down to 20 minutes because of some diagnostic messages
that were printing [fconfigure $sock] results.

RK
davygrvyplain2002-04-07 11:50:17
Logged In: YES 
user_id=7549

That might be a global setting on the machine regarding the 
sockets implimentation for getXbyY().  Off-hand, I don't 
know of a localized way to set a getXbyY timeout.  Then 
again, it's been ages since I've done any sockets 
programming.
dkfplain2002-04-08 16:22:10
Logged In: YES 
user_id=79902

There's no parameter for timeout on standard getXbyY calls
(nor any guarantee on what underlying lookup mechanism will
be used; I know of systems that use host files, DNS and
NIS+, and could well believe it if others used LDAP or
something equally horrific) and they are all synchronous.

This sucks, but it is not our fault. :^(

Suggested fix: helper processes/threads, perhaps with a
clever cache (with timed expiry) as well.  There are a
number of interesting issues with how you bind this into Tcl
though, particularly in relation to async socket handling
and whether people should be penalized for information they
don't look at...
cdclercqplain2005-09-19 14:45:36
Logged In: YES 
user_id=617750

When using ActiveTcl ftp package I have exactly the same thing.
But only on Solaris (not on Windows).

I takes sometimes more than a minut (sometimes a timeout) to
do a set peer [fconfigure $ftp(CtrlSock) -peername].
* We only have this when starting on Solaris connecting
to Windows via a Fortigate 200 Antivirus Appl. and a
firewall.
dkfplain2012-07-03 15:15:40
This needs to be reevaluated with 8.6 to see if it is still relevant; we now use getaddrinfo() for name resolution (so we can handle IPv6 and avoid a whole pack of thread problems). However, IIRC reverse name lookup was found to be such a huge cost (in Wub) that a mitigation strategy was put in place: set the variable ::tcl::unsupported::noReverseDNS to something (anything!) and reverse DNS will be switched off in that interpreter.

That was not backported to 8.5 or before. It might be worth doing.
dkf Ticket [533301ffff]: 1 change [History diff]2012-07-03 15:15:41
rmaxplain2012-07-03 22:42:09
::tcl::unsupported::noReverseDNS was only meant as a temporary workaround for WUB to fiix the performance problems of the Tcl'ers wiki. I think backporting should wait until a final mechanism for avoiding reverse DNS lookups has been added to 8.6.
Suggestions for how such a mechanism could/should look like are welcome.
ferrieuxplain2012-07-04 04:53:22
Yes, but it goes beyond just fixing the Wiki. While the unsupported namespace is clearly not meant to hots it forever, the advantage of a global switch like this is that it avoids the proliferation of "fixed" fconfigure options like -peerhostport and -sockhostport. Another nice feature is that it allows to fix a whole app with a single line (unlike a per-channel [fconfigure -norevdns]), as it appears in hindsight that reverse DNS is almost always a bad idea.
rmaxplain2012-07-04 05:03:14
I wouldn't say generally that reverse DNS is a bad idea, but enforcing it in situations where the result might not even be used was a bad decision.

One way out without breaking backwards compatibility might be to change -sockname and -peername to always return the IP address in place of the host name and provide a separate command for reverse lookup.
Log in (anonymous is fine) to add a comment.