[Zodb-checkins] SVN: ZODB/branches/3.10/src/ZEO/zrpc/smac.py Simplified code to get a small reduction in CPU time for object loads.
Jim Fulton
jim at zope.com
Mon Apr 11 17:24:59 EDT 2011
Log message for revision 121396:
Simplified code to get a small reduction in CPU time for object loads.
Changed:
U ZODB/branches/3.10/src/ZEO/zrpc/smac.py
-=-
Modified: ZODB/branches/3.10/src/ZEO/zrpc/smac.py
===================================================================
--- ZODB/branches/3.10/src/ZEO/zrpc/smac.py 2011-04-11 21:24:56 UTC (rev 121395)
+++ ZODB/branches/3.10/src/ZEO/zrpc/smac.py 2011-04-11 21:24:58 UTC (rev 121396)
@@ -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