HI, the other day, talking to youness we thought amsn was being quite
unresponssive on start and connection due to sockets blocking while
resolving the host names (that is, the dns resolution was being
synchronous and blocking, even when the sockets are asynchronous).

I made a small tcl extension to allow for asynchronous resolution. The
idea was to replace the socket command, and when -async option was
used, return inmediately, launch a thread to resolve hostname, and
when resolution was done, call the original socket command with the
resolved IP instead of the hostname.

The problem is this can't be done that easy, because when socket
-async is used, it should return inmediately and return a channel
identifier. As we don't know the channel identifier until the real
socket is created, what should the extension socket wrapper return if
the socket won't be created until hostname is resolved?

So, i just made a new command that resolves a hostname in background
and callbacks a procedure with the resolved IP when finished.

Before starting to change the connection code to use the resolver, I
decided to measure the time spen on socket creation. I made a
socket_wrapper function like this in amsncore.tcl:

--------------

proc socket_wrapper { args } {
        puts "socket_wrapper $args"
        
        puts [time {
        set sock [eval [linsert $args 0 _oldsocket] ]}]

        return $sock
}

rename socket _oldsocket
rename socket_wrapper socket

--------------

running and connection amsn displays this:

socket_wrapper -server phony 60671
415 microseconds per iteration
socket_wrapper -myaddr 127.0.0.1 -server lockSvrNew 64123
323 microseconds per iteration
socket_wrapper -async 207.46.111.90 1863
339 microseconds per iteration
socket_wrapper login.live.com 443
343022 microseconds per iteration
socket_wrapper contacts.msn.com 443
289655 microseconds per iteration
socket_wrapper contacts.msn.com 443
251321 microseconds per iteration
socket_wrapper -server abook::dummysocketserver 6891
148 microseconds per iteration
socket_wrapper -async firewall.amsn-project.net 80
59207 microseconds per iteration
socket_wrapper storage.msn.com 443
298166 microseconds per iteration
socket_wrapper contacts.msn.com 443
254806 microseconds per iteration
socket_wrapper -async 207.46.27.197 1863
353 microseconds per iteration
socket_wrapper -async 207.46.26.66 1863
335 microseconds per iteration


So, it looks like connections with name resolution are taking about
0,06 seconds (like http connection to firewall.amsn-project.net), and
https connections are taking about 0,25-0,3 seconds. That's pretty
quick. However, it looks like things are locking longer, amsn seems
quite unresponsive while connection.

It looks like maybe name resolution is not the bottleneck. The TLS
layer is taking some time, for sure, but I think problem is SOAP
replies are read synchronously, and blocking. These are the new
timings:

ocket_wrapper -server phony 61199 time: 238 microseconds per iteration
socket_wrapper -myaddr 127.0.0.1 -server lockSvrNew 62966 time: 282
microseconds per iteration
socket_wrapper -async 207.46.111.90 1863 time: 20350 microseconds per iteration
socket_wrapper login.live.com 443 time: 228129 microseconds per iteration
SOAPRequest time: 295017 microseconds per iteration
SOAPReply time: 819305 microseconds per iteration
socket_wrapper contacts.msn.com 443 time: 236107 microseconds per iteration
SOAPRequest time: 243931 microseconds per iteration
socket_wrapper contacts.msn.com 443 time: 232883 microseconds per iteration
SOAPRequest time: 240097 microseconds per iteration
socket_wrapper -server abook::dummysocketserver 6891 time: 177
microseconds per iteration
socket_wrapper -async firewall.amsn-project.net 80 time: 2317
microseconds per iteration
SOAPReply time: 1672309 microseconds per iteration
socket_wrapper storage.msn.com 443 time: 241007 microseconds per iteration
SOAPRequest time: 248864 microseconds per iteration
SOAPReply time: 10365145 microseconds per iteration
SOAPReply time: 2872543 microseconds per iteration

Look at that SOAPReply times!! 0,8 seconds, 1,67 seconds, 2,87 seconds
and 10,36 seconds!!!! During that time AMSN is completely blocked!!

So, I'm going to fix this first, and then i'll think about the dns
resolve, maybe it's not worth the effort.

If you have any questions or want to help me, just find me at amsn :)

Greets.

-- 
(:===========================================:)
 Alvaro J. Iradier Muro - [EMAIL PROTECTED]

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel

Reply via email to