[Twisted-Python] Re: [Twisted-commits] r10475 - Use writeSequence instead of silly for-loop.

Bob Ippolito bob at redivi.com
Thu Apr 15 14:27:16 EDT 2004


On Apr 15, 2004, at 2:00 PM, Itamar Shtull-Trauring wrote:

> On Thu, 2004-04-15 at 13:27, James Y Knight wrote:
>
>> Unfortunately, python doesn't expose the writev syscall, which means
>> that you depend on Nagling to not coalesce the TCP packets. There *is*
>> a TCP option which you can use to help fix too many small packets:
>> TCP_CORK on linux and TCP_NOPUSH on FreeBSD. This keeps partial 
>> packets
>> from being sent at all until you close the connection or turn off the
>> option (except on older freebsd, where it's broken and you need to 
>> turn
>> off the option and call write again to wake it up).
>
> JP has code for using writev in the sandbox (sandbox/exarkun/iovec/)
> which ought to be integrated at some point.

I think the best answer to this performance talk is: don't bother.  I 
once set out to fix his implementation, and did (but I'm not sure what 
happened to it).  It wasn't really much faster, definitely not enough 
to warrant an extension.  You know what?  The overhead doesn't seem to 
be in the write calls or the str joins, it's the rest of Python that's 
slow :)

I think that this sort of time would be better spent on epoll and 
kqueue.  Last I checked, enabling kqueue in Twisted required 
downloading some ancient code written for Python 1.5 from a ftp site 
that hasn't been updated since 2001, patching it, writing a makefile 
for your platform, and building the extension separately.

-bob





More information about the Twisted-Python mailing list