diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-02-16 13:40:36 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-02-16 13:40:36 +0000 |
commit | 1ebfead9da0596e8e84231f7ea8ba25a650a4d1e (patch) | |
tree | 15e18d104477e04ffb5fcb31b3fb43f20dcfe996 /src/core/ngx_radix_tree.c | |
parent | 675cc5a855cec4acaae2937cb832c424e4d3bacf (diff) | |
download | nginx-release-0.1.19.tar.gz nginx-release-0.1.19.zip |
nginx-0.1.19-RELEASE importrelease-0.1.19
*) Bugfix: now, if request contains the zero, then the 404 error is
returned for the local requests.
*) Bugfix: nginx could not be built on NetBSD 2.0.
*) Bugfix: the timeout may occur while reading of the the client
request body via SSL connections.
Diffstat (limited to 'src/core/ngx_radix_tree.c')
-rw-r--r-- | src/core/ngx_radix_tree.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/core/ngx_radix_tree.c b/src/core/ngx_radix_tree.c index e0ce095b0..fa056afe3 100644 --- a/src/core/ngx_radix_tree.c +++ b/src/core/ngx_radix_tree.c @@ -12,7 +12,7 @@ static void *ngx_radix_alloc(ngx_radix_tree_t *tree); ngx_radix_tree_t * -ngx_radix_tree_create(ngx_pool_t *pool, ngx_uint_t preallocate) +ngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate) { uint32_t key, mask, inc; ngx_radix_tree_t *tree; @@ -35,13 +35,46 @@ ngx_radix_tree_create(ngx_pool_t *pool, ngx_uint_t preallocate) tree->root->parent = NULL; tree->root->value = NGX_RADIX_NO_VALUE; + if (preallocate == 0) { + return tree; + } + /* * We preallocate the first nodes: 0, 1, 00, 01, 10, 11, 000, 001, etc., * to increase the TLB hits even if for the first lookup iterations. * On the 32-bit platforms the 7 preallocated bits takes continuous 4K, - * 8 - 8K, 9 - 16K, etc. + * 8 - 8K, 9 - 16K, etc. On the 64-bit platforms the 6 preallocated bits + * takes continuous 4K, 7 - 8K, 8 - 16K, etc. There is no sense to + * to preallocate more than one page, because further preallocation + * distribute the only bit per page. Instead, the random insertion + * may distribute several bits per page. + * + * Thus, by default we preallocate maximum + * 6 bits on amd64 (64-bit platform and 4K pages) + * 7 bits on i386 (32-bit platform and 4K pages) + * 7 bits on sparc64 in 64-bit mode (8K pages) + * 8 bits on sparc64 in 32-bit mode (8K pages) */ + if (preallocate == -1) { + switch (ngx_pagesize / sizeof(ngx_radix_tree_t)) { + + /* amd64 */ + case 128: + preallocate = 6; + break; + + /* i386, sparc64 */ + case 256: + preallocate = 7; + break; + + /* sparc64 in 32-bit mode */ + default: + preallocate = 8; + } + } + mask = 0; inc = 0x80000000; |