[Zodb-checkins] SVN: ZODB/trunk/src/ZEO/zrpc/smac.py Simplified code to get a small reduction in CPU time for object loads.
Jim Fulton
jim at zope.com
Tue Apr 5 16:57:17 EDT 2011
Log message for revision 121289:
Simplified code to get a small reduction in CPU time for object loads.
Changed:
U ZODB/trunk/src/ZEO/zrpc/smac.py
-=-
Modified: ZODB/trunk/src/ZEO/zrpc/smac.py
===================================================================
--- ZODB/trunk/src/ZEO/zrpc/smac.py 2011-04-05 18:45:24 UTC (rev 121288)
+++ ZODB/trunk/src/ZEO/zrpc/smac.py 2011-04-05 20:57:16 UTC (rev 121289)
@@ -279,26 +279,9 @@
else:
size += self.__message_output(message, output)
- # Accumulate output into a single string so that we avoid
- # multiple send() calls, but avoid accumulating too much
- # data. If we send a very small string and have more data
- # to send, we will likely incur delays caused by the
- # unfortunate interaction between the Nagle algorithm and
- # delayed acks. If we send a very large string, only a
- # portion of it will actually be delivered at a time.
- l = 0
- for i in range(len(output)):
- l += len(output[i])
- if l > SEND_SIZE:
- break
- i += 1
- # It is very unlikely that i will be 1.
- v = "".join(output[:i])
- # Note: "output" usually contains the output not yet sent
- # The "del" below breaks this invariant temporarily.
- # We must ensure its satisfaction again when we leave the loop
- del output[:i]
+ v = "".join(output)
+ del output[:]
try:
n = self.send(v)
@@ -310,8 +293,8 @@
break # we couldn't write anything
raise
- if n < l:
- output.insert(0, v[n:])
+ if n < len(v):
+ output.append(v[n:])
break # we can't write any more
def handle_close(self):
More information about the Zodb-checkins
mailing list