From patchwork Thu Jun 6 08:52:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [V2] discovery: be more conservative when adjusting the sample size From: Pierre-Yves David X-Patchwork-Id: 40334 Message-Id: <84886efab235050be22d.1559811142@nodosa.octopoid.net> To: mercurial-devel@mercurial-scm.org Date: Thu, 06 Jun 2019 10:52:22 +0200 # HG changeset patch # User Pierre-Yves David # Date 1559726605 -7200 # Wed Jun 05 11:23:25 2019 +0200 # Node ID 84886efab235050be22d3fd737226c6473004f24 # Parent 12793787439538411013edffe0f9b98762d38a37 # EXP-Topic discovery-large-undecided # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 84886efab235 discovery: be more conservative when adjusting the sample size Since 5b34972a0094, the discovery will increase the sample size when it detect a "complex" undecided set. However this detection focussed on the number of roots only, this could regress discovery performance when the undecided set has many roots that eventually get merged into a few heads. To prevent such misbehavior, we adjust the logic to take in account both heads and roots. The sample size will be increased only if both are especially large. Performance testing on the same case as 5b34972a0094, does not show a significant difference. diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py --- a/mercurial/setdiscovery.py +++ b/mercurial/setdiscovery.py @@ -241,14 +241,18 @@ class partialdiscovery(object): _updatesample(revs, revsheads, sample, parentrevs) # update from roots - revsroots = set(repo.revs('roots(%ld)', revs)) - if not self._respectsize: - size = max(size, len(revsroots)) childrenrevs = self._childrengetter() + revsroots = set(repo.revs('roots(%ld)', revs)) _updatesample(revs, revsroots, sample, childrenrevs) assert sample + + if not self._respectsize: + nbroots = len(revsroots) + nbheads = len(revsheads) + size = max(size, min(nbroots, nbheads)) + sample = _limitsample(sample, size) if len(sample) < size: more = size - len(sample)