]> arthur.barton.de Git - bup.git/commitdiff
cmd/margin: interpret the meaning of the margin bits.
authorAvery Pennarun <apenwarr@gmail.com>
Sun, 5 Sep 2010 18:59:39 +0000 (11:59 -0700)
committerAvery Pennarun <apenwarr@gmail.com>
Mon, 6 Sep 2010 07:52:16 +0000 (00:52 -0700)
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 <apenwarr@gmail.com>
Documentation/bup-margin.md
cmd/margin-cmd.py

index b3b78a2928b3529d477c2acc26c5343b1ccc9f3f..8f1ebeb60ee76f65c71a620856f569bab0eacde3 100644 (file)
@@ -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.
index e61d0573aba00fde59c4583f8236b0b38f78abe5..90dbdcd8f90edad112c48cc5d513b95554b709fe 100755 (executable)
@@ -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))