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.
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to