Mercurial > hg > nginx
comparison src/http/modules/ngx_http_limit_req_module.c @ 4419:7084faa7a4b4
Limit req: number of cleanup calls reduced.
Doing a cleanup before every lookup seems to be too aggressive. It can lead to
premature removal of the nodes still usable, which increases the amount of work
under a mutex lock and therefore decreases performance.
In order to improve cleanup behavior, cleanup function call has been moved right
before the allocation of a new node.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Mon, 30 Jan 2012 10:01:39 +0000 |
parents | aac79fc948cc |
children | 9ce48f9eb85b |
comparison
equal
deleted
inserted
replaced
4418:aac79fc948cc | 4419:7084faa7a4b4 |
---|---|
180 | 180 |
181 hash = ngx_crc32_short(vv->data, len); | 181 hash = ngx_crc32_short(vv->data, len); |
182 | 182 |
183 ngx_shmtx_lock(&ctx->shpool->mutex); | 183 ngx_shmtx_lock(&ctx->shpool->mutex); |
184 | 184 |
185 ngx_http_limit_req_expire(ctx, 1); | |
186 | |
187 rc = ngx_http_limit_req_lookup(lrcf, hash, vv->data, len, &excess); | 185 rc = ngx_http_limit_req_lookup(lrcf, hash, vv->data, len, &excess); |
188 | 186 |
189 ngx_shmtx_unlock(&ctx->shpool->mutex); | 187 ngx_shmtx_unlock(&ctx->shpool->mutex); |
190 | 188 |
191 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 189 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
383 | 381 |
384 size = offsetof(ngx_rbtree_node_t, color) | 382 size = offsetof(ngx_rbtree_node_t, color) |
385 + offsetof(ngx_http_limit_req_node_t, data) | 383 + offsetof(ngx_http_limit_req_node_t, data) |
386 + len; | 384 + len; |
387 | 385 |
386 ngx_http_limit_req_expire(ctx, 1); | |
387 | |
388 node = ngx_slab_alloc_locked(ctx->shpool, size); | 388 node = ngx_slab_alloc_locked(ctx->shpool, size); |
389 | 389 |
390 if (node == NULL) { | 390 if (node == NULL) { |
391 ngx_http_limit_req_expire(ctx, 0); | 391 ngx_http_limit_req_expire(ctx, 0); |
392 | 392 |