comparison hgext3rd/pullbundle.py @ 4144:b5cd26712e4b

pullbundle: add some information on the cached change This also adds a way to skip "caching" smaller range in the debugcommand (not in the extensions itself).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 25 Sep 2018 19:35:33 +0200
parents 2ddd8785f8d7
children 08b3c370e8b3
comparison
equal deleted inserted replaced
4143:2ddd8785f8d7 4144:b5cd26712e4b
446 partdata = (cachedata, nbchanges, pversion) 446 partdata = (cachedata, nbchanges, pversion)
447 return _makepartfromstream(newpart, repo, *partdata) 447 return _makepartfromstream(newpart, repo, *partdata)
448 448
449 @command('^debugpullbundlecacheoverlap', 449 @command('^debugpullbundlecacheoverlap',
450 [('', 'count', 100, _('of "client" pulling')), 450 [('', 'count', 100, _('of "client" pulling')),
451 ('', 'min-cache', 1, _('minimum size of cached bundle')),
451 ], 452 ],
452 _('hg debugpullbundlecacheoverlap [--client 100] REVSET')) 453 _('hg debugpullbundlecacheoverlap [--client 100] REVSET'))
453 def debugpullbundlecacheoverlap(ui, repo, *revs, **opts): 454 def debugpullbundlecacheoverlap(ui, repo, *revs, **opts):
454 '''Display statistic on bundle cache hit 455 '''Display statistic on bundle cache hit
455 456
459 ''' 460 '''
460 actionrevs = scmutil.revrange(repo, revs) 461 actionrevs = scmutil.revrange(repo, revs)
461 if not revs: 462 if not revs:
462 raise error.Abort('No revision selected') 463 raise error.Abort('No revision selected')
463 count = opts['count'] 464 count = opts['count']
465 min_cache = opts['min_cache']
464 466
465 bundlehits = collections.defaultdict(lambda: 0) 467 bundlehits = collections.defaultdict(lambda: 0)
466 pullstats = [] 468 pullstats = []
467 469
468 rlen = lambda rangeid: repo.stablerange.rangelength(repo, rangeid) 470 rlen = lambda rangeid: repo.stablerange.rangelength(repo, rangeid)
469 471
470 repo.ui.write("gathering %d sample pulls within %d revisions\n" 472 repo.ui.write("gathering %d sample pulls within %d revisions\n"
471 % (count, len(actionrevs))) 473 % (count, len(actionrevs)))
474 if 1 < min_cache:
475 repo.ui.write(" not caching ranges smaller than %d changesets\n" % min_cache)
472 for i in xrange(count): 476 for i in xrange(count):
473 repo.ui.progress('gathering data', i, total=count) 477 repo.ui.progress('gathering data', i, total=count)
474 outgoing = takeonesample(repo, actionrevs) 478 outgoing = takeonesample(repo, actionrevs)
475 ranges = sliceoutgoing(repo, outgoing) 479 ranges = sliceoutgoing(repo, outgoing)
476 hitranges = 0 480 hitranges = 0
477 hitchanges = 0 481 hitchanges = 0
478 totalchanges = 0 482 totalchanges = 0
483 largeranges = []
479 for rangeid, __ in ranges: 484 for rangeid, __ in ranges:
480 length = rlen(rangeid) 485 length = rlen(rangeid)
481 totalchanges += length 486 totalchanges += length
482 if bundlehits[rangeid]: 487 if bundlehits[rangeid]:
483 hitranges += 1 488 hitranges += 1
484 hitchanges += rlen(rangeid) 489 hitchanges += rlen(rangeid)
485 bundlehits[rangeid] += 1 490 if min_cache <= length:
491 bundlehits[rangeid] += 1
492 largeranges.append(rangeid)
493
486 stats = (len(outgoing.missing), 494 stats = (len(outgoing.missing),
487 totalchanges, 495 totalchanges,
488 hitchanges, 496 hitchanges,
489 len(ranges), 497 len(largeranges),
490 hitranges, 498 hitranges,
491 ) 499 )
492 pullstats.append(stats) 500 pullstats.append(stats)
493 repo.ui.progress('gathering data', None) 501 repo.ui.progress('gathering data', None)
494 502
501 bundlecount = [] 509 bundlecount = []
502 for entry in pullstats: 510 for entry in pullstats:
503 sizes.append(entry[0]) 511 sizes.append(entry[0])
504 changesmissing.append(entry[1] - entry[2]) 512 changesmissing.append(entry[1] - entry[2])
505 changesratio.append(entry[2] / float(entry[1])) 513 changesratio.append(entry[2] / float(entry[1]))
506 rangesratio.append(entry[4] / float(entry[3])) 514 if entry[3]:
515 rangesratio.append(entry[4] / float(entry[3]))
516 else:
517 rangesratio.append(1)
507 bundlecount.append(entry[3]) 518 bundlecount.append(entry[3])
508 totalchanges += entry[1] 519 totalchanges += entry[1]
509 totalcached += entry[2] 520 totalcached += entry[2]
510 521
511 cachedsizes = [] 522 cachedsizes = []
512 cachedhits = [] 523 cachedhits = []
513 for rangeid, hits in bundlehits.items(): 524 for rangeid, hits in bundlehits.items():
525 if hits <= 0:
526 continue
514 length = rlen(rangeid) 527 length = rlen(rangeid)
515 cachedsizes.append(length) 528 cachedsizes.append(length)
516 cachedhits.append(hits) 529 cachedhits.append(hits)
517 530
518 sizesdist = distribution(sizes) 531 sizesdist = distribution(sizes)