This definitely sounds impressive, but, FMI:<br><br><div><span class="gmail_quote">On 11/28/06, <b class="gmail_sendername">Andrei Pelinescu-Onciul</b> &lt;<a href="mailto:andrei@iptel.org">andrei@iptel.org</a>&gt; wrote:</span>
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Why would you want to change the hash size from the config? Do you<br>really know somebody who wanted/needed to do this? If you use a variable
<br>for the hash size the compiler will not be able to optimize the modulo<br>operation (x % hash_size) and it will have to implement it using slow<br>DIVs. Using a 2^k constant the whole modulo operation will be optimized
<br>to&nbsp;&nbsp;&amp; (2^k - 1). A DIV takes minimum 56 cycles on a P4 and 16 on an<br>AMD64 (and this if the operands are in _registers_ which will probably<br>not happen for the variable containing the hash size). An&nbsp;&nbsp;&quot;and&quot; takes
<br>only 1 cycle (and the operand is an immediate constant).<br>Look also at the rest of the hash function: it uses only XORs, shifts<br>and additions, operations that all execute in 1 cycle =&gt; for normal small<br> uris your DIV operation will take a very significant time from the
<br> total ammount spent hashing.</blockquote><div><br>Unfortunately Daniel didn't reply anymore (maybe he wants to cover trade secrets ;-) ), but OpenSER uses now the much faster masking operation instead of the always costly modulo (which I expect to execute faster even with the cost of extra memory fetch for the hash size). I don't know whether hashing is also cheap or the result has a good distribution, but this should be something you should look at: I expect he did some research too, before changing, maybe this is a fix worth porting.
<br><br>WL.<br></div></div>