[Twisted-Python] Re: [Twisted-commits] CVS: Twisted/twisted/internet poll.py,NONE,1.1

Glyph Lefkowitz glyph at twistedmatrix.com
Thu Nov 22 22:39:50 EST 2001

On Thu, Nov 22, 2001 at 03:27:20PM +0200, Itamar Shtull-Trauring wrote:
> Glyph Lefkowitz wrote:
> > I'm confused.  In what way is "adding/removing a reader/writer" not
> > "registering/unregistering an object"?
> Here's one issue - removeWriter is called every time the buffer is epmtied
> out. In the lifetime of a connection, the transport keeps on adding and
> removing, adding and removing itself as a writer because of this. In
> select() this isn't an issue, but in poll() it is, since removing and adding
> the writer is an expensive operation (in fact it adds a %33 overhead, in
> tests under high loads).
> I'll see what I can do to fix the poll()-based implementation, but meanwhile
> the select event loop is much faster under high loads.

What I don't understand is that frequently, in an implementation where there is
no distinction between registering for reads and registering for writes, you
won't care if a socket is writable, only if it's readable.  What does the
higher-level implementation do then?  Just early-out of the callback if the
connection isn't "really" registerd for writes?

Even though I am not sure I understand the problem :), perhaps the right answer
to this question, since the common case is that all data can be written at
once, is that the write should happen immediately, only being added to the
select/poll loop if the write would block.  This would probably add a little
complexity to the code but save a bunch of performance on small-write heavy

______      you are in a maze of twisted little applications, all
|   |_\     remarkably consistent.
|     |          -- glyph lefkowitz, glyph @ twisted matrix . com
|_____|             http://www.twistedmatrix.com/

More information about the Twisted-Python mailing list