<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">What is the reason to use different hash functions for these two cases? I mean if using SHA1 is faster than a noncryptic hash function with content comparison, why don't you always use SHA1?</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Tue, Dec 5, 2017 at 7:03 AM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>In the case of a LocallyHashedType, collision doesn’t matter at all because we fall back to a full record comparison when there is a collision.   This is the method that is used today.<br><br>In the PDB, we actually store CRC32s as hashes, which is even worse, but again it doesn’t matter because it’s just to get the bucket, probing will do a full equality check.  So collision is not even a theoretical problem for a LocallyHashedType.<br><br><div dir="auto">For a GloballyHashedType, the hash is intended to be “as good as” the record, so instead of a full equality comparison we only compare the full 20 bytes of SHA1 hash.  In this case, collision is a theoretical problem , but with probability O(10^-18) because a type stream can’t have more than 2^32 elements anyway </div></div><div class="HOEnZb"><div class="h5"><div><br><br><div class="gmail_quote"><div>On Mon, Dec 4, 2017 at 11:12 PM Rui Ueyama via Phabricator <<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ruiu added inline comments.<br>
<br>
<br>
================<br>
Comment at: llvm/include/llvm/DebugInfo/<wbr>CodeView/TypeHashing.h:29<br>
+struct LocallyHashedType {<br>
+  hash_code Hash;<br>
+  ArrayRef<uint8_t> RecordData;<br>
----------------<br>
Is this used when an object file doesn't have type record hash values?<br>
<br>
If you use 64-bit values as unique keys and want to maintain a probability of collision lower than 10^-9, for example, the maximum number of type records you can have is 190,000, according to [1]. Is this enough?<br>
<br>
<a href="https://en.wikipedia.org/wiki/Birthday_problem#Probability_table" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/<wbr>Birthday_problem#Probability_<wbr>table</a><br>
<br>
<br>
================<br>
Comment at: llvm/include/llvm/DebugInfo/<wbr>CodeView/TypeHashing.h:41<br>
+/// global hashes of the types that B refers to), a global hash can uniquely<br>
+/// identify identify that A occurs in another stream that has a completely<br>
+/// different graph structure.  Although the hash itself is slower to compute,<br>
----------------<br>
identify<br>
<br>
<br>
<a href="https://reviews.llvm.org/D40736" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D40736</a><br>
<br>
<br>
<br>
</blockquote></div></div>
</div></div></blockquote></div><br></div></div>