Re: [REVISED PATCH 2/6] Introduce commit notes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 19 Jul 2007, Olivier Galibert wrote:

> On Wed, Jul 18, 2007 at 08:28:27PM -0700, Linus Torvalds wrote:
> > And yes, the "search for zero bytes" is not *guaranteed* to find any 
> > beginning at all, if you have lots of short names, *and* lots of zero 
> > bytes in the SHA1's. But while short names may be common, zero bytes in 
> > SHA1's are not so much (since you should expect to see a very even 
> > distribution of bytes, and as such most SHA1's by far should have no zero 
> > bytes at all!)
> 
> The probability of a sha1 to have a zero is approximatively 0.075.
> That's 1 in 13, more or less.

Sure. And since we handle it fine even when it does happen, we don't care.

In fact, since we only need 20 non-zero bytes in between zeroes to know 
that it's ok, and since the ASCII part is already 7 bytes of "mode + 
space" plus <n> bytes of actual name (let's say that names average to be 
about 8 characters - which is low: in the kernel it seems to be about 10.5 
characters), we can say that the ASCII part of a tree tends to be about 15 
characters.

So in order to be unlucky, it's not enough for the previous SHA1 to have a 
NUL character in it, it actually has to be in the last five bytes of the 
SHA1 - so now we're talking something like a 1:50 chance.

And with longer names, it matters even less (to the point where it 
matters not at all if all filenames are >= 14 characters in length).

So we can be unlucky, but it's fairly rare, and when it happens, at worst 
we'll just need to scan to the next entry (and if we're *really* unlucky 
and it keeps happening until we scan until the end, we'll have to do the 
linear search).

The point being that you always get the right answer, and the likelihood 
that you have to do something slow to get that rigth answer is really 
really low.

		Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux