Rev 2889: (robertc) Use prejoined content for knit storage when performing a full-text store of unannotated content. (Robert Collins) in http://people.ubuntu.com/~robertc/baz2.0/knits

Robert Collins robertc at robertcollins.net
Thu Oct 4 23:30:35 BST 2007


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

------------------------------------------------------------
revno: 2889
revision-id: robertc at robertcollins.net-20071004223027-e92ucdpgeh0s67g4
parent: pqm at pqm.ubuntu.com-20071004215001-549ul8av89cwpnjp
committer: Robert Collins <robertc at robertcollins.net>
branch nick: knits
timestamp: Fri 2007-10-05 08:30:27 +1000
message:
  (robertc) Use prejoined content for knit storage when performing a full-text store of unannotated content. (Robert Collins)
modified:
  bzrlib/knit.py                 knit.py-20051212171256-f056ac8f0fbe1bd9
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py	2007-10-04 03:05:26 +0000
+++ b/bzrlib/knit.py	2007-10-04 22:30:27 +0000
@@ -890,6 +890,7 @@
                 lines = lines[:]
                 options.append('no-eol')
                 lines[-1] = lines[-1] + '\n'
+                line_bytes += '\n'
 
         if delta:
             # To speed the extract of texts the delta chain is limited
@@ -912,11 +913,16 @@
                 store_lines)
         else:
             options.append('fulltext')
-            # get mixed annotation + content and feed it into the
-            # serialiser.
-            store_lines = self.factory.lower_fulltext(content)
-            size, bytes = self._data._record_to_data(version_id, digest,
-                store_lines)
+            if self.factory.__class__ == KnitPlainFactory:
+                # use the prejoined bytes
+                size, bytes = self._data._record_to_data(version_id, digest,
+                    lines, [line_bytes])
+            else:
+                # get mixed annotation + content and feed it into the
+                # serialiser.
+                store_lines = self.factory.lower_fulltext(content)
+                size, bytes = self._data._record_to_data(version_id, digest,
+                    store_lines)
 
         access_memo = self._data.add_raw_records([size], bytes)[0]
         self._index.add_versions(
@@ -1989,17 +1995,21 @@
     def _open_file(self):
         return self._access.open_file()
 
-    def _record_to_data(self, version_id, digest, lines):
+    def _record_to_data(self, version_id, digest, lines, dense_lines=None):
         """Convert version_id, digest, lines into a raw data block.
         
+        :param dense_lines: The bytes of lines but in a denser form.
         :return: (len, a StringIO instance with the raw data ready to read.)
         """
-        bytes = (''.join(chain(
+        # Note: using a string copy here increases memory pressure with e.g.
+        # ISO's, but it is about 3 seconds faster on a 1.2Ghz intel machine
+        # when doing the initial commit of a mozilla tree. RBC 20070921
+        bytes = ''.join(chain(
             ["version %s %d %s\n" % (version_id,
                                      len(lines),
                                      digest)],
-            lines,
-            ["end %s\n" % version_id])))
+            dense_lines or lines,
+            ["end %s\n" % version_id]))
         assert bytes.__class__ == str
         compressed_bytes = bytes_to_gzip(bytes)
         return len(compressed_bytes), compressed_bytes



More information about the bazaar-commits mailing list