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