Mercurial > hg
changeset 46372:3e91d9978bec
branchmap: update rev-branch-cache incrementally
Historically, the revision to branch mapping cache was updated on demand
and shared via bundle2 to avoid the cost of rebuilding on first use.
Use the new `register_changeset` callback and update rbc directly on
every change. Make the transfer of the bundle part redundant, but keep
it for the moment to avoid the test churn.
Over all, "hg unbundle" for large bundles is less than 1.8% slower for
different larger repositories and that seems to a reasonable trade off.
Differential Revision: https://phab.mercurial-scm.org/D9781
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 15 Jan 2021 01:58:59 +0100 |
parents | 0903d6b9b1df |
children | 711ba0f1057e |
files | mercurial/branchmap.py mercurial/bundle2.py mercurial/localrepo.py relnotes/next tests/test-acl.t tests/test-inherit-mode.t tests/test-rebase-conflicts.t |
diffstat | 7 files changed, 22 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/branchmap.py Tue Jan 19 00:20:53 2021 +0100 +++ b/mercurial/branchmap.py Fri Jan 15 01:58:59 2021 +0100 @@ -706,8 +706,10 @@ self._setcachedata(rev, reponode, branchidx) return b, close - def setdata(self, branch, rev, node, close): + def setdata(self, rev, changelogrevision): """add new data information to the cache""" + branch, close = changelogrevision.branchinfo + if branch in self._namesreverse: branchidx = self._namesreverse[branch] else: @@ -716,7 +718,7 @@ self._namesreverse[branch] = branchidx if close: branchidx |= _rbccloseflag - self._setcachedata(rev, node, branchidx) + self._setcachedata(rev, self._repo.changelog.node(rev), branchidx) # If no cache data were readable (non exists, bad permission, etc) # the cache was bypassing itself by setting: #
--- a/mercurial/bundle2.py Tue Jan 19 00:20:53 2021 +0100 +++ b/mercurial/bundle2.py Fri Jan 15 01:58:59 2021 +0100 @@ -2478,35 +2478,10 @@ @parthandler(b'cache:rev-branch-cache') def handlerbc(op, inpart): - """receive a rev-branch-cache payload and update the local cache - - The payload is a series of data related to each branch - - 1) branch name length - 2) number of open heads - 3) number of closed heads - 4) open heads nodes - 5) closed heads nodes - """ - total = 0 - rawheader = inpart.read(rbcstruct.size) - cache = op.repo.revbranchcache() - cl = op.repo.unfiltered().changelog - while rawheader: - header = rbcstruct.unpack(rawheader) - total += header[1] + header[2] - utf8branch = inpart.read(header[0]) - branch = encoding.tolocal(utf8branch) - for x in pycompat.xrange(header[1]): - node = inpart.read(20) - rev = cl.rev(node) - cache.setdata(branch, rev, node, False) - for x in pycompat.xrange(header[2]): - node = inpart.read(20) - rev = cl.rev(node) - cache.setdata(branch, rev, node, True) - rawheader = inpart.read(rbcstruct.size) - cache.write() + """Legacy part, ignored for compatibility with bundles from or + for Mercurial before 5.7. Newer Mercurial computes the cache + efficiently enough during unbundling that the additional transfer + is unnecessary.""" @parthandler(b'pushvars')
--- a/mercurial/localrepo.py Tue Jan 19 00:20:53 2021 +0100 +++ b/mercurial/localrepo.py Fri Jan 15 01:58:59 2021 +0100 @@ -2063,7 +2063,7 @@ return self._revbranchcache def register_changeset(self, rev, changelogrevision): - pass + self.revbranchcache().setdata(rev, changelogrevision) def branchtip(self, branch, ignoremissing=False): """return the tip node for a given branch
--- a/relnotes/next Tue Jan 19 00:20:53 2021 +0100 +++ b/relnotes/next Fri Jan 15 01:58:59 2021 +0100 @@ -44,6 +44,9 @@ * The `branchmap` cache is updated more intelligently and can be significantly faster for repositories with many branches and changesets. + * The `rev-branch-cache` is now updated incrementally whenever changesets + are added. + == New Experimental Features ==
--- a/tests/test-acl.t Tue Jan 19 00:20:53 2021 +0100 +++ b/tests/test-acl.t Fri Jan 15 01:58:59 2021 +0100 @@ -204,6 +204,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -283,6 +284,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -806,6 +808,7 @@ acl: acl.deny.bookmarks not enabled acl: bookmark access granted: "ef1ea85a6374b77d6da9dcda9541f498f2d17df7" on bookmark "moving-bookmark" bundle2-input-bundle: 7 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache invalid branch cache (served.hidden): tip differs added 1 changesets with 1 changes to 1 files @@ -982,6 +985,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -1318,6 +1322,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -1408,6 +1413,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total @@ -1577,6 +1583,7 @@ bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 5 parts total + truncating cache/rbc-revs-v1 to 8 updating the branch cache added 3 changesets with 3 changes to 3 files bundle2-output-bundle: "HG20", 1 parts total
--- a/tests/test-inherit-mode.t Tue Jan 19 00:20:53 2021 +0100 +++ b/tests/test-inherit-mode.t Fri Jan 15 01:58:59 2021 +0100 @@ -134,6 +134,8 @@ 00660 ../push/.hg/00changelog.i 00770 ../push/.hg/cache/ 00660 ../push/.hg/cache/branch2-base + 00660 ../push/.hg/cache/rbc-names-v1 + 00660 ../push/.hg/cache/rbc-revs-v1 00660 ../push/.hg/dirstate 00660 ../push/.hg/requires 00770 ../push/.hg/store/
--- a/tests/test-rebase-conflicts.t Tue Jan 19 00:20:53 2021 +0100 +++ b/tests/test-rebase-conflicts.t Fri Jan 15 01:58:59 2021 +0100 @@ -318,10 +318,10 @@ bundle2-input-part: total payload size 1686 bundle2-input-part: "cache:rev-branch-cache" (advisory) supported bundle2-input-part: total payload size 74 - truncating cache/rbc-revs-v1 to 56 bundle2-input-part: "phase-heads" supported bundle2-input-part: total payload size 24 bundle2-input-bundle: 3 parts total + truncating cache/rbc-revs-v1 to 72 added 2 changesets with 2 changes to 1 files updating the branch cache invalid branch cache (served): tip differs