From patchwork Sun Dec 14 18:34:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,6] branchmap: use revbranchcache when updating branch map From: Mads Kiilerich X-Patchwork-Id: 7090 Message-Id: To: mercurial-devel@selenic.com Date: Sun, 14 Dec 2014 19:34:23 +0100 # HG changeset patch # User Mads Kiilerich # Date 1418581984 -3600 # Sun Dec 14 19:33:04 2014 +0100 # Node ID a84099ef1a332eb93bc9287d74c64af7e510f90e # Parent eeeae034dc7aa8501c3e8f510a0788a77e54bc9f branchmap: use revbranchcache when updating branch map This will speed repeated branchmap calculation up. perfbranchmap base on mozilla-central, before: ! wall 6.995851 comb 6.990000 user 6.970000 sys 0.020000 (best of 3) After: ! wall 2.599774 comb 2.600000 user 2.600000 sys 0.000000 (best of 4) On the hg repo, before: ! wall 0.718498 comb 0.720000 user 0.720000 sys 0.000000 (best of 14) After: ! wall 0.284678 comb 0.290000 user 0.290000 sys 0.000000 (best of 32) The use of revbranchcache for branch map will also make sure the revbranchcache "always" is kept up-to-date. If the cache for some reason should be out of sync, the wrong information in the cache will be skipped and the branch information will be retrieved as normally and the cache entry will be updated. diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -234,13 +234,15 @@ cl = repo.changelog # collect new branch entries newbranches = {} - getbranchinfoutf8 = cl.branchinfoutf8 + cache = revbranchcache(repo) + getbranchinfoutf8 = cache.branchinfoutf8 for r in revgen: branchutf8, closesbranch = getbranchinfoutf8(r) branch = encoding.tolocal(branchutf8) newbranches.setdefault(branch, []).append(r) if closesbranch: self._closednodes.add(cl.node(r)) + cache.save() # fetch current topological heads to speed up filtering topoheads = set(cl.headrevs()) diff --git a/tests/test-clone.t b/tests/test-clone.t --- a/tests/test-clone.t +++ b/tests/test-clone.t @@ -31,6 +31,7 @@ default 10:a7949464abda $ ls .hg/cache branch2-served + revbranchnames Default operation: diff --git a/tests/test-fncache.t b/tests/test-fncache.t --- a/tests/test-fncache.t +++ b/tests/test-fncache.t @@ -71,6 +71,7 @@ .hg/00manifest.i .hg/cache .hg/cache/branch2-served + .hg/cache/revbranchnames .hg/data .hg/data/tst.d.hg .hg/data/tst.d.hg/foo.i @@ -99,6 +100,7 @@ .hg/00changelog.i .hg/cache .hg/cache/branch2-served + .hg/cache/revbranchnames .hg/dirstate .hg/last-message.txt .hg/requires diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t --- a/tests/test-hardlinks.t +++ b/tests/test-hardlinks.t @@ -196,6 +196,7 @@ 2 r4/.hg/00changelog.i 2 r4/.hg/branch 2 r4/.hg/cache/branch2-served + 2 r4/.hg/cache/revbranchnames 2 r4/.hg/dirstate 2 r4/.hg/hgrc 2 r4/.hg/last-message.txt @@ -226,6 +227,7 @@ 2 r4/.hg/00changelog.i 1 r4/.hg/branch 2 r4/.hg/cache/branch2-served + 2 r4/.hg/cache/revbranchnames 1 r4/.hg/dirstate 2 r4/.hg/hgrc 2 r4/.hg/last-message.txt diff --git a/tests/test-inherit-mode.t b/tests/test-inherit-mode.t --- a/tests/test-inherit-mode.t +++ b/tests/test-inherit-mode.t @@ -66,6 +66,7 @@ 00600 ./.hg/00changelog.i 00770 ./.hg/cache/ 00660 ./.hg/cache/branch2-served + 00660 ./.hg/cache/revbranchnames 00660 ./.hg/dirstate 00660 ./.hg/last-message.txt 00600 ./.hg/requires @@ -111,6 +112,7 @@ 00660 ../push/.hg/00changelog.i 00770 ../push/.hg/cache/ 00660 ../push/.hg/cache/branch2-base + 00660 ../push/.hg/cache/revbranchnames 00660 ../push/.hg/requires 00770 ../push/.hg/store/ 00660 ../push/.hg/store/00changelog.i