A method, system, device and computer readable storage medium for underflushing a cache

By using multi-threaded parallel processing for cache flushing, with a one-to-one correspondence between candidate threads and sub-hash tables, the system filters target threads and iterates through dirty data to flush the cache, thus solving the problem of low cache flushing efficiency and achieving fast and efficient cache flushing, thereby improving the user experience.

CN119248671BActive Publication Date: 2026-04-21INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INSPUR SUZHOU INTELLIGENT TECH CO LTD
Filing Date
2024-09-20
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Current technologies suffer from low caching efficiency and time-consuming single-threaded processing of hash tables, which negatively impacts user experience.

Method used

Multi-threaded parallel processing is adopted, with candidate threads corresponding one-to-one with sub-hash tables. The target thread is selected and its traversal is controlled to flush out dirty data.

Benefits of technology

It improves the efficiency of cache flushing, avoids the backlog of single-threaded flushing tasks, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248671B_ABST
    Figure CN119248671B_ABST
Patent Text Reader

Abstract

The application discloses a cache flushing method, system and device and a computer readable storage medium, relates to the technical field of storage, determines candidate threads for executing cache flushing, and the number of the candidate threads is greater than or equal to 2; in the candidate threads, a target thread is screened out; a target sub-hash table corresponding to the target thread is determined; the target thread is controlled to traverse the target sub-hash table, and dirty data obtained through the traversal is flushed; wherein the sub-hash table is used for storing the dirty data; and the candidate threads correspond to the sub-hash tables one by one. The application sets the sub-hash tables to store the dirty data, and the candidate threads correspond to the sub-hash tables one by one, and the number of the candidate threads is greater than or equal to 2, so that each candidate thread can flush the dirty data in the sub-hash table corresponding to the candidate thread. Compared with the prior scheme of flushing the dirty data through a single hash table and a single thread, the application improves the flushing efficiency of the dirty data, realizes the function of quickly flushing the cache, and improves the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of storage technology, and more specifically, to a cache flushing method, system, device, and computer-readable storage medium. Background Technology

[0002] Currently, it's necessary to flush dirty data cached in servers and other devices as needed. For example, when performing command-line operations such as starting a snapshot, disabling the cache, or deleting a node, all the dirty data in the cache must be flushed before proceeding. Therefore, the speed of flushing dirty data affects the speed of command-line execution, which in turn affects the user experience. However, dirty data in the cache is stored in a hash table data structure. Flushing dirty data requires traversing the hash table first, finding the dirty data, and then flushing it. This can only be done by a single thread on a single hash table, which is time-consuming and inefficient.

[0003] In conclusion, how to quickly perform cache flushing is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] The purpose of this application is to provide a cache flushing method, which can solve the technical problem of how to quickly flush the cache to a certain extent. This application also provides a cache flushing system, an electronic device, and a computer-readable storage medium.

[0005] To achieve the above objectives, this application provides the following technical solution:

[0006] A cache flushing method includes:

[0007] Determine candidate threads for performing cache flushing, wherein the number of candidate threads is greater than or equal to 2;

[0008] The target thread is selected from the candidate threads.

[0009] Determine the target sub-hash table corresponding to the target thread;

[0010] The target thread is controlled to traverse the target sub-hash table and flush the dirty data obtained during the traversal.

[0011] The sub-hash table is used to store dirty data; and each candidate thread corresponds one-to-one with a sub-hash table.

[0012] In one exemplary embodiment, the step of filtering out the target thread from the candidate threads includes:

[0013] Among the candidate threads, the initial thread for performing the cache flush operation is selected;

[0014] Obtain the busy level of the initial thread;

[0015] Check whether the busy level of the initial thread is greater than the set busy level value;

[0016] If the busyness of the initial thread is less than or equal to the set busyness value, then the initial thread is determined as the target thread;

[0017] If the initial thread's busyness is greater than the set busyness value, then a candidate thread with a busyness less than or equal to the set busyness value is selected as a backup thread, and the initial thread and the backup thread are used as the target thread.

[0018] In an exemplary embodiment, determining the target sub-hash table corresponding to the target thread includes:

[0019] Use the sub-hash table corresponding to the initial thread as the target sub-hash table;

[0020] The step of controlling the target thread to traverse the target sub-hash table and flushing the dirty data obtained during the traversal includes:

[0021] In response to the target thread including only the initial thread, the initial thread is controlled to traverse the target sub-hash table and flush the dirty data obtained during the traversal.

[0022] In response to the target thread including the initial thread and the backup thread, the backup thread is controlled to traverse the target sub-hash table, and the initial thread is controlled to flush the dirty data obtained during the traversal.

