强扣教科书的字眼的话,nginx中的radix tree似乎更像bitwise trie。bitwise trie的性质不难理解:从key的二进制最高位起,按位区分左子树还是右子树数据只保存于叶节点因此:特定key的查找路径总是固定的树的高度等于key的位数nginx中默认的模块中,只有http/modules/ngx_http_geo_module.c用到了radix_tree。它可以依据ip的范围划定出地理区域。这里记一下nginx的实现中有趣的地方,为了与教科书上的Radix Tree区分,这里统称为radix_tree。Code Notesngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate)关于preallocation参数有一大段注释:/*
* Preallocation of first nodes : 0, 1, 00, 01, 10, 11, 000, 001, etc.
* increases TLB hits even if for first lookup iterations.
* On 32-bit platforms the 7 preallocated bits takes continuous 4K,
* 8 - 8K, 9 - 16K, etc. On 64-bit platf
...
继续阅读
(25)