Method for optimizing HASH lookup configuration

By using 4 indexes and table entry migration methods in HASH search configuration, the conflict problems caused by HASH algorithm are solved, and the RAM resource utilization and configuration efficiency are improved.

CN119906670APending Publication Date: 2025-04-29NANJING YITAI MICROELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411765117.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

The HASH algorithm maps the KEY value of the large bit width to the index of the lower bit width, resulting in conflicts. When splitting table entries through multi-value, there may still be cases where the cache space is not used and the table entries are not configured in.

Method used

By obtaining 4 indexes, reading the corresponding RAM table entries, checking the use value, and if not all are 1, write directly; if all are 1, transfer the KEY HASH algorithm and table entries to ensure that the storage location is found or the interrupt is reported.

Benefits of technology

Without adding RAM splitting, the probability of avoiding conflict in conflict scenarios is increased, the use of RAM resources is increased, and the configuration process is simplified.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119906670A_ABST
    Figure CN119906670A_ABST
Patent Text Reader

Abstract

The invention provides a method for optimizing HASH lookup configuration, which comprises the following steps of: S1, obtaining four indexes by a newly configured KEY through an algorithm module, then reading table entries of corresponding rams according to the indexes, if the contents stored in the table entries comprise {ures, keys and other}, directly writing keynew into the corresponding rams according to a sequence principle according to whether the ures in the four rams are all 1 or not and are not all 1, and executing the next step if all the ures in the four rams are all 1; and S2, storing the four keys read in the step S1 by using a register, carrying out process operation, and explaining by taking keyram0 as an example. According to the method for optimizing the HASH lookup configuration, the situation that addresses corresponding to four rams are all occupied according to a HASH algorithm configuration value in a certain KEY is improved by moving occupied table entries to available table entries, the probability of avoiding conflicts in a conflict scene is increased under the condition that ram splitting is not increased, and the probability of avoiding the conflicts in the conflict scene is increased. The use of RAM resources in some scenes is increased, and the configuration process is simple.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of message search, and in particular to a method for optimizing HASH search configuration. Background Art

[0002] Message lookup technology refers to extracting the characteristic information of the message to look up the table items to obtain routing information. Currently, there are two widely used methods: TCAM (Ternary Content Addressable Memory) and HASH. However, TCAM search is costly, power-hungry, and complex in routing updates. Therefore, the low-cost and low-power HASH search is more widely used.

[0003] The implementation mechanism of the HASH search algorithm is: extract the characteristic information of the message to form a KEY, obtain the address index of the lookup table through the HASH algorithm, and obtain the table item content according to the index. The original KEY is stored in the table item content. Only when the lookup KEY and the original KEY are the same is a real hit. Since the HASH algorithm uses the HASH algorithm to obtain a low-width index for the large-bit-width KEY value, conflicts are inevitable. In order to reduce conflicts, multiple values ​​can be obtained through the HASH algorithm. For example, the table item is split into 4 blocks, each block uses a different HASH algorithm or a different value-taking method of the same HASH algorithm. However, there is still a situation where there is cache space and the table item cannot be configured.

[0004] Therefore, it is necessary to provide a method for optimizing HASH search configuration to solve the above technical problems. Summary of the invention

[0005] The present invention provides a method for optimizing HASH search configuration, which solves the problem that conflicts will inevitably occur because the HASH algorithm uses a HASH algorithm to obtain a low-width index for a large-width KEY value. In order to reduce the conflicts, the method can obtain multiple values ​​through the HASH algorithm, such as splitting a table item into 4 blocks, each block using a different HASH algorithm or a different value-taking method of the same HASH algorithm. However, there is still a problem that there is cache space but the table item cannot be configured.

[0006] In order to solve the above technical problems, the present invention provides a method for optimizing HASH search configuration, comprising the following steps: S1: The newly configured KEY obtains 4 indexes through the algorithm module, and then reads the table items of the corresponding RAM according to the index. The contents stored in the table items include {use, key, other}. It is determined whether the use in the 4 RAM blocks is 1. If not, key_new is directly written into the corresponding RAM in order. If all are 1, the next step is executed. S2: The 4 keys read out in step S1 are stored in registers and the process operation is performed. Key_ram0 is used as an example for explanation. First, the key_ram0 is subjected to the HASH algorithm. Then, ram1-3 are read respectively according to the obtained index. The read table items are shown as dotted lines in the figure. Then, the use value in the table items is queried. If not all of them are 1, key_ram0 is stored in a ram whose use is not 1 in sequence. At the same time, key_new is stored in the position of ram0. If the use value in the query table items is 1, the operation process of key_ram1 is started and step S2 is executed. S3: When executing to key_ram3, the storage location is still not found, so an interrupt can only be reported to inform that this table entry is not configured due to conflict.

