Rev 4381: Avoiding set operations when the ancestor_of field is the same helps quite a bit. in http://bazaar.launchpad.net/~jameinel/bzr/1.16-better_heads

John Arbash Meinel john at arbash-meinel.com
Mon Jun 8 22:56:31 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.16-better_heads

------------------------------------------------------------
revno: 4381
revision-id: john at arbash-meinel.com-20090608215625-dnc3fzepsc2d4nkj
parent: john at arbash-meinel.com-20090608214233-q81n5f3hc3jotnia
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.16-better_heads
timestamp: Mon 2009-06-08 16:56:25 -0500
message:
  Avoiding set operations when the ancestor_of field is the same helps quite a bit.
  
  Now down to 0.65:1
-------------- next part --------------
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py	2009-06-08 21:42:33 +0000
+++ b/bzrlib/graph.py	2009-06-08 21:56:25 +0000
@@ -1392,6 +1392,10 @@
         nodes = self._nodes
         heappop = heapq.heappop
         heappush = heapq.heappush
+        def combine_parents(one, two):
+            all_ancestors = set(one)
+            all_ancestors.update(two)
+            return tuple(sorted(all_ancestors))
         while queue and len(candidate_nodes) > 1:
             counters[0] += 1
             _, next = heappop(queue)
@@ -1443,11 +1447,9 @@
                     else:
                         counters[3] += 1
                         # Combine to get the full set of parents
-                        def combine_parents():
-                            all_ancestors = set(ancestor_of)
-                            all_ancestors.update(next_ancestor_of)
-                            return tuple(all_ancestors)
-                        parent_node.ancestor_of = combine_parents()
+                        if ancestor_of != next_ancestor_of:
+                            parent_node.ancestor_of = combine_parents(
+                                ancestor_of, next_ancestor_of)
                         # This would otherwise require popping the item out of the
                         # queue, because we think we are done processing it.
                         # As is, we'll just let the queue clean itself up



More information about the bazaar-commits mailing list