Use primes for hashtable size
Andrew Borodin
borodin at octonica.com
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
https://stackoverflow.com/questions/3980117/hash-table-why-size-should-be-prime
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: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20170530/a8d7dc28/attachment.obj>
More information about the nginx-devel
mailing list