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.
--- a/mercurial/setdiscovery.py Thu May 16 16:22:20 2019 +0200
+++ b/mercurial/setdiscovery.py Wed Jun 05 11:23:25 2019 +0200
@@ -242,13 +242,13 @@
# update from roots
revsroots = set(repo.revs('roots(%ld)', revs))
- if not self._respectsize:
- size = max(size, len(revsroots))
-
childrenrevs = self._childrengetter()
-
_updatesample(revs, revsroots, sample, childrenrevs)
assert sample
+
+ if not self._respectsize:
+ size = max(size, min(len(revsroots), len(revsheads)))
+
sample = _limitsample(sample, size)
if len(sample) < size:
more = size - len(sample)