[Twisted-Python] Performance and select.select

Nitro nitro at dr-code.org
Thu Jan 10 21:36:45 EST 2008

Am 04.01.2008, 04:19 Uhr, schrieb Jean-Paul Calderone <exarkun at divmod.com>:

> Twisted does use select by default on Windows.  One thing you might try  
> is
> one of the other reactors available on Windows; there are two,
> win32eventreactor and iocpreactor.  You can read about how to do this  
> here:
> http://twistedmatrix.com/projects/core/documentation/howto/choosing-reactor.html
> Depending on what your application does, iocpreactor may not be complete
> enough to actually run your code.  It lacks some features provided by the
> default reactor.
> Whether either of these reactors will actually improve the performance of
> your application, I don't know.  You pointed out that a lot of time is
> spent in select, but this doesn't mean that spending less time inside the
> event notification function will make your overall application faster.
> Also, you are right to be suspicious of these profile results.  Python  
> has
> a very spotty history when it comes to profilers.  They are often  
> inaccurate
> or completely wrong.  cProfile is supposed to be better than the previous
> attempts, but I haven't personally used it extensively enough (nor at  
> all on
> Windows) to say whether this is true.

As I explained in my other post, cProfile's output wasn't what I expected  
it to be. I tried IOCP reactor nevertheless and it worked for my  
application. Can't see a real performance difference, I guess I am not  
performance limited by twisted anymore. At least for the moment being :-)

>   * How often do timed events go off?  These also cause more trips into
>     select, since each one causes select to return when it is time to  
> run.
>     Do you use reactor.callLater() with a 0 timeout a lot?

What is a lot? I am probably using it 10-50 times per iteration. Just out  
of curiosity - since my real problem is solved - which difference do those  
callLater(0, ...) calls make?

Thanks for helping, also thanks to Itamar.


More information about the Twisted-Python mailing list