Cache refreshing method, system and equipment and computer readable storage medium

By processing cached brushing in parallel with multi-threading, candidate threads correspond to sub-hash tables one by one, solving the problem of low cache brushing efficiency in the existing technology, realizing rapid brushing and improving user experience.

CN119248671AActive Publication Date: 2025-01-03INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411314013.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2025-01-03
Estimated Expiration
2044-09-20

AI Technical Summary

Technical Problem

In the prior art, the buffering efficiency is low, and single thread processing of single hash tables is time-consuming, affecting the user experience.

Method used

Through multi-thread parallel processing, candidate threads correspond to the sub hash table one by one, filter the target thread and control it to traverse and brush the target sub hash table to avoid the accumulation of brushing tasks in a single thread.

Benefits of technology

Improve the efficiency of cache brushing, realize rapid brushing, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248671A_ABST
    Figure CN119248671A_ABST
Patent Text Reader

Abstract

The invention discloses a cache downrefreshing method, system and device and a computer readable storage medium, and relates to the technical field of storage, candidate threads used for executing cache downrefreshing are determined, and the number of the candidate threads is larger than or equal to 2; screening out a target thread from the candidate threads; determining a target sub-hash table corresponding to the target thread; the target thread is controlled to traverse the target sub hash table, and dirty data obtained through traversal is downbrushed; wherein the sub hash table is used for storing dirty data; the candidate threads are in one-to-one correspondence with the sub hash tables. According to the method, the sub hash tables are set to store the dirty data, the candidate threads are in one-to-one correspondence with the sub hash tables, and the number of the candidate threads is larger than or equal to 2, so that each candidate thread can brush the dirty data in the sub hash table corresponding to the candidate thread, and compared with an existing scheme that the dirty data are brushed through a single hash table and a single thread, the dirty data can be brushed by the candidate threads, and the dirty data can be brushed by the candidate threads. According to the method, the downbrushing efficiency of the dirty data is improved, the function of quickly performing cache downbrushing is realized, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Currently, dirty data cached in servers and other devices needs to be flushed according to demand. For example, when starting snapshots, closing caches, deleting nodes, and other command line operations, all cached dirty data needs to be flushed before continuing. Therefore, the speed of flushing dirty data will affect the speed of command line execution, which in turn affects the user experience. Dirty data in the cache is stored in a data structure such as a hash table. To flush dirty data, the hash table needs to be traversed first, and the dirty data needs to be found and then flushed. Only a single thread can process a single hash table, which takes a long time and has low cache flushing efficiency.

[0003] In summary, how to quickly flush the cache is a problem that currently needs to be solved urgently by those skilled in the art. Summary of the invention

[0004] The purpose of the present 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. The present application also provides a cache flushing system, an electronic device and a computer-readable storage medium.

[0005] In order to achieve the above objectives, this application provides the following technical solutions:

[0006] A cache flushing method, comprising:

[0007] Determine candidate threads for executing cache flush, where the number of candidate threads is greater than or equal to 2;

[0008] Screening out a target thread from among the candidate threads;

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

[0010] Control the target thread to traverse the target sub-hash table, and flush the dirty data obtained by the traversal;

[0011] The sub-hash table is used to store dirty data; and the candidate threads correspond to the sub-hash tables one by one.

[0012] In an exemplary embodiment, screening out a target thread from the candidate threads includes:

[0013] Screening out an initial thread for performing a cache flush operation from among the candidate threads;

[0014] Obtaining the busyness of the initial thread;

[0015] Detecting whether the busyness of the initial thread is greater than a set busyness value;

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

[0017] If the busyness of the initial thread is greater than the set busyness value, a candidate thread whose busyness is 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 threads.

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

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

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

[0021] In response to the target thread only including the initial thread, controlling the initial thread to traverse the target sub-hash table and flushing dirty data obtained by the traversal;

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

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

[0024] Get the cache flush instruction;

[0025] Determine the target IO that needs to be processed by the cache flush instruction;

[0026] Determine the offset address of the target IO in the cache volume;

[0027] The initial thread is selected from the candidate threads according to the offset address.

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

