Cache management system and method
By introducing cache line management module and storage module in the cache management system, using lock units, waiting queues and dirty cache line queues to manage cache line status, the problems of delay and memory usage under hash linked list management are solved, and the problem of large amount of time and memory usage is realized More efficient IO operation and parallelism.
Patent Information
- Application Number
- CN202411209012.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2024-12-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
There are long delays and additional memory usage problems when existing hash linked lists manage caches, resulting in insufficient IO delays and IOPS capabilities.
A cache management system is designed, including cache line management module and storage module. Through locking units, waiting queues and dirty cache line queues, the status information of cache line is managed, frequent interactions with memory are reduced, and the utilization efficiency of cache line is improved. And optimize read and write operations through read-preview windows and data mapping units.
Reduces IO delay, improves IOPS capabilities, reduces the use of memory mutexes, allows multiple input and output requests to operate cache lines simultaneously, and improves parallelism.
Smart Images

Figure CN119065989A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a cache management system and method. Background Art
[0002] In order to reduce IO latency and improve IOPS (Input / Output Operations Per Second), a hash table is currently commonly used to manage cache. However, hash table management consumes a lot of time and additional memory, resulting in a long latency. Summary of the invention
[0003] In view of the above problems, an embodiment of the present invention provides a cache management system and method for solving the problems in the prior art that cache management has a long delay and requires additional memory.
[0004] According to one aspect of an embodiment of the present invention, a cache management system is provided, the system comprising:
[0005] A cache line management module and a storage module; the cache line management module and the storage module are in communication connection;
[0006] The cache line management module is used to respond to the received input and output requests, and based on the input and output requests, operate the cache line corresponding to the input and output requests, and send operation instructions to the storage module; the storage module is used to perform the operation corresponding to the operation instruction on the storage data corresponding to the operation instruction; the operation instruction includes reading data and writing data;
[0007] The cache line management module includes a lock unit, a waiting queue and a dirty cache line queue; the lock unit is used to store the status information of the cache line, and the status information includes the occupied state and the idle state; the waiting queue is used to store the input and output requests of the corresponding cache line in the occupied state; if the corresponding cache line is in the idle state, the input and output requests stored in the waiting queue are taken out and awakened; the dirty cache line queue is used to arrange and store the dirty cache lines in the access order.
[0008] In an optional implementation, the storage module includes an off-chip storage unit and an on-chip storage unit; the on-chip storage unit and the off-chip storage unit are communicatively connected;
[0009] The data in the dirty cache line in the dirty cache line queue corresponds to the storage data in the on-chip storage unit; the storage data in the off-chip storage unit is the data corresponding to the released dirty cache line;
[0010] If the number of dirty cache lines in the dirty cache line queue exceeds a preset number, the cache line management module releases the dirty cache lines in the dirty cache line queue and stores data corresponding to the dirty cache lines in the dirty cache line queue from the on-chip storage unit to the off-chip storage unit.
[0011] In an optional embodiment, the cache line management module also includes a pre-read window unit; the pre-read window unit is used to create a pre-read window or extend the window length of the pre-read window when a read command is received, and the pre-read window is used to represent the data range that the on-chip storage unit extends to read from the off-chip storage unit.
[0012] In an optional implementation, the cache line management module further includes a data mapping unit;
[0013] The data mapping unit is used to store data mapping information; the data mapping information corresponds to the cache line one by one.
[0014] According to another aspect of an embodiment of the present invention, a cache management method is provided, which can be applied to any of the above cache management systems, and the method includes:
[0015] Obtain the current request and determine the target cache line corresponding to the current request; the current request is the input and output request that is currently arbitrated;
[0016] Based on the operation type of the current request on the target cache line, or based on the operation type and the state information of the target cache line, determine and execute the operation on the current request and the target cache line; the state information is obtained from the lock unit; the operation on the current request includes executing the current request, returning the response information of the current request, and placing the current request in a waiting queue; the operation on the target cache line includes allocating the target cache line, releasing the target cache line, and placing the target cache line in a dirty cache line queue;
[0017] If the current request is executed, an operation on the storage module and / or the target cache line is determined and executed based on the current request.
[0018] In an optional implementation, determining and executing an operation on a current request and a target cache line based on the operation type and the state information of the target cache line includes:
[0019] If the operation type is to apply for a cache line, then the data mapping information corresponding to the target cache line is searched in the data mapping unit;
[0020] If data mapping information corresponding to the target cache line exists in the data mapping unit, then the state information of the target cache line is obtained;
[0021] If the state information is an idle state, or the data mapping information corresponding to the target cache line does not exist in the data mapping unit, the target cache line is allocated to the current request;
[0022] Execute the current request, update the data mapping information corresponding to the target cache line in the data mapping unit, and change the state information of the target cache line to an occupied state.
[0023] In an optional implementation, after acquiring the state information of the target cache line, the method further includes:
[0024] If the status information is occupied, the current request is placed in a waiting queue until the status information changes from occupied to idle, and the current request is taken out of the waiting queue.
[0025] In an optional implementation, based on the operation type, determining and executing the operation on the current request and the target cache line includes:
[0026] If the operation type is to release the cache line, then searching the data mapping information corresponding to the target cache line in the data mapping unit;
[0027] If data mapping information corresponding to the target cache line exists in the data mapping unit, it is determined that the target cache line is released successfully;
[0028] Return the response information of the current request, change the status information of the target cache line to the idle state, and take out the input and output requests from the waiting queue;
[0029] If the target cache line is a dirty cache line, the target cache line is placed in a dirty cache line queue.
[0030] In an optional embodiment, the method further includes:
[0031] If the number of dirty cache lines in the dirty cache line queue exceeds a preset number, taking out multiple dirty cache lines in the dirty cache line queue and sorting the multiple dirty cache lines;
[0032] If the sorted multiple dirty cache lines are continuous dirty cache lines, the multiple dirty cache lines are aggregated to obtain an aggregate request;
[0033] The multiple dirty cache lines or the aggregate requests are refreshed to store the data corresponding to the multiple dirty cache lines or the aggregate requests from the on-chip storage unit to the off-chip storage unit.
[0034] In an optional embodiment, the method further includes:
[0035] If the starting read address corresponding to the first read request is not in the existing pre-read window, creating a first pre-read window with the starting read address corresponding to the first read request as the starting address;
[0036] If the start read address corresponding to the second read request is located in the first pre-read window, based on the position of the start read address corresponding to the second read request in the first pre-read window, the end read address corresponding to the second read request is extended to obtain an extended read address;
[0037] The data corresponding to the starting read address to the extended read address corresponding to the second read request is read from the off-chip storage unit to the on-chip storage unit, and the corresponding cache line is updated.
[0038] In an optional implementation, based on the position of the start read address corresponding to the second read request in the first pre-read window, the end read address corresponding to the second read request is extended to obtain the extended read address, including:
[0039] If the start read address corresponding to the second read request is located in the non-end area of the first pre-read window, the end address of the first pre-read window is used as the extended read address;
[0040] If the start read address corresponding to the second read request is located in the end area of the first pre-read window, the second preset length is extended from the end address of the first pre-read window to obtain the extended read address.
[0041] In an optional implementation, determining and executing an operation on a storage module and / or a target cache line based on a current request includes:
[0042] If the request type of the current request is a write-back request, a front-end read-write instruction is issued to instruct the on-chip storage unit to obtain and store data;
[0043] Based on the data stored in the on-chip storage unit, update the data of the target cache line;
[0044] If the request type of the current request is a read request and the target cache line exists in the dirty cache line queue, a front-end read / write instruction is issued to instruct the on-chip storage unit to send data corresponding to the current request;
[0045] If the request type of the current request is a read request and the target cache line does not exist in the dirty cache line queue, a backend read / write instruction is issued to instruct the off-chip storage unit to send data corresponding to the current request.
[0046] The embodiment of the present invention sets a lock unit, a waiting queue and a dirty cache line queue in a cache line management module, and manages the status information of the cache line corresponding to the input and output request through the lock unit, so as to first determine whether the corresponding cache line is available before reading or writing the memory, and then interact with the memory when the corresponding cache line is in an idle state to complete the relevant operations corresponding to the input and output request, so as to realize the response and operation of the input and output request without setting a mutual exclusion lock in the memory, and there is no need to interact with the memory frequently, which reduces the delay, and multiple input and output requests can operate the cache line at the same time, which improves the parallelism.
[0047] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:
[0049] Figure 1 It is a schematic diagram of the structure of a cache management system provided by an embodiment of the present invention;
[0050] Figure 2 is a system architecture diagram of a cache management system provided by an embodiment of the present invention;
[0051] Figure 3 It is a flowchart of a cache management method provided by an embodiment of the present invention;
[0052] Figure 4 It is a flow chart of determining and executing operations on a current request and a target cache line in a cache management method provided by an embodiment of the present invention;
[0053] Figure 5 It is a flow chart of determining and executing operations on a current request and a target cache line in a cache management method provided by an embodiment of the present invention;
[0054] Figure 6 It is a schematic diagram of a flow chart of extending a read address in a cache management method provided by an embodiment of the present invention;
[0055] Figure 7 It is a schematic diagram of extending the pre-reading window in a cache management method provided by an embodiment of the present invention;
[0056] Figure 8It is a flowchart of determining and executing operations on a storage module and / or a target cache line in a cache management method provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0057] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0058] In order to reduce IO latency and improve IOPS (Input / Output Operations Per Second), hash lists are currently commonly used to manage caches. However, hash list management consumes a lot of time and extra memory, resulting in longer latency. Specifically, when using hash lists to manage caches, when querying the cache, you first need to traverse the entire hash list and continuously perform memory read operations. At the same time, atomic operations are used, which requires allocating a portion of memory to set a mutex, first obtaining operation authorization through the mutex, and then operating the cache line. Therefore, using hash lists to manage caches not only takes up extra memory, but also results in larger latency.
[0059] Based on this, an embodiment of the present invention provides a cache management system on one hand, including: a cache line management module and a storage module; the cache line management module and the storage module are communicatively connected; the cache line management module is used to respond to received input and output requests, and operate the cache lines corresponding to the input and output requests based on the input and output requests, and send operation instructions to the storage module; the storage module is used to perform the operation corresponding to the operation instruction on the storage data corresponding to the operation instruction; the operation instruction includes reading data and writing data; the cache line management module includes a lock unit, a waiting queue and a dirty cache line queue; the lock unit is used to store the status information of the cache line, and the status information includes an occupied state and an idle state; the waiting queue is used to store the input and output requests of the corresponding cache line in the occupied state; if the corresponding cache line is in the idle state, the input and output requests stored in the waiting queue are taken out and awakened; the dirty cache line queue is used to arrange and store the dirty cache lines in access order. On the other hand, a cache management method is provided, which is applied to any of the above cache management systems, including: obtaining a current request and determining a target cache line corresponding to the current request; the current request is an input / output request that is currently arbitrated; based on the operation type of the current request on the target cache line, or based on the operation type and status information of the target cache line, determining and executing the operation on the current request and the target cache line; the status information is obtained from a lock unit; the operation on the current request includes executing the current request and placing the current request in a waiting queue; the operation on the target cache line includes allocating the target cache line, releasing the target cache line, and placing the target cache line in a dirty cache line queue; if the current request is executed, determining and executing the operation on the storage module and / or the target cache line based on the current request. In this way, a lock unit, a waiting queue and a dirty cache line queue are set in the cache line management module, and the status information of the cache line corresponding to the input and output request is managed through the lock unit, so as to first determine whether the corresponding cache line is available before reading or writing the memory, and then interact with the memory when the corresponding cache line is in an idle state to complete the relevant operations corresponding to the input and output request, so as to realize the response and operation of the input and output request without setting a mutex lock in the memory, and there is no need to interact with the memory frequently, which reduces the delay, and multiple input and output requests can operate the cache line at the same time, which improves the parallelism.
[0060] In one aspect, an embodiment of the present invention provides a cache management system. Figure 1 is a schematic diagram of the structure of a cache management system provided by an embodiment of the present invention, such as Figure 1As shown, the system includes: a cache line management module 1 and a storage module 2. The cache line management module 1 and the storage module 2 are in communication connection; the cache line management module 1 is used to manage cache lines in the cache, specifically, the cache line management module 1 is used to respond to received input and output requests, and based on the input and output requests, operate the cache lines corresponding to the input and output requests, and send operation instructions to the storage module 2; the storage module 2 stores system-related data, which is used to perform operations corresponding to the operation instructions on the storage data corresponding to the operation instructions; the operation instructions include reading data and writing data.
[0061] In the embodiment of the present invention, Figure 1 As shown, the cache line management module 1 includes a lock unit 11, a waiting queue 12 and a dirty cache line queue 13. Among them, the lock unit 11 is used to store and manage the state information of the cache line, and the state information includes the occupied state and the idle state. The lock unit 11 is actually an IO mutex lock, which maintains data consistency by managing the state information of the cache line stored therein, so as to coordinate the use of the cache line and the response of the input and output request when multiple input and output requests or multiple hosts operate on the same cache line at the same time. The waiting queue 12 is used to store the input and output requests of the corresponding cache line in the occupied state. If the corresponding cache line is in the idle state, the input and output request stored in the waiting queue 12 is taken out and awakened; that is, when the lock unit 11 confirms that the cache line corresponding to the input and output request is in the occupied state, the input and output request will be placed in the waiting queue 12, and the response to the input and output request will be suspended. When the state information of the cache line is restored to the idle state, the input and output request is taken out and awakened, and the response to the input and output request continues. The dirty cache line queue 13 is used to arrange and store dirty cache lines in an access order. When the data in a cache line is modified to become a dirty cache line, the dirty cache line is put into the dirty cache line queue 13 .
[0062] In an optional embodiment, Figure 2 is a system architecture diagram of a cache management system provided by an embodiment of the present invention, Figure 2 In FIG. 1 , CL_crtl is a cache line management module 1, lock is a lock unit 11, wait_q is a wait queue 12, and WBL_q is a dirty cache line queue 13. Figure 1 and Figure 2As shown, the storage module 2 includes an off-chip storage unit 22, i.e., an off-chip storage body, and an on-chip storage unit 21, i.e., an on-chip storage body, and the on-chip storage unit 21 and the off-chip storage unit 22 are in communication connection. The data in the dirty cache line in the dirty cache line queue 13 corresponds to the storage data in the on-chip storage unit 21. The on-chip storage unit 21 serves as an on-chip storage body, and the operation corresponding to the input and output request will perform related operations on the storage data in the on-chip storage unit 21, wherein the stored data is consistent with the data of the corresponding cache line in the cache; the storage data in the off-chip storage unit 22 is the data corresponding to the released dirty cache line, which is used as a supplementary storage for the data to avoid too many dirty cache lines in the cache and is not conducive to search, wherein the data corresponding to the released dirty cache line is stored. If the number of dirty cache lines in the dirty cache line queue 13 exceeds the preset number, the cache line management module 1 releases the dirty cache lines in the dirty cache line queue 13 and stores the data corresponding to the dirty cache lines in the dirty cache line queue 13 from the on-chip storage unit 21 to the off-chip storage unit 22.
[0063] In an optional embodiment, if Figure 2 As shown, the storage module 2 may also include a storage controller (storage_crtl), which is respectively connected to the on-chip storage unit 21, the off-chip storage unit 22 and the cache line management module 1. Inside the storage module 2, the storage controller is used to move or read the storage data in the on-chip storage unit 21 to the off-chip storage unit 22, or move or read the data in the off-chip storage unit 22 to the on-chip storage unit 21; outside the storage module 2, the storage controller is used to receive instructions sent by the cache line management module 1, which are usually back-end commands, i.e., BIO. The back-end command instructs to read data from the off-chip storage unit 22. Therefore, after receiving the back-end command, the storage controller will move or read the data in the off-chip storage unit 22 to the on-chip storage unit 21 according to the response.
[0064] In an optional embodiment, if Figure 2 As shown, the storage module 2 may also include a DMA (Direct Memory Access) controller, which is respectively connected to the cache line management module 1, the on-chip storage body, and the external host. The DMA controller is used to respond to the front-end command, i.e., FIO, issued by the cache line management module 1, read the storage data in the on-chip storage unit 21, and send the data directly to the host, or move the data from the host to the on-chip storage unit 21 for storage.
[0065] In an optional embodiment, if Figure 1 and Figure 2As shown, the cache line management module 1 also includes a pre-read window unit (ra_win) and a data mapping unit (tag). The pre-read window unit is used to create a pre-read window or extend the window length of the pre-read window when receiving a read command. The pre-read window is used to represent the data range that the on-chip storage unit 21 extends to read from the off-chip storage unit 22; through the pre-read window set by the pre-read window unit, the storage data in the off-chip storage unit 22 is read into the on-chip storage unit 21 in advance, and when the access of the read command falls within the pre-read window, the corresponding data can be directly read from the on-chip storage unit 21, thereby realizing a fast response to the read command. The data mapping unit is used to store data mapping information, and the data mapping information corresponds to the cache line one by one; the data mapping information is used to represent the allocation and update of the corresponding cache line and the mapping information in the on-chip storage unit 21.
[0066] On the other hand, an embodiment of the present invention provides a cache management method, which can be applied to any of the above-mentioned cache management systems. The following describes a specific embodiment of a cache management method of the present invention. Figure 3 It is a flowchart of a cache management method provided by an embodiment of the present invention. This specification provides method operation steps such as the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only execution order. When the actual system or server product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment). Specifically, Figure 3 As shown, the method may include:
[0067] Step 310: Get the current request and determine the target cache line corresponding to the current request.
[0068] In the embodiment of the present invention, the current request is the input / output request that is currently being arbitrated. The operation on the cache line may include application, release and flush, each operation includes multiple steps, and each step cannot be interrupted by other operations. Therefore, in order to maintain data consistency, the cache line operation corresponding to the received input / output request needs to be arbitrated first, and only one cache line operation is arbitrated and authorized at a time.
[0069] In an optional embodiment, in order to improve the parallel capability of responding to input and output requests, the cache line operations corresponding to the input and output requests for the same cache line are arbitrated, so that for a cache line, only one cache line operation can be performed at a time, but within the cache, multiple cache line operations for different cache lines can be performed simultaneously.
[0070] Step 320: Determine and execute an operation on the current request and the target cache line based on the operation type of the current request on the target cache line, or based on the operation type and the state information of the target cache line.
[0071] In an embodiment of the present invention, status information is obtained from a lock unit, and the status information includes an occupied state and an idle state. The operation types of the current request on the target cache line include applying for a cache line and releasing a cache line. Different operation types have different methods for determining the operation on the current request and the target cache line, and the determined operations on the current request and the target cache line are also different. For the operation type of applying for a cache line, since the target cache line needs to be allocated to the current request, the status information of the target cache line needs to be determined before allocation to determine whether the target cache line is occupied by other input and output requests. Therefore, for the operation type of applying for a cache line, it is necessary to determine and execute the operation on the current request and the target cache line based on the operation type and the status information of the target cache line. For the operation type of releasing a cache line, the release operation indicates that the target cache line has been allocated to the current request. Therefore, based on the operation type, the operation on the current request and the target cache line is determined and executed.
[0072] In the embodiment of the present invention, the operation on the current request includes executing the current request, returning the response information of the current request, and placing the current request in a waiting queue. The operation on the target cache line includes allocating the target cache line, releasing the target cache line, and placing the target cache line in a dirty cache line queue.
[0073] Step 330: If the current request is executed, then based on the current request, determine and execute operations on the storage module and / or the target cache line.
[0074] In an embodiment of the present invention, if the operation on the current request is to execute the current request, then based on the current request, the operation on the storage module and / or the target cache line is determined and executed. Specifically, the operation on the storage module and / or the target cache line is related to the request type of the current request, and the input and output requests of different request types have different corresponding operation targets, that is, whether the operation is performed on the storage module or the target cache line or the storage module and the target cache line is different, and the operation on the operation target is also different, that is, the specific operation actions are different, such as writing data or reading data.
[0075] In an optional embodiment, Figure 4 FIG. 1 is a flow chart of determining and executing operations on a current request and a target cache line in a cache management method provided by an embodiment of the present invention, such as Figure 4 As shown, in the above step 320, based on the operation type and the state information of the target cache line, determining and executing the operation on the current request and the target cache line may include the following steps:
[0076] Step 410: If the operation type is to apply for a cache line, then search the data mapping information corresponding to the target cache line in the data mapping unit.
[0077] In an embodiment of the present invention, if the operation type is to apply for a cache line, it is necessary to determine and execute the operation on the current request and the target cache line in combination with the status information of the target cache line. First, the data mapping information corresponding to the target cache line is searched in the data mapping unit. Since the data mapping information can characterize the allocation and update status of the corresponding cache line and the mapping information in the on-chip storage unit, if the data mapping information corresponding to the target cache line is found in the data mapping unit, it indicates that the target cache line has been allocated to other input and output requests for use. If the data mapping information corresponding to the target cache line is not found in the data mapping unit, it indicates that the target cache line has not been allocated for use.
[0078] Step 420: If data mapping information corresponding to the target cache line exists in the data mapping unit, then the state information of the target cache line is obtained.
[0079] In an embodiment of the present invention, if data mapping information corresponding to the target cache line exists in the data mapping unit, it indicates that the target cache line has been allocated for use by other input and output requests. At this time, it is necessary to further determine whether there is a resource conflict, that is, whether the target cache line is still currently occupied by other input and output requests. Therefore, the data in the lock unit is queried to obtain the status information of the target cache line.
[0080] Step 430: If the state information is an idle state, or the data mapping information corresponding to the target cache line does not exist in the data mapping unit, the target cache line is allocated to the current request.
[0081] In the embodiment of the present invention, if the state information of the target cache line obtained from the lock unit is an idle state, it indicates that the target cache line has been released by other input and output requests, and there is no resource conflict at present, so the target cache line can be allocated to the current request at this time. Correspondingly, after searching the data mapping information corresponding to the target cache line in the data mapping unit in the above step 410, if the data mapping information corresponding to the target cache line is not found in the data mapping unit, that is, the data mapping information corresponding to the target cache line does not exist in the data mapping unit, it indicates that the target cache line has not been allocated for use, so the target cache line can be allocated to the current request at this time.
[0082] In an optional embodiment, if the status information of the target cache line obtained from the lock unit is occupied, it indicates that the target cache line is still occupied by other input and output requests and there is currently a resource conflict. Therefore, the current request is placed in a waiting queue until the status information changes from occupied to idle, and the current request is taken out of the waiting queue.
[0083] In an optional implementation, if there are multiple input / output requests in the waiting queue, when the state information of the target cache line changes from occupied state to idle state, the input / output requests are taken out of the waiting queue in sequence in the waiting queue and arbitration authorization is applied for.
[0084] Step 440: Execute the current request, update the data mapping information corresponding to the target cache line in the data mapping unit, and change the state information of the target cache line to an occupied state.
[0085] In an embodiment of the present invention, after the target cache line is allocated to the current request, the current request locks the target cache line. At this time, a response is generated and executed for the current request, and the data mapping information corresponding to the target cache line in the data mapping unit is synchronously updated. At the same time, since the current request locks the target cache line, the status information of the target cache line is changed to an occupied state to avoid resource conflicts when other subsequent input and output requests also point to the target cache line.
[0086] In an optional embodiment, Figure 5 FIG. 1 is a flow chart of determining and executing operations on a current request and a target cache line in a cache management method provided by an embodiment of the present invention, such as Figure 4 As shown, in the above step 320, based on the operation type, determining and executing the operation on the current request and the target cache line may include the following steps:
[0087] Step 510: If the operation type is to release the cache line, then search the data mapping information corresponding to the target cache line in the data mapping unit.
[0088] In an embodiment of the present invention, if the operation type is to release a cache line, then the target cache line is currently in an occupied state, and the response and execution of the current request have been completed at this time. At this time, it is necessary to search the data mapping information corresponding to the target cache line in the data mapping unit to determine whether the current request has completed the response normally and whether the corresponding execution operation has been completed normally during the execution process.
[0089] Step 520: If the data mapping information corresponding to the target cache line exists in the data mapping unit, it is determined that the target cache line is released successfully.
[0090] In an embodiment of the present invention, if data mapping information corresponding to the target cache line is found in the data mapping unit, and the data mapping information is consistent with the relevant information corresponding to the current request, such as the address information, it is determined that there is no problem with the response to the current request, that is, the execution operation corresponding to the current request is completed normally, and it can be determined that the target cache line is released successfully.
[0091] Step 530: Return the response information of the current request, change the state information of the target cache line to an idle state, and take out the input and output requests from the waiting queue.
[0092] In an embodiment of the present invention, the response information of the current request is returned to indicate that the current request has completed the response, and the state information of the target cache line is changed to an idle state to release the occupation of the target cache line. If there are input and output requests in the waiting queue, the waiting queue is released to take out and wake up the input and output requests from the waiting queue.
[0093] Step 540: If the target cache line is a dirty cache line, put the target cache line into a dirty cache line queue.
[0094] In the embodiment of the present invention, if the target cache line is a dirty cache line, the target cache line is put into a dirty cache line queue, so that the dirty cache lines generated in the input and output request response process are managed through the dirty cache line queue.
[0095] In an optional implementation, if there are multiple disk arrays in the system, that is, there are multiple on-chip storage units, or the on-chip storage unit is divided or defined as multiple sub-storage units, then a dirty cache line queue is established for each disk array to facilitate separate management of dirty cache lines corresponding to different disk arrays.
[0096] In an optional implementation, since the number of dirty cache lines that can be placed in the dirty cache line queue is limited and the storage space of the on-chip storage unit is limited, when the number of dirty cache lines reaches a certain number, the dirty cache lines need to be flushed to the off-chip storage unit. Specifically, if the number of dirty cache lines in the dirty cache line queue exceeds the preset number, multiple dirty cache lines in the dirty cache line queue are taken out and the multiple dirty cache lines are sorted. If the sorted multiple dirty cache lines are continuous dirty cache lines, the multiple dirty cache lines are aggregated to obtain an aggregate request; wherein the continuity of the dirty cache lines means that the corresponding address range is continuous, and at this time, the continuous dirty cache lines are aggregated into an IO request to obtain an aggregate request, and flush is performed according to the aggregate request. Refreshing multiple dirty cache lines or aggregate requests to store the data corresponding to the multiple dirty cache lines or aggregate requests from the on-chip storage unit to the off-chip storage unit, on the one hand, fully utilizing the storage space of the on-chip storage unit and the off-chip storage unit, and on the other hand, giving full play to the ability of the off-chip storage unit to process large blocks of continuous data. Optionally, since the dirty cache lines taken out from the dirty cache line queue may be partially continuous and partially discontinuous, multiple segments of continuous dirty cache lines can be aggregated separately to obtain multiple aggregation requests, and then the aggregation requests and the remaining discontinuous dirty cache lines are flushed to the off-chip storage unit respectively, and their corresponding data are moved from the on-chip storage unit to the off-chip storage unit.
[0097] In an optional implementation, since the storage module is divided into an on-chip storage unit and an off-chip storage unit, data is distributed and stored in the on-chip storage unit and the off-chip storage unit. At the same time, in order to improve the response speed to the read command and shorten the read delay, the cache management method provided by the embodiment of the present invention also uses a pre-read window unit, sets a pre-read window and extends the read address, so as to use the pre-read window to pre-move data from the off-chip storage unit to the on-chip storage unit to shorten the read delay. Specifically, Figure 6 FIG. 1 is a flow chart of extending a read address in a cache management method provided by an embodiment of the present invention. Figure 6 As shown, the method may also include the following steps:
[0098] Step 610: If the starting read address corresponding to the first read request is not in the existing pre-read window, create a first pre-read window with the starting read address corresponding to the first read request as the starting address.
[0099] In an embodiment of the present invention, if the starting read address corresponding to the first read request is not in the existing pre-read window, that is, the first read request does not hit the existing pre-read window, a new pre-read window is created to cover the first read request. Specifically, the starting read address corresponding to the first read request is used as the starting address of the first pre-read window, and a pre-read window is created according to the preset window length of the pre-read window to obtain the first pre-read window.
[0100] In an optional implementation, in order to improve the hit rate of sequential flow detection, that is, to improve the hit rate of the pre-reading window, multiple pre-reading windows can be designed. If a new pre-reading window is created, causing the number of pre-reading windows to exceed a threshold, the LRU (Least Recently Used) strategy can be adopted to replace the least hit pre-reading window with the newly created pre-reading window, thereby ensuring the hit rate of the pre-reading window. Specifically, through the LRU strategy, cache lines are sorted according to their usage frequency, and cache lines with relatively high usage frequency are ranked high, and cache lines with relatively low usage frequency are ranked low. When replacing the pre-reading window, the pre-reading window with the lowest usage frequency of the corresponding cache line is replaced to add the newly created pre-reading window.
[0101] Step 620: If the start read address corresponding to the second read request is located in the first pre-read window, based on the position of the start read address corresponding to the second read request in the first pre-read window, the end read address corresponding to the second read request is extended to obtain an extended read address.
[0102] In an embodiment of the present invention, if the starting read address corresponding to the second read request is located in the first pre-read window, that is, the second read request hits the first pre-read window, then based on the position of the starting read address corresponding to the second read request in the first pre-read window, the first pre-read window is expanded to obtain the expanded first pre-read window.
[0103] In an optional implementation, the manner of extending the first pre-reading window may vary according to the position of the start read address corresponding to the second read request in the first pre-reading window. Figure 7 is a schematic diagram of extending the pre-reading window in a cache management method provided by an embodiment of the present invention, such as Figure 7 As shown, if the starting read address corresponding to the first read request is not in the existing pre-read window, the first pre-read window is created with the starting read address (new RA start) corresponding to the first read request as the starting address and RA window size as the window length, and the end area of the first pre-read window is tail_buffer. If the starting read address corresponding to the second read request is located in the non-end area of the first pre-read window, the end address of the first pre-read window is used as the extended read address, and the corresponding extended read range is from the end read address corresponding to the second read request to the end address (read_ahead_size) of the first pre-read window; if the starting read address corresponding to the second read request is located in the end area (tail_buffer) of the first pre-read window, the second preset length (exp_read_ahead_size) is extended from the end address of the first pre-read window to obtain the extended read address, and the corresponding extended read range is from the end read address (IO_hit_offset) corresponding to the second read request to the extended read address.
[0104] Step 630: Read the data corresponding to the starting read address to the extended read address corresponding to the second read request from the off-chip storage unit to the on-chip storage unit, and update the corresponding cache line.
[0105] In an embodiment of the present invention, data corresponding to the starting read address to the extended read address corresponding to the second read request are read in advance from an off-chip storage unit to an on-chip storage unit, and the corresponding cache line is updated synchronously, thereby moving the data to the on-chip storage unit in advance. When the host reads the sequential address, the corresponding data can be directly obtained from the on-chip storage unit, thereby saving the process of searching for data in the off-chip storage unit and moving the data from the off-chip storage unit to the on-chip storage unit, thereby shortening the read delay.
[0106] In an optional embodiment, Figure 8 FIG. 1 is a flow chart of determining and executing operations on a storage module and / or a target cache line in a cache management method provided by an embodiment of the present invention, such as Figure 8 As shown, in the above step 130, based on the current request, determining and executing the operation on the storage module and / or the target cache line may include the following steps:
[0107] Step 810: If the request type of the current request is a write-back request, a front-end read-write instruction is issued to instruct the on-chip storage unit to obtain and store data.
[0108] In an embodiment of the present invention, if the request type of the current request is a write-back request (WB IO), then after allocating a target cache line to the current request, the cache line management module issues a front-end read and write command (FIO) to instruct the on-chip storage unit to directly obtain and store data from the host that issues the current request through the DMA controller.
[0109] Step 820: Update the target cache line based on the data stored in the on-chip storage unit.
[0110] In an embodiment of the present invention, after data is moved from a host to an on-chip storage unit and stored, a target cache line is updated accordingly based on the data stored in the on-chip storage unit, specifically including updating the data in the target cache line and updating data mapping information corresponding to the target cache line. At the same time, when a subsequent current request to release the target cache line is authorized, the target cache line is released and placed in a dirty cache line queue.
[0111] Step 830: If the request type of the current request is a read request and the target cache line exists in the dirty cache line queue, a front-end read / write instruction is issued to instruct the on-chip storage unit to send data corresponding to the current request.
[0112] In an embodiment of the present invention, if the request type of the current request is a read request (read IO), and there is a target cache line in the dirty cache line queue, it indicates that the data corresponding to the current request is stored in the on-chip storage unit. At this time, a front-end read and write command (FIO) is issued, and the corresponding data is directly obtained from the on-chip storage unit through the DMA controller, and the relevant data is transferred to the host, thereby completing the response to the current request.
[0113] Step 840: If the request type of the current request is a read request and the target cache line does not exist in the dirty cache line queue, a backend read / write instruction is issued to instruct the off-chip storage unit to send data corresponding to the current request.
[0114] In an embodiment of the present invention, if the request type of the current request is a read request, and the target cache line does not exist in the dirty cache line queue, it indicates that the data corresponding to the current request has been moved to the off-chip storage unit and is stored in the off-chip storage unit. At this time, a back-end read and write command (BIO) is issued to move the relevant data from the off-chip storage unit to the host, thereby completing the response to the current request.
[0115] In an optional implementation, if there are multiple target cache lines corresponding to the current request, and some of the target cache lines are in the dirty cache line queue, while other target cache lines are not in the dirty cache line queue, front-end read and write commands and back-end read and write commands are respectively issued to obtain corresponding data from the on-chip storage unit and the off-chip storage unit and transfer them to the host, thereby completing the response to the current request.
[0116] On the one hand, an embodiment of the present invention provides a cache management system, including: a cache line management module and a storage module; the cache line management module and the storage module are communicatively connected; the cache line management module is used to respond to received input and output requests, and based on the input and output requests, operate the cache line corresponding to the input and output requests, and send operation instructions to the storage module; the storage module is used to perform the operation corresponding to the operation instruction on the storage data corresponding to the operation instruction; the operation instruction includes reading data and writing data; the cache line management module includes a lock unit, a waiting queue and a dirty cache line queue; the lock unit is used to store the status information of the cache line, and the status information includes an occupied state and an idle state; the waiting queue is used to store the input and output requests of the corresponding cache line in the occupied state; if the corresponding cache line is in the idle state, the input and output requests stored in the waiting queue are taken out and awakened; the dirty cache line queue is used to arrange and store the dirty cache lines in the access order. On the other hand, a cache management method is provided, which is applied to any of the above cache management systems, including: obtaining a current request and determining a target cache line corresponding to the current request; the current request is an input / output request that is currently arbitrated; based on the operation type of the current request on the target cache line, or based on the operation type and status information of the target cache line, determining and executing the operation on the current request and the target cache line; the status information is obtained from a lock unit; the operation on the current request includes executing the current request and placing the current request in a waiting queue; the operation on the target cache line includes allocating the target cache line, releasing the target cache line, and placing the target cache line in a dirty cache line queue; if the current request is executed, determining and executing the operation on the storage module and / or the target cache line based on the current request. In this way, a lock unit, a waiting queue and a dirty cache line queue are set in the cache line management module, and the state information of the cache line corresponding to the input and output request is managed through the lock unit, so as to first determine whether the corresponding cache line is available before reading or writing the memory, and then interact with the memory when the corresponding cache line is in an idle state to complete the relevant operations corresponding to the input and output request, thereby realizing the response and operation of the input and output request without setting a mutual exclusion lock in the memory, and there is no need to frequently interact with the memory, which reduces the delay, and multiple input and output requests can operate the cache line at the same time, which improves the parallelism. The algorithm or display provided herein is not inherently related to any specific computer, virtual system or other device. In addition, the embodiments of the present invention are not directed to any specific programming language.
[0117] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. Similarly, in order to simplify the present invention and help understand one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof.
[0118] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and further may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive.
[0119] It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of protection of the present invention. The word "comprising" does not exclude the existence of elements or steps not listed in the present invention. The word "one" or "an" preceding an element does not exclude the existence of multiple such elements. The present invention can be implemented by means of hardware including several different elements and by means of appropriately programmed computers. In the embodiments in which several devices are listed, several of these devices can be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words can be interpreted as names. The steps in the above embodiments should not be understood as limiting the order of execution unless otherwise specified.
Claims
1. A cache management system, characterized in that: The system comprises: a cache line management module and a storage module; the cache line management module is communicatively connected with the storage module; The cache line management module is used to respond to the received input / output request, and based on the input / output request, operate the cache line corresponding to the input / output request, and send an operation instruction to the storage module; the storage module is used to perform the operation corresponding to the operation instruction on the storage data corresponding to the operation instruction; the operation instruction includes reading data and writing data; The cache line management module includes a lock unit, a waiting queue and a dirty cache line queue; the lock unit is used to store the status information of the cache line, and the status information includes an occupied state and an idle state; the waiting queue is used to store the input and output requests of the corresponding cache line in the occupied state; if the corresponding cache line is in the idle state, the input and output requests stored in the waiting queue are taken out and awakened; the dirty cache line queue is used to arrange and store the dirty cache lines in the access order.
2. The system according to claim 1, characterized in that The storage module includes an off-chip storage unit and an on-chip storage unit; the on-chip storage unit is communicatively connected with the off-chip storage unit; The data in the dirty cache line in the dirty cache line queue corresponds to the storage data in the on-chip storage unit; the storage data in the off-chip storage unit is the data corresponding to the released dirty cache line; If the number of dirty cache lines in the dirty cache line queue exceeds a preset number, the cache line management module releases the dirty cache lines in the dirty cache line queue and stores data corresponding to the dirty cache lines in the dirty cache line queue from the on-chip storage unit to the off-chip storage unit.
3. The system according to claim 2, characterized in that The cache line management module also includes a pre-read window unit; the pre-read window unit is used to create a pre-read window or extend the window length of the pre-read window when receiving a read command, and the pre-read window is used to represent the data range that the on-chip storage unit extends to read from the off-chip storage unit.
4. The system according to claim 1, characterized in that The cache line management module also includes a data mapping unit; The data mapping unit is used to store data mapping information; the data mapping information corresponds to the cache line one by one.
5. A cache management method, characterized in that: Applied to the cache management system according to any one of claims 1 to 4, the method comprises: Obtaining a current request and determining a target cache line corresponding to the current request; the current request is an input / output request that is currently arbitrated; Determine and execute an operation on the current request and the target cache line based on an operation type of the current request on the target cache line, or based on the operation type and status information of the target cache line; the status information is obtained from a lock unit; the operation on the current request includes executing the current request, returning response information of the current request, and placing the current request in a waiting queue; the operation on the target cache line includes allocating the target cache line, releasing the target cache line, and placing the target cache line in a dirty cache line queue; If the current request is executed, an operation on the storage module and / or the target cache line is determined and executed based on the current request.
6. The method according to claim 5, characterized in that Determining and executing an operation on the current request and the target cache line based on the operation type and the state information of the target cache line includes: If the operation type is to apply for a cache line, searching the data mapping information corresponding to the target cache line in the data mapping unit; If the data mapping unit contains data mapping information corresponding to the target cache line, acquiring status information of the target cache line; If the state information is an idle state, or the data mapping information corresponding to the target cache line does not exist in the data mapping unit, allocating the target cache line to the current request; The current request is executed, data mapping information corresponding to the target cache line in the data mapping unit is updated, and state information of the target cache line is changed to an occupied state.
7. The method according to claim 6, characterized in that After acquiring the state information of the target cache line, the method further includes: If the state information is an occupied state, the current request is put into the waiting queue until the state information is changed from the occupied state to the idle state, and the current request is taken out from the waiting queue.
8. The method according to claim 5, characterized in that Based on the operation type, determining and performing an operation on the current request and the target cache line includes: If the operation type is to release the cache line, searching the data mapping information corresponding to the target cache line in the data mapping unit; If the data mapping information corresponding to the target cache line exists in the data mapping unit, determining that the target cache line is released successfully; Returning the response information of the current request, changing the state information of the target cache line to an idle state, and taking out the input and output request from the waiting queue; If the target cache line is a dirty cache line, the target cache line is placed in the dirty cache line queue.
9. The method according to claim 5, characterized in that The method further comprises: If the number of dirty cache lines in the dirty cache line queue exceeds a preset number, taking out a plurality of dirty cache lines in the dirty cache line queue and sorting the plurality of dirty cache lines; If the sorted multiple dirty cache lines are continuous dirty cache lines, aggregating the multiple dirty cache lines to obtain an aggregate request; The multiple dirty cache lines or the aggregate request are refreshed to store data corresponding to the multiple dirty cache lines or the aggregate request from an on-chip storage unit to an off-chip storage unit.
10. The method according to claim 9, characterized in that The method further comprises: If the starting read address corresponding to the first read request is not in the existing pre-read window, creating a first pre-read window with the starting read address corresponding to the first read request as the starting address; If the starting read address corresponding to the second read request is located in the first pre-read window, then based on the position of the starting read address corresponding to the second read request in the first pre-read window, the ending read address corresponding to the second read request is extended to obtain an extended read address; The data from the starting read address corresponding to the second read request to the extended read address are read from the off-chip storage unit to the on-chip storage unit, and the corresponding cache line is updated.
11. The method according to claim 10, characterized in that The step of extending the end read address corresponding to the second read request based on the position of the start read address corresponding to the second read request in the first pre-read window to obtain the extended read address includes: If the start read address corresponding to the second read request is located in a non-end area of the first pre-read window, the end address of the first pre-read window is used as the extended read address; If the start read address corresponding to the second read request is located in the end area of the first pre-read window, a second preset length is extended from the end address of the first pre-read window to obtain the extended read address.
12. The method according to any one of claims 5 to 11, characterized in that: The determining and executing an operation on a storage module and / or the target cache line based on the current request includes: If the request type of the current request is a write-back request, a front-end read-write instruction is issued to instruct the on-chip storage unit to obtain and store data; Based on the data stored in the on-chip storage unit, updating the data of the target cache line; If the request type of the current request is a read request, and the target cache line exists in the dirty cache line queue, a front-end read / write instruction is issued to instruct the on-chip storage unit to send data corresponding to the current request; If the request type of the current request is a read request, and the target cache line does not exist in the dirty cache line queue, a backend read / write instruction is issued to instruct the off-chip storage unit to send data corresponding to the current request.
Citation Information
Patent Citations
Memory access and execution device for non-blocking transmission and execution
CN102662634A
Method and system for requesting to accessing zero-copy Cache
CN103136115A
System and method for writing cache data and system and method for reading cache data
US20100332743A1
Supporting concurrent operations at fine granularity in a caching framework
US20170139832A1