[0023] In one exemplary embodiment, the step of selecting an initial thread for performing the cache flush operation from the candidate threads includes:

[0024] Get the cache flush command;

[0025] Determine the target I / O to be processed by the cache flush instruction;

[0026] Determine the offset address of the target I / O in the cache volume;

[0027] The initial thread is selected from the candidate threads based on the offset address.

[0028] In an exemplary embodiment, selecting the initial thread from the candidate threads based on the offset address includes:

[0029] Determine the total number of candidate threads;

[0030] The cache volume is divided equally to obtain the total number of sub-cache volumes;

[0031] Determine the sub-cache volume corresponding to each of the candidate threads;

[0032] The sub-cache volume where the offset address is located is taken as the target sub-cache volume;

[0033] The candidate thread corresponding to the target sub-cached volume is used as the initial thread.

[0034] In an exemplary embodiment, controlling the target thread to traverse the target sub-hash table and flushing the dirty data obtained during the traversal includes:

[0035] The number of nodes traversed by the target thread in the target sub-hash table is counted to obtain a real-time count value;

[0036] Detect whether the real-time count value has reached the first preset value;

[0037] If the real-time count value reaches the first set value, then the first quantity value containing dirty data nodes is determined, and the first ratio of the first quantity value to the first set value is calculated.

[0038] Detect whether the first ratio is less than the first proportion value;

[0039] If the first ratio is greater than or equal to the first ratio value, then control the target thread to flush the dirty data obtained by traversal;

[0040] If the first ratio is less than the first proportion value, then control the target thread to continue traversing the target sub-hash table and update the real-time count value;

[0041] Detect whether the real-time count value has reached the second preset value;

[0042] If the real-time count value reaches the second set value, then a second quantity value containing dirty data nodes is determined, and a second ratio between the second quantity value and the second set value is calculated;

[0043] Detect whether the second ratio is less than the second proportion value;

[0044] If the second ratio is greater than or equal to the second ratio value, then control the target thread to flush the dirty data obtained by traversal;

[0045] If the second ratio is less than the second proportion value, the target thread is controlled to continue traversing the target sub-hash table and update the real-time count value; when the real-time count value reaches the third set value, the target thread is controlled to flush the dirty data obtained from the traversal.

[0046] In one exemplary embodiment, before determining the candidate thread for performing cache flushing, the method further includes:

[0047] Check if the number of threads used to perform cache flushing is one;

[0048] If the number of threads used to perform cache flushing is one, then one thread is selected from each processor core as the candidate thread.

[0049] A hash table is determined for storing dirty data, and the hash table is split to obtain sub-hash tables that correspond one-to-one with the candidate threads.

[0050] A cache flushing system, comprising:

[0051] The first determining module is used to determine candidate threads for performing cache flushing, wherein the number of candidate threads is greater than or equal to 2;

[0052] The first filtering module is used to filter out the target thread from the candidate threads;

[0053] The second determining module is used to determine the target sub-hash table corresponding to the target thread;

[0054] The first control module is used to control the target thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal.

[0055] The sub-hash table is used to store dirty data; and each candidate thread corresponds one-to-one with a sub-hash table.

[0056] An electronic device, comprising:

[0057] Memory, used to store computer programs;

[0058] A processor, configured to implement the steps of any of the above-described cache flushing methods when executing the computer program.

[0059] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the cache flushing methods described above.

[0060] This application provides a cache flushing method that determines candidate threads for performing cache flushing, with the number of candidate threads being greater than or equal to two; selects a target thread from the candidate threads; determines the target sub-hash table corresponding to the target thread; controls the target thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal; wherein the sub-hash table is used to store dirty data; and there is a one-to-one correspondence between the candidate threads and the sub-hash table. In this application, by setting a sub-hash table to store dirty data and ensuring that there is a one-to-one correspondence between the candidate threads and the sub-hash table, with the number of candidate threads being greater than or equal to two, each candidate thread can flush dirty data according to its corresponding sub-hash table. Compared with existing schemes that flush dirty data using a single thread and a single hash table, this application can flush dirty data in parallel using multiple threads, avoiding the accumulation of flushing tasks in a single thread, improving the flushing efficiency of dirty data, and realizing fast cache flushing, thereby improving the user experience. The cache flushing system, electronic device, and computer-readable storage medium provided in this application also solve the corresponding technical problems. Attached Figure Description

[0061] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0062] Figure 1 A flowchart of a cache flushing method provided in an embodiment of this application;