[0029] Determining the total number of candidate threads;

[0030] Evenly divide the cache volume to obtain the total number of sub-cache volumes;

[0031] Determine the sub-cache volumes corresponding to the candidate threads one by one;

[0032] Taking the sub-cache volume at the offset address as the target sub-cache volume;

[0033] The candidate thread corresponding to the target sub-cache 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 by the traversal includes:

[0035] Counting the nodes traversed by the target thread in the target sub-hash table to obtain a real-time count value;

[0036] Detecting whether the real-time count value reaches a first set value;

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

[0038] detecting whether the first ratio is less than a first ratio value;

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

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

[0041] Detecting whether the real-time count value reaches a second set value;

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

[0043] detecting whether the second ratio is less than a second ratio value;

[0044] If the second ratio is greater than or equal to the second ratio, controlling the target thread to flush the traversed dirty data;

[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 a third set value, the target thread is controlled to flush the dirty data obtained by the traversal.

[0046] In an exemplary embodiment, before determining the candidate thread for executing cache flush, the method further includes:

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

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

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

[0050] A cache flushing system, comprising:

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

[0052] A first screening module, used for screening out a target thread from the candidate threads;

[0053] A second determination module, used to determine a target sub-hash table corresponding to the target thread;

[0054] A first control module, used to control the target thread to traverse the target sub-hash table and flush dirty data obtained by the traversal;

[0055] The sub-hash table is used to store dirty data; and the candidate threads correspond to the sub-hash tables one by one.

[0056] An electronic device, comprising:

[0057] Memory for storing computer programs;

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

[0059] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the cache flushing methods described above are implemented.

[0060] The present application provides a cache flushing method, which determines the candidate threads for executing cache flushing, and the number of candidate threads is greater than or equal to 2; among the candidate threads, the target thread is screened out; the target sub-hash table corresponding to the target thread is determined; the target thread is controlled to traverse the target sub-hash table, and the dirty data obtained by the traversal is flushed; wherein the sub-hash table is used to store dirty data; and the candidate thread corresponds to the sub-hash table one by one. In the present application, a sub-hash table is set to store dirty data, and the candidate thread corresponds to the sub-hash table one by one, and the number of candidate threads is greater than or equal to 2. In this way, each candidate thread can flush dirty data according to its corresponding sub-hash table. Compared with the existing scheme of flushing dirty data through a single thread and a single hash table, the present application can flush dirty data through multiple threads in parallel, avoiding the accumulation of flushing tasks in a single thread, improving the flushing efficiency of dirty data, and realizing the rapid cache flushing function, thereby improving the user experience. The cache flushing system, electronic device and computer-readable storage medium provided by the present application also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

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

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

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

[0065] Figure 4 Schematic diagram of the relationship between candidate threads and sub-hash tables;

[0066] Figure 5 A schematic diagram of the structure of a cache flushing system provided in an embodiment of the present application;

[0067] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0068] Figure 7 Another structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0070] See also Figure 1 , Figure 1 A flowchart of a cache flushing method provided in an embodiment of the present application.

[0071] A cache flushing method provided in an embodiment of the present application may include the following steps:

[0072] Step S101: determining candidate threads for executing cache flushing, where the number of candidate threads is greater than or equal to 2.

[0073] In actual applications, multiple candidate threads for performing cache flushing operations may be set in the server, so that dirty data in the server cache may be flushed in parallel with the help of multiple candidate threads.

[0074] It should be noted that the more candidate threads there are, the higher the performance consumption for cache flushing. Therefore, the number of candidate threads can be flexibly determined according to the performance allocation requirements of the server. Of course, there can also be 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 a 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 by the traversal; wherein the sub-hash table is used to store dirty data; and the candidate threads correspond to the sub-hash tables one by one.

[0078] In actual applications, cache flushing is affected by operations such as starting snapshots, closing caches, and deleting nodes, and the dirty data that needs to be flushed for specific operations is specific dirty data. Since the dirty data processed by the candidate threads that perform cache flushing operations are different, it is necessary to screen out 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 by the traversal. It should be noted that the candidate threads in this application correspond one-to-one to the sub-hash tables, and the sub-hash tables are used to store dirty data, and the dirty data stored in each sub-hash table is different. In this way, the process of each candidate thread processing the sub-hash table is independent of each other, and there is no situation where multiple threads traverse the same sub-hash table. In other words, the candidate threads can process the sub-hash tables in parallel.

