Rev 3824: Only pull out the parent texts if the text doesn't already exist. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/hack

John Arbash Meinel john at arbash-meinel.com
Wed Dec 24 17:20:55 GMT 2008


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/hack

------------------------------------------------------------
revno: 3824
revision-id: john at arbash-meinel.com-20081224172036-sp0yksa4obnrt047
parent: john at arbash-meinel.com-20081224170009-z175uhn3iq9h29su
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: hack
timestamp: Wed 2008-12-24 11:20:36 -0600
message:
  Only pull out the parent texts if the text doesn't already exist.
  
  Fixing _check_remap makes 255-fan-out faster than 16-way fan out.
  
  Include parent_texts from the page cache for leaf nodes as well.
  Shaves about 2m21s=>2m10s for converting the first 1k records.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2008-12-24 17:00:09 +0000
+++ b/bzrlib/chk_map.py	2008-12-24 17:20:36 +0000
@@ -700,13 +700,22 @@
             lines.extend(value_lines)
         sha1 = osutils.sha_strings(lines)
         key = ('sha1:' + sha1,)
-        if self._orig_key is None:
-            parents = ()
-        else:
-            parents = (self._orig_key,)
         if not store.has_key(key):
             # We know the key doesn't exist, because we just checked
-            store.add_lines(key, parents, lines, random_id=True)
+            if self._orig_key is None:
+                parents = ()
+                parent_texts = None
+            else:
+                parents = (self._orig_key,)
+                orig_bytes = _page_cache.get(self._orig_key, None)
+                if orig_bytes is None:
+                    parent_texts = None
+                else:
+                    parent_lines = osutils.chunks_to_lines([orig_bytes])
+                    parent_content = knit.PlainKnitContent(parent_lines, self._orig_key)
+                    parent_texts = {self._orig_key: parent_content}
+            store.add_lines(key, parents, lines, random_id=True,
+                            parent_texts=parent_texts)
         self._key = key
         self._orig_key = self._key
         bytes = ''.join(lines)
@@ -1021,19 +1030,19 @@
             lines.append(serialised[prefix_len:])
         sha1 = osutils.sha_strings(lines)
         key = ('sha1:' + sha1,)
-        if self._orig_key is None:
-            parents = ()
-            parent_texts = None
-        else:
-            parents = (self._orig_key,)
-            orig_bytes = _page_cache.get(self._orig_key, None)
-            if orig_bytes is None:
+        if not store.has_key(key):
+            if self._orig_key is None:
+                parents = ()
                 parent_texts = None
             else:
-                parent_lines = osutils.chunks_to_lines([orig_bytes])
-                parent_content = knit.PlainKnitContent(parent_lines, self._orig_key)
-                parent_texts = {self._orig_key: parent_content}
-        if not store.has_key(key):
+                parents = (self._orig_key,)
+                orig_bytes = _page_cache.get(self._orig_key, None)
+                if orig_bytes is None:
+                    parent_texts = None
+                else:
+                    parent_lines = osutils.chunks_to_lines([orig_bytes])
+                    parent_content = knit.PlainKnitContent(parent_lines, self._orig_key)
+                    parent_texts = {self._orig_key: parent_content}
             # We know the key doesn't exist, because we just checked
             store.add_lines(key, parents, lines, random_id=True,
                             parent_texts=parent_texts)



More information about the bazaar-commits mailing list