branchmap: Save changectx creation during update
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 11 Jan 2013 18:47:42 +0100
changeset 18307 0eed2546118a
parent 18306 06185554e7e3
child 18308 4e27b06a0fd9
branchmap: Save changectx creation during update The newly introduced `branchmap` function allows us to skip the creation of changectx objects. This speeds up the construction of the branchmap. On the mozilla repository (117293 changesets, 15490 mutable) Before: ! impactable 19.9 ! mutable 0.576 ! unserved 3.16 After: ! impactable 7.03 (2.8x faster) ! mutable 0.352 (1.6x) ! unserved 1.15 (2.7x) On the cpython repository (81418 changesets, 6418 mutable) Before: ! impactable 15.9 ! mutable 0.451 ! unserved 0.861 After: ! impactable 6.55 (2.4x faster) ! mutable 0.170 (2.6x faster) ! unserved 0.289 (2.9x faster) On the pypy repository (58852 changesets) Before: ! impactable 13.6 After: ! impactable 6.17 (2.2x faster) On my Mercurial repository (18295 changesets, 2210 mutable) Before: ! impactable 23.9 ! mutable 0.368 ! unserved 0.057 After: ! impactable 1.31 (18x faster) ! mutable 0.042 (8.7x) ! unserved 0.025 (2.2x)
mercurial/branchmap.py
--- a/mercurial/branchmap.py	Thu Jan 10 00:41:40 2013 +0100
+++ b/mercurial/branchmap.py	Fri Jan 11 18:47:42 2013 +0100
@@ -149,11 +149,11 @@
         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)