[0079] In a specific application scenario, in the process of selecting a target thread from candidate threads, the candidate thread that processes dirty data to be flushed can be directly used as the target thread. This method is simple and direct, but considering that the dirty data stored on each sub-hash table may be different, and the performance pressure of each candidate thread is different, in order to avoid excessive performance pressure of a single candidate thread affecting the cache flushing efficiency, the initial thread used to perform the cache flushing operation can be selected from the candidate threads; the busyness of the initial thread is obtained; whether the busyness of the initial thread is greater than the set busyness value is detected; 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; if the busyness of the initial thread is greater than the set busyness value, a candidate thread whose busyness is 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 target threads to share the performance pressure of the initial thread with the help of the backup thread. Among them, the set busyness value can be a CPU (Central Processing Unit) utilization rate of 95% and 50 tasks waiting to be executed on the thread, etc., which can be flexibly determined according to the application scenario.

[0080] In a specific application scenario, because the initial thread is used to perform cache flushing operations, and the backup thread is used to share the performance pressure of the initial thread, the target thread essentially performs cache flushing on the sub-hash table corresponding to the initial thread. Therefore, in the process of 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 the process of controlling the target thread to traverse the target sub-hash table and flushing the dirty data obtained by the traversal, in response to the target thread only including the initial thread, the initial thread is controlled to traverse the target sub-hash table and flush the dirty data obtained by the traversal; 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 by the traversal. At this time, 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, and the performance pressure is reduced.

[0081] In a specific application scenario, when selecting the initial thread for performing the cache flush operation from the candidate threads, when flushing all dirty data, all candidate threads can be used as the initial threads; when only part of the dirty data is flushed, the cache flush instruction can be obtained first; when the cache flush instruction specifies a specific IO, the target IO (Input / Output) to be processed by the cache flush instruction can be determined, and the offset address of the target IO in the cache volume can be determined; finally, the initial thread is selected from the candidate threads according to the offset address. The initial thread can be selected with the help of the user's cache flush instruction. And in the process of selecting the initial thread among the candidate threads according to the offset address, 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 volumes corresponding to each candidate thread are determined; the sub-cache volume at the offset address is used as the target sub-cache volume; the candidate thread corresponding to the target sub-cache volume is used as the initial thread, so that each candidate thread needs to process the same sub-cache volume size, the same maximum amount of dirty data to be processed, and the same maximum amount of dirty data stored in each sub-hash table, which is convenient for achieving load balancing among candidate threads.

[0082] In actual applications, when controlling the target thread to traverse the target sub-hash table and flushing the dirty data obtained by the traversal, because each traversal of the target sub-hash table starts from the beginning, and the dirty data may be stored at the end of the target sub-hash table, then due to the limitation of the traversal time, there will be too little dirty data obtained in each traversal. For example, each time 20 nodes in the sub-hash table are traversed, the node is a hash table node storing dirty data. If the total number of nodes in the sub-hash table is greater than 20 and the dirty data is mainly stored in the nodes exceeding 20, there will be too little dirty data obtained in the traversal, affecting the cache flushing efficiency. In order to avoid this situation, the nodes traversed by the target thread in the target sub-hash table can be counted to obtain a real-time count value; detect whether the real-time count value reaches a first set value; if the real-time count value reaches the first set value, determine the first number value of the node containing dirty data, and count Calculate a first ratio of a first quantity value to a first set value; detect whether the first ratio is less than the first ratio value; if the first ratio is greater than or equal to the first ratio value, control the target thread to flush the dirty data obtained by traversal; if the first ratio is less than the first ratio value, control the target thread to continue traversing the target sub-hash table and update the real-time count value; detect whether the real-time count value reaches a second set value; if the real-time count value reaches the second set value, determine a second quantity value of nodes containing dirty data, calculate a second ratio of the second quantity value to the second set value; detect whether the second ratio is less than the second ratio value; if the second ratio is greater than or equal to the second ratio value, control the target thread to flush the dirty data obtained by traversal; if the second ratio is less than the second ratio 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 by traversal.