[0063] Figure 2 This is a schematic diagram of the hash table structure;

[0064] Figure 3 This is a diagram illustrating the splitting of a hash table;

[0065] Figure 4 This is a schematic diagram illustrating the relationship between candidate threads and sub-hash tables.

[0066] Figure 5 This is a schematic diagram of a cache flushing system provided in an embodiment of this application;

[0067] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0068] Figure 7 This is another structural schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0069] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0070] Please see Figure 1 , Figure 1 This is a flowchart of a cache flushing method provided in an embodiment of this application.

[0071] This application provides a cache flushing method, which may include the following steps:

[0072] Step S101: Determine the candidate threads for performing cache flushing, with the number of candidate threads being greater than or equal to 2.

[0073] In practical applications, multiple candidate threads can be set up in the server to perform cache flushing operations, so that dirty data in the server cache can be flushed in parallel by multiple candidate threads.

[0074] It should be noted that the more candidate threads there are, the higher the performance cost of cache flushing. Therefore, the number of candidate threads can be flexibly determined according to the server's performance allocation requirements. Of course, there are other ways to determine the number of candidate threads. For example, in the case of a multi-core server, one or more threads can be selected from each processor core as candidate threads.

[0075] Step S102: Filter out the target thread from the candidate threads.

[0076] Step S103: Determine the target sub-hash table corresponding to the target thread.

[0077] Step S104: Control the target thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal; wherein, the sub-hash table is used to store dirty data; and the candidate thread corresponds one-to-one with the sub-hash table.

[0078] In practical applications, cache flushing is affected by operations such as starting snapshots, closing caches, and deleting nodes. The dirty data to be flushed in each specific operation is specific dirty data. Since the candidate threads performing the cache flushing operation process different dirty data, it is necessary to select the target thread from the candidate threads; then determine the target sub-hash table corresponding to the target thread; finally, control the target thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal. It should be noted that in this application, there is a one-to-one correspondence between the candidate threads and the sub-hash tables. The sub-hash tables are used to store dirty data, and each sub-hash table stores different dirty data. In this way, the process of each candidate thread processing the sub-hash table is independent, and there is no situation where multiple threads traverse the same sub-hash table. In other words, candidate threads can process the sub-hash tables in parallel.

[0079] In specific application scenarios, during the process of selecting the target thread from candidate threads, the candidate thread that handles the dirty data to be flushed can be directly used as the target thread. This method is simple and direct. However, considering that the dirty data stored on each sub-hash table may be different, and the performance pressure of each candidate thread may be different, in order to avoid the performance pressure of a single candidate thread being too high and affecting the cache flushing efficiency, an initial thread for performing the cache flushing operation can be selected from the candidate threads. The busyness of the initial thread is obtained; it is checked whether the busyness of the initial thread is greater than a set busyness value; if the busyness of the initial thread is less than or equal to the set busyness value, then the initial thread is determined as the target thread; if the busyness of the initial thread is greater than the set busyness value, then a candidate thread with a busyness less than or equal to the set busyness value is selected as a backup thread. The initial thread and the backup thread are used as the target thread to share the performance pressure of the initial thread with the help of the backup thread. The set busyness value can be, for example, a CPU (Central Processing Unit) utilization rate of 95% and 50 tasks waiting to be executed on the thread, which can be flexibly determined according to the application scenario.

[0080] In specific application scenarios, since the initial thread is used to perform cache flushing operations, while the backup thread is used to share the performance burden of the initial thread, the target thread essentially performs cache flushing on the sub-hash table corresponding to the initial thread. Therefore, in determining the target sub-hash table corresponding to the target thread, the sub-hash table corresponding to the initial thread can be used as the target sub-hash table. Correspondingly, in controlling the target thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal, if the target thread only includes the initial thread, then the initial thread is controlled to traverse the target sub-hash table and flush the dirty data obtained during the traversal; if the target thread includes both the initial thread and the backup thread, then the backup thread is controlled to traverse the target sub-hash table, and the initial thread is controlled to flush the dirty data obtained during the traversal. In this case, the initial thread does not need to perform the operation of traversing the target sub-hash table, but only needs to perform the operation of flushing the dirty data, thus reducing the performance burden.

[0081] In specific application scenarios, during the process of selecting the initial thread for performing the cache flush operation from candidate threads, when flushing all dirty data, all candidate threads can be used as the initial thread; however, when flushing only a portion of dirty data, the cache flush instruction can be obtained first. If the cache flush instruction specifies a particular I / O, the target I / O (Input / Output) to be processed by the cache flush instruction can be determined, along with its offset address in the cache volume. Finally, the initial thread is selected from the candidate threads based on the offset address. This method utilizes the user's cache flush instruction to filter the initial thread. Furthermore, during the process of selecting the initial thread based on the offset address among the candidate threads, the total number of candidate threads can be determined; the cache volume is evenly divided to obtain a total number of sub-cache volumes; the sub-cache volume corresponding to each candidate thread is determined; the sub-cache volume where the offset address is located is taken as the target sub-cache volume; and the candidate thread corresponding to the target sub-cache volume is taken as the initial thread. In this way, each candidate thread needs to process the same size sub-cache volume, the same maximum amount of dirty data to process, and the same maximum amount of dirty data stored in each sub-hash table, which facilitates load balancing among candidate threads.

[0082] In practical applications, during the process of controlling the target thread to traverse the target sub-hash table and flushing the dirty data obtained during the traversal, because each traversal of the target sub-hash table starts from the beginning, and dirty data may be stored at the end of the target sub-hash table, the limited traversal time may result in insufficient dirty data being obtained in each traversal. For example, if each traversal involves 20 nodes in the sub-hash table, where each node is a hash table node storing dirty data, and if the total number of nodes in the sub-hash table is greater than 20 and the dirty data is mainly stored in nodes exceeding 20, then insufficient dirty data will be obtained, affecting the cache flushing efficiency. To avoid this situation, the number of nodes traversed by the target thread in the target sub-hash table can be counted in real time; if the real-time count reaches a first set value, then the first number of nodes containing dirty data is determined, and the count is calculated. Calculate a first ratio between a first quantity value and a first set value; check if the first ratio is less than a first proportion value; if the first ratio is greater than or equal to the first proportion value, control the target thread to flush the dirty data obtained during traversal; if the first ratio is less than the first proportion value, control the target thread to continue traversing the target sub-hash table and update the real-time count value; check if the real-time count value has reached a second set value; if the real-time count value has reached the second set value, determine a second quantity value containing dirty data nodes, and calculate a second ratio between the second quantity value and the second set value; check if the second ratio is less than the second proportion value; if the second ratio is greater than or equal to the second proportion value, control the target thread to flush the dirty data obtained during traversal; if the second ratio is less than the second proportion value, control the target thread to continue traversing the target sub-hash table and update the real-time count value; when the real-time count value reaches a third set value, control the target thread to flush the dirty data obtained during traversal.

[0083] As can be seen from the implementation process, this application counts the nodes obtained by the target thread traversing the target sub-hash table to obtain a real-time count value. Then, when the real-time count value reaches a first set value, a first quantity value containing dirty data nodes is determined, a first ratio of the first quantity value to the first set value is calculated, and it is checked whether the first ratio is less than a first proportion value. If the first ratio is greater than or equal to the first proportion value, the target thread is controlled to flush the traversed dirty data. Since the first ratio represents the validity of the traversed dirty data, and the first proportion value is equivalent to the data volume setting value of dirty data, it can ensure that the nodes of the first set value are traversed and the traversed dirty data meets the set data volume, so as to ensure that the data volume of dirty data flushed to the cache meets the requirements and improves the cache flushing efficiency. And when the first ratio is less than the first proportion value, the target thread continues to traverse the target sub-hash table and updates the real-time count value. At this time, if the real-time count value reaches a second set value, the first node containing dirty data nodes is determined. The system calculates a second ratio between a second quantity value and a second set value. It checks if this second ratio is less than a second proportional value. If the second ratio is greater than or equal to the second proportional value, the target thread is controlled to flush the dirty data obtained during traversal. This is done to expand the dirty data volume by continuing to traverse nodes when the dirty data obtained from traversing the first set value of nodes does not meet the set data volume requirement. Then, if the second ratio is less than the second proportional value, the target thread is controlled to continue traversing the target sub-hash table and update the real-time count value. When the real-time count value reaches a third set value, the target thread is controlled to flush the dirty data obtained during traversal. At this point, three rounds of operations to expand the number of traversed nodes have been performed, so it can be considered that the dirty data obtained during traversal meets the requirements. Moreover, the time spent by the target thread to traverse the target sub-hash table is relatively long, and the performance consumption is relatively high. Considering the dirty data volume and performance consumption, the dirty data obtained during traversal can be directly flushed to achieve a balance between caching efficiency and performance consumption.