[0007] Preferably, the reading of the table entry of the corresponding RAM according to the index is embodied in the implementation in the RAM.

[0008] Preferably, the use represents the usage of the address, 1 represents use; key is the original key corresponding to the address, and other is other content.

[0009] Preferably, the key lookup is sent into a HASH algorithm to obtain four different HASH values, and the content in the table entry is obtained according to the HASH value to determine whether all four table entries are occupied.

[0010] Preferably, if at least one of the HASH values ​​is not occupied, it can be written into the free table entry according to the rules. If it is found that all four table entries are occupied, it is necessary to confirm whether there is available space for the four occupied KEYs to be moved.

[0011] Preferably, the method of confirming whether there is available space for moving the 4 occupied keys is to use 4 registers to cache the 4 keys, and then execute according to the RAM numbers corresponding to the 4 keys.

[0012] Preferably, when the method is executed according to the RAM numbers corresponding to the four keys, the first KEY executes the HASH algorithm and reads the other three table items according to the index.

[0013] Preferably, the first KEY executes the HASH algorithm, reads the other three table items according to the index, and if there is a vacant position, the first key is written into the vacant position, and the new configuration is written into the position of the original first KEY.

[0014] Preferably, the first KEY executes the HASH algorithm, reads the other three table items according to the index, and if there is no space, executes the second key again, and so on.

[0015] Preferably, the new configuration is a real conflict only when the other positions corresponding to the four keys are occupied.

[0016] Compared with the related art, the method for optimizing HASH search configuration provided by the present invention has the following beneficial effects: The present invention provides a method for optimizing HASH search configuration, which improves the situation that the addresses corresponding to four RAM blocks are all occupied according to the configuration value of a certain KEY according to the HASH algorithm by moving the occupied table items to the available table items. The method increases the probability of avoiding conflicts in conflict scenarios without increasing RAM splitting, increases the use of RAM resources in certain scenarios, and has a simple configuration process. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A flow chart of a method for optimizing HASH search configuration provided by the present invention; Figure 2 A flow chart of a method for optimizing HASH search configuration provided by the present invention executing a second key again. DETAILED DESCRIPTION

[0018] The present invention will be further described below in conjunction with the accompanying drawings and implementation modes.

[0019] Please refer to Figure 1 and Figure 2 ,in, Figure 1 A flow chart of a method for optimizing HASH search configuration provided by the present invention; Figure 2 A method for optimizing HASH search configuration provided by the present invention is a flowchart of executing the second key again. A method for optimizing HASH search configuration includes the following steps: S1: The newly configured KEY obtains 4 indexes through the algorithm module, and then reads the table items of the corresponding RAM according to the index. The contents stored in the table items include {use, key, other}. It is determined whether the use in the 4 RAM blocks is 1. If not, key_new is directly written into the corresponding RAM in order. If all are 1, the next step is executed. S2: The 4 keys read out in step S1 are stored in registers and the process operation is performed. Key_ram0 is used as an example for explanation. First, the key_ram0 is subjected to the HASH algorithm. Then, ram1-3 are read respectively according to the obtained index. The read table items are shown as dotted lines in the figure. Then, the use value in the table items is queried. If not all of them are 1, key_ram0 is stored in a ram whose use is not 1 in sequence. At the same time, key_new is stored in the position of ram0. If the use value in the query table items is 1, the operation process of key_ram1 is started and step S2 is executed. S3: When executing to key_ram3, the storage location is still not found, so an interrupt can only be reported to inform that this table entry is not configured due to conflict.

[0020] The table entry of the corresponding RAM is read according to the index and is implemented in the RAM.

[0021] The use represents the usage of the address, 1 represents use; key is the original key corresponding to the address, and other is other content.

[0022] The key search is sent to the HASH algorithm to obtain 4 different HASH values, and the content in the table entry is obtained according to the HASH value to determine whether all 4 table entries are occupied.

[0023] If at least one of the HASH values ​​is not occupied, it can be written into the free table entry according to the rules. If it is found that all four table entries are occupied, it is necessary to confirm whether there is available space for the four occupied keys to be moved.

[0024] The method of confirming whether there is available space for moving the 4 occupied keys is to use 4 registers to cache the 4 keys, and then execute according to the RAM numbers corresponding to the 4 keys.

[0025] When the above is executed according to the RAM numbers corresponding to the four keys, the first KEY executes the HASH algorithm and reads the other three table items according to the index.

[0026] The first KEY executes the HASH algorithm and reads the other three table items according to the index. If there is a vacant position, the first key is written into the vacant position, and the new configuration is written into the position of the original first KEY.

[0027] The first KEY executes the HASH algorithm and reads the other three table items according to the index. If there is no space, the second key is executed again, and so on.

