D2643: setdiscovery: back out changeset 5cfdf6137af8 (issue5809)

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sun Mar 4 16:58:16 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As explained in the bug report, this commit caused a performance
  regression. The problem occurs when the local repo has very many
  heads. Before https://phab.mercurial-scm.org/rHG5cfdf6137af87e52063a5a11a697bab805e4b03d, we used to get the remote's list of heads
  and if these heads mostly overlapped with the local repo's heads, we
  would mark these common heads as common, which would greatly reduce
  the size of the set of undecided nodes.
  
  Note that a similar problem existed before https://phab.mercurial-scm.org/rHG5cfdf6137af87e52063a5a11a697bab805e4b03d: If the local
  repo had very many heads and the server just had a few (or many heads
  from a disjoint set), we would do the same kind of slow discovery as
  we would with https://phab.mercurial-scm.org/rHG5cfdf6137af87e52063a5a11a697bab805e4b03d in the case where local and remote repos
  share a large set of common nodes.
  
  For now, we just back out https://phab.mercurial-scm.org/rHG5cfdf6137af87e52063a5a11a697bab805e4b03d. We should improve the
  discovery in the "local has many heads, remote has few heads" case,
  but let's do that after backing this out.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2643

AFFECTED FILES
  mercurial/discovery.py
  mercurial/setdiscovery.py

CHANGE DETAILS

diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -130,7 +130,7 @@
         sample = set(random.sample(sample, desiredlen))
     return sample
 
-def findcommonheads(ui, local, remote, heads=None,
+def findcommonheads(ui, local, remote,
                     initialsamplesize=100,
                     fullsamplesize=200,
                     abortwhenunrelated=True,
@@ -155,15 +155,11 @@
     sample = _limitsample(ownheads, initialsamplesize)
     # indices between sample and externalized version must match
     sample = list(sample)
-    if heads:
-        srvheadhashes = heads
-        yesno = remote.known(dag.externalizeall(sample))
-    else:
-        batch = remote.iterbatch()
-        batch.heads()
-        batch.known(dag.externalizeall(sample))
-        batch.submit()
-        srvheadhashes, yesno = batch.results()
+    batch = remote.iterbatch()
+    batch.heads()
+    batch.known(dag.externalizeall(sample))
+    batch.submit()
+    srvheadhashes, yesno = batch.results()
 
     if cl.tip() == nullid:
         if srvheadhashes != [nullid]:
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -57,7 +57,7 @@
         if all(knownnode(h) for h in heads):
             return (heads, False, heads)
 
-    res = setdiscovery.findcommonheads(repo.ui, repo, remote, heads,
+    res = setdiscovery.findcommonheads(repo.ui, repo, remote,
                                        abortwhenunrelated=not force,
                                        ancestorsof=ancestorsof)
     common, anyinc, srvheads = res



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list