From: Zooko O'Whielacronx Date: Thu, 9 Aug 2007 05:31:12 +0000 (-0700) Subject: misc/sizes.py: rename "block" to "share" and "subblock" to "block" X-Git-Url: https://git.rkrishnan.org/architecture.txt?a=commitdiff_plain;h=63d7e126ff4ea3215f541e02d090708a7fcc219d;p=tahoe-lafs%2Ftahoe-lafs.git misc/sizes.py: rename "block" to "share" and "subblock" to "block" This renaming is already in place in all of our other documentation and code, but misc/sizes.py got overlooked. --- diff --git a/misc/sizes.py b/misc/sizes.py index 5d7eec04..5b2c0328 100644 --- a/misc/sizes.py +++ b/misc/sizes.py @@ -42,90 +42,90 @@ class Sizes: self.file_size = file_size self.seg_size = seg_size = 1.0 * min(MAX_SEGSIZE, file_size) self.num_segs = num_segs = math.ceil(file_size / seg_size) - self.num_subblocks = num_subblocks = num_segs + self.num_blocks = num_blocks = num_segs - self.num_blocks = num_blocks = 100 - self.blocks_needed = blocks_needed = 25 + self.num_shares = num_shares = 100 + self.shares_needed = shares_needed = 25 - self.subblock_size = subblock_size = seg_size / blocks_needed - self.block_size = block_size = subblock_size * num_subblocks + self.block_size = block_size = seg_size / shares_needed + self.share_size = share_size = block_size * num_blocks - # none of this includes the block-level hash chain yet, since that is - # only a function of the number of blocks. All overhead numbers - # assume that the block-level hash chain has already been sent, - # including the root of the subblock-level hash tree. + # none of this includes the share-level hash chain yet, since that is + # only a function of the number of shares. All overhead numbers + # assume that the share-level hash chain has already been sent, + # including the root of the block-level hash tree. if mode == "alpha": # no hash tree at all - self.subblock_arity = 0 - self.subblock_tree_depth = 0 - self.subblock_overhead = 0 - self.bytes_until_some_data = 20 + block_size - self.block_storage_overhead = 0 - self.block_transmission_overhead = 0 + self.block_arity = 0 + self.block_tree_depth = 0 + self.block_overhead = 0 + self.bytes_until_some_data = 20 + share_size + self.share_storage_overhead = 0 + self.share_transmission_overhead = 0 elif mode == "beta": - # k=num_subblocks, d=1 - # each subblock has a 20-byte hash - self.subblock_arity = num_subblocks - self.subblock_tree_depth = 1 - self.subblock_overhead = 20 - # the block has a list of hashes, one for each subblock - self.block_storage_overhead = (self.subblock_overhead * - num_subblocks) - # we can get away with not sending the hash of the block that + # k=num_blocks, d=1 + # each block has a 20-byte hash + self.block_arity = num_blocks + self.block_tree_depth = 1 + self.block_overhead = 20 + # the share has a list of hashes, one for each block + self.share_storage_overhead = (self.block_overhead * + num_blocks) + # we can get away with not sending the hash of the share that # we're sending in full, once - self.block_transmission_overhead = self.block_storage_overhead - 20 + self.share_transmission_overhead = self.share_storage_overhead - 20 # we must get the whole list (so it can be validated) before # any data can be validated - self.bytes_until_some_data = (self.block_transmission_overhead + - subblock_size) + self.bytes_until_some_data = (self.share_transmission_overhead + + block_size) elif mode == "gamma": - self.subblock_arity = k = arity - d = math.ceil(math.log(num_subblocks, k)) - self.subblock_tree_depth = d + self.block_arity = k = arity + d = math.ceil(math.log(num_blocks, k)) + self.block_tree_depth = d num_leaves = k ** d # to make things easier, we make the pessimistic assumption that # we have to store hashes for all the empty places in the tree - # (when the number of blocks is not an exact exponent of k) - self.subblock_overhead = 20 - # the subblock hashes are organized into a k-ary tree, which + # (when the number of shares is not an exact exponent of k) + self.block_overhead = 20 + # the block hashes are organized into a k-ary tree, which # means storing (and eventually transmitting) more hashes. This - # count includes all the low-level block hashes and the root. + # count includes all the low-level share hashes and the root. hash_nodes = (num_leaves*k - 1) / (k - 1) #print "hash_depth", d #print "num_leaves", num_leaves #print "hash_nodes", hash_nodes # the storage overhead is this - self.block_storage_overhead = 20 * (hash_nodes - 1) + self.share_storage_overhead = 20 * (hash_nodes - 1) # the transmission overhead is smaller: if we actually transmit - # every subblock, we don't have to transmit 1/k of the - # lowest-level subblock hashes, and we don't have to transmit the - # root because it was already sent with the block-level hash tree - self.block_transmission_overhead = 20 * (hash_nodes + # every block, we don't have to transmit 1/k of the + # lowest-level block hashes, and we don't have to transmit the + # root because it was already sent with the share-level hash tree + self.share_transmission_overhead = 20 * (hash_nodes - 1 # the root - num_leaves / k) # we must get a full sibling hash chain before we can validate # any data sibling_length = d * (k-1) - self.bytes_until_some_data = 20 * sibling_length + subblock_size + self.bytes_until_some_data = 20 * sibling_length + block_size else: raise RuntimeError("unknown mode '%s" % mode) - self.storage_overhead = self.block_storage_overhead * num_blocks + self.storage_overhead = self.share_storage_overhead * num_shares self.storage_overhead_percentage = 100.0 * self.storage_overhead / file_size def dump(self): for k in ("mode", "file_size", "seg_size", - "num_segs", "num_subblocks", "num_blocks", "blocks_needed", - "subblock_size", "block_size", - "subblock_arity", "subblock_tree_depth", - "subblock_overhead", - "block_storage_overhead", "block_transmission_overhead", + "num_segs", "num_blocks", "num_shares", "shares_needed", + "block_size", "share_size", + "block_arity", "block_tree_depth", + "block_overhead", + "share_storage_overhead", "share_transmission_overhead", "storage_overhead", "storage_overhead_percentage", "bytes_until_some_data"): print k, getattr(self, k) @@ -164,7 +164,7 @@ def text(): # 0123456789012345678901234567890123456789012345678901234567890123456 print "mode=%s" % mode, " arity=%d" % arity print " storage storage" - print "Size blocksize overhead overhead k d alacrity" + print "Size sharesize overhead overhead k d alacrity" print " (bytes) (%)" print "------- ------- -------- -------- ---- -- --------" #sizes = [2 ** i for i in range(7, 41)] @@ -177,11 +177,11 @@ def text(): s = Sizes(mode, file_size, arity) out = "" out += "%7s " % fmt(file_size, trim=True) - out += "%7s " % fmt(s.block_size) + out += "%7s " % fmt(s.share_size) out += "%8s" % fmt(s.storage_overhead) out += "%10.2f " % s.storage_overhead_percentage - out += " %4d" % int(s.subblock_arity) - out += " %2d" % int(s.subblock_tree_depth) + out += " %4d" % int(s.block_arity) + out += " %2d" % int(s.block_tree_depth) out += " %8s" % fmt(s.bytes_until_some_data) print out