[0084] It should be noted that the specific values ​​of the first set value, the first ratio value, the second set value, the second ratio value, and the third set value in this application can be flexibly determined according to the application scenario. For example, the first set value can be 20, the first ratio value can be 0.5, the second set value can be 30, the second ratio value can be 0.5, and the third set value can be 40. Alternatively, the first set value can be 20, the first ratio value can be 0.4, the second set value can be 35, the second ratio value can be 0.6, and the third set value can be 45, etc.

[0085] In specific application scenarios, considering that the specific values ​​of the first, second, and third preset values ​​will affect the performance consumption of the target thread, the specific values ​​of the first, second, and third preset values ​​can be flexibly set according to the performance consumption of the target thread. For example, when counting the nodes obtained by the target thread traversing the target sub-hash table and obtaining the real-time count value, the real-time duration of the target thread traversing the target sub-hash table can also be accumulated. After obtaining each real-time count value and its corresponding real-time duration, the growth rate of the real-time duration with respect to the real-time count value can be calculated. This growth rate can be calculated when the real-time count value increases by 1. The increase in real-time duration, etc., is determined based on the maximum performance consumption of the target thread when the real-time duration is just greater than half of the maximum traversal duration of the target thread. The growth rate is checked to see if there has been a jump. If not, the real-time count value is doubled to obtain the first set value. If so, the real-time count value is multiplied by 0.6 to obtain the first set value. Then, the sum of the first set value and the fixed value can be used as the second set value, and the sum of the second set value and the fixed value can be used as the third set value. Because the first set value makes the performance consumption of the target thread close to the maximum value, the fixed value can be set to a small value, such as 2 or 3.

[0086] As can be seen from the implementation process, during the counting of nodes obtained by the target thread traversing the target sub-hash table, this application also accumulates the real-time duration of the target thread traversing the target sub-hash table. Since the maximum traversal duration is determined based on the maximum performance consumption of the target thread, when the real-time duration is just greater than half of the maximum traversal duration of the target thread, it can be considered that the performance consumption of the target thread is relatively large. At this time, it is possible to detect whether the growth rate has jumped. If not, it indicates that the time consumed by each node traversal is close, and each node either has no dirty data or has dirty data. The real-time count value can be doubled to obtain the first set value. If yes, it indicates that the node has changed from having no dirty data to having dirty data. After that, the time for traversing each node will increase, and the target thread will quickly reach the maximum performance consumption. At this time, the real-time count value can be multiplied by 0.6 to obtain the first set value. Then, the sum of the first set value and the fixed value can be used as the second set value, and the sum of the second set value and the fixed value can be used as the third set value. In this way, when the real-time count reaches the first set value, the target thread basically reaches its maximum performance consumption, which allows the target thread to traverse the node according to the maximum performance consumption, increasing the amount of dirty data obtained during traversal, and thus improving the cache flushing efficiency.

[0087] In practical applications, considering that servers typically use a single thread for cache flushing and a single hash table to store dirty data, such as Figure 2As shown, candidate threads can be obtained by expanding the number of threads, and sub-hash tables can be obtained by splitting the hash table. Specifically, before determining the candidate threads for cache flushing, it can be checked whether the number of threads for cache flushing is one. If the number of threads for cache flushing is one, one thread is selected from each processor core as a candidate thread. At this point, there is a one-to-one correspondence between candidate threads and processor cores; one candidate thread can only execute on one processor core, and one processor core can only execute one candidate thread for cache flushing. The hash table used to store dirty data is determined, and the hash table is split to obtain sub-hash tables corresponding to the candidate threads. During this process, the total number of candidate threads can be counted, and the maximum capacity of the hash table can be divided by this total number to obtain the maximum capacity of each sub-hash table. The hash table can then be split according to this maximum capacity. Figure 3 As shown, the relationship between the sub-hash table and the candidate thread is as follows: Figure 4 As shown. It should be noted that after splitting the hash table to obtain sub-hash tables, the sub-hash tables can be directly used for storing and flushing dirty data. In addition, when the hash table is empty due to the server just starting up or initialization operations, candidate threads can be selected directly, and corresponding sub-hash tables can be created for each candidate thread, so that the sub-hash tables corresponding to each candidate thread can be obtained directly through creation.