[0028] When the other positions corresponding to the four keys are occupied, the new configuration is a real conflict.

[0029] Simplified description of the process: Read the newly configured KEY and obtain 4 indexes through the algorithm module; Read the table entry in the corresponding RAM according to the index; Check whether the use in the table entries is 1; If not all are 1, key_new is directly written into the corresponding RAM in order; If both are 1, proceed to the next step; The 4 keys read out are stored in registers and process operations are performed; Taking key_ram0 as an example, first perform the HASH algorithm on key_ram0; Read ram1-3 respectively according to the obtained index, and the read table entries are shown as dotted lines in the figure; Query the value of use in the table entry; If they are not all 1, key_ram0 is stored in a ram where use is not 1 in order, and key_new is stored in the location of ram0; If both are 1, start the key_ram1 operation process and repeat the above steps; If the key_ram3 is executed and the storage location is still not found, an interrupt is reported to inform that this table entry is not configured due to conflict.

[0030] To read the corresponding random access memory (RAM) table entry according to the index, the following steps can be used: Determine the storage structure of table entries: Understand how table entries are organized and stored in RAM, including the fields and layout of each entry.

[0031] Calculate the address of the table entry: Based on the index value and the storage structure of the table entry, calculate the address of the table entry to be read in RAM, which involves performing some operation on the index and the offset or index of the table entry.

[0032] Issue a read request: Using the appropriate hardware interface or instruction, send a read request to the RAM and specify the address to be read.

[0033] Receive table entry data: RAM will return the table entry data at the specified address.

[0034] Parse and use table item data: Parse the read data according to the fields and layout of the table item, and further process or use it as needed.

[0035] The specific implementation method will vary depending on the hardware platform, programming language, and RAM characteristics. In actual programming, you may need to use specific hardware registers, memory access instructions, or library functions to complete these steps.

[0036] In addition, boundary conditions and error handling need to be considered, such as index out-of-bounds or RAM access failure. During design and implementation, relevant hardware and programming specifications should be followed, and sufficient testing and debugging should be performed to ensure that table entry data is read correctly.

[0037] The working principle of a method for optimizing HASH search configuration provided by the present invention is as follows: When working, first the newly configured KEY is passed through the algorithm module to obtain 4 indexes, and then the corresponding RAM table entry is read according to the index ( Figure 1 ram), the contents stored in the table item include {use, key, other} (use represents whether the address is used, 1 represents use; key is the original key corresponding to the address, other is other content, which is not used in the present invention), according to whether the use in the four rams is 1, if not all are 1, then directly write key_new into the corresponding ram according to the sequential principle, if all are 1, then execute the next step; The 4 keys read out are stored in registers and process operations are performed, as shown in the attached figure. Figure 2 As shown, take key_ram0 as an example, first perform the HASH algorithm on key_ram0, and then read ram1-3 respectively according to the obtained index. The read table items are shown as dotted lines in the figure, and then query the value of use in the table items. If they are not all 1, key_ram0 is stored in a ram where use is not 1 in sequence, and key_new is stored in the position of ram0. If they are all 1, start the operation process of key_ram1 and execute the above steps again; If the execution reaches key_ram3 and the storage location is still not found, the only option is to report an interrupt to inform that this entry is not configured due to a conflict.

[0038] The newly configured KEY obtains 4 indexes through the algorithm module, and then reads the table items of the corresponding RAM according to the index. The contents stored in the table items include {use, key, other}. It is determined whether the uses in the 4 RAM blocks are all 1. If not, key_new is directly written into the corresponding RAM in sequence. If all are 1, the next step is executed.

[0039] In this description, it is mentioned that the newly configured KEY obtains 4 indexes through the algorithm module, and then reads the corresponding RAM table items based on these indexes. The table items contain {use, key, other}, etc. If the use in the 4 RAM blocks is not all 1, key_new is written to the corresponding RAM in order; if they are all 1, the next step is executed. This involves the concept of index and related data operations and conditional judgments.

[0040] Is there any other information in the ram table besides {use, key, other}? In the background information provided, it is only clearly mentioned that the memory table entry contains content such as {use, key, other}, but no specific information is specified as to what other exact information is included.

[0041] What exactly is the principle of order? According to the background information, if the use in the four RAM blocks is not all 1, key_new will be written to the corresponding RAM in order.

[0042] If both are 1, what is the next step? The background information does not clearly mention what the next step is if the use of all four RAM blocks is 1. It only states that if all are 1, the next step is executed.

