Re: WARNING! Object DB conversion (was Re: [PATCH] write-tree performance problems)
- From
C. Scott Ananian <cscott@cscott.net>
- Date
- Apr 20, 2005, 15:28 UTC
- Message-ID
- <Pine.LNX.4.61.0504201121490.2630@cag.csail.mit.edu>
- In-Reply-To
- <20050420151902.GA13175@macavity>
On Wed, 20 Apr 2005, Martin Uecker wrote:
Show 14 quoted lines
>> You can (and my code demonstrates/will demonstrate) still use a whole-file >> hash to use chunking. With content prefixes, this takes O(N ln M) time >> (where N is the file size and M is the number of chunks) to compute all >> hashes; if subtrees can share the same prefix, then you can do this in >> O(N) time (ie, as fast as possible, modulo a constant factor, which is >> '2'). You don't *need* internal hashing functions. > > I don't understand this paragraph. What is an internal > hash function? Your code seems to do exactly what I want. > The hashes are computed recusively as in a hash tree > with O(N ln N). The only difference between your design > and a design based on a conventional (binary) hash tree > seems to be that data is stored in the intermediate nodes > too.
A merkle-tree (which I think you initially pointed me at) makes the hash of the internal nodes be a hash of the chunk's hashes; ie not a straight content hash. This is roughly what my current implementation does, but I would like to identify each subtree with the hash of the *(expanded) contents of that subtree* (ie no explicit reference to subtree hashes). This makes it interoperable with non-chunked or differently-chunked representations, in that the top-level hash is *just the hash of the complete content*, not some hash-of-subtree-hashes. Does that make more sense?
The code I posted doesn't demonstrate this very well, but now that Linus has abandoned the 'hash of compressed content' stuff, my next code posting should show this more clearly.
Show 5 quoted lines
> If I don't miss anything essential, you can validate > each treap piece at the moment you get it from the > network with its SHA1 hash and then proceed with > downloading the prefix and suffix tree (in parallel > if you have more than one peer a la bittorrent).
Yes, I guess this is the detail I was going to abandon. =)
I viewed the fact that the top-level hash was dependent on the exact chunk makeup a 'misfeature', because it doesn't allow easy interoperability with existing non-chunked repos. --scott
WTO atomic operation Mossad Castro overthrow FSF fissionable HTAUTOMAT
LCPANES MKDELTA Bush non-violent protest OVER THE HORIZON RADAR KUPALM
( http://cscott.net/ )