[0088] It should also be noted that the existing process for storing dirty data in a hash table is as follows: A key value is calculated based on each IO's volume ID and LBA (Logical Block Address). Then, the row in the hash table is selected based on the key value, and the IO is placed at the tail of the linked list of nodes for that row. Based on this operation, when the cache volume is divided into sub-cache volumes, and each sub-cache volume corresponds one-to-one with a candidate thread, the process for storing dirty data in this application can be as follows: The initial thread is determined based on the IO's offset address within the cache volume. The IO is then handed over to the initial thread for processing. The initial thread calculates the key value based on the IO's volume ID and LBA, selects the row in the target sub-hash table based on the key value, and places the IO at the tail of the linked list of nodes for that row. Based on this, dirty data for specific IO operations can be flushed according to the dirty data storage method. For example, the dirty data that the user needs to flush can be determined, the sub-hash table storing the dirty data can be determined as the target sub-hash table, the candidate thread corresponding to the target sub-hash table can be determined as the target thread, the target thread can be controlled to traverse the target sub-hash table, and the dirty data obtained by the traversal can be flushed.

[0089] This application provides a cache flushing method that determines candidate threads for performing cache flushing, with the number of candidate threads being greater than or equal to two; selects a target thread from the candidate threads; determines the target sub-hash table corresponding to the target thread; controls the target thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal; wherein the sub-hash table is used to store dirty data; and there is a one-to-one correspondence between the candidate threads and the sub-hash table. In this application, by setting a sub-hash table to store dirty data and ensuring that there is a one-to-one correspondence between the candidate threads and the sub-hash table, with the number of candidate threads being greater than or equal to two, each candidate thread can flush dirty data according to its corresponding sub-hash table. Compared with existing schemes that flush dirty data using a single thread and a single hash table, this application can flush dirty data in parallel using multiple threads, avoiding the accumulation of flushing tasks in a single thread, improving the flushing efficiency of dirty data, realizing fast cache flushing, and thus improving the user experience.

[0090] Please see Figure 5 , Figure 5 This is a schematic diagram of a cache flushing system provided in an embodiment of this application.

[0091] This application provides a cache flushing system, which may include:

[0092] The first determining module 101 is used to determine the candidate threads for performing cache flushing, and the number of candidate threads is greater than or equal to 2.

[0093] The first filtering module 102 is used to filter out the target thread from the candidate threads;

[0094] The second determining module 103 is used to determine the target sub-hash table corresponding to the target thread;

[0095] The first control module 104 is used to control the target thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal.

[0096] The sub-hash table is used to store dirty data; and there is a one-to-one correspondence between candidate threads and sub-hash tables.

[0097] This application provides a cache flushing system, wherein the first filtering module may include:

[0098] The first filtering unit is used to filter out the initial thread for performing the cache flush operation from the candidate threads;

[0099] The first acquisition unit is used to acquire the busyness of the initial thread;

[0100] The first detection unit is used to detect whether the busyness of the initial thread is greater than the set busyness value; if the busyness of the initial thread is less than or equal to the set busyness value, the initial thread is determined as the target thread.

[0101] The first selection unit is used to select a candidate thread whose busyness is less than or equal to the set busyness value as a backup thread if the busyness of the initial thread is greater than the set busyness value, and to use the initial thread and the backup thread as the target thread.

[0102] This application provides a cache flushing system, wherein the second determining module may include:

[0103] The first setting unit is used to set the sub-hash table corresponding to the initial thread as the target sub-hash table;

[0104] The first control module may include:

[0105] The first control unit is configured to, in response to the target thread consisting only of the initial thread, control the initial thread to traverse the target sub-hash table and flush the dirty data obtained during the traversal.

[0106] The second control unit is used to control the backup thread to traverse the target sub-hash table and control the initial thread to flush the dirty data obtained from the traversal in response to the target thread including the initial thread and the backup thread.

[0107] This application provides a cache flushing system, in which a first filtering unit can be used to: obtain a cache flushing instruction; determine the target I / O to be processed by the cache flushing instruction; determine the offset address of the target I / O in the cache volume; and select an initial thread from candidate threads based on the offset address.

[0108] This application provides a cache flushing system, in which a first filtering unit can be used to: determine the total number of candidate threads; divide the cache volume equally to obtain a total number of sub-cache volumes; determine the sub-cache volume corresponding to each candidate thread; take the sub-cache volume where the offset address is located as the target sub-cache volume; and take the candidate thread corresponding to the target sub-cache volume as the initial thread.

[0109] This application provides a cache flushing system, wherein the first control module may include:

[0110] The first counting unit is used to count the nodes traversed by the target thread in the target sub-hash table to obtain the real-time count value;

[0111] The second detection unit is used to detect whether the real-time count value has reached the first set value; if the real-time count value has reached the first set value, the first quantity value containing dirty data nodes is determined, and the first ratio of the first quantity value to the first set value is calculated.

[0112] The third detection unit is used to detect whether the first ratio is less than the first proportion value; if the first ratio is greater than or equal to the first proportion value, the target thread is controlled to flush the dirty data obtained by traversal; if the first ratio is less than the first proportion value, the target thread is controlled to continue traversing the target sub-hash table and update the real-time count value.

