← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/turnip:pack-protocol-fast-path into turnip:master

 

Colin Watson has proposed merging ~cjwatson/turnip:pack-protocol-fast-path into turnip:master.

Commit message:
Add a fast path for raw data transfer

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/turnip/+git/turnip/+merge/405404

This is a bit experimental, and I don't have good profiling.  However, intuitively it seems that we should avoid appending `raw_data` to `self.__buffer` (thus creating a new `bytes` object) for every packet received after the initial negotiation step, where we're just doing bulk packfile forwarding.  Add a fast path for this that avoids the extra allocation work.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/turnip:pack-protocol-fast-path into turnip:master.
diff --git a/turnip/pack/git.py b/turnip/pack/git.py
index 79d973e..2123bfd 100644
--- a/turnip/pack/git.py
+++ b/turnip/pack/git.py
@@ -118,6 +118,12 @@ class PackProtocol(protocol.Protocol, object):
         raise NotImplementedError()
 
     def dataReceived(self, raw_data):
+        if self.raw and not self.paused and not self.__buffer:
+            # Fast path.  We don't care about the content; just forward the
+            # bytes with a minimum of copying.
+            self.rawDataReceived(raw_data)
+            return
+
         self.__buffer += raw_data
         while not self.paused and not self.raw:
             try: