##// END OF EJS Templates
discovery: add a devel.discovery.exchange-heads...
marmoute -
r47034:6ee9bd69 default
parent child Browse files
Show More
@@ -702,6 +702,13 b' coreconfigitem('
702 702 b'debug.peer-request',
703 703 default=False,
704 704 )
705 # If discovery.exchange-heads is False, the discovery will not start with
706 # remote head fetching and local head querying.
707 coreconfigitem(
708 b'devel',
709 b'discovery.exchange-heads',
710 default=True,
711 )
705 712 # If discovery.grow-sample is False, the sample size used in set discovery will
706 713 # not be increased through the process
707 714 coreconfigitem(
@@ -314,6 +314,8 b' def findcommonheads('
314 314 else:
315 315 ownheads = [rev for rev in cl.headrevs() if rev != nullrev]
316 316
317 initial_head_exchange = ui.configbool(b'devel', b'discovery.exchange-heads')
318
317 319 # We also ask remote about all the local heads. That set can be arbitrarily
318 320 # large, so we used to limit it size to `initialsamplesize`. We no longer
319 321 # do as it proved counter productive. The skipped heads could lead to a
@@ -365,33 +367,39 b' def findcommonheads('
365 367 # graph (with many heads) attached to, but very independant to a the
366 368 # "simple" graph on the server. This is a fairly usual case and have
367 369 # not been met in the wild so far.
368 if remote.limitedarguments:
369 sample = _limitsample(ownheads, initialsamplesize)
370 # indices between sample and externalized version must match
371 sample = list(sample)
372 else:
373 sample = ownheads
370 if initial_head_exchange:
371 if remote.limitedarguments:
372 sample = _limitsample(ownheads, initialsamplesize)
373 # indices between sample and externalized version must match
374 sample = list(sample)
375 else:
376 sample = ownheads
374 377
375 ui.debug(b"query 1; heads\n")
376 roundtrips += 1
377 with remote.commandexecutor() as e:
378 fheads = e.callcommand(b'heads', {})
379 fknown = e.callcommand(
380 b'known',
381 {
382 b'nodes': [clnode(r) for r in sample],
383 },
384 )
378 ui.debug(b"query 1; heads\n")
379 roundtrips += 1
380 with remote.commandexecutor() as e:
381 fheads = e.callcommand(b'heads', {})
382 fknown = e.callcommand(
383 b'known',
384 {
385 b'nodes': [clnode(r) for r in sample],
386 },
387 )
388
389 srvheadhashes, yesno = fheads.result(), fknown.result()
385 390
386 srvheadhashes, yesno = fheads.result(), fknown.result()
387
388 if audit is not None:
389 audit[b'total-roundtrips'] = 1
391 if audit is not None:
392 audit[b'total-roundtrips'] = 1
390 393
391 if cl.tip() == nullid:
392 if srvheadhashes != [nullid]:
393 return [nullid], True, srvheadhashes
394 return [nullid], False, []
394 if cl.tip() == nullid:
395 if srvheadhashes != [nullid]:
396 return [nullid], True, srvheadhashes
397 return [nullid], False, []
398 else:
399 # we still need the remote head for the function return
400 with remote.commandexecutor() as e:
401 fheads = e.callcommand(b'heads', {})
402 srvheadhashes = fheads.result()
395 403
396 404 # start actual discovery (we note this before the next "if" for
397 405 # compatibility reasons)
@@ -408,15 +416,16 b' def findcommonheads('
408 416 except error.LookupError:
409 417 continue
410 418
411 # early exit if we know all the specified remote heads already
412 if len(knownsrvheads) == len(srvheadhashes):
413 ui.debug(b"all remote heads known locally\n")
414 return srvheadhashes, False, srvheadhashes
419 if initial_head_exchange:
420 # early exit if we know all the specified remote heads already
421 if len(knownsrvheads) == len(srvheadhashes):
422 ui.debug(b"all remote heads known locally\n")
423 return srvheadhashes, False, srvheadhashes
415 424
416 if len(sample) == len(ownheads) and all(yesno):
417 ui.note(_(b"all local changesets known remotely\n"))
418 ownheadhashes = [clnode(r) for r in ownheads]
419 return ownheadhashes, True, srvheadhashes
425 if len(sample) == len(ownheads) and all(yesno):
426 ui.note(_(b"all local changesets known remotely\n"))
427 ownheadhashes = [clnode(r) for r in ownheads]
428 return ownheadhashes, True, srvheadhashes
420 429
421 430 # full blown discovery
422 431
@@ -429,12 +438,13 b' def findcommonheads('
429 438 disco = partialdiscovery(
430 439 local, ownheads, hard_limit_sample, randomize=randomize
431 440 )
432 # treat remote heads (and maybe own heads) as a first implicit sample
433 # response
434 disco.addcommons(knownsrvheads)
435 disco.addinfo(zip(sample, yesno))
441 if initial_head_exchange:
442 # treat remote heads (and maybe own heads) as a first implicit sample
443 # response
444 disco.addcommons(knownsrvheads)
445 disco.addinfo(zip(sample, yesno))
436 446
437 full = False
447 full = not initial_head_exchange
438 448 progress = ui.makeprogress(_(b'searching'), unit=_(b'queries'))
439 449 while not disco.iscomplete():
440 450
@@ -1412,23 +1412,22 b' One with >200 heads. We now switch to se'
1412 1412 missing: 1040
1413 1413 common heads: 3ee37d65064a
1414 1414
1415 $ hg -R a debugdiscovery b --debug --config devel.discovery.randomize=false --config devel.discovery.grow-sample.rate=1.01
1415 $ hg -R a debugdiscovery b --debug --config devel.discovery.exchange-heads=false --config devel.discovery.randomize=false --config devel.discovery.grow-sample.rate=1.01
1416 1416 comparing with b
1417 query 1; heads
1418 1417 searching for changes
1419 taking quick initial sample
1420 query 2; still undecided: 1080, sample size is: 100
1421 1418 sampling from both directions
1422 query 3; still undecided: 980, sample size is: 200
1419 query 1; still undecided: 1340, sample size is: 200
1420 sampling from both directions
1421 query 2; still undecided: 795, sample size is: 202
1423 1422 sampling from both directions
1424 query 4; still undecided: 497, sample size is: 202
1423 query 3; still undecided: 525, sample size is: 204
1425 1424 sampling from both directions
1426 query 5; still undecided: 294, sample size is: 204
1425 query 4; still undecided: 252, sample size is: 206
1427 1426 sampling from both directions
1428 query 6; still undecided: 90, sample size is: 90
1429 6 total queries in *s (glob)
1427 query 5; still undecided: 44, sample size is: 44
1428 5 total queries in *s (glob)
1430 1429 elapsed time: * seconds (glob)
1431 round-trips: 6
1430 round-trips: 5
1432 1431 heads summary:
1433 1432 total common heads: 1
1434 1433 also local heads: 0
General Comments 0
You need to be logged in to leave comments. Login now