# Is this a bug?

**URL:** <https://www.ruby-forum.com/t/is-this-a-bug/222234>\
**Category:** NGINX\
**Created:** [August 18, 2012, 3:24pm UTC](https://www.ruby-forum.com/t/is-this-a-bug/222234 "2012-08-18T15:24:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [August 18, 2012, 3:24pm UTC](https://www.ruby-forum.com/t/is-this-a-bug/222234/1 "2012-08-18T15:24:07Z")

</div>

45: /\*  
46: \* Preallocation of first nodes : 0, 1, 00, 01, 10, 11, 000,  
001,  
etc.  
47: \* increases TLB hits even if for first lookup iterations.  
48: \* On 32-bit platforms the 7 preallocated bits takes continuous  
4K,  
49: \* 8 - 8K, 9 - 16K, etc. On 64-bit platforms the 6  
preallocated  
bits  
50: \* takes continuous 4K, 7 - 8K, 8 - 16K, etc. There is no  
sense to  
51: \* to preallocate more than one page, because further  
preallocation  
52: \* distributes the only bit per page. Instead, a random  
insertion  
53: \* may distribute several bits per page.  
54: \*  
55: \* Thus, by default we preallocate maximum  
56: \* 6 bits on amd64 (64-bit platform and 4K pages)  
57: \* 7 bits on i386 (32-bit platform and 4K pages)  
58: \* 7 bits on sparc64 in 64-bit mode (8K pages)  
59: \* 8 bits on sparc64 in 32-bit mode (8K pages)  
60: \*/  
61:  
62: if (preallocate == -1) {  
63: switch (ngx\_pagesize / sizeof(ngx\_radix\_tree\_t)) {  
//ngx\_radix\_tree\_t → ngx\_radix\_node\_t ?

Thanks in advance.

Posted at Nginx Forum:

> **[Is this a bug?](https://forum.nginx.org/read.php?2,229884,229884#msg-229884)**
>
> 45: /\* 46: \* Preallocation of first nodes : 0, 1, 00, 01, 10, 11, 000, 001, etc. 47: \* increases TLB hits even if for first lookup iterations. 48: \* On 32-bit platforms the 7 preallocated bits takes continuous 4K, 49: \* 8 - 8K, 9 - 16K, etc. On 64

---

<div class="post-metadata">

**Author:** ![lenky0401](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/977dab/32.png) [@lenky0401](https://www.ruby-forum.com/u/lenky0401)\
**Post date:** [August 19, 2012, 1:18am UTC](https://www.ruby-forum.com/t/is-this-a-bug/222234/2 "2012-08-19T01:18:52Z")

</div>

Hello!

On Sat, Aug 18, 2012 at 09:23:47AM -0400, lenky0401 wrote:

> 53: \* may distribute several bits per page.  
> //ngx\_radix\_tree\_t → ngx\_radix\_node\_t ?
> 
> Thanks in advance.

Sure. Thanks for spotting this, fix committed:

[http://trac.nginx.org/nginx/changeset/4824/nginx](http://trac.nginx.org/nginx/changeset/4824/nginx)

Maxim D.
