[Twisted-Python] twisted 30% slower than asyncore?

Jp Calderone exarkun at intarweb.us
Wed Apr 30 23:29:53 MDT 2003


On Thu, May 01, 2003 at 03:18:58PM +1000, Anthony Baxter wrote:
> 
> >>> Itamar Shtull-Trauring wrote
> > We'll see what we can do to improve this (if we can, and when we have
> > time :).
> 
> If it helps, I have slabs of hotshot data on this. The top 10 (from 20,000
> small HTTP fetches:
> 
>    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
>     20082   50.981    0.003  172.623    0.009 default.py:418(doSelect)
>     60024   26.018    0.000   26.018    0.000 tcp.py:116(writeSomeData)
>     40022   22.463    0.001   24.738    0.001 failure.py:91(__init__)
>    488147   21.022    0.000   24.747    0.000 <string>:1(fileno)
>     20010    4.160    0.000    4.932    0.000 tcp.py:209(createInternetSocket)
>     60024    3.486    0.000    6.361    0.000 tcp.py:97(doRead)
>     60030    2.795    0.000    2.795    0.000 default.py:489(addReader)
>     40020    2.789    0.000    3.782    0.000 tcp.py:90(__init__)
>     40020    2.746    0.000   47.347    0.001 tcp.py:232(doConnect)
>     20010    2.573    0.000    4.484    0.000 abstract.py:87(doWrite)
> 
> That 'failure.py' is looking like some tasty low-hanging fruit to me,
> but doSelect should be amenable to some speedups as well...
> 

  Boy would it be great if Failures could be sped up some more, but it
doesn't seem likely without some mind-bending rework of the whole design. 
I think most, if not all, of the worthwhile local optimizations have been
made on it.

  What I learned from Twisted.names is to not write code that uses Failures
anywhere except where they are absolutely necessary.  Python exceptions
might be cheap enough to use as a kind of fancy flow control, but failures
definitely are not.


> I should probably add that even though Twisted is slower than asyncore,
> pythondirector using Twisted is still 10-15% faster than the written-in-C 
> "Pound" load balancer, and about 5% slower than the "balance" load balancer
> (also in C).

  Cool beans.

  Jp

-- 
"There is no reason for any individual to have a computer in their
home."
                -- Ken Olson, President of DEC, World Future Society
                   Convention, 1977
-- 
 up 42 days, 1:04, 5 users, load average: 0.00, 0.02, 0.02
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030501/31cc8897/attachment.sig>


More information about the Twisted-Python mailing list