[Twisted-Python] How to Improve Twisted efficiency

Itamar Turner-Trauring itamar at itamarst.org
Tue Mar 13 08:31:01 EDT 2012


On 03/13/2012 05:50 AM, Peng Xiao -X (penxiao - Digital China at Cisco) 
wrote:
>
> Hi experts,
>
> I wrote a TCP client program used twisted to receive lots of data from 
> the server and decode them for analysis.
>
> But the efficiency is ugly.
>
> I used*"profile" and "pstats" *to analysis and found 
> *selectreactor.py* is time consuming.
>
> what is *selectreactor.py* used for?
>
> How can I improve that?
>
>
selectreactor is the core event loop; it waits for events to happen and 
calls other code.

In general, if you have many connections (hundreds or thousands) 
switching to the IOCP reactor on Windows, epoll on Linux, or poll on 
other Unix platforms may help (next release will also have kqueue 
support for FreeBSD). Running your application with PyPy may also help.

It may also be, though, that your program is taking a long time because 
it's waiting for data to arrive, for example, and that won't show up in 
a profile because it has nothing to do with CPU time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20120313/ae4fae16/attachment.htm 


More information about the Twisted-Python mailing list