Hash chain table tuning method and device, storage medium and electronic equipment
By combining multi-dimensional analysis of loading factors, conflict equalization values and longest conflict chain length in the hash linked list, the problem of relying solely on loading factors in the existing technology cannot be accurately tuned, and more accurate hash linked list performance tuning is achieved.
Patent Information
- Application Number
- CN202510115646.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-23
- Publication Date
- 2025-05-27
AI Technical Summary
The prior art only relies on loading factors when analyzing the performance of hash linked lists, and cannot accurately reflect the overall performance status of the hash linked list, and thus cannot accurately tune.
By receiving performance analysis instructions, the loading factor, conflict equalization value and maximum conflict chain length of the hash linked list are determined, and the adjustment is performed based on these parameters, including capacity reduction, capacity expansion and hash function adjustment.
Through multi-dimensional performance analysis, the performance status of the hash linked list can be more comprehensively reflected, thereby achieving more accurate tuning and improving the overall performance of the hash linked list.
Smart Images

Figure CN120045561A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a method, device, storage medium, and electronic device for tuning a hash list. Background Art
[0002] A hash list is a data structure that combines the characteristics of hash functions, arrays, and linked lists. It has a wide range of applications in programming, and is often applied to computational problems such as data duplication detection, set operations, and task allocation. Among many data structures, hash lists offer efficient data retrieval and insertion. Specifically, they are often used in log processing, policy additions and deletions, and load balancing, enabling fast data access and balanced resource scheduling.
[0003] Hash linked lists achieve fast data access by mapping data items to a fixed-size array. Since the array size is fixed, the input data in actual applications is often larger than the number of array elements, so there will definitely be multiple data items mapped to the same array position. This phenomenon is called hash conflict. Chain address method is a common method to resolve hash conflicts, such as Figure 1 shown.
[0004] Figure 1 This is a schematic diagram of a hash list provided in this manual.
[0005] from Figure 1 As can be seen, the input data can be mapped to an array index after the calculation of the hash function. If multiple data are mapped to the same array index, a hash conflict will occur. The conflicting data will be mounted behind the array with the same index in the form of a linked list node (this chain is the conflict chain), forming a hash bucket. For example, Figure 1 There are 8 hash buckets in total. Figure 1 The data structure that combines hash function, array and linked list is called hash linked list.
[0006] Existing techniques optimize hash tables based on the load factor. The load factor is a key metric for measuring hash table performance and is defined as the ratio of the number of used hash buckets to the total number of hash buckets in the table. Traditionally, the load factor is used to determine whether the hash table needs to be expanded or to adjust the hash function associated with the hash table.
[0007] However, the performance analysis of the hash list based only on the load factor is not accurate enough, and thus it is impossible to accurately tune the hash list.
[0008] Based on this, how to improve the accuracy of analyzing the performance of hash lists so as to make precise adjustments to the hash lists is an urgent problem to be solved. Summary of the Invention
[0009] This specification provides a hash table tuning method, device, storage medium and electronic device to partially solve the above-mentioned problems existing in the prior art.
[0010] This manual adopts the following technical solutions:
[0011] This manual provides a method for tuning a hash table, including:
[0012] Receive a performance analysis instruction for a hash list;
[0013] Determining, according to the performance analysis instruction, a load factor, a conflict balance value, and a longest conflict chain length of the hash chain table; the load factor is used to represent the ratio of the number of used hash buckets to the total number of hash buckets in the hash chain table, the conflict balance value is used to represent the distribution of conflicting data in the hash chain table, and the longest conflict chain length is used to represent the length of the longest conflict chain in the hash chain table;
[0014] The hash chain table is tuned according to the load factor, the conflict balance value and the longest conflict chain length.
[0015] Optionally, the hash chain table is tuned according to the load factor, the conflict balance value, and the longest conflict chain length, specifically including:
[0016] Determining performance information of the hash table according to the load factor, the conflict balance value, and the longest conflict chain length;
[0017] The hash chain table is tuned according to the performance information.
[0018] Optionally, the performance information includes loading status information, balancing status information, and conflict chain length status information;
[0019] Determining performance information of the hash table according to the load factor, the conflict balance value, and the longest conflict chain length, specifically including:
[0020] The loading status information is determined according to the loading factor, the preset first loading threshold and the preset second loading threshold; the balance status information is determined according to the conflict balance value and the preset balance threshold; and the conflict chain length status information is determined according to the longest conflict chain length, the total number of hash buckets of the hash chain table and the preset length threshold.
[0021] Optionally, the hash chain table is tuned according to the load factor, the conflict balance value, and the longest conflict chain length, specifically including:
[0022] If it is determined that the load factor is less than a preset first load threshold and the conflict balance value is less than a preset balance threshold, a capacity reduction adjustment instruction is executed to tune the hash table, where the capacity reduction adjustment instruction is used to reduce the capacity of the hash table.
[0023] Optionally, the hash chain table is tuned according to the load factor, the conflict balance value, and the longest conflict chain length, specifically including:
[0024] If it is determined that the loading factor is not less than a preset first loading threshold and the conflict balance value is not less than a preset balance threshold, determining whether the loading factor is greater than a preset second loading threshold;
[0025] If so, execute a capacity expansion adjustment instruction to optimize the hash list, where the capacity expansion adjustment instruction is used to expand the capacity of the hash list.
[0026] Optionally, the hash chain table is tuned according to the load factor, the conflict balance value, and the longest conflict chain length, specifically including:
[0027] If it is determined that the loading factor is less than a preset first loading threshold and the conflict balance value is not less than a preset balance threshold, or if it is determined that the loading factor is within a preset threshold interval and the conflict balance value is not less than a preset balance threshold, or if it is determined that the loading factor is within the preset threshold interval and the conflict chain length ratio is not less than a preset length threshold, a hash function adjustment instruction is executed to tune the hash chain table; the hash function adjustment instruction is used to adjust the hash function of the hash chain table; the preset threshold interval is determined based on the first loading threshold and the preset second loading threshold; the conflict chain length ratio is used to characterize the ratio relationship between the longest conflict chain length and the total number of hash buckets of the hash chain table.
[0028] Optionally, the method further includes:
[0029] After completing the tuning process of the hash chain table, performing a performance analysis on the hash chain table to determine feedback information;
[0030] The hash chain table is tuned according to the feedback information.
[0031] This specification provides a hash table tuning device, including:
[0032] A receiving module, configured to receive a performance analysis instruction for a hash list;
[0033] a determination module, configured to determine, according to the performance analysis instruction, a load factor, a conflict balance value, and a longest conflict chain length of the hash chain table; the load factor being used to represent a ratio of the number of used hash buckets to the total number of hash buckets in the hash chain table, the conflict balance value being used to represent a distribution of conflicting data in the hash chain table, and the longest conflict chain length being used to represent a length of the longest conflict chain in the hash chain table;
[0034] A tuning module is used to tune the hash chain table according to the loading factor, the conflict balance value and the longest conflict chain length.
[0035] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned hash table tuning method.
[0036] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the above-mentioned hash table tuning method is implemented.
[0037] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0038] In the hash table tuning method provided in this specification, a performance analysis instruction for the hash table is received, and based on the performance analysis instruction, a load factor, a conflict balance value, and a maximum conflict chain length of the hash table are determined. The load factor is used to represent the ratio of the number of used hash buckets to the total number of hash buckets in the hash table, the conflict balance value is used to represent the distribution of conflicting data in the hash table, and the maximum conflict chain length is used to represent the length of the longest conflict chain in the hash table. Furthermore, the hash table is tuned based on the load factor, the conflict balance value, and the maximum conflict chain length.
[0039] As can be seen from the above method, in the hash table tuning method provided in this specification, the hash table is tuned based on the load factor, conflict balance value, and longest conflict chain length of the hash table. This method can analyze the hash table through multiple dimensions of analysis parameters, which can more comprehensively reflect the performance status of the hash table, and then accurately adjust the hash table based on more accurate analysis results. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The exemplary embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings:
[0041] Figure 1 A schematic diagram of a hash list provided in this specification;
[0042] Figure 2 A flowchart of a hash table optimization method provided in this specification;
[0043] Figure 3 A schematic diagram of the performance of the hash table based on the performance information provided in this manual;
[0044] Figure 4 A schematic diagram of a hash linked table corresponding to the eighth performance case is provided for the purpose of this specification;
[0045] Figure 5 A schematic diagram of a hash linked table corresponding to the 12th performance case is provided for the purpose of this specification;
[0046] Figure 6 A flowchart of hash table optimization provided in this manual;
[0047] Figure 7 A schematic diagram of a hash table optimization device provided in this specification;
[0048] Figure 8 This manual provides a corresponding Figure 2 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0049] To make the objectives, technical solutions, and advantages of this specification more clear, the following will clearly and completely describe the technical solutions of this specification in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this specification.
[0050] Currently, the hash table can generally be adjusted according to the load factor. Specifically, the capacity of the hash function can be adjusted according to the calculated load factor, for example, the number of hash buckets corresponding to the hash table can be increased or decreased.
[0051] However, the method of adjusting the hash list by relying solely on a single parameter cannot fully reflect the performance status of the hash list, and thus cannot accurately adjust the hash list.
[0052] Based on this, this specification provides a method for tuning a hash table. The method receives a performance analysis instruction for a hash table and determines, based on the performance analysis instruction, a load factor, a conflict balance value, and a maximum conflict chain length of the hash table. The load factor represents the ratio of the number of used hash buckets to the total number of hash buckets in the hash table, the conflict balance value represents the distribution of conflicting data in the hash table, and the maximum conflict chain length represents the length of the longest conflict chain in the hash table. Furthermore, the hash table is tuned based on the load factor, the conflict balance value, and the maximum conflict chain length.
[0053] This approach can analyze the hash table through parameters in multiple dimensions, which can more comprehensively reflect the performance status of the hash table, and then accurately adjust the hash table based on more accurate analysis results.
[0054] The technical solutions provided by the embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0055] Figure 2 The flowchart of a hash table optimization method provided in this specification includes the following steps:
[0056] S201: Receive a performance analysis instruction for a hash list.
[0057] In this specification, the execution entity for implementing a hash list tuning method can be a terminal device such as a laptop computer, a tablet computer, or, of course, a server. For the sake of ease of description, this specification only takes the server as the execution entity as an example to illustrate a hash list tuning method provided in this specification.
[0058] The server receives a performance analysis instruction for the hash linked table to analyze the performance status of the hash linked table.
[0059] S202: Determine the load factor, conflict balance value, and longest conflict chain length of the hash chain table according to the performance analysis instruction.
[0060] The server analyzes the performance status of the hash table according to the received performance analysis instruction for the hash table, determines the load factor, conflict balance value and the longest conflict chain length of the hash table,
[0061] Specifically, the load factor is used to represent the ratio of the number of used hash buckets to the total number of hash buckets in the hash list, which can be expressed as follows:
[0062]
[0063] For example, for Figure 1 The load factor of the hash list in is Right now The server can determine the load factor corresponding to the hash list according to the above formula.
[0064] Secondly, the conflict balance value is used to characterize the distribution of conflicting data in the hash list, which can be expressed as follows:
[0065]
[0066] Among them, x i The value is the number of conflicting nodes in the i-th bucket of the hash list (i.e., the total number of data in the i-th bucket), μ is the average number of conflicting nodes across all buckets in the hash list, and n is the total number of hash buckets in the hash list. The server can determine the conflict balance value for the hash list based on the above formula.
[0067] For example, for Figure 1 The hash list in Its conflict equilibrium value is x0=3,x1=1,x2=2,x3=0,x4=1,x5=0,x6=2,x7=1.
[0068] Finally, the longest collision chain length is used to represent the length of the longest collision chain in the hash chain table. Specifically, the server can traverse all hash buckets in the hash chain table, determine the length of each hash bucket, and then determine the hash bucket with the longest collision chain. The length of the hash bucket with the longest collision chain is used as the longest collision chain length. Figure 1 In the hash linked list, the longest conflict chain is the conflict chain at the array position with array index 0, and the length of the conflict chain is 3.
[0069] S203: Optimizing the hash chain table according to the load factor, the conflict balance value, and the longest conflict chain length.
[0070] The server tunes the hash table based on the load factor, conflict balance value, and longest conflict chain length of the hash table. In this specification, the server can determine a performance condition corresponding to the hash table based on the load factor, conflict balance value, and longest conflict chain length of the hash table, further determine tuning instructions for the performance condition based on the performance condition of the hash table, and tune the hash table based on the tuning instructions for the performance condition.
[0071] Specifically, the server may determine the performance information of the hash chain table according to the load factor, the conflict balance value, and the longest conflict chain length of the hash chain table.
[0072] Furthermore, the performance information of the hash table may include loading status information, balance status information, and collision chain length status information. The loading status information may be determined by the server based on a loading factor, a preset first loading threshold, and a preset second loading threshold. Here, the preset first loading threshold may be 0.7, and the second loading threshold may be 0.8. That is, when the loading factor is less than 0.7, the loading status information may indicate that the loading factor of the hash table is low; when the loading factor is greater than or equal to 0.7 and less than or equal to 0.8, the loading status information may indicate that the loading factor of the hash table is normal; and when the loading factor is greater than 0.8, the loading status information may indicate that the loading factor of the hash table is high.
[0073] It should be noted that a loading factor between 0.7 and 0.8 is generally a reasonable value, with 0.75 being the optimal value. If it is significantly less than 0.75, the loading factor is considered low; if it is significantly greater than 0.75, the loading factor is considered high; and if it is between 0.7 and 0.8, the loading factor is considered normal.
[0074] The balance status information can be determined by the server based on the conflict balance value and a preset balance threshold. Generally, a smaller conflict balance value indicates a more balanced distribution of conflicting nodes in the hash list, while a larger conflict balance value indicates a more unbalanced distribution of conflicting nodes in the hash list. In practical applications, a reasonable balance threshold can be set based on past experience and the current storage conditions of the hash list. When the conflict balance value is less than the balance threshold, the balance status information can indicate that the data distribution in the hash list is balanced. When the conflict balance value is greater than or equal to the balance threshold, the balance status information can indicate that the data distribution in the hash list is unbalanced.
[0075] The collision chain length status information may be determined by the server based on the longest collision chain length, the total number of hash buckets in the hash chain table, and a preset length threshold. For example, the ratio of the longest collision chain length to the total number of hash buckets is compared with a preset length threshold. When the ratio of the longest collision chain length to the total number of hash buckets is greater than or equal to the preset length threshold, the collision chain length status information may be that the longest collision chain is excessively long. When the ratio of the longest collision chain length to the total number of hash buckets is less than the preset length threshold, the collision chain length status information may be that the longest collision chain is normal.
[0076] When the server optimizes the hash table based on the load status information, balance status information, and conflict chain length status information contained in the performance information, a total of 12 performance conditions corresponding to the hash table are generated, such as Figure 3 shown.
[0077] Figure 3 This is a schematic diagram of the performance of the hash table based on the performance information provided in this manual.
[0078] from Figure 3 As can be seen, there are three types of load factor status information: normal, low, and high; two types of balance status information: balanced and unbalanced; and two types of collision chain length status information: normal and overlong. Furthermore, the server optimizes the hash table based on twelve performance conditions based on the three types of load factor status information, the two types of balance status information, and the two types of collision chain length status information, as follows:
[0079] 1. If the loading status information is normal, the balance status information is balanced, and the conflict chain length status information is normal, the hash table performance status can be considered healthy. In this performance status, the server does not need to tune the hash table.
[0080] 2. For the case where the loading status information is normal, the balance status information is balanced, and the conflict chain length status information is excessively long, generally speaking, if the longest conflict chain is too long, the remaining data will be dispersed to other conflict chains. In this case, most of the other conflict chains should be short chains, and the balance degree of the conflict nodes should be unbalanced.
[0081] However, under the current performance conditions, the balance status information is balanced, so the judgment standard for whether the balance status information is balanced needs to be adjusted, that is, the preset balance threshold corresponding to the conflict balance value is set unreasonably; or it indicates that the amount of input data is small, and the remaining data may all be discretized into another conflict chain. For example, if there are only 8 data input into the hash chain, there are 5 data in one conflict chain and 3 data in the other conflict chain.
[0082] For this performance situation, the performance information is of little reference value. At this time, the server can appropriately increase the amount of input data, or adjust the balance threshold and length threshold to re-determine the performance information of the hash table.
[0083] 3. When the loading status information is normal, the balance status information is unbalanced, and the conflict chain length status information is normal, the server can execute a hash function adjustment instruction to optimize the hash chain table.
[0084] 4. When the loading status information is normal, the balance status information is unbalanced, and the conflict chain length status information is too long, that is, the data causing conflicts in the hash list is relatively concentrated, the server can execute the hash function adjustment instruction to tune the hash list.
[0085] Specifically, the server can analyze the input data corresponding to the longest collision chain to obtain data characteristics of the input data, such as the type, distribution, and size range of the input data. Based on these data characteristics, the server can adjust the hash function to reduce collisions. For example, the server can adjust hash function parameters, change the hash value calculation method, or introduce more randomness. Furthermore, the server can also reduce the input of input data with these data characteristics in actual application environments.
[0086] 5. If the load status is low, the balance status is balanced, and the collision chain length status is normal, the low load status indicates that a large number of hash buckets in the hash table are idle, while the balance status and the normal collision chain length status indicate that the hash function corresponding to the hash table has good discreteness. Therefore, in this case, there is no need to adjust the hash function. The server can execute a capacity reduction adjustment command to save storage space.
[0087] 6. For the situation where the loading status information is low, the balance status information is balanced, and the conflict chain length status information is too long, generally speaking, it is abnormal for the conflict chain length status information to be too long but the balance status information to be balanced. The performance information is of little reference value. The server can appropriately increase the amount of input data, or adjust the balance threshold and length threshold to re-determine the performance information of the hash table.
[0088] 7. If the load status information is low, the balance status information is unbalanced, and the collision chain length status information is normal, it indicates that the hash table space utilization is low and the collision distribution is uneven. The server can execute the hash function adjustment instruction or the capacity reduction adjustment instruction. However, since adjusting the hash function may improve the space utilization of the hash table, in this performance situation, the server can prioritize the hash function adjustment instruction and then the capacity reduction adjustment instruction.
[0089] 8. If the load status information is low, the balance status information is unbalanced, and the collision chain length status information is excessively long, this indicates that the hash table's space utilization is low and the data causing the collisions is concentrated. Since adjusting the hash function may improve the hash table's space utilization, the server can prioritize executing the hash function adjustment instruction before executing the capacity reduction adjustment instruction. The specific process for adjusting the hash function parameters has been described in case 4 and will not be repeated here. Of course, in actual application environments, the server can also reduce the input of data with these data characteristics.
[0090] in addition, Figure 4 A schematic diagram of a hash linked table corresponding to the eighth performance scenario is provided for the purpose of this specification.
[0091] from Figure 4 As can be seen from the image, the conflict chain length at array position 0 is too long, while the conflict chains at other array positions are shorter. Therefore, the balance status information is unbalanced and the conflict chain length status information is too long. Furthermore, data is only stored at array positions 0, 2, 3, and 4, so the loading status information is low.
[0092] 9. If the Load Status is High, the Balance Status is Balanced, and the Conflict Chain Length is Normal, the High Load Status indicates that most of the hash buckets in the hash table are loaded with data, while the Balance Status and the Normal Conflict Chain Length indicate that the hash function corresponding to the hash table has good discreteness. In this case, the hash function does not need to be adjusted. Instead, the array allocated to the hash table is too short, which can easily lead to an increased data collision rate. The server can execute a capacity expansion adjustment command to reduce the data collision rate.
[0093] 10. For situations where the loading status information is high, the balance status information is balanced, and the conflict chain length status information is overlong, generally speaking, it is abnormal for the conflict chain length status information to be overlong but the balance status information to be balanced. The performance information is of little reference value. The server can appropriately increase the amount of input data, or adjust the balance threshold and length threshold to re-determine the performance information of the hash list.
[0094] 11. If the load status information is high, the balance status information is unbalanced, and the collision chain length status information is normal, the high load status information indicates an increased probability of data conflicts in the hash table; the unbalanced balance status information indicates that the hash function corresponding to the hash table can be adjusted. However, in this case, there are few free hash buckets in the hash table, so conflicts will still occur even if the hash function is adjusted, which may further increase the load factor. Therefore, in this case, the server can prioritize executing capacity expansion adjustment instructions to alleviate data conflicts. However, if the hash table array already occupies a large amount of storage space and the cost of capacity expansion is too high, the server can execute the hash function adjustment instruction.
[0095] 12. If the load status information indicates high, the balance status information indicates imbalance, or the conflict chain length status information indicates excessive length, the server can prioritize executing capacity expansion adjustment instructions to alleviate data conflicts. Secondly, the server can execute hash function adjustment instructions to optimize the hash chain. The specific process for adjusting the hash function parameters has been described in the fourth scenario and will not be repeated here. Of course, the server can also reduce the input of data with these data characteristics in actual application environments.
[0096] in addition, Figure 5 A schematic diagram of a hash linked table corresponding to the 12th performance scenario is provided for the purpose of this specification.
[0097] from Figure 5 As can be seen from the image, the conflict chain length at array position 0 is too long, while the conflict chains at other array positions are shorter. Therefore, the balance status information is unbalanced and the conflict chain length status information is too long. Furthermore, only array positions 1 and 5 have no data stored, resulting in the loading status information being too high.
[0098] In addition, after the server completes the hash table optimization process, it can perform another performance analysis on the hash table to determine feedback information. The feedback information can include the performance information of the hash table in the previous performance analysis and the performance information of the hash table in the current performance analysis. The server further optimizes the hash table based on the feedback information.
[0099] In summary, the server can determine the performance information of the hash table based on the load factor, the conflict balance value, and the longest conflict chain length. This performance information includes load status information, balance status information, and conflict chain length status information. Based on different performance information, there are 12 performance conditions described above. In each performance condition, the server executes different tuning instructions based on the different performance information to tune the hash table.
[0100] However, in the above process, there are many performance conditions corresponding to the hash linked table, which is more complicated for the server to handle. Therefore, this specification can also simplify the above method.
[0101] Specifically, the server can determine whether the load factor is less than a preset first load threshold and whether the conflict balance value is less than a preset balance threshold. If it is determined that the load factor is less than the first load threshold and the conflict balance value is less than the balance threshold (that is, when the load status information is low and the balance status information is balanced), execute the capacity reduction adjustment instruction to tune the hash list, wherein the capacity reduction adjustment instruction is used to reduce the capacity of the hash list.
[0102] The server may also determine whether the load factor is greater than a preset second load threshold when the load factor is not less than a preset first load threshold and the conflict balance value is not less than a preset balance threshold. If the load factor is greater than the preset second load threshold (i.e., when the load status information is high), the server executes a capacity expansion adjustment instruction to optimize the hash table, wherein the capacity expansion adjustment instruction is used to expand the capacity of the hash table.
[0103] The method in this specification can also be used to determine whether the loading factor is less than a preset first loading threshold and whether the conflict balance value is not less than a preset balance threshold, or whether the loading factor is in a preset threshold interval and whether the conflict balance value is not less than a preset balance threshold, or whether the loading factor is in a preset threshold interval and whether the conflict chain length ratio is not less than a preset length threshold. If the server determines that the load factor is less than a preset first load threshold and the conflict balance value is not less than a preset balance threshold (i.e., when the load status information is low and the balance status information is unbalanced), or determines that the load factor is within a preset threshold interval and the conflict balance value is not less than the preset balance threshold (i.e., when the load status information is normal and the balance status information is unbalanced), or determines that the load factor is within a preset threshold interval and the conflict chain length ratio is not less than a preset length threshold (i.e., when the load status information is normal and the conflict chain length status information is overlong), the server executes a hash function adjustment instruction to tune the hash chain table, wherein the hash function adjustment instruction is used to adjust the hash function of the hash chain table, the preset threshold interval is determined based on the first load threshold and the preset second load threshold (i.e., when the load factor is greater than or equal to the first load threshold and less than or equal to the second load threshold, the load factor is considered to be within the preset threshold interval), and the conflict chain length ratio is used to represent the ratio between the longest conflict chain length and the total number of hash buckets in the hash chain table.
[0104] That is to say, since it is relatively simple to adjust the capacity of the hash list, the server can first determine whether the current hash list needs to have its capacity adjusted, and if not, then execute the instruction to adjust the hash function.
[0105] Next, a complete example will be provided to explain the method in this manual. Figure 6 shown.
[0106] Figure 6 This is a flowchart for hash table tuning provided in this manual.
[0107] from Figure 6 It can be seen that the server receives the performance analysis instruction, determines the loading factor, conflict balance value and longest conflict chain length of the hash list according to the performance analysis instruction, and determines the performance information of the hash list according to the loading factor, conflict balance value and longest conflict chain length of the hash list, wherein the performance information includes loading status information, balance status information and conflict chain length status information.
[0108] The server first determines whether the loading status information is low and the balance status information is balanced. If it is determined that the loading status information is low and the balance status information is balanced, the server executes a capacity reduction adjustment instruction to reduce the capacity of the hash list.
[0109] If it is determined that the loading status information is not too low and the balance status information is not balanced, it can be further determined whether the loading status information is too high. If the loading status information is too high at this time, the server can execute a capacity expansion adjustment instruction to expand the capacity of the hash linked list.
[0110] If the load status information is also not too high, the server will further determine whether the balance status information is unbalanced or the collision chain length status information is too long. If the balance status information is unbalanced or the collision chain length status information is too long, the server can execute the hash function adjustment instruction to adjust the hash function corresponding to the hash table. Otherwise, if the balance status information is normal and the collision chain length status information is normal, the hash table does not need to be tuned.
[0111] It should be noted that if the server still finds that the conflict chain length status information is too long after automatically tuning the hash chain table, the input data, loading factor and conflict balance value corresponding to the longest conflict chain are obtained, and the input data, loading factor and conflict balance value corresponding to the longest conflict chain are displayed to the user for the user to analyze and decide, so that the user can manually tune the hash chain table based on the input data, loading factor and conflict balance value corresponding to the longest conflict chain.
[0112] After the above series of tuning processes, the server can output a report. The report here is used to record the detailed information of all the tuning instructions performed by the server and generate a corresponding report so that the administrator can review and analyze it according to the report output by the server.
[0113] It's important to note that once a tuning decision is made, the server automatically executes the corresponding tuning instructions, such as capacity reduction and expansion instructions, as well as hash function adjustment instructions. These instructions involve expanding or reducing the capacity of the hash table, or replacing the corresponding hash function. After each tuning instruction is executed, the server re-determines the load factor, collision balance value, and maximum collision chain length of the hash table, and then re-evaluates the performance of the hash table to ensure that the tuning achieves the expected results. If the results are not as expected, the server will re-tune the hash table based on the feedback provided.
[0114] This document utilizes a multi-dimensional performance analysis method to optimize hash tables, utilizing a comprehensive approach, including load factor, longest collision chain length, and collision balance, rather than relying solely on load factor. This method provides a more comprehensive picture of hash table performance. This approach improves the accuracy and comprehensiveness of hash table performance analysis, as well as the targeted and intelligent nature of performance tuning. It offers significant technical advantages and practical application value.
[0115] Furthermore, the method in this specification can analyze the input data corresponding to the longest conflict chain to adjust the hash function according to the input characteristics of the input data, thereby reducing specific types of conflicts.
[0116] In addition, the server can continue to perform performance analysis on the hash list after each execution of the tuning instruction, and can dynamically and continuously track the performance parameters of the hash list (i.e., loading factor, conflict balance value and longest conflict chain length), and compare them with the preset thresholds (i.e., the first loading threshold, the second loading threshold, the balance threshold and the length threshold) to adjust the performance optimization strategy in real time.
[0117] The above is one or more implementations of the hash table tuning method of this specification. Based on the same idea, this specification also provides a corresponding hash table tuning device, such as Figure 7 shown.
[0118] Figure 7 A schematic diagram of a hash table tuning device provided in this specification includes:
[0119] Receiving module 701, used for receiving a performance analysis instruction for a hash list;
[0120] Determination module 702, configured to determine a load factor, a conflict balance value, and a longest conflict chain length of the hash chain according to the performance analysis instruction; the load factor is used to represent the ratio of the number of used hash buckets to the total number of hash buckets in the hash chain, the conflict balance value is used to represent the distribution of conflicting data in the hash chain, and the longest conflict chain length is used to represent the length of the longest conflict chain in the hash chain;
[0121] The tuning module 703 is configured to perform tuning processing on the hash chain table according to the load factor, the conflict balance value, and the longest conflict chain length.
[0122] Optionally, the tuning module 703 is specifically configured to determine performance information of the hash chain table according to the load factor, the conflict balance value, and the longest conflict chain length; and perform tuning processing on the hash chain table according to the performance information.
[0123] Optionally, the performance information includes loading status information, balancing status information, and conflict chain length status information;
[0124] The tuning module 703 is specifically used to determine the loading status information based on the loading factor, the preset first loading threshold and the preset second loading threshold; determine the balance status information based on the conflict balance value and the preset balance threshold; determine the conflict chain length status information based on the longest conflict chain length, the total number of hash buckets in the hash chain table and the preset length threshold.
[0125] Optionally, the tuning module 703 is specifically used to execute a capacity reduction adjustment instruction to tune the hash list if it is determined that the loading factor is less than a preset first loading threshold and the conflict balance value is less than a preset balance threshold, wherein the capacity reduction adjustment instruction is used to reduce the capacity of the hash list.
[0126] Optionally, the tuning module 703 is specifically used to, if it is determined that the loading factor is not less than a preset first loading threshold and the conflict balance value is not less than a preset balance threshold, determine whether the loading factor is greater than a preset second loading threshold; if so, execute a capacity expansion adjustment instruction to tune the hash list, and the capacity expansion adjustment instruction is used to expand the capacity of the hash list.
[0127] Optionally, the tuning module 703 is specifically used to execute a hash function adjustment instruction to tune the hash chain table if it is determined that the loading factor is less than a preset first loading threshold and the conflict balance value is not less than a preset balance threshold, or if it is determined that the loading factor is in a preset threshold interval and the conflict balance value is not less than a preset balance threshold, or if it is determined that the loading factor is in the preset threshold interval and the conflict chain length ratio is not less than a preset length threshold; the hash function adjustment instruction is used to adjust the hash function of the hash chain table; the preset threshold interval is determined based on the first loading threshold and the preset second loading threshold; the conflict chain length ratio is used to characterize the ratio relationship between the longest conflict chain length and the total number of hash buckets of the hash chain table.
[0128] Optionally, the tuning module 703 is further configured to, after completing the tuning process on the hash chain table, perform a performance analysis on the hash chain table to determine feedback information; and perform tuning process on the hash chain table according to the feedback information.
[0129] This specification also provides a computer-readable storage medium, which stores a computer program that can be used to execute the above Figure 2 A hash list tuning method is provided.
[0130] This manual also provides Figure 8 The one shown corresponds to Figure 2 Schematic diagram of the electronic equipment. Figure 8 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 2 The above-mentioned hash table tuning method. Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0131] Improvements to a technology can be clearly distinguished as either hardware improvements (for example, improvements to circuit structures such as diodes, transistors, and switches) or software improvements (improvements to process flows). However, with technological advancements, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always program the improved process flow into the hardware circuit to obtain the corresponding hardware circuit structure. Therefore, it cannot be said that a process flow improvement cannot be implemented using a hardware module. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
[0132] The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
[0133] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0134] For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0135] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0136] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0137] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0139] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0140] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0141] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0142] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0143] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Thus, this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0144] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.
[0145] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
[0146] The foregoing is merely an example of the present invention and is not intended to limit the present invention. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.
Claims
1. A method for tuning a hash linked list, characterized in that: include: Receive a performance analysis instruction for a hash list; According to the performance analysis instruction, determine the loading factor, conflict balance value and longest conflict chain length of the hash chain table; the loading factor is used to represent the ratio of the number of used hash buckets to the total number of hash buckets in the hash chain table, the conflict balance value is used to represent the distribution of conflicting data in the hash chain table, and the longest conflict chain length is used to represent the length of the longest conflict chain in the hash chain table; The hash chain table is tuned according to the loading factor, the conflict balance value and the longest conflict chain length.
2. The method according to claim 1, characterized in that According to the load factor, the conflict balance value and the longest conflict chain length, the hash chain table is tuned, specifically including: Determining performance information of the hash chain table according to the loading factor, the conflict balance value, and the longest conflict chain length; The hash linked list is tuned according to the performance information.
3. The method according to claim 2, characterized in that The performance information includes loading status information, balancing status information and conflict chain length status information; Determining performance information of the hash linked table according to the load factor, the conflict balance value, and the longest conflict chain length, specifically including: The loading status information is determined according to the loading factor, a preset first loading threshold and a preset second loading threshold; the balance status information is determined according to the conflict balance value and the preset balance threshold; the conflict chain length status information is determined according to the longest conflict chain length, the total number of hash buckets of the hash link table and the preset length threshold.
4. The method according to claim 1, characterized in that According to the load factor, the conflict balance value and the longest conflict chain length, the hash chain table is tuned, specifically including: If it is determined that the loading factor is less than a preset first loading threshold and the conflict balance value is less than a preset balance threshold, a capacity reduction adjustment instruction is executed to tune the hash list, and the capacity reduction adjustment instruction is used to reduce the capacity of the hash list.
5. The method according to claim 1, characterized in that According to the load factor, the conflict balance value and the longest conflict chain length, the hash chain table is tuned, specifically including: If it is determined that the loading factor is not less than a preset first loading threshold and the conflict balance value is not less than a preset balance threshold, determining whether the loading factor is greater than a preset second loading threshold; If so, execute a capacity expansion adjustment instruction to optimize the hash list, wherein the capacity expansion adjustment instruction is used to expand the capacity of the hash list.
6. The method according to claim 1, characterized in that According to the load factor, the conflict balance value and the longest conflict chain length, the hash chain table is tuned, specifically including: If it is determined that the loading factor is less than a preset first loading threshold and the conflict balance value is not less than a preset balance threshold, or it is determined that the loading factor is in a preset threshold interval and the conflict balance value is not less than a preset balance threshold, or it is determined that the loading factor is in the preset threshold interval and the conflict chain length ratio is not less than a preset length threshold, a hash function adjustment instruction is executed to tune the hash chain table; the hash function adjustment instruction is used to adjust the hash function of the hash chain table; the preset threshold interval is determined based on the first loading threshold and the preset second loading threshold; the conflict chain length ratio is used to characterize the ratio relationship between the longest conflict chain length and the total number of hash buckets of the hash chain table.
7. The method according to claim 1, characterized in that The method further comprises: After completing the tuning process of the hash linked table, performing performance analysis on the hash linked table to determine feedback information; The hash linked list is tuned according to the feedback information.
8. A hash table tuning device, characterized in that: include: A receiving module, used for receiving a performance analysis instruction for a hash linked list; A determination module, configured to determine a loading factor, a conflict balance value, and a longest conflict chain length of the hash chain list according to the performance analysis instruction; the loading factor is used to characterize the ratio of the number of used hash buckets to the total number of hash buckets in the hash chain list, the conflict balance value is used to characterize the distribution of conflicting data in the hash chain list, and the longest conflict chain length is used to characterize the length of the longest conflict chain in the hash chain list; A tuning module is used to tune the hash chain table according to the loading factor, the conflict balance value and the longest conflict chain length.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.