[0043] What are the possible values ​​for use? According to the background information, if the use values ​​in the four RAM blocks are not all 1, key_new will be written to the corresponding RAM in order; if they are all 1, the next step will be executed. Therefore, the use values ​​in the corresponding RAM may have the following situations: First, the use values ​​in the four RAM blocks are not all 1, that is, some are 1 and some are not 1; second, the use values ​​in the four RAM blocks are all 1. At the same time, the background information also mentions that the table items contain {use, key, other}, which also implies that the use value may have multiple specific numerical situations. In addition, this involves the algorithm module and related data operations and conditional judgments.

[0044] How do different use values ​​affect operation? If the use values ​​in the four RAM blocks are not all 1, key_new will be written to the corresponding RAM in order; if they are all 1, the next step will be executed. Different use values ​​determine whether to perform a write operation and the direction of the subsequent process. This reflects the judgment and corresponding processing of data operation conditions to ensure the correct storage of data and the reasonable advancement of the operation process.

[0045] What is the role of an index? The specific role of indexes includes fast data search, just like the catalog of a book can quickly locate the required information to speed up query and retrieval operations. It can also optimize sorting and grouping, speed up table connections, and improve data integrity. In large databases, indexing frequently queried columns or tables can greatly improve query efficiency. Indexes are usually implemented using B-trees and their variants, B+ trees. The database system maintains data structures for specific search algorithms and references (points to) data in some way, so that relevant data can be quickly located on these data structures. In the new configuration, the four indexes obtained through the algorithm module can be used to quickly locate the corresponding RAM table items to achieve efficient data operations.

[0046] Compared with the related art, the method for optimizing HASH search configuration provided by the present invention has the following beneficial effects: The present invention provides a method for optimizing HASH search configuration, which improves the situation that the addresses corresponding to four RAM blocks are all occupied according to the configuration value of a certain KEY according to the HASH algorithm by moving the occupied table items to the available table items. The method increases the probability of avoiding conflicts in conflict scenarios without increasing RAM splitting, increases the use of RAM resources in certain scenarios, and has a simple configuration process.

[0047] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for optimizing HASH search configuration, characterized in that: The following steps are involved: S1: The newly configured KEY obtains 4 indexes through the algorithm module, and then reads the table items of the corresponding RAM according to the index. The contents stored in the table items include {use, key, other}. It is determined whether the use in the 4 RAM blocks is 1. If not, key_new is directly written into the corresponding RAM in order. If all are 1, the next step is executed. S2: The 4 keys read out in step S1 are stored in registers and the process operation is performed. Key_ram0 is used as an example for explanation. First, the key_ram0 is subjected to the HASH algorithm. Then, ram1-3 are read respectively according to the obtained index. The read table items are shown as dotted lines in the figure. Then, the use value in the table items is queried. If not all of them are 1, key_ram0 is stored in a ram whose use is not 1 in sequence. At the same time, key_new is stored in the position of ram0. If the use value in the query table items is 1, the operation process of key_ram1 is started and step S2 is executed. S3: When executing to key_ram3, the storage location is still not found, so an interrupt can only be reported to inform that this table entry is not configured due to conflict.

2. A method for optimizing HASH search configuration according to claim 1, characterized in that: The table entry of the corresponding RAM is read according to the index and is implemented in the RAM.

3. A method for optimizing HASH search configuration according to claim 1, characterized in that: The use represents the usage of the address, 1 represents use; key is the original key corresponding to the address, and other is other content.

4. A method for optimizing HASH search configuration according to claim 1, characterized in that: The key search is sent to the HASH algorithm to obtain 4 different HASH values, and the content in the table entry is obtained according to the HASH value to determine whether all 4 table entries are occupied.

5. A method for optimizing HASH search configuration according to claim 4, characterized in that: If at least one of the HASH values ​​is not occupied, it can be written into the free table entry according to the rules. If it is found that all four table entries are occupied, it is necessary to confirm whether there is available space for the four occupied keys to be moved.

6. A method for optimizing HASH search configuration according to claim 5, characterized in that: The method of confirming whether there is available space for moving the 4 occupied keys is to use 4 registers to cache the 4 keys, and then execute according to the RAM numbers corresponding to the 4 keys.

7. A method for optimizing HASH search configuration according to claim 6, characterized in that: When the above is executed according to the RAM numbers corresponding to the four keys, the first KEY executes the HASH algorithm and reads the other three table items according to the index.

8. A method for optimizing HASH search configuration according to claim 7, characterized in that: The first KEY executes the HASH algorithm and reads the other three table items according to the index. If there is a vacant position, the first key is written into the vacant position, and the new configuration is written into the position of the original first KEY.

9. A method for optimizing HASH search configuration according to claim 7, characterized in that: The first KEY executes the HASH algorithm and reads the other three table items according to the index. If there is no space, the second key is executed again, and so on.

10. A method for optimizing HASH search configuration according to claim 6, characterized in that: When the other positions corresponding to the four keys are occupied, the new configuration is a real conflict.