[PATCH] Optimized murmurhash performance

Ruslan Ermilov ru at nginx.com
Sat Feb 3 13:29:45 UTC 2018


On Fri, Feb 02, 2018 at 11:10:57AM -0800, Matthew Marangoni wrote:
> # HG changeset patch
> # User Matthew Marangoni <matthew.marangoni at gmail.com>
> # Date 1516655725 28800
> #      Mon Jan 22 13:15:25 2018 -0800
> # Node ID e84b174c99ca39155e80dbb7458181e20190b70b
> # Parent  cbf59d483c9cd94dc0fb05f1978601d02af69c20
> Optimized murmurhash performance.
> 
> Improved performance for little endian machines.
> 
> diff -r cbf59d483c9c -r e84b174c99ca src/core/ngx_murmurhash.c
> --- a/src/core/ngx_murmurhash.c	Tue Jan 16 13:52:03 2018 +0300
> +++ b/src/core/ngx_murmurhash.c	Mon Jan 22 13:15:25 2018 -0800
> @@ -16,10 +16,14 @@
>      h = 0 ^ len;
>  
>      while (len >= 4) {
> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__

Please use NGX_HAVE_LITTLE_ENDIAN instead.

> +        k = *(u_int32_t*)data;

Please use uint32_t instead.

> +#else
>          k  = data[0];
>          k |= data[1] << 8;
>          k |= data[2] << 16;
>          k |= data[3] << 24;
> +#endif
>  
>          k *= 0x5bd1e995;
>          k ^= k >> 24;
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
> 

-- 
Ruslan Ermilov
Assume stupidity not malice


More information about the nginx-devel mailing list