From: Avery Pennarun Date: Sun, 5 Sep 2010 18:59:39 +0000 (-0700) Subject: cmd/margin: interpret the meaning of the margin bits. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=aa1244949b7494af92c55c0261cfd639fe2e0048;p=packages%2Fb%2Fbup.git cmd/margin: interpret the meaning of the margin bits. Maybe you were wondering how good it is when 'bup margin' returns 40 or 45. Well, now it'll tell you. Signed-off-by: Avery Pennarun --- diff --git a/Documentation/bup-margin.md b/Documentation/bup-margin.md index b3b78a2..8f1ebeb 100644 --- a/Documentation/bup-margin.md +++ b/Documentation/bup-margin.md @@ -54,8 +54,16 @@ close to 160 bits. # EXAMPLE $ bup margin - Reading indexes: 100.00% (11188299/11188299), done. - 45 + Reading indexes: 100.00% (1612581/1612581), done. + 40 + 40 matching prefix bits + 1.94 bits per doubling + 120 bits (61.86 doublings) remaining + 4.19338e+18 times larger is possible + + Everyone on earth could have 625878182 data sets + like yours, all in one repository, and we would + expect 1 object collision. $ bup margin --predict PackIdxList: using 1 index. diff --git a/cmd/margin-cmd.py b/cmd/margin-cmd.py index e61d057..90dbdcd 100755 --- a/cmd/margin-cmd.py +++ b/cmd/margin-cmd.py @@ -1,8 +1,9 @@ #!/usr/bin/env python -import sys, struct +import sys, struct, math from bup import options, git, _helpers from bup.helpers import * +POPULATION_OF_EARTH=6.7e9 # as of September, 2010 optspec = """ bup margin @@ -51,3 +52,16 @@ else: longmatch = max(longmatch, pm) last = i print longmatch + log('%d matching prefix bits\n' % longmatch) + doublings = math.log(len(mi), 2) + bpd = longmatch / doublings + log('%.2f bits per doubling\n' % bpd) + remain = 160 - longmatch + rdoublings = remain / bpd + log('%d bits (%.2f doublings) remaining\n' % (remain, rdoublings)) + larger = 2**rdoublings + log('%g times larger is possible\n' % larger) + perperson = larger/POPULATION_OF_EARTH + log('\nEveryone on earth could have %d data sets like yours, all in one\n' + 'repository, and we would expect 1 object collision.\n' + % int(perperson))