Multi-level hash application in the kernel: application of the variant Radix tree in the page Cache

Source: Internet
Author: User
Refer:
Radix tree in kernel: trees I: Radix trees
Http://lwn.net/articles/175432/ordinary Radix tree (note: this is not the radix tree used in the kernel)
Http://en.wikipedia.org/wiki/Radix_tree

The variant Radix tree is discussed here. Please note.
What is the core idea of Radix tree?The radix tree used in the kernel is not a strict Radix tree, but a variant Radix tree. essentially multi-level hash. the Linux kernel uses the radix tree to organize the page cache so that you can quickly find whether an address is in the page cache. the hash conflict processing policy is Zipper.
The hash key is an integer value (address), and the value is a pointer. It is a multi-level hash_map. The implementation of multi-level hash is that the first few digits of the integer value (1 ~ 6 bit) used for hash, the number of digits in the middle (7 ~ 12) used for second-level hash. The next few digits (13 ~ 18) as hash is used for level-3 hash, the search speed is extremely fast. Because the tree height is only three layers, you only need to perform three searches (without considering hash conflicts ).
Why use multi-level hash? Instead of common hash?If hash is used, the length of the hash algorithm in the kernel is fixed at the beginning. if it is set to an excessively small value, when the page cache becomes larger, there will be many conflicts. if the setting is too large, it is a waste of time when the page cache is very small! Therefore, the kernel uses multi-level hash. the benefits of multi-level hash are that the storage efficiency is extremely high in the face of sparse page cache, so there is no waste of space. because most of the child nodes are empty, that is, there is no child branch. for example, if there is only one page in the page cache, the radix tree only needs three internal nodes. The first layer has one node: root, and the second layer has only one node, the third layer has only one node !! Such as a radix tree of the running kernel.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.