[PATCH 4 of 4] branchmap: Save changectx creation during update

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Fri Jan 11 12:17:55 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357926462 -3600
# Node ID 832f614278aeac035ae61ba51503a205504a5ad6
# Parent  dc2e69dcdb6e477b1cbc15b08a51990de8737b0b
branchmap: Save changectx creation during update

The newly introduced `branchmap` function allows for skip the creation of
changectx object. Speeding up the population of the branchmap.


On the mozilla repository (117293 changesets 15490 mutables)
------------------------------------------------------------

Before:

  ! impactable
  ! wall 19.902619 comb 19.860000 user 17.060000 sys 2.800000 (best of 3)
  ! mutable
  ! wall 0.575906 comb 0.580000 user 0.510000 sys 0.070000 (best of 18)
  ! unserved
  ! wall 3.157477 comb 3.140000 user 2.700000 sys 0.440000 (best of 4)
  ! hidden
  ! wall 0.000273 comb 0.000000 user 0.000000 sys 0.000000 (best of 10396)
  ! None
  ! wall 0.000123 comb 0.000000 user 0.000000 sys 0.000000 (best of 23006)

After:

  ! impactable
  ! wall 7.033758 comb 7.020000 user 6.990000 sys 0.030000 (best of 3)
  ! mutable
  ! wall 0.351910 comb 0.350000 user 0.350000 sys 0.000000 (best of 28)
  ! unserved
  ! wall 1.147860 comb 1.140000 user 1.140000 sys 0.000000 (best of 9)
  ! hidden
  ! wall 0.000272 comb 0.000000 user 0.000000 sys 0.000000 (best of 9778)
  ! None
  ! wall 0.000123 comb 0.000000 user 0.000000 sys 0.000000 (best of 21214)

On the cpython repository (81418 changesets 6418 mutables)
------------------------------------------------------------

Before:

  ! impactable
  ! wall 15.889462 comb 15.860000 user 13.700000 sys 2.160000 (best of 3)
  ! mutable
  ! wall 0.450637 comb 0.450000 user 0.390000 sys 0.060000 (best of 22)
  ! unserved
  ! wall 0.861112 comb 0.870000 user 0.770000 sys 0.100000 (best of 12)
  ! hidden
  ! wall 0.000260 comb 0.000000 user 0.000000 sys 0.000000 (best of 10876)
  ! None
  ! wall 0.000114 comb 0.000000 user 0.000000 sys 0.000000 (best of 24413)

After:

  ! impactable
  ! wall 6.545139 comb 6.530000 user 6.520000 sys 0.010000 (best of 3)
  ! mutable
  ! wall 0.170059 comb 0.170000 user 0.170000 sys 0.000000 (best of 51)
  ! unserved
  ! wall 0.288760 comb 0.290000 user 0.290000 sys 0.000000 (best of 35)
  ! hidden
  ! wall 0.000255 comb 0.000000 user 0.000000 sys 0.000000 (best of 10673)
  ! None
  ! wall 0.000113 comb 0.000000 user 0.000000 sys 0.000000 (best of 24378)

On the pypy repository (58852 changesets)
------------------------------------------------------------

Before:

  ! impactable
  ! wall 13.595905 comb 13.570000 user 12.040000 sys 1.530000 (best of 3)
  ! mutable
  ! wall 0.000318 comb 0.000000 user 0.000000 sys 0.000000 (best of 9029)
  ! unserved
  ! wall 0.000320 comb 0.000000 user 0.000000 sys 0.000000 (best of 8967)
  ! hidden
  ! wall 0.000320 comb 0.000000 user 0.000000 sys 0.000000 (best of 8355)
  ! None
  ! wall 0.000113 comb 0.000000 user 0.000000 sys 0.000000 (best of 24553)

After:

  ! impactable
  ! wall 6.166525 comb 6.150000 user 6.140000 sys 0.010000 (best of 3)
  ! mutable
  ! wall 0.000322 comb 0.000000 user 0.000000 sys 0.000000 (best of 7862)
  ! unserved
  ! wall 0.000320 comb 0.000000 user 0.000000 sys 0.000000 (best of 7638)
  ! hidden
  ! wall 0.000320 comb 0.000000 user 0.000000 sys 0.000000 (best of 8105)
  ! None
  ! wall 0.000112 comb 0.000000 user 0.000000 sys 0.000000 (best of 22523)


On my Mercurial repository (18295 changesets 2210 mutables)
------------------------------------------------------------

Before:

  ! impactable
  ! wall 23.898376 comb 18.170000 user 5.130000 sys 13.040000 (best of 3)
  ! mutable
  ! wall 0.367526 comb 0.270000 user 0.110000 sys 0.160000 (best of 25)
  ! unserved
  ! wall 0.057340 comb 0.050000 user 0.020000 sys 0.030000 (best of 100)
  ! hidden
  ! wall 0.004699 comb 0.010000 user 0.010000 sys 0.000000 (best of 561)
  ! None
  ! wall 0.003068 comb 0.000000 user 0.000000 sys 0.000000 (best of 940)

After:

  ! impactable
  ! wall 1.309182 comb 1.280000 user 1.240000 sys 0.040000 (best of 7)
  ! mutable
  ! wall 0.041512 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)
  ! unserved
  ! wall 0.024674 comb 0.020000 user 0.020000 sys 0.000000 (best of 103)
  ! hidden
  ! wall 0.004926 comb 0.000000 user 0.000000 sys 0.000000 (best of 448)
  ! None
  ! wall 0.003212 comb 0.000000 user 0.000000 sys 0.000000 (best of 740)

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -147,15 +147,15 @@ class branchcache(dict):
         """Given a branchhead cache, self, that may have extra nodes or be
         missing heads, and a generator of nodes that are at least a superset of
         heads missing, this function updates self to be correct.
         """
         cl = repo.changelog
-        ctxgen = (repo[r] for r in revgen)
         # collect new branch entries
         newbranches = {}
-        for c in ctxgen:
-            newbranches.setdefault(c.branch(), []).append(c.node())
+        getbranch = cl.branch
+        for r in revgen:
+            newbranches.setdefault(getbranch(r), []).append(cl.node(r))
         # if older branchheads are reachable from new ones, they aren't
         # really branchheads. Note checking parents is insufficient:
         # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
         for branch, newnodes in newbranches.iteritems():
             bheads = self.setdefault(branch, [])


More information about the Mercurial-devel mailing list