[Twisted-Python] Return of the "write immediately" patch

Itamar Shtull-Trauring twisted at itamarst.org
Tue Jan 1 12:40:54 EST 2002


Last time I tried this, my benchmarks were being screwed up by a bug in 
twisted's threading. This time I'm getting consistent results - an 
improvement in write performance (large writes over loopback) of 22%!


Index: twisted/internet/abstract.py
===================================================================
RCS file: /cvs/Twisted/twisted/internet/abstract.py,v
retrieving revision 1.11
diff -c -r1.11 abstract.py
*** twisted/internet/abstract.py	30 Oct 2001 23:55:39 -0000	1.11
--- twisted/internet/abstract.py	1 Jan 2002 17:40:27 -0000
***************
*** 106,112 ****
           if not self.connected:
               return
           if data:
!             self.unsent = self.unsent + data
               if self.producer is not None:
                   if len(self.unsent) > self.bufferSize:
                       self.producerPaused = 1
--- 106,118 ----
           if not self.connected:
               return
           if data:
!             if not self.unsent:
!                 l = self.writeSomeData(data)
!                 if l < 0 or l == len(data):
!                     return
!                 self.unsent = data[l:]
!             else:
!                 self.unsent = self.unsent + data
               if self.producer is not None:
                   if len(self.unsent) > self.bufferSize:
                       self.producerPaused = 1





More information about the Twisted-Python mailing list