Mercurial > hg
comparison mercurial/setdiscovery.py @ 36715:613954a17a25
setdiscovery: back out changeset 5cfdf6137af8 (issue5809)
As explained in the bug report, this commit caused a performance
regression. The problem occurs when the local repo has very many
heads. Before 5cfdf6137af8, 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 5cfdf6137af8: 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 5cfdf6137af8 in the case where local and remote repos
share a large set of common nodes.
For now, we just back out 5cfdf6137af8. 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.
Differential Revision: https://phab.mercurial-scm.org/D2643
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 04 Mar 2018 07:37:08 -0800 |
parents | 5cfdf6137af8 |
children | bf485b70d0ae |
comparison
equal
deleted
inserted
replaced
36714:250f3168d907 | 36715:613954a17a25 |
---|---|
128 """return a random subset of sample of at most desiredlen item""" | 128 """return a random subset of sample of at most desiredlen item""" |
129 if len(sample) > desiredlen: | 129 if len(sample) > desiredlen: |
130 sample = set(random.sample(sample, desiredlen)) | 130 sample = set(random.sample(sample, desiredlen)) |
131 return sample | 131 return sample |
132 | 132 |
133 def findcommonheads(ui, local, remote, heads=None, | 133 def findcommonheads(ui, local, remote, |
134 initialsamplesize=100, | 134 initialsamplesize=100, |
135 fullsamplesize=200, | 135 fullsamplesize=200, |
136 abortwhenunrelated=True, | 136 abortwhenunrelated=True, |
137 ancestorsof=None): | 137 ancestorsof=None): |
138 '''Return a tuple (common, anyincoming, remoteheads) used to identify | 138 '''Return a tuple (common, anyincoming, remoteheads) used to identify |
153 roundtrips += 1 | 153 roundtrips += 1 |
154 ownheads = dag.heads() | 154 ownheads = dag.heads() |
155 sample = _limitsample(ownheads, initialsamplesize) | 155 sample = _limitsample(ownheads, initialsamplesize) |
156 # indices between sample and externalized version must match | 156 # indices between sample and externalized version must match |
157 sample = list(sample) | 157 sample = list(sample) |
158 if heads: | 158 batch = remote.iterbatch() |
159 srvheadhashes = heads | 159 batch.heads() |
160 yesno = remote.known(dag.externalizeall(sample)) | 160 batch.known(dag.externalizeall(sample)) |
161 else: | 161 batch.submit() |
162 batch = remote.iterbatch() | 162 srvheadhashes, yesno = batch.results() |
163 batch.heads() | |
164 batch.known(dag.externalizeall(sample)) | |
165 batch.submit() | |
166 srvheadhashes, yesno = batch.results() | |
167 | 163 |
168 if cl.tip() == nullid: | 164 if cl.tip() == nullid: |
169 if srvheadhashes != [nullid]: | 165 if srvheadhashes != [nullid]: |
170 return [nullid], True, srvheadhashes | 166 return [nullid], True, srvheadhashes |
171 return [nullid], False, [] | 167 return [nullid], False, [] |