cubicdaiya / ngx_small_light

Dynamic Image Transformation Module For nginx.
Other
472 stars 80 forks source link

What's going on in `small_light_init_params` #65

Closed takano32 closed 8 years ago

takano32 commented 8 years ago

I got this message.

2016/08/12 19:12:56 [emerg] 13477#0: *134 could not build the small_light_init_params, you should increase either small_light_init_params_max_size: 128 or small_light_init_params_bucket_size: 32 while reading response header from upstream, client: 192.168.15.101, server: dev01.as, request: "GET /small_light(dw=660,da=l,q=50,e=imagemagick,jpeghint=y)/auction-image/b2735155-66e8-4a0c-bd8f-18f3854be511/1.jpg HTTP/1.0", upstream: "http://x.y.z.w:80/stock-auction-photo-dev/b2735155-66e8-4a0c-bd8f-18f3854be511/1.jpg", host: "dev01.as"

But these parameters are not able to set in nginx.conf. And src/ngx_http_small_light_module.c has these parameter.

I can't understand this error message. What does this mean?

cubicdaiya commented 8 years ago

The message above indicates that the bucket size of the hash table of the name of small_light_init_params is not enough.

https://github.com/cubicdaiya/ngx_small_light/blob/master/src/ngx_http_small_light_module.c#L266

The bucket size of this hash table is assigned to ngx_cacheline_size. The value of this variable is environment-dependent. Would you like to try the patch below?

diff --git a/src/ngx_http_small_light_module.c b/src/ngx_http_small_light_module.c
index 6c03fa1..b5b7809 100644
--- a/src/ngx_http_small_light_module.c
+++ b/src/ngx_http_small_light_module.c
@@ -263,7 +263,7 @@ static ngx_int_t ngx_http_small_light_header_filter(ngx_http_request_t *r)
     hash_init.hash        = &ctx->hash;
     hash_init.key         = ngx_hash_key_lc;
     hash_init.max_size    = 128;
-    hash_init.bucket_size = ngx_cacheline_size;
+    hash_init.bucket_size = 128;
     hash_init.name        = "small_light_init_params";
     hash_init.pool        = ctx->params.keys.pool;
     hash_init.temp_pool   = NULL;

And tell me about your environment such as OS and CPU architecture (e.g. amd64, i386).

takano32 commented 8 years ago

Thanks!

I'll try above fix. In advance, my Nginx machine environment is these.

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : QEMU Virtual CPU version 2.0.0
stepping        : 3
microcode       : 0x1
cpu MHz         : 3392.292
cache size      : 4096 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 4
wp              : yes
flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good n
opl pni vmx cx16 x2apic popcnt hypervisor lahf_lm tpr_shadow vnmi flexpriority ept vpid
bugs            :
bogomips        : 6784.58
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : QEMU Virtual CPU version 2.0.0
stepping        : 3
microcode       : 0x1
cpu MHz         : 3392.292
cache size      : 4096 KB
physical id     : 1
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 4
wp              : yes
flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good n
opl pni vmx cx16 x2apic popcnt hypervisor lahf_lm tpr_shadow vnmi flexpriority ept vpid
bugs            :
bogomips        : 6784.58
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

and uname -a outputs Linux dev01 4.4.0-34-generic #53~14.04.1-Ubuntu SMP Wed Jul 27 16:56:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux.

takano32 commented 8 years ago

Thank you. This patch well it works!