Rev 2720: Buffer writes to packs, giving a significant performance boost over sftp. in http://people.ubuntu.com/~robertc/baz2.0/repository

Robert Collins robertc at robertcollins.net
Thu Aug 16 10:41:25 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/repository

------------------------------------------------------------
revno: 2720
revision-id: robertc at robertcollins.net-20070816094119-934cn03uls16spes
parent: robertc at robertcollins.net-20070816094035-sng7y55hvkm5hg98
committer: Robert Collins <robertc at robertcollins.net>
branch nick: repository
timestamp: Thu 2007-08-16 19:41:19 +1000
message:
  Buffer writes to packs, giving a significant performance boost over sftp.
modified:
  bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
=== modified file 'bzrlib/repofmt/pack_repo.py'
--- a/bzrlib/repofmt/pack_repo.py	2007-08-16 09:40:35 +0000
+++ b/bzrlib/repofmt/pack_repo.py	2007-08-16 09:41:19 +0000
@@ -220,9 +220,14 @@
                 time.ctime(), self.repo._upload_transport.base, random_name,
                 time.time() - start_time)
         pack_hash = md5.new()
+        buffer = []
         def write_data(bytes, update=pack_hash.update):
-            write_stream(bytes)
-            update(bytes)
+            buffer.append(bytes)
+            if len(buffer) == 640:
+                bytes = ''.join(buffer)
+                write_stream(bytes)
+                update(bytes)
+                del buffer[:]
         writer = pack.ContainerWriter(write_data)
         writer.begin()
         # open new indices
@@ -273,6 +278,10 @@
                 time.time() - start_time)
         # finish the pack
         writer.end()
+        if len(buffer):
+            bytes = ''.join(buffer)
+            write_stream(bytes)
+            pack_hash.update(bytes)
         new_name = pack_hash.hexdigest()
         # if nothing has been written, discard the new pack.
         if 0 == sum((len(list(revision_index.iter_all_entries())),



More information about the bazaar-commits mailing list