[0113] The fourth detection unit is used to detect whether the real-time count value has reached the second set value; if the real-time count value has reached the second set value, the second quantity value containing dirty data nodes is determined, and the second ratio of the second quantity value to the second set value is calculated.

[0114] The fifth detection unit is used to detect whether the second ratio is less than the second proportion value; if the second ratio is greater than or equal to the second proportion value, the target thread is controlled to flush the dirty data obtained by traversal; if the second ratio is less than the second proportion value, the target thread is controlled to continue traversing the target sub-hash table and update the real-time count value; when the real-time count value reaches the third set value, the target thread is controlled to flush the dirty data obtained by traversal.

[0115] The cache flushing system provided in this application embodiment may further include:

[0116] The first detection module is used to detect whether the number of threads used to perform cache flushing is one before the first determination module determines the candidate threads for performing cache flushing; if the number of threads used to perform cache flushing is one, then select one thread from each processor core as a candidate thread; determine the hash table used to store dirty data, split the hash table, and obtain sub-hash tables that correspond one-to-one with the candidate threads.

[0117] This application also provides an electronic device and a computer-readable storage medium, both of which have the corresponding effects of the cache flushing method provided in the embodiments of this application. Please refer to... Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0118] An electronic device provided in this application includes a memory 201 and a processor 202. The memory 201 stores a computer program, and when the processor 202 executes the computer program, it implements the steps of the cache flushing method described in any of the above embodiments.

[0119] Please see Figure 7Another electronic device provided in this application embodiment may further include: an input port 203 connected to the processor 202 for transmitting commands input from the outside to the processor 202; a display unit 204 connected to the processor 202 for displaying the processing results of the processor 202 to the outside; and a communication module 205 connected to the processor 202 for realizing communication between the electronic device and the outside. The display unit 204 may be a display panel, a laser scanner, or the like; the communication method adopted by the communication module 205 includes, but is not limited to, Mobile High-Definition Link (MHL), Universal Serial Bus (USB), High-Definition Multimedia Interface (HDMI), wireless connectivity: Wireless Fidelity (WiFi), Bluetooth communication technology, Bluetooth Low Energy communication technology, and communication technology based on IEEE 802.11s.

[0120] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the steps of the cache flushing method described in any of the above embodiments.

[0121] The computer-readable storage media involved in this application include random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs (compact disc read-only memory), or any other form of storage media known in the art.

[0122] This application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the cache flushing method described in any of the above embodiments.

[0123] For descriptions of relevant parts in the cache flushing system, electronic device, computer-readable storage medium, and computer program product provided in this application's embodiments, please refer to the detailed description of the corresponding parts in the cache flushing method provided in this application's embodiments; they will not be repeated here. Furthermore, parts of the technical solutions provided in this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.

[0124] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0125] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method of underflushing a cache, the method comprising: The method comprises the following steps: determining a plurality of candidate threads for performing cache flushing, wherein the number of the candidate threads is greater than or equal to 2; selecting a target thread from the candidate threads; determining a target sub-hash table corresponding to the target thread; controlling the target thread to traverse the target sub-hash table and flush dirty data obtained through the traversal; wherein a sub-hash table is used to store dirty data, and the candidate threads correspond to the sub-hash tables one by one; wherein the step of selecting the target thread from the candidate threads comprises the following steps: selecting an initial thread for performing a cache flushing operation from the candidate threads; obtaining the busy degree of the initial thread; detecting whether the busy degree of the initial thread is greater than a set busy degree value; if the busy degree of the initial thread is less than or equal to the set busy degree value, determining the initial thread as the target thread; if the busy degree of the initial thread is greater than the set busy degree value, selecting a candidate thread with a busy degree less than or equal to the set busy degree value as a backup thread, and determining the initial thread and the backup thread as the target thread; wherein the step of determining the target sub-hash table corresponding to the target thread comprises the following step: determining a sub-hash table corresponding to the initial thread as the target sub-hash table; the step of controlling the target thread to traverse the target sub-hash table and flush dirty data obtained through the traversal comprises the following steps: in response to the target thread including only the initial thread, controlling the initial thread to traverse the target sub-hash table and flush dirty data obtained through the traversal; in response to the target thread including the initial thread and the backup thread, controlling the backup thread to traverse the target sub-hash table and controlling the initial thread to flush dirty data obtained through the traversal.

