comparison mercurial/setdiscovery.py @ 23813:932f814bf016

setdiscovery: always add exponential sample to the heads As explained in a previous changeset, prioritizing heads too much behaves pathologically when there are more heads than the sample size. To counter this, we always inject exponential samples before reducing to the sample size limit. This already show some benefit in the test themselves, but on a real-world example this moves my discovery for push to pathologically headed repo from 45 rounds to 17 of them. We should maybe ensure that at least 25% of the result sample is heads, but I think the random sampling will be fine in practice.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 07 Jan 2015 17:28:51 -0800
parents db58186dd8e3
children 6a5877a73141
comparison
equal deleted inserted replaced
23812:db58186dd8e3 23813:932f814bf016
103 _updatesample(dag, None, sample, always, quicksamplesize=desiredlen) 103 _updatesample(dag, None, sample, always, quicksamplesize=desiredlen)
104 sample.update(always) 104 sample.update(always)
105 return sample 105 return sample
106 106
107 def _takefullsample(dag, nodes, size): 107 def _takefullsample(dag, nodes, size):
108 always = dag.headsetofconnecteds(nodes) 108 sample = always = dag.headsetofconnecteds(nodes)
109 if size <= len(always):
110 return always
111 sample = always
112 # update from heads 109 # update from heads
113 _updatesample(dag, nodes, sample, always) 110 _updatesample(dag, nodes, sample, always)
114 # update from roots 111 # update from roots
115 _updatesample(dag.inverse(), nodes, sample, always) 112 _updatesample(dag.inverse(), nodes, sample, always)
116 assert sample 113 assert sample