Mercurial > evolve
comparison hgext3rd/pullbundle.py @ 4143:2ddd8785f8d7
pullbundle: add data about the cached bundle size and hit
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 25 Sep 2018 18:41:51 +0200 |
parents | 683ceec8d37e |
children | b5cd26712e4b |
comparison
equal
deleted
inserted
replaced
4142:683ceec8d37e | 4143:2ddd8785f8d7 |
---|---|
506 rangesratio.append(entry[4] / float(entry[3])) | 506 rangesratio.append(entry[4] / float(entry[3])) |
507 bundlecount.append(entry[3]) | 507 bundlecount.append(entry[3]) |
508 totalchanges += entry[1] | 508 totalchanges += entry[1] |
509 totalcached += entry[2] | 509 totalcached += entry[2] |
510 | 510 |
511 cachedsizes = [] | |
512 cachedhits = [] | |
513 for rangeid, hits in bundlehits.items(): | |
514 length = rlen(rangeid) | |
515 cachedsizes.append(length) | |
516 cachedhits.append(hits) | |
517 | |
511 sizesdist = distribution(sizes) | 518 sizesdist = distribution(sizes) |
512 repo.ui.write(fmtdist('pull size', sizesdist)) | 519 repo.ui.write(fmtdist('pull size', sizesdist)) |
520 | |
513 changesmissingdist = distribution(changesmissing) | 521 changesmissingdist = distribution(changesmissing) |
514 repo.ui.write(fmtdist('non-cached changesets', changesmissingdist)) | 522 repo.ui.write(fmtdist('non-cached changesets', changesmissingdist)) |
523 | |
515 changesratiodist = distribution(changesratio) | 524 changesratiodist = distribution(changesratio) |
516 repo.ui.write(fmtdist('ratio of cached changesets', changesratiodist)) | 525 repo.ui.write(fmtdist('ratio of cached changesets', changesratiodist)) |
526 | |
517 bundlecountdist = distribution(bundlecount) | 527 bundlecountdist = distribution(bundlecount) |
518 repo.ui.write(fmtdist('bundle count', bundlecountdist)) | 528 repo.ui.write(fmtdist('bundle count', bundlecountdist)) |
529 | |
519 rangesratiodist = distribution(rangesratio) | 530 rangesratiodist = distribution(rangesratio) |
520 repo.ui.write(fmtdist('ratio of cached bundles', rangesratiodist)) | 531 repo.ui.write(fmtdist('ratio of cached bundles', rangesratiodist)) |
532 | |
521 repo.ui.write('changesets served:\n') | 533 repo.ui.write('changesets served:\n') |
522 repo.ui.write(' total: %7d\n' % totalchanges) | 534 repo.ui.write(' total: %7d\n' % totalchanges) |
523 repo.ui.write(' from cache: %7d (%2d%%)\n' | 535 repo.ui.write(' from cache: %7d (%2d%%)\n' |
524 % (totalcached, (totalcached * 100 // totalchanges))) | 536 % (totalcached, (totalcached * 100 // totalchanges))) |
525 repo.ui.write(' bundle: %7d\n' % sum(bundlecount)) | 537 repo.ui.write(' bundle: %7d\n' % sum(bundlecount)) |
538 | |
539 cachedsizesdist = distribution(cachedsizes) | |
540 repo.ui.write(fmtdist('size of cached bundles', cachedsizesdist)) | |
541 | |
542 cachedhitsdist = distribution(cachedhits) | |
543 repo.ui.write(fmtdist('hit on cached bundles', cachedhitsdist)) | |
526 | 544 |
527 def takeonesample(repo, revs): | 545 def takeonesample(repo, revs): |
528 node = repo.changelog.node | 546 node = repo.changelog.node |
529 pulled = random.sample(revs, max(4, len(revs) // 1000)) | 547 pulled = random.sample(revs, max(4, len(revs) // 1000)) |
530 pulled = repo.revs('%ld::%ld', pulled, pulled) | 548 pulled = repo.revs('%ld::%ld', pulled, pulled) |
539 '10%': data[length // 10], | 557 '10%': data[length // 10], |
540 '25%': data[length // 4], | 558 '25%': data[length // 4], |
541 '50%': data[length // 2], | 559 '50%': data[length // 2], |
542 '75%': data[(length // 4) * 3], | 560 '75%': data[(length // 4) * 3], |
543 '90%': data[(length // 10) * 9], | 561 '90%': data[(length // 10) * 9], |
562 '95%': data[(length // 20) * 19], | |
544 'max': data[-1], | 563 'max': data[-1], |
545 } | 564 } |
546 | 565 |
547 STATSFORMAT = """{name}: | 566 STATSFORMAT = """{name}: |
548 min: {min} | 567 min: {min} |
549 10%: {10%} | 568 10%: {10%} |
550 25%: {25%} | 569 25%: {25%} |
551 50%: {50%} | 570 50%: {50%} |
552 75%: {75%} | 571 75%: {75%} |
553 90%: {90%} | 572 90%: {90%} |
573 95%: {95%} | |
554 max: {max} | 574 max: {max} |
555 """ | 575 """ |
556 | 576 |
557 def fmtdist(name, data): | 577 def fmtdist(name, data): |
558 return STATSFORMAT.format(name=name, **data) | 578 return STATSFORMAT.format(name=name, **data) |