Use primes for hashtable size

Andrew Borodin borodin at
Tue May 30 10:28:03 UTC 2017

Hi, nginxers!

We often use hashtable sizes equal to the power of 2. This can be
damaging for a hashtable. I haven't found any mitigation for this in
nginx code. So I made my own. If this issue is addressed somewhere
just ignore my message. Or I'd be happy if someone will point me it.

For the explanation of problem see

Code is checked for correctness of ngx_hash_min_prime(), I haven't
done any regression testing, sorry.

Also beware that I've changed state of paremeter hinit. I'm not sure
this is acceptable.

Thank you for your attention.

Best regards, Andrey Borodin, Octonica.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: primes_for_hash.patch
Type: application/octet-stream
Size: 5777 bytes
Desc: not available
URL: <>

More information about the nginx-devel mailing list