On 12/24/2015 07:48 PM, Alex Peshkoff wrote:
> On 12/24/2015 04:19 PM, Dimitry Sibiryakov wrote:
>> Hello, All.
>>
>>    I played a little with hash calculation code from lock manager and
>> found that there is a room for improvement.
>>    Attached test program compiled by GCC 4.7.1 with switches "-O3
>> -msse4.2" shown that simple unroll of the loop makes it 2-3 times
>> faster. Current code is even slower than CPU-accelerated CRC32.
>>    Comments?
> Use of CPU-accelerated code appears suspicious from non-intel ports POV.
> What about unrolled loop - I like it.

BTW, please try it in such form:

        int hash_value = 0;
         { // scope
             char* p;
             const char* q = value;
             int l = length;
             while (l >= 4)
             {
                 p = (char*) &hash_value;
                 *p++ += *q++;
                 *p++ += *q++;
                 *p++ += *q++;
                 *p++ += *q++;
                 l -= 4;
             }
             p = (char*) &hash_value;
             if (l >= 2)
             {
                 *p++ += *q++;
                 *p++ += *q++;
                 l -= 2;
             }
             if (l)
             {
                 *p++ += *q++;
             }
         } // scope

For me (AMD CPU) it behaves much better for length in 11,15,19,etc.



------------------------------------------------------------------------------
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to