Use primes for hashtable size

Andrew Borodin borodin at octonica.com
Thu Jun 1 17:57:09 UTC 2017


2017-06-01 22:39 GMT+05:00 Maxim Dounin <mdounin at mdounin.ru>:
> Thanks, though suggested change will certainly modify current
> nginx (documented) approach of searching for minimum possible
> hash sizes.
>
> It might be a better solution for large hashes though, as
> currently optimized by using a larger start size:
>
>     if (hinit->max_size > 10000 && nelts && hinit->max_size / nelts < 100) {
>         start = hinit->max_size - 1000;
>     }

Yeah, maybe put the primes loop under if.

> Not sure it is at all needed though, as I don't remember any
> "words about startup speed" in the documentation and startup
> speed of hashes wasn't a practical problem as far as I remember.


Here  https://nginx.ru/en/docs/http/server_names.html
"if nginx’s start time is unacceptably long, try to increase
server_names_hash_bucket_size" It's about allowing more hash
collisions.
But I do not insist, though :) I've done the patch jut for fun

Best regards, Andrey Borodin, Octonica.


More information about the nginx-devel mailing list