[0083] From this implementation process, it can be seen that the present 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 of the node containing dirty data is determined, a first ratio of the first quantity value to the first set value is calculated, and whether the first ratio is less than the first ratio value is detected. If the first ratio is greater than or equal to the first ratio value, the target thread is controlled to flush the dirty data obtained through the traversal. Since the first ratio represents the validity of the dirty data obtained through the traversal, and the first ratio value is equivalent to the data volume setting value for the dirty data, it can be ensured that the nodes of the first set value are traversed and the dirty data obtained through the traversal meet the set data volume, so as to ensure that the data volume of the dirty data flushed from the cache meets the requirements and improve the cache flushing efficiency; and when the first ratio is less than the first ratio value, the target thread is continued to be controlled to continue traversing the target sub-hash table and update the real-time count value. At this time, if the real-time count value reaches the second set value, the first node containing the dirty data is determined. A second quantity value is calculated, a second ratio of the second quantity value to the second set value is calculated, and whether the second ratio is less than the second ratio value is detected. If the second ratio is greater than or equal to the second ratio value, the target thread is controlled to flush the dirty data obtained by the traversal, so that when the node of the first set value is traversed and the dirty data obtained by the traversal does not meet the set data amount, the dirty data amount is expanded by continuing to traverse the node; thereafter, when the second ratio 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. When the real-time count value reaches the third set value, the target thread is controlled to flush the dirty data obtained by the traversal. At this time, three rounds of operations to expand the number of nodes traversed are performed. It can be considered that the dirty data obtained by the traversal has met the requirements, and the time for the target thread to traverse the target sub-hash table is long, and the performance consumption is high. After comprehensively considering the dirty data amount and performance consumption, the dirty data obtained by the traversal can be directly flushed to achieve a balance between cache 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 the present 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. The first set value can also 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 a specific application scenario, considering that the specific values ​​of the first set value, the second set value, and the third set value will affect the performance consumption of the target thread, the specific values ​​of the first set value, the second set value, and the third set value can be flexibly set according to the performance consumption of the target thread. For example, in the process of counting the nodes obtained by the target thread traversing the target sub-hash table to obtain the real-time count value, the real-time duration of the target thread traversing the target sub-hash table can also be accumulated. After each real-time count value and the corresponding real-time duration are obtained, the growth rate of the real-time duration with the real-time count value is calculated. This growth rate can be an increase of 1 hour for the real-time count value. The growth amount of the real-time duration, etc. When the real-time duration is just greater than half of the maximum traversal duration of the target thread, the maximum traversal duration is determined according to the maximum performance consumption of the target thread, and whether the growth rate has jumped is detected. If not, the real-time count value is doubled to obtain the first set value. If so, the real-time count value is increased by 0.6 times to obtain the first set value. After that, 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 smaller, such as 2, 3, etc.

[0086] From this implementation process, it can be seen that in the process of counting the nodes obtained by the target thread traversing the target sub-hash table, the real-time duration of the target thread traversing the target sub-hash table will also be accumulated. Since the maximum traversal duration is determined according to 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 large. At this time, it can be detected whether the growth rate has jumped. If not, it indicates that the time taken to traverse the node each time is close. At this time, each node has no dirty data or has dirty data. The real-time count value can be doubled to obtain the first set value; if so, it indicates that the node changes from no dirty data at the beginning to dirty data, and then the time to traverse each node will increase, and the target thread will quickly obtain the maximum performance consumption. At this time, the real-time count value can be expanded by 0.6 times 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 value reaches the first set value, the target thread basically reaches the maximum performance consumption, so that the target thread can traverse the node according to the maximum performance consumption, thereby increasing the amount of dirty data obtained by the traversal, and thus improving the cache flushing efficiency.

[0087] In actual applications, considering that the server generally uses a single thread to flush the cache and a single hash table to store dirty data, such as Figure 2As shown, at this time, the candidate threads can be obtained by expanding the number of threads, and the hash table can be split to obtain the sub-hash table, that is, before determining the candidate thread for executing the cache flush, it can also be detected whether the number of threads for executing the cache flush is one; if the number of threads for executing the cache flush is one, then a thread is selected from each processor core as the candidate thread. At this time, the candidate threads correspond to the processor cores one-to-one, and one candidate thread can only be executed on one processor core, and one processor core can only execute one candidate thread to perform the cache flush; determine the hash table for storing dirty data, split the hash table, and obtain the sub-hash tables corresponding to the candidate threads one-to-one. In this process, the total number of candidate threads can be counted, and the maximum capacity of the hash table is divided by the total number to obtain the maximum capacity of each sub-hash table. The hash table can be split according to this maximum capacity, as shown in FIG. Figure 3 As shown, the relationship between the sub-hash table and the candidate thread is as follows Figure 4 It should be noted that after the hash table is split to obtain sub-hash tables, the sub-hash tables can be directly used to store and flush dirty data. In addition, when the hash table is empty due to operations such as the server just starting to work or initialization, the candidate threads can be directly selected, and then corresponding sub-hash tables can be created for each candidate thread, so as to directly obtain the sub-hash tables corresponding to each candidate thread by creation.

[0088] It should also be noted that the existing process of storing dirty data in the hash table is as follows: calculate the key value based on each IO's own volume ID and lba (Logical Block Address), and then choose which row of the hash table to put it in based on the key value. After choosing which row, put the IO at the end of the linked list of the node linked list of that row. Based on this operation, when the cache volume is divided into sub-cache volumes and the sub-cache volumes correspond to candidate threads one by one, the process of storing dirty data in this application can be as follows: determine the corresponding initial thread based on the offset address of the IO itself in the cache volume, deliver the IO to the initial thread for processing, the initial thread calculates the key value based on the IO's volume ID and lba, and chooses which row of the target sub-hash table to put it in based on the key value. After choosing which row, put the IO at the end of the linked list of the node linked list of that row. On this basis, the dirty data of a specific IO can also be flushed according to the dirty data storage method. For example, the dirty data that the user needs to flush is determined, the sub-hash table storing the dirty data is determined as the target sub-hash table, the candidate thread corresponding to the target sub-hash table is used as the target thread, the target thread is controlled to traverse the target sub-hash table, and the dirty data obtained by the traversal is flushed.

[0089] The present application provides a cache flushing method, which determines the candidate threads for executing cache flushing, and the number of candidate threads is greater than or equal to 2; among the candidate threads, the target thread is screened out; the target sub-hash table corresponding to the target thread is determined; the target thread is controlled to traverse the target sub-hash table, and the dirty data obtained by the traversal is flushed; wherein the sub-hash table is used to store dirty data; and the candidate threads correspond to the sub-hash table one-to-one. In the present application, a sub-hash table is set to store dirty data, and the candidate threads correspond to the sub-hash table one-to-one, and the number of candidate threads is greater than or equal to 2. In this way, each candidate thread can flush dirty data according to its corresponding sub-hash table. Compared with the existing scheme of flushing dirty data through a single thread and a single hash table, the present application can flush dirty data through multiple threads in parallel, avoiding the accumulation of flushing tasks in a single thread, improving the flushing efficiency of dirty data, and realizing the fast cache flushing function, thereby improving the user experience.

[0090] See also Figure 5 , Figure 5 A schematic diagram of the structure of a cache flushing system provided in an embodiment of the present application.

[0091] A cache flushing system provided in an embodiment of the present application may include:

[0092] A first determination module 101 is used to determine candidate threads for performing cache flushing, where the number of candidate threads is greater than or equal to 2;

[0093] A first screening module 102 is used to screen out a target thread from candidate threads;

[0094] A second determination module 103, used to determine a target sub-hash table corresponding to a target thread;

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

[0096] The sub-hash table is used to store dirty data; and the candidate threads correspond to the sub-hash tables one by one.

[0097] In a cache flushing system provided by an embodiment of the present application, a first screening module may include:

