Use primes for hashtable size

Andrew Borodin borodin at
Sat Jun 3 06:00:44 UTC 2017

Hello world!

2017-06-02 16:46 GMT+05:00 Maxim Dounin <mdounin at>:
> Hello!
> On Fri, Jun 02, 2017 at 10:56:31AM +1000, Mathew Heard wrote:
>> If this actually yields a decrease in start time while not introducing
>> other effects we would use it. Our start time of a couple minutes is
>> annoying at times.
> Do you have any details of what contributes to the start time in
> your case?
> In general, nginx trades start time to faster operation once
> started, and trying to build minimal hash is an example of this
> practice.  If it results in unacceptable start times we certainly
> should optimize it, though I don't think I've seen such cases in
> my practice.
> Most time-consuming things during start I've seen so far are:
> - multiple DNS names in the configuration and slow system
>   resolver;
> - multiple SSL certificates;
> - very large geo{} maps.

Mathew could you plz make some profiling?
As I see it:
1. htop during nginx start, if you see spikes of CPU proceed to 2, else end;
2. perf top during nginx start, if you see ngx_hash_init proceed to 3,
else send here top slow functions
3. measure ngxinx start time with and without this patch

Maybe, we could crunch some of these 2 minutes of startup. Thank you for help.

Best regards, Andrey Borodin, Octonica.

More information about the nginx-devel mailing list