comparison mercurial/treediscovery.py @ 49017:f054a557aab8

discovery: also audit the number of queries done In addition to the number of roundtrip, we now also track the number of queries we perform, this is useful to assert the tradeoff between number of roundtrip and the number of queries. Differential Revision: https://phab.mercurial-scm.org/D12398
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 14 Mar 2022 05:59:20 +0100
parents 6000f5b25c9b
children d44e3c45f0e4
comparison
equal deleted inserted replaced
49016:a2bd6b23881d 49017:f054a557aab8
37 with remote.commandexecutor() as e: 37 with remote.commandexecutor() as e:
38 heads = e.callcommand(b'heads', {}).result() 38 heads = e.callcommand(b'heads', {}).result()
39 39
40 if audit is not None: 40 if audit is not None:
41 audit[b'total-roundtrips'] = 1 41 audit[b'total-roundtrips'] = 1
42 audit[b'total-queries'] = 0
42 43
43 if repo.changelog.tip() == repo.nullid: 44 if repo.changelog.tip() == repo.nullid:
44 base.add(repo.nullid) 45 base.add(repo.nullid)
45 if heads != [repo.nullid]: 46 if heads != [repo.nullid]:
46 return [repo.nullid], [repo.nullid], list(heads) 47 return [repo.nullid], [repo.nullid], list(heads)
67 # search through remote branches 68 # search through remote branches
68 # a 'branch' here is a linear segment of history, with four parts: 69 # a 'branch' here is a linear segment of history, with four parts:
69 # head, root, first parent, second parent 70 # head, root, first parent, second parent
70 # (a branch always has two parents (or none) by definition) 71 # (a branch always has two parents (or none) by definition)
71 with remote.commandexecutor() as e: 72 with remote.commandexecutor() as e:
73 if audit is not None:
74 audit[b'total-queries'] += len(unknown)
72 branches = e.callcommand(b'branches', {b'nodes': unknown}).result() 75 branches = e.callcommand(b'branches', {b'nodes': unknown}).result()
73 76
74 unknown = collections.deque(branches) 77 unknown = collections.deque(branches)
75 while unknown: 78 while unknown:
76 r = [] 79 r = []
113 repo.ui.debug( 116 repo.ui.debug(
114 b"request %d: %s\n" % (reqcnt, b" ".join(map(short, r))) 117 b"request %d: %s\n" % (reqcnt, b" ".join(map(short, r)))
115 ) 118 )
116 for p in pycompat.xrange(0, len(r), 10): 119 for p in pycompat.xrange(0, len(r), 10):
117 with remote.commandexecutor() as e: 120 with remote.commandexecutor() as e:
121 subset = r[p : p + 10]
122 if audit is not None:
123 audit[b'total-queries'] += len(subset)
118 branches = e.callcommand( 124 branches = e.callcommand(
119 b'branches', 125 b'branches',
120 { 126 {
121 b'nodes': r[p : p + 10], 127 b'nodes': subset,
122 }, 128 },
123 ).result() 129 ).result()
124 130
125 for b in branches: 131 for b in branches:
126 repo.ui.debug( 132 repo.ui.debug(
133 newsearch = [] 139 newsearch = []
134 reqcnt += 1 140 reqcnt += 1
135 progress.increment() 141 progress.increment()
136 142
137 with remote.commandexecutor() as e: 143 with remote.commandexecutor() as e:
144 if audit is not None:
145 audit[b'total-queries'] += len(search)
138 between = e.callcommand(b'between', {b'pairs': search}).result() 146 between = e.callcommand(b'between', {b'pairs': search}).result()
139 147
140 for n, l in zip(search, between): 148 for n, l in zip(search, between):
141 l.append(n[1]) 149 l.append(n[1])
142 p = n[0] 150 p = n[0]