[0098] A first screening unit is used to screen out an initial thread for performing a cache flush operation from candidate threads;

[0099] A first acquisition unit, used to acquire the busyness of an initial thread;

[0100] A first detection unit is used to detect 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, the initial thread is determined as a 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 use the initial thread and the backup thread as target threads.

[0102] In a cache flushing system provided by an embodiment of the present application, the second determining module may include:

[0103] A first setting unit, configured to use the sub-hash table corresponding to the initial thread as the target sub-hash table;

[0104] The first control module may include:

[0105] A first control unit, configured to control the initial thread to traverse the target sub-hash table in response to the target thread only including the initial thread, and to flush dirty data obtained by the traversal;

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

[0107] In a cache flushing system provided by an embodiment of the present application, a first screening unit can be used to: obtain a cache flushing instruction; determine a target IO to be processed by the cache flushing instruction; determine an offset address of the target IO in the cache volume; and select an initial thread from candidate threads according to the offset address.

[0108] In a cache flushing system provided by an embodiment of the present application, a first screening unit can be used to: determine the total number of candidate threads; evenly divide the cache volume to obtain a total number of sub-cache volumes; determine the sub-cache volumes corresponding to each candidate thread; use the sub-cache volume at the offset address as the target sub-cache volume; and use the candidate thread corresponding to the target sub-cache volume as the initial thread.

[0109] In a cache flushing system provided in an embodiment of the present application, a 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 a real-time count value;

[0111] A second detection unit is used to detect whether the real-time count value reaches a first set value; if the real-time count value reaches the first set value, a first number value of nodes containing dirty data is determined, and a first ratio of the first number value to the first set value is calculated;

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

[0113] a fourth detection unit, configured to detect whether the real-time count value reaches a second set value; if the real-time count value reaches the second set value, determining a second quantity value of nodes containing dirty data, and calculating a second ratio of the second quantity value to the second set value;

[0114] The fifth detection unit is used to detect whether the second ratio is less than the second ratio value; if the second ratio is greater than or equal to the second ratio value, the target thread is controlled to flush the dirty data obtained by the traversal; if the second ratio is less than the second ratio 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 by the traversal.

[0115] A cache flushing system provided in an embodiment of the present application may further include:

[0116] The first detection module is used to detect whether the number of threads for executing cache flushing is one before the first determination module determines the candidate thread for executing cache flushing; if the number of threads for executing cache flushing is one, a thread is selected from each processor core as a candidate thread; a hash table for storing dirty data is determined, and the hash table is split to obtain sub-hash tables corresponding to the candidate threads one by one.

[0117] The present 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 embodiment of the present application. Figure 6 , Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0118] An electronic device provided in an embodiment of the present application includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the steps of the cache flushing method described in any of the above embodiments are implemented.

[0119] See also Figure 7, another electronic device provided in the embodiment of the present application may also 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; a communication module 205 connected to the processor 202, for realizing communication between the electronic device and the outside. The display unit 204 can be a display panel, a laser scanning display, etc.; the communication method adopted by the communication module 205 includes but is not limited to mobile high-definition link technology (Mobile High-Definition Link, MHL), Universal Serial Bus (Universal Serial Bus, USB), High-Definition Multimedia Interface (High-Definition Multimedia Interface, HDMI), wireless connection: wireless fidelity technology (WIreless Fidelity, WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.

[0120] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the cache flushing method described in any of the above embodiments are implemented.

[0121] The computer-readable storage medium involved in this application includes random access memory (RAM), internal 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 medium known in the technical field.

[0122] A computer program product provided in an embodiment of the present application includes 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 the description of the relevant parts of a cache flushing system, electronic device, computer-readable storage medium, and computer program product provided in the embodiments of the present application, please refer to the detailed description of the corresponding parts in a cache flushing method provided in the embodiments of the present application, which will not be repeated here. In addition, the parts of the above technical solutions provided in the embodiments of the present application that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.

[0124] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0125] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be 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 the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A cache flushing method, characterized in that: include: Determine candidate threads for executing cache flush, where the number of candidate threads is greater than or equal to 2; Screening out a target thread from among the candidate threads; Determine a target sub-hash table corresponding to the target thread; Control the target thread to traverse the target sub-hash table, and flush the dirty data obtained by the traversal; The sub-hash table is used to store dirty data; and the candidate threads correspond to the sub-hash tables one by one.

