changeset 46300:f17b6e40a775

discovery: add a discovery.grow-sample.rate This allow to control the effect of the growth rate on the discovery process while doing analysis. Differential Revision: https://phab.mercurial-scm.org/D9799
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 16 Jan 2021 00:48:11 +0100
parents 397e39ad0174
children 9689d3f3f8c5
files mercurial/configitems.py mercurial/setdiscovery.py tests/test-setdiscovery.t
diffstat 3 files changed, 51 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Sat Jan 16 00:29:17 2021 +0100
+++ b/mercurial/configitems.py	Sat Jan 16 00:48:11 2021 +0100
@@ -707,6 +707,12 @@
     b'discovery.grow-sample',
     default=True,
 )
+# discovery.grow-sample.rate control the rate at which the sample grow
+coreconfigitem(
+    b'devel',
+    b'discovery.grow-sample.rate',
+    default=1.05,
+)
 # If discovery.randomize is False, random sampling during discovery are
 # deterministic. It is meant for integration tests.
 coreconfigitem(
--- a/mercurial/setdiscovery.py	Sat Jan 16 00:29:17 2021 +0100
+++ b/mercurial/setdiscovery.py	Sat Jan 16 00:48:11 2021 +0100
@@ -290,7 +290,6 @@
     fullsamplesize=200,
     abortwhenunrelated=True,
     ancestorsof=None,
-    samplegrowth=1.05,
     audit=None,
 ):
     """Return a tuple (common, anyincoming, remoteheads) used to identify
@@ -300,6 +299,9 @@
     will be updated with extra data about the discovery, this is useful for
     debug.
     """
+
+    samplegrowth = float(ui.config(b'devel', b'discovery.grow-sample.rate'))
+
     start = util.timer()
 
     roundtrips = 0
--- a/tests/test-setdiscovery.t	Sat Jan 16 00:29:17 2021 +0100
+++ b/tests/test-setdiscovery.t	Sat Jan 16 00:48:11 2021 +0100
@@ -1412,6 +1412,48 @@
       missing:                1040
   common heads: 3ee37d65064a
 
+  $ hg -R a debugdiscovery b --debug --config devel.discovery.randomize=false --config devel.discovery.grow-sample.rate=1.01
+  comparing with b
+  query 1; heads
+  searching for changes
+  taking quick initial sample
+  query 2; still undecided: 1080, sample size is: 100
+  sampling from both directions
+  query 3; still undecided: 980, sample size is: 200
+  sampling from both directions
+  query 4; still undecided: 497, sample size is: 202
+  sampling from both directions
+  query 5; still undecided: 294, sample size is: 204
+  sampling from both directions
+  query 6; still undecided: 90, sample size is: 90
+  6 total queries in *s (glob)
+  elapsed time: * seconds (glob)
+  round-trips:                   6
+  heads summary:
+    total common heads:          1
+      also local heads:          0
+      also remote heads:         0
+      both:                      0
+    local heads:               260
+      common:                    0
+      missing:                 260
+    remote heads:                1
+      common:                    0
+      unknown:                   1
+  local changesets:           1340
+    common:                    300
+      heads:                     1
+      roots:                     1
+    missing:                  1040
+      heads:                   260
+      roots:                   260
+    first undecided set:      1340
+      heads:                   260
+      roots:                     1
+      common:                  300
+      missing:                1040
+  common heads: 3ee37d65064a
+
 Test actual protocol when pulling one new head in addition to common heads
 
   $ hg clone -U b c