2. The method of claim 1, wherein, the step of selecting the initial thread for performing a cache flushing operation from the candidate threads comprises the following steps: obtaining a cache flushing instruction; determining a target IO required to be processed by the cache flushing instruction; determining the offset address of the target IO in a cache volume; selecting the initial thread from the candidate threads according to the offset address.

3. The method of claim 2, wherein, the step of selecting the initial thread from the candidate threads according to the offset address comprises the following steps: determining the total number of the candidate threads; equally dividing the cache volume to obtain a total number of sub-cache volumes; determining that each of the candidate threads corresponds to a sub-cache volume one by one; determining the sub-cache volume in which the offset address is located as a target sub-cache volume; determining the candidate thread corresponding to the target sub-cache volume as the initial thread.

4. The method of claim 1, wherein, the step of controlling the target thread to traverse the target sub-hash table and flush dirty data obtained through the traversal comprises the following steps: counting the nodes traversed by the target thread in the target sub-hash table to obtain a real-time count value; detecting whether the real-time count value reaches a first set value; if the real-time count value reaches the first set value, determining a first number of nodes containing dirty data, and calculating a first ratio of the first number to the first set value; detecting whether the first ratio is less than a first ratio value; If the first ratio value is greater than or equal to the first ratio value, the target thread is controlled to flush the dirty data obtained through traversal; If the first ratio value is less than the first ratio value, the target thread is controlled to continue to traverse the target sub-hash table and update the real-time count value; It is detected whether the real-time count value reaches a second set value; If the real-time count value reaches the second set value, a second quantity value containing dirty data node is determined, and a second ratio value of the second quantity value and the second set value is calculated; It is detected whether the second ratio value is less than a second ratio value; If the second ratio value is greater than or equal to the second ratio value, the target thread is controlled to flush the dirty data obtained through traversal; If the second ratio value is less than the second ratio value, the target thread is controlled to continue to traverse the target sub-hash table and update the real-time count value; and when the real-time count value reaches a third set value, the target thread is controlled to flush the dirty data obtained through traversal.

5. The method of claim 1, wherein, Before the candidate thread for performing cache flushing is determined, the method further includes: It is detected whether the number of threads for performing cache flushing is one; If the number of threads for performing cache flushing is one, a thread is selected as the candidate thread in each processor core; A hash table for storing dirty data is determined, and the hash table is split to obtain a sub-hash table corresponding to the candidate thread.

6. A system for caching underbrush, characterized by It includes: A first determination module is configured to determine a candidate thread for performing cache flushing, and the number of candidate threads is greater than or equal to 2; A first screening module is configured to screen a target thread from the candidate thread; A second determination module is configured to determine a target sub-hash table corresponding to the target thread; A first control module is configured to control the target thread to traverse the target sub-hash table and flush the dirty data obtained through traversal; Wherein, the sub-hash table is used for storing dirty data; and the candidate thread and the sub-hash table correspond to each other; The first screening module includes: A first screening unit is configured to screen an initial thread for performing a cache flushing operation from the candidate thread; A first acquisition unit is configured to acquire the busy degree of the initial thread; A first detection unit is configured to detect whether the busy degree of the initial thread is greater than a set busy degree value; if the busy degree of the initial thread is less than or equal to the set busy degree value, the initial thread is determined as the target thread; A first selection unit is configured to select a candidate thread with a busy degree less than or equal to the set busy degree value as a backup thread if the busy degree of the initial thread is greater than the set busy degree value, and the initial thread and the backup thread are used as the target thread; The second determination module includes: A first setting unit is configured to set the sub-hash table corresponding to the initial thread as the target sub-hash table; The first control module includes: A first control unit is configured to control the initial thread to traverse the target sub-hash table and flush the dirty data obtained through traversal in response to the target thread including only the initial thread. A second control unit is configured to control the standby thread to traverse the target sub-hash table and control the initial thread to flush the dirty data obtained by the traversal, in response to the target thread comprising the initial thread and the standby thread.

7. An electronic device, comprising: The application also provides a computer readable storage medium having stored therein a computer program, wherein the computer program is executed by a processor to implement the steps of the cache flushing method according to any one of claims 1 to 5. The application also provides a computer readable storage medium having stored therein a computer program, wherein the computer program is executed by a processor to implement the steps of the cache flushing method according to any one of claims 1 to 5. The application also provides a computer readable storage medium having stored therein a computer program, wherein the computer program is executed by a processor to implement the steps of the cache flushing method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

  • Method and system for controlling SSD cache brushing-down speed in distributed storage system

    CN111857589A

  • TLB table item management method and device and storage medium

    CN114676073A