[Twisted-Python] Performance and select.select

Nitro nitro at dr-code.org
Thu Jan 10 21:32:06 EST 2008

Am 04.01.2008, 04:18 Uhr, schrieb Itamar Shtull-Trauring  
<itamar at itamarst.org>:

>> a) the select calls are really taking up that much time (more than 50%!)
> They're certainly going to take up lots and lots of *clock* time, not
> necessarily CPU time: select() is the way Twisted (in default reactors)
> waits for events to happen. So if your program does nothing at all (e.g.
> just reactor.run(), select() will actually be close to 100% of clock
> time, even though CPU usage will be minuscule.

I guess this is what cProfile is actually outputting. Clock time and not  
cpu time. If the app is under more load, the percentage of the time spent  
in select() calls decreases to a minimum. So select() isn't bad then.

> If you have many TCP connections (or really, file descriptors), hundreds
> or thousands, select() will also start taking up CPU time. Using poll
> reactor, or in next version of Twisted (2.5 had some bugs) epoll reactor
> on Linux will use less CPU for this scenario.

I have very few connections, so this was not the problem. Only cProfile  
being a bit strange.


More information about the Twisted-Python mailing list