2. The method according to claim 1, characterized in that The step of selecting a target thread from the candidate threads includes: Screening out an initial thread for performing a cache flush operation from among the candidate threads; Obtaining the busyness of the initial thread; Detecting 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, determining the initial thread as the target thread; If the busyness of the initial thread is greater than the set busyness value, a candidate thread whose busyness is 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 threads.

3. The method according to claim 2, characterized in that The determining the target sub-hash table corresponding to the target thread includes: Using the sub-hash table corresponding to the initial thread as the target sub-hash table; The controlling the target thread to traverse the target sub-hash table and flushing the dirty data obtained by the traversal includes: In response to the target thread only including the initial thread, controlling the initial thread to traverse the target sub-hash table and flushing dirty data obtained by the traversal; In response to the target thread including the initial thread and the standby thread, the standby thread is controlled to traverse the target sub-hash table, and the initial thread is controlled to flush dirty data obtained by the traversal.

4. The method according to claim 2, characterized in that: The step of selecting an initial thread for performing a cache flush operation from the candidate threads includes: Get the cache flush instruction; Determine the target IO that needs to be processed by the cache flush instruction; Determine the offset address of the target IO in the cache volume; The initial thread is selected from the candidate threads according to the offset address.

5. The method according to claim 4, characterized in that The step of selecting the initial thread from the candidate threads according to the offset address includes: Determining the total number of candidate threads; Evenly divide the cache volume to obtain the total number of sub-cache volumes; Determine the sub-cache volumes corresponding to the candidate threads one by one; Taking the sub-cache volume at the offset address as the target sub-cache volume; The candidate thread corresponding to the target sub-cache volume is used as the initial thread.

6. The method according to claim 1, characterized in that The controlling the target thread to traverse the target sub-hash table and flushing the dirty data obtained by the traversal includes: 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, a first quantity value of nodes containing dirty data is determined, and a first ratio of the first quantity value to the first set value is calculated; detecting whether the first ratio is less than a first ratio value; If the first ratio is greater than or equal to the first ratio value, controlling the target thread to flush the dirty data obtained through traversal; If the first ratio is less than the first proportion value, controlling the target thread to continue traversing the target sub-hash table and updating the real-time count value; Detecting whether the real-time count value reaches a second set value; If the real-time count value reaches the second set value, a second number value of nodes containing dirty data is determined, and a second ratio of the second number value to the second set value is calculated; detecting whether the second ratio is less than a second ratio value; If the second ratio is greater than or equal to the second ratio, controlling the target thread to flush the traversed dirty data; 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 a third set value, the target thread is controlled to flush the dirty data obtained by the traversal.

7. The method according to claim 1, characterized in that Before determining the candidate thread for executing cache flush, the method further includes: Check whether the number of threads used to perform cache flushing is one; If the number of threads used to execute cache flushing is one, then one thread is selected from each processor core as the candidate thread; A hash table for storing dirty data is determined, and the hash table is split to obtain sub-hash tables corresponding to the candidate threads one by one.

8. A cache flushing system, characterized in that: include: A first determination module, used to determine candidate threads for performing cache flushing, where the number of the candidate threads is greater than or equal to 2; A first screening module, used for screening out a target thread from the candidate threads; A second determining module, used to determine a target sub-hash table corresponding to the target thread; A first control module, used to control the target thread to traverse the target sub-hash table and flush dirty data obtained by the traversal; The sub-hash table is used to store dirty data; and the candidate threads correspond to the sub-hash tables one by one.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the cache flushing method as claimed in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the cache flushing method according to any one of claims 1 to 7 are implemented.

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

  • Data flashing method and device, cache equipment and storage medium

    CN117591015A

  • Cache processing method and device, computer equipment and storage medium

    CN117992366A

  • Storage I / O path partitioning to eliminate I / O interference in consolidated servers

    US20140310473A1