<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 25, 2014 at 1:59 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":8xl" class="a3s" style="overflow:hidden">  2. Grab the upper 64 bits of MD5.<br></div></blockquote></div><br>
</div><div class="gmail_extra">How about this.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Pack the bits of the enum into a 64-bit integer. When we fill the integer, spin up an MD5 context, and shove the integer through it, rinse, repeat. When done, if you have an MD5, take the upper 64-bits. If not, just take the integer.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">This should incur no cost for the most common case (only a few CFG elements) and no collisions roughly ever, and scale nicely due to using 64-bit chunks.</div><div class="gmail_extra">
<br></div><div class="gmail_extra">s/MD5/any other stable hashing function really/ -- my hope is that after doing this, the performance of the case where all the CFG elements didn't just serialize is relatively unimportant.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Then, benchmark it, and if MD5 is a problem, revisit it with faster and/or lower overhead algorithms which still have well known and fixed results such as MD4, blake2, etc.</div>
</div>