Cache management method, electronic device, storage medium and program product
By calculating the current access popularity of data blocks in the storage system and dynamically adjusting the allocation of cache resources, the problem of low data access efficiency in the storage system is solved, and the cache hit rate and data access speed are improved.
Patent Information
- Application Number
- CN202510158280.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2045-02-13
AI Technical Summary
Due to the complex and changeable demands for accessing data in the storage system, the cached data is not the data to be accessed at present, resulting in data access delays and low data access efficiency of the storage system.
By obtaining the current running data of the storage system in the current cycle and the historical access popularity of multiple data blocks, the current access popularity of each data block is calculated, and dynamically adjusting the resource allocation of the target cache based on the current access popularity and historical access popularity to update the data blocks in the target cache.
By dynamically adjusting cache resource allocation, the cache hit rate can be improved, data read and write speed can be improved, data access delay can be reduced, and data access efficiency of storage systems can be improved.
Smart Images

Figure CN119620961A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a cache management method, electronic device, storage medium, and program product. Background Art
[0002] As the amount of data continues to grow, the performance requirements for storage systems are also getting higher and higher. Storage systems can include network attached storage (NAS) systems, cloud storage systems, distributed storage systems, etc. As the demand for data access in storage systems continues to increase, it is necessary to optimize the performance of storage systems.
[0003] In the related art, the data access performance of the storage system can be optimized by upgrading the hardware in the storage system, such as increasing the memory capacity in the storage system, upgrading the disk drive, upgrading the network interface card, etc. A certain amount of data can also be cached in the storage system to optimize the data access performance of the storage system. However, due to the complex and changeable requirements for accessing data, the cached data is not the data currently to be accessed, resulting in data access delays and low data access efficiency of the storage system. Summary of the invention
[0004] The present application provides a cache management method, an electronic device, a storage medium, and a program product to at least solve the problem of low data access efficiency of a storage system in the related art.
[0005] The present application provides a cache management method, including:
[0006] Acquire current operation data of the storage system in a current cycle and historical access heat of multiple data blocks, where the multiple data blocks are stored in the storage system;
[0007] Determine, according to the current running data, a first weight of the current running data and a second weight of the historical access popularity;
[0008] For any data block, determine the current access popularity of the data block in the current cycle according to the current running data, the historical access popularity, the first weight and the second weight;
[0009] According to the current access heat and historical access heat of each data block, the data blocks in the target cache are updated. The target cache is used to store hot data.
[0010] In a possible implementation, updating the data blocks in the target cache according to the current access popularity and the historical access popularity of each data block includes:
[0011] Determining a plurality of first data blocks from a plurality of data blocks according to the current access popularity of each data block;
[0012] Determining a plurality of second data blocks from the plurality of data blocks according to the current access popularity and the historical access popularity of each data block;
[0013] Determine a plurality of update data blocks of the target cache according to the plurality of first data blocks, the plurality of second data blocks, and the plurality of current data blocks in the target cache;
[0014] The data blocks in the target cache are updated according to the multiple updated data blocks.
[0015] In a possible implementation, updating a data block in a target cache according to a plurality of updated data blocks includes:
[0016] Determine the data capacity corresponding to the multiple update data blocks;
[0017] Determine whether the remaining capacity of the target cache is greater than the data capacity;
[0018] If so, store the multiple updated data blocks into the cache space corresponding to the target cache;
[0019] If not, obtain the historical access data corresponding to each current data block, determine at least one data block to be deleted from multiple current data blocks based on the historical access data corresponding to each current data block and the current access popularity of each current data block, delete at least one data block to be deleted, and store multiple updated data blocks in the cache space corresponding to the target cache.
[0020] In a possible implementation, determining at least one data block to be deleted from a plurality of current data blocks according to historical access data corresponding to each current data block and current access popularity of each current data block includes:
[0021] Get the remaining capacity of the target cache.
[0022] Determine the capacity difference between the remaining capacity of the cache and the data capacity;
[0023] According to the capacity difference, determine the number of data blocks to be deleted;
[0024] According to the historical access data corresponding to each current data block and the current access popularity of each current data block, the to-be-deleted data blocks corresponding to the number of data blocks are determined from the multiple current data blocks.
[0025] In a possible implementation, determining the to-be-deleted data blocks corresponding to the number of data blocks in a plurality of current data blocks according to the historical access data corresponding to each current data block and the current access popularity of each current data block includes:
[0026] Determine, among the multiple current data blocks, multiple candidate data blocks whose current access heat is lower than a first threshold;
[0027] Determine the last access time of each candidate data block according to the historical access data corresponding to each candidate data block;
[0028] Sort multiple candidate data blocks according to the order of the last access time from far to near to obtain a first sequence;
[0029] The first n to-be-selected data blocks in the first sequence are determined as the to-be-deleted data blocks, where n is the number of data blocks.
[0030] In a possible implementation, determining the to-be-deleted data blocks corresponding to the number of data blocks in a plurality of current data blocks according to the historical access data corresponding to each current data block and the current access popularity of each current data block includes:
[0031] Determine the last access time corresponding to each current data block according to the historical access data corresponding to each current data block;
[0032] Sorting the multiple current data blocks according to the order of the last access time of each current data block from far to near to obtain a second sequence;
[0033] Determine the first m current data blocks in the second sequence as the third data block, where m is the sum of the number of data blocks and the first preset number;
[0034] Sorting the plurality of third data blocks in ascending order of the current access popularity of each third data block to obtain a third sequence;
[0035] The first n third data blocks in the third sequence are determined as data blocks to be deleted, where n is the number of data blocks and n is less than m.
[0036] In a possible implementation, determining a plurality of first data blocks from a plurality of data blocks according to the current access popularity of each data block includes:
[0037] Sorting the multiple data blocks in descending order of the current access popularity of each data block to obtain a fourth sequence;
[0038] The first a data blocks in the fourth sequence are determined as a plurality of first data blocks, where a is a second preset number.
[0039] In a possible implementation, determining a plurality of second data blocks from a plurality of data blocks according to the current access popularity and the historical access popularity of each data block includes:
[0040] Predict the second threshold based on historical access popularity;
[0041] Among the multiple data blocks, multiple data blocks whose current access heat is greater than a second threshold are determined as multiple second data blocks.
[0042] In a possible implementation, determining a plurality of update data blocks of the target cache according to a plurality of first data blocks, a plurality of second data blocks, and a plurality of current data blocks in the target cache includes:
[0043] Determine a first set, where the first set includes a plurality of first data blocks and a plurality of second data blocks;
[0044] In the first set, determining at least one fourth data block, the fourth data block being the same as any current data block;
[0045] Deleting at least one fourth data block from the first set to obtain a target set;
[0046] According to the target set, multiple update data blocks are determined.
[0047] In a possible implementation, determining a first weight of the current running data and a second weight of the historical access popularity according to the current running data includes:
[0048] Determine a first weight of the current running data according to the current running data;
[0049] A second weight of the historical access heat is determined according to the first weight and a preset value.
[0050] In a possible implementation, determining the first weight of the current operating data according to the current operating data includes:
[0051] Analyze the current running data to obtain data read and write records, input the data read and write records into the weight prediction model, and determine the first weight of the current running data; or,
[0052] According to the current operation data, a load value corresponding to the storage system is determined, and according to the load value and a preset mapping relationship, a first weight of the current operation data is determined.
[0053] In a possible implementation, the current operation data includes a read and write frequency, and determining the current access heat of the data block in the current cycle according to the current operation data, the historical access heat, the first weight, and the second weight includes:
[0054] Determine a first product between the read / write frequency and the first weight;
[0055] Determine a second product between the historical access popularity and the second weight;
[0056] The sum of the first product and the second product is determined as the current access heat.
[0057] The present application also provides a cache management device, including:
[0058] An acquisition module, used to acquire current operation data of the storage system in a current cycle and historical access heat of multiple data blocks, where the multiple data blocks are stored in the storage system;
[0059] A first determination module, used to determine a first weight of the current operation data and a second weight of the historical access heat according to the current operation data;
[0060] A second determination module is used to determine, for any data block, the current access heat of the data block in the current cycle according to the current running data, the historical access heat, the first weight and the second weight;
[0061] The update module is used to update the data blocks in the target cache according to the current access heat and historical access heat of each data block. The target cache is used to store hot data.
[0062] In a possible implementation manner, the update module is specifically used to:
[0063] Determining a plurality of first data blocks from a plurality of data blocks according to the current access popularity of each data block;
[0064] Determining a plurality of second data blocks from the plurality of data blocks according to the current access popularity and the historical access popularity of each data block;
[0065] Determine a plurality of update data blocks of the target cache according to the plurality of first data blocks, the plurality of second data blocks, and the plurality of current data blocks in the target cache;
[0066] The data blocks in the target cache are updated according to the multiple updated data blocks.
[0067] In a possible implementation manner, the update module is specifically used to:
[0068] Determine the data capacity corresponding to the multiple update data blocks;
[0069] Determine whether the remaining capacity of the target cache is greater than the data capacity;
[0070] If so, store the multiple updated data blocks into the cache space corresponding to the target cache;
[0071] If not, obtain the historical access data corresponding to each current data block, determine at least one data block to be deleted from multiple current data blocks based on the historical access data corresponding to each current data block and the current access popularity of each current data block, delete at least one data block to be deleted, and store multiple updated data blocks in the cache space corresponding to the target cache.
[0072] In a possible implementation manner, the update module is specifically used to:
[0073] Get the remaining capacity of the target cache.
[0074] Determine the capacity difference between the remaining capacity of the cache and the data capacity;
[0075] According to the capacity difference, determine the number of data blocks to be deleted;
[0076] According to the historical access data corresponding to each current data block and the current access popularity of each current data block, the to-be-deleted data blocks corresponding to the number of data blocks are determined from the multiple current data blocks.
[0077] In a possible implementation manner, the update module is specifically used to:
[0078] Determine, among the multiple current data blocks, multiple candidate data blocks whose current access heat is lower than a first threshold;
[0079] Determine the last access time of each candidate data block according to the historical access data corresponding to each candidate data block;
[0080] Sort multiple candidate data blocks according to the order of the last access time from far to near to obtain a first sequence;
[0081] The first n to-be-selected data blocks in the first sequence are determined as the to-be-deleted data blocks, where n is the number of data blocks.
[0082] In a possible implementation manner, the update module is specifically used to:
[0083] Determine the last access time corresponding to each current data block according to the historical access data corresponding to each current data block;
[0084] Sorting the multiple current data blocks according to the order of the last access time of each current data block from far to near to obtain a second sequence;
[0085] Determine the first m current data blocks in the second sequence as the third data block, where m is the sum of the number of data blocks and the first preset number;
[0086] Sorting the plurality of third data blocks in ascending order of the current access popularity of each third data block to obtain a third sequence;
[0087] The first n third data blocks in the third sequence are determined as data blocks to be deleted, where n is the number of data blocks and n is less than m.
[0088] In a possible implementation manner, the update module is specifically used to:
[0089] Sorting the multiple data blocks in descending order of the current access popularity of each data block to obtain a fourth sequence;
[0090] The first a data blocks in the fourth sequence are determined as a plurality of first data blocks, where a is a second preset number.
[0091] In a possible implementation manner, the update module is specifically used to:
[0092] Predict the second threshold based on historical access popularity;
[0093] Among the multiple data blocks, multiple data blocks whose current access heat is greater than a second threshold are determined as multiple second data blocks.
[0094] In a possible implementation manner, the update module is specifically used to:
[0095] Determine a first set, where the first set includes a plurality of first data blocks and a plurality of second data blocks;
[0096] In the first set, determining at least one fourth data block, the fourth data block being the same as any current data block;
[0097] Deleting at least one fourth data block from the first set to obtain a target set;
[0098] According to the target set, multiple update data blocks are determined.
[0099] In a possible implementation manner, the first determining module is specifically configured to:
[0100] Determine a first weight of the current running data according to the current running data;
[0101] A second weight of the historical access heat is determined according to the first weight and a preset value.
[0102] In a possible implementation manner, the first determining module is specifically configured to:
[0103] Analyze the current running data to obtain data read and write records, input the data read and write records into the weight prediction model, and determine the first weight of the current running data; or,
[0104] According to the current operation data, a load value corresponding to the storage system is determined, and according to the load value and a preset mapping relationship, a first weight of the current operation data is determined.
[0105] In a possible implementation manner, the current operation data includes a read and write frequency, and the second determination module is specifically configured to:
[0106] Determine a first product between the read / write frequency and the first weight;
[0107] Determine a second product between the historical access popularity and the second weight;
[0108] The sum of the first product and the second product is determined as the current access heat.
[0109] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above cache management methods when executing the computer program.
[0110] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned cache management methods are implemented.
[0111] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above cache management methods when executed by a processor.
[0112] Through this application, the current access popularity of each data block is calculated, and the resource allocation of the target cache is dynamically adjusted according to the current access popularity. Therefore, the problem of low data access efficiency of the storage system in the related art can be solved, and it can better adapt to the dynamic changes of data access, improve the cache hit rate, thereby increasing the data reading and writing speed, reducing the data access delay, and improving the data access efficiency of the storage system. BRIEF DESCRIPTION OF THE DRAWINGS
[0113] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0114] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;
[0115] Figure 2 A schematic diagram of a cache management method provided in an embodiment of the present application;
[0116] Figure 3 A flowchart of another cache management method provided in an embodiment of the present application;
[0117] Figure 4 A schematic diagram of the structure of a cache management device provided in an embodiment of the present application;
[0118] Figure 5 A schematic diagram of the structure of the electronic device provided in this application.
[0119] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0120] 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.
[0121] It should be noted that, in the description of this application, the terms "include", "comprise" or any other variant 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 includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0122] As the amount of data continues to grow, the performance requirements for storage systems are also getting higher and higher. Storage systems can include network attached storage (NAS) systems, cloud storage systems, distributed storage systems, etc. As the demand for data access in storage systems continues to increase, it is necessary to optimize the performance of storage systems.
[0123] In the related art, the data access performance of the storage system can be optimized by upgrading the hardware in the storage system, such as increasing the memory capacity in the storage system, upgrading the disk drive, upgrading the network interface card, etc. A certain amount of data can also be cached in the storage system to optimize the data access performance of the storage system. However, due to the complex and changeable requirements for accessing data, the cached data is not the data currently to be accessed, resulting in data access delays and low data access efficiency of the storage system.
[0124] In order to solve the above technical problems, the embodiment of the present application provides a cache management method, which obtains the current operation data of the storage system in the current cycle, determines the current access heat corresponding to multiple data blocks according to the current operation data, and stores multiple data blocks in the storage system. According to the current access heat of each data block, the data blocks in the target cache are updated, and the target cache is used to store hot data. In this way, by calculating the current access heat of each data block, the resource allocation of the target cache is dynamically adjusted according to the current access heat, so as to better adapt to the dynamic changes of data access, improve the cache hit rate, thereby improving the data reading and writing speed, reducing the data access delay, and improving the data access efficiency of the storage system.
[0125] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0126] In conjunction with the specific application environment architecture or the specific hardware architecture on which the execution of the cache management method depends, the specific application environment architecture or the specific hardware architecture is described herein.
[0127] Next, combine Figure 1 , taking the NAS system as an example, the storage system is explained.
[0128] See also Figure 1 , Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application. Figure 1 A NAS system 100 may be included. The NAS system 100 may include a NAS controller and a storage subsystem. The NAS controller may include a processor 101, a memory 102, a network interface 103, and a disk interface 104. The storage subsystem may include a hard disk 105 and a storage device 106.
[0129] The processor 101 , the memory 102 , the network interface 103 , and the disk interface 104 may be connected via a bus, and the disk interface 104 may be connected to a storage subsystem.
[0130] The processor 101 may be used to process data and manage network communications.
[0131] The memory 102 may be used to temporarily store operation data to improve system performance. The memory 102 may include a target cache.
[0132] The network interface 103 can be used to provide an interface for network connection, so that the NAS system can be connected to the network and perform data transmission through the network. For example, the network interface is an Ethernet port.
[0133] The disk interface 104 may be used to provide a channel for data transmission between the NAS controller and the storage subsystem to implement data storage and data access.
[0134] The hard disk 105 can be used to receive and store data from the controller or other network devices. The data may include files, databases, backup data, etc., depending on the usage scenario and user needs of the NAS system, which are not limited here.
[0135] The storage device 106 can be used to store data and connect to the NAS controller to read and write data.
[0136] Figure 2 A schematic diagram of a cache management method provided in an embodiment of the present application. The execution subject of the embodiment of the present application may be a NAS controller or a processor in the NAS controller. Figure 2 As shown, the method is as follows:
[0137] S201: Acquire current operation data of the storage system in the current cycle and historical access heats of multiple data blocks.
[0138] Multiple data blocks are stored in the storage system.
[0139] The current period may be a period determined according to a preset duration.
[0140] The current operation data may include resource usage data and performance indicator data.
[0141] Resource usage data may include processor usage, memory usage data, disk input and output operation data, and so on.
[0142] Performance indicator data may include read and write frequency, throughput, latency, etc.
[0143] The read / write frequency can be used to indicate the number of input / output operations per second of the storage system.
[0144] The historical access heat may include the access heat corresponding to the data block in at least one historical period.
[0145] The access popularity can be calculated using a preset algorithm.
[0146] The access popularity can be used to indicate the access trend corresponding to the data block.
[0147] The higher the access popularity of the data block, the greater the probability that the data block is accessed.
[0148] The system monitoring tool can be used to monitor the storage system in real time within the preset duration corresponding to the current cycle, obtain the current operation data of the storage system in the current cycle, and obtain the historical access popularity of multiple data blocks in the storage space.
[0149] S202: Determine a first weight of the current running data and a second weight of the historical access popularity according to the current running data.
[0150] The first weight and the second weight can be used to calculate the current access popularity.
[0151] The first weight may be used to indicate the weight ratio of the current running data in the current access heat.
[0152] The second weight may be used to indicate the weight ratio of the historical access heat to the current access heat.
[0153] The first weight and the second weight may be dynamically determined according to the load status of the storage system.
[0154] When the load of the storage system is high, the first weight is small and the second weight is large. The first weight and the second weight are dynamically adjusted to improve the response capability of the preset algorithm to sudden data access situations.
[0155] When the load of the storage system is low, the first weight is larger and the second weight is smaller. The stability and prediction accuracy of the preset algorithm are improved through dynamic adjustment of the first weight and the second weight.
[0156] Optionally, the first weight of the current running data and the second weight of the historical access popularity can be determined in the following manner: determine the first weight of the current running data based on the current running data; determine the second weight of the historical access popularity based on the first weight and a preset value.
[0157] Among them, the first weight of the current running data can be determined in the following ways: the current running data can be analyzed and processed to obtain data read and write records, and the data read and write records can be input into the weight prediction model to determine the first weight of the current running data; or, based on the current running data, the load value corresponding to the storage system can be determined, and the first weight of the current running data can be determined based on the load value and the preset mapping relationship.
[0158] The weight prediction model can be used to predict the first weight of the current running data.
[0159] The load value can be used to indicate the load condition of the storage system.
[0160] The preset mapping relationship may include multiple load ranges and a weight value corresponding to each load range.
[0161] Optionally, the first weight of the current running data and the second weight of the historical access popularity may be determined in the following manner: the current running data may be input into a preset model to obtain the first weight of the current running data and the second weight of the historical access popularity.
[0162] It should be noted that the first weight of the current running data and the second weight of the historical access popularity can be determined according to any feasible implementation method, and the embodiment of the present application is not limited to this.
[0163] S203: For any data block, determine the current access heat of the data block in the current cycle according to the current running data, the historical access heat, the first weight and the second weight.
[0164] The current access heat can be used to indicate the access trend of the data block in the current cycle.
[0165] Optionally, the current running data includes read and write frequencies, and the current access heat of the data block in the current cycle can be determined in the following manner: determine a first product between the read and write frequency and a first weight; determine a second product between the historical access heat and a second weight; and determine the sum of the first product and the second product as the current access heat.
[0166] Optionally, the current access heat of the data block in the current cycle can be determined by the following method: input the current running data, historical access heat, the first weight and the second weight into the heat prediction model to obtain the current access heat of the data block in the current cycle.
[0167] The popularity prediction model may be a trained learning model that is pre-stored in a storage system, and the form of the learning model is not limited here.
[0168] It should be noted that the current access popularity of a data block in the current cycle may be determined according to any feasible implementation method, and the embodiments of the present application are not limited to this.
[0169] S204: Update the data blocks in the target cache according to the current access popularity and historical access popularity of each data block.
[0170] The target cache is used to store hot data.
[0171] Optionally, the heat value of each data block may be determined according to the current access heat and the historical access heat of each data block, and the data blocks in the target cache may be updated according to the heat value of each data block.
[0172] The heat value may be determined based on the current access heat and the historical access heat.
[0173] Optionally, based on the current access heat of each data block, multiple first data blocks are determined among the multiple data blocks; based on the current access heat and historical access heat of each data block, multiple second data blocks are determined among the multiple data blocks; based on the multiple first data blocks, the multiple second data blocks, and the multiple current data blocks in the target cache, multiple updated data blocks of the target cache are determined; based on the multiple updated data blocks, the data blocks in the target cache are updated.
[0174] It should be noted that the data blocks in the target cache may be updated according to any feasible implementation method, and the embodiments of the present application are not limited to this.
[0175] The cache management method provided in this embodiment obtains the current running data of the storage system in the current cycle and the historical access heat of multiple data blocks, and multiple data blocks are stored in the storage system; according to the current running data, the first weight of the current running data and the second weight of the historical access heat are determined; for any data block, the current access heat of the data block in the current cycle is determined according to the current running data, the historical access heat, the first weight and the second weight; according to the current access heat and the historical access heat of each data block, the data blocks in the target cache are updated, and the target cache is used to store hot data. In this way, by calculating the current access heat of each data block, the resource allocation of the target cache is dynamically adjusted according to the current access heat, so as to better adapt to the dynamic changes of data access, improve the cache hit rate, thereby improving the data reading and writing speed, reducing the data access delay, and improving the data access efficiency of the storage system.
[0176] Next, combine Figure 3 , the process (S204) of updating the data blocks in the target cache according to the current access heat and the historical access heat of each data block is explained.
[0177] Figure 3 A flowchart of another cache management method provided by an embodiment of the present application. Based on the above embodiment, see Figure 3 , the method is described in detail. The method comprises:
[0178] S301: Determine a plurality of first data blocks from a plurality of data blocks according to the current access popularity of each data block.
[0179] The first data block may be used to indicate a data block that is more likely to be frequently accessed.
[0180] The first data block may include a data block whose current access heat value is greater than a third threshold, or may include a data block whose current access heat value is higher than the current access heat value of some data blocks.
[0181] Optionally, multiple first data blocks can be determined from multiple data blocks according to the current access popularity of each data block in the following manner: sort the multiple data blocks in order from large to small according to the current access popularity of each data block to obtain a fourth sequence; and determine the first a data blocks in the fourth sequence as multiple first data blocks.
[0182] Wherein, a is a second preset number, which is not limited here.
[0183] Optionally, multiple first data blocks may be determined from multiple data blocks according to the current access heat of each data block in the following manner: among the multiple data blocks, data blocks whose current access heat is greater than a third threshold are determined as multiple first data blocks.
[0184] The third threshold is an integer greater than 1.
[0185] It should be noted that multiple first data blocks can be determined according to any feasible implementation method, and the embodiments of the present application are not limited to this.
[0186] S302: Determine a plurality of second data blocks from a plurality of data blocks according to the current access popularity and the historical access popularity of each data block.
[0187] The second data block may be used to indicate a data block for which a pre-fetch operation is to be performed.
[0188] Optionally, multiple second data blocks can be determined from multiple data blocks based on the current access popularity and historical access popularity of each data block: a second threshold can be predicted based on the historical access popularity; and among the multiple data blocks, multiple data blocks whose current access popularity is greater than the second threshold are determined as multiple second data blocks.
[0189] The second threshold may be obtained by inputting the historical access heat into the prediction threshold model.
[0190] Optionally, multiple second data blocks can be determined from multiple data blocks based on the current access popularity and historical access popularity of each data block: a second threshold can be predicted based on the current access popularity and the historical access popularity; and among the multiple data blocks, multiple data blocks whose current access popularity is greater than the second threshold are determined as multiple second data blocks.
[0191] The second threshold may be obtained by inputting the historical access popularity and the current access popularity into a prediction threshold model.
[0192] It should be noted that multiple second data blocks can be determined according to any feasible implementation method, and the embodiments of the present application are not limited to this.
[0193] S303: Determine a plurality of update data blocks of the target cache according to a plurality of first data blocks, a plurality of second data blocks, and a plurality of current data blocks in the target cache.
[0194] The updated data block may be a data block to be stored in the target cache.
[0195] Optionally, multiple update data blocks can be determined in the following manner: determine a first set; determine at least one fourth data block in the first set; delete at least one fourth data block in the first set to obtain a target set; and determine multiple update data blocks based on the target set.
[0196] The first set includes a plurality of first data blocks and a plurality of second data blocks, and the fourth data block is the same as any current data block.
[0197] Optionally, multiple updated data blocks can be determined in the following manner: determine at least one fifth data block different from any current data block among multiple first data blocks, determine at least one sixth data block different from any current data block among multiple second data blocks, and determine multiple updated data blocks based on the at least one fifth data block and the at least one sixth data block.
[0198] It should be noted that the multiple update data blocks of the target cache may be determined according to any feasible implementation method, and the embodiments of the present application are not limited to this.
[0199] S304: Determine the data capacity corresponding to the multiple update data blocks.
[0200] The data capacity can be used to indicate the size of multiple update data blocks.
[0201] A first number of the plurality of update data blocks may be determined, and the data capacity may be determined based on the first number.
[0202] S305: Determine whether the remaining capacity of the cache corresponding to the target cache is greater than the data capacity.
[0203] If yes, execute S306;
[0204] If not, execute S307.
[0205] The remaining cache capacity corresponding to the target cache may be obtained to determine whether the remaining cache capacity corresponding to the target cache is greater than the data capacity.
[0206] S306: Store the multiple updated data blocks into the cache space corresponding to the target cache.
[0207] S307: Obtain historical access data corresponding to each current data block, determine at least one data block to be deleted from multiple current data blocks based on the historical access data corresponding to each current data block and the current access popularity of each current data block, delete at least one data block to be deleted, and store multiple updated data blocks in the cache space corresponding to the target cache.
[0208] The historical access data may include access data corresponding to at least one historical period.
[0209] The historical access data may include at least one historical access time and access times, and the like.
[0210] The data blocks to be deleted may be used to represent data blocks in the target cache that are not frequently accessed and have not been accessed for a long period of time.
[0211] Optionally, at least one data block to be deleted can be determined from multiple current data blocks based on historical access data corresponding to each current data block and the current access popularity of each current data block in the following manner: obtain the cache remaining capacity corresponding to the target cache; determine the capacity difference between the cache remaining capacity and the data capacity; determine at least one data block to be deleted from multiple current data blocks based on historical access data corresponding to each current data block and the current access popularity of each current data block, and the capacity corresponding to at least one data block to be deleted is greater than or equal to the capacity difference.
[0212] Optionally, at least one data block to be deleted can be determined from multiple current data blocks based on historical access data corresponding to each current data block and the current access popularity of each current data block in the following manner: obtain the cache remaining capacity corresponding to the target cache; determine the capacity difference between the cache remaining capacity and the data capacity; determine the number of data blocks to be deleted based on the capacity difference; determine the data blocks to be deleted corresponding to the number of data blocks from multiple current data blocks based on the historical access data corresponding to each current data block and the current access popularity of each current data block.
[0213] It should be noted that at least one data block to be deleted can be determined according to any feasible implementation method, and the embodiments of the present application are not limited to this.
[0214] Optionally, data blocks to be deleted corresponding to the number of data blocks can be determined among multiple current data blocks according to historical access data corresponding to each current data block and the current access heat of each current data block in the following manner: among multiple current data blocks, determine multiple candidate data blocks whose current access heat is lower than a first threshold; determine the last access time of each candidate data block according to the historical access data corresponding to each candidate data block; sort the multiple candidate data blocks according to the order of the last access time from far to near to obtain a first sequence; and determine the first n candidate data blocks in the first sequence as the data blocks to be deleted, where n is the number of data blocks.
[0215] The last access time may be the time closest to the current time in the historical access times.
[0216] Optionally, data blocks to be deleted corresponding to the number of data blocks can be determined in multiple current data blocks according to historical access data corresponding to each current data block and the current access heat of each current data block in the following manner: determine the last access time corresponding to each current data block according to the historical access data corresponding to each current data block; sort the multiple current data blocks according to the order of the last access time of each current data block from far to near to obtain a second sequence; determine the first m current data blocks in the second sequence as third data blocks, where m is the sum of the number of data blocks and the first preset number; sort the multiple third data blocks in the order of the current access heat of each third data block from small to large to obtain a third sequence; determine the first n third data blocks in the third sequence as data blocks to be deleted, where n is the number of data blocks, and n is less than m.
[0217] The first preset number may be determined according to the number of current data blocks and a first mapping relationship, and the first mapping relationship may include multiple number ranges and a preset number corresponding to each number range.
[0218] The cache management method provided in the present embodiment determines a plurality of first data blocks from a plurality of data blocks according to the current access heat of each data block; determines a plurality of second data blocks from a plurality of data blocks according to the current access heat and the historical access heat of each data block; determines a plurality of updated data blocks of a target cache according to the plurality of first data blocks, the plurality of second data blocks, and the plurality of current data blocks in the target cache; determines the data capacity corresponding to the plurality of updated data blocks; determines whether the remaining cache capacity corresponding to the target cache is greater than the data capacity; if so, stores the plurality of updated data blocks in the cache space corresponding to the target cache; if not, obtains the historical access data corresponding to each current data block, determines at least one data block to be deleted from the plurality of current data blocks according to the historical access data corresponding to each current data block and the current access heat of each current data block, deletes at least one data block to be deleted, and stores the plurality of updated data blocks in the cache space corresponding to the target cache. In this way, by calculating the current access popularity of each data block, the resource allocation of the target cache is dynamically adjusted according to the current access popularity, so as to better adapt to the dynamic changes of data access and improve the cache hit rate, thereby increasing the data reading and writing speed, reducing the data access latency, and improving the data access efficiency of the storage system.
[0219] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.
[0220] Figure 4 A schematic diagram of the structure of a cache management device provided in an embodiment of the present application. Figure 4 The cache management device 400 includes an acquisition module 401, a first determination module 402, a second determination module 403 and an update module 404, wherein:
[0221] The acquisition module 401 is used to acquire the current operation data of the storage system in the current cycle and the historical access heat of multiple data blocks, where the multiple data blocks are stored in the storage system;
[0222] A first determination module 402, configured to determine a first weight of the current operation data and a second weight of the historical access popularity according to the current operation data;
[0223] The second determination module 403 is used to determine, for any data block, the current access heat of the data block in the current cycle according to the current running data, the historical access heat, the first weight and the second weight;
[0224] The updating module 404 is used to update the data blocks in the target cache according to the current access heat and the historical access heat of each data block, and the target cache is used to store hot data.
[0225] In a possible implementation, the updating module 404 is specifically configured to:
[0226] Determining a plurality of first data blocks from a plurality of data blocks according to the current access popularity of each data block;
[0227] Determining a plurality of second data blocks from the plurality of data blocks according to the current access popularity and the historical access popularity of each data block;
[0228] Determine a plurality of update data blocks of the target cache according to the plurality of first data blocks, the plurality of second data blocks, and the plurality of current data blocks in the target cache;
[0229] The data blocks in the target cache are updated according to the multiple updated data blocks.
[0230] In a possible implementation, the updating module 404 is specifically configured to:
[0231] Determine the data capacity corresponding to the multiple update data blocks;
[0232] Determine whether the remaining capacity of the target cache is greater than the data capacity;
[0233] If so, store the multiple updated data blocks into the cache space corresponding to the target cache;
[0234] If not, obtain the historical access data corresponding to each current data block, determine at least one data block to be deleted from multiple current data blocks based on the historical access data corresponding to each current data block and the current access popularity of each current data block, delete at least one data block to be deleted, and store multiple updated data blocks in the cache space corresponding to the target cache.
[0235] In a possible implementation, the updating module 404 is specifically configured to:
[0236] Get the remaining capacity of the target cache.
[0237] Determine the capacity difference between the remaining capacity of the cache and the data capacity;
[0238] According to the capacity difference, determine the number of data blocks to be deleted;
[0239] According to the historical access data corresponding to each current data block and the current access popularity of each current data block, the to-be-deleted data blocks corresponding to the number of data blocks are determined from the multiple current data blocks.
[0240] In a possible implementation, the updating module 404 is specifically configured to:
[0241] Determine, among the multiple current data blocks, multiple candidate data blocks whose current access heat is lower than a first threshold;
[0242] Determine the last access time of each candidate data block according to the historical access data corresponding to each candidate data block;
[0243] Sort multiple candidate data blocks according to the order of the last access time from far to near to obtain a first sequence;
[0244] The first n to-be-selected data blocks in the first sequence are determined as the to-be-deleted data blocks, where n is the number of data blocks.
[0245] In a possible implementation, the updating module 404 is specifically configured to:
[0246] Determine the last access time corresponding to each current data block according to the historical access data corresponding to each current data block;
[0247] Sorting the multiple current data blocks according to the order of the last access time of each current data block from far to near to obtain a second sequence;
[0248] Determine the first m current data blocks in the second sequence as the third data block, where m is the sum of the number of data blocks and the first preset number;
[0249] Sorting the plurality of third data blocks in ascending order of the current access popularity of each third data block to obtain a third sequence;
[0250] The first n third data blocks in the third sequence are determined as data blocks to be deleted, where n is the number of data blocks and n is less than m.
[0251] In a possible implementation, the updating module 404 is specifically configured to:
[0252] Sorting the multiple data blocks in descending order of the current access popularity of each data block to obtain a fourth sequence;
[0253] The first a data blocks in the fourth sequence are determined as a plurality of first data blocks, where a is a second preset number.
[0254] In a possible implementation, the updating module 404 is specifically configured to:
[0255] Predict the second threshold based on historical access popularity;
[0256] Among the multiple data blocks, multiple data blocks whose current access heat is greater than a second threshold are determined as multiple second data blocks.
[0257] In a possible implementation, the updating module 404 is specifically configured to:
[0258] Determine a first set, where the first set includes a plurality of first data blocks and a plurality of second data blocks;
[0259] In the first set, determining at least one fourth data block, the fourth data block being the same as any current data block;
[0260] Deleting at least one fourth data block from the first set to obtain a target set;
[0261] According to the target set, multiple update data blocks are determined.
[0262] In a possible implementation manner, the first determining module 402 is specifically configured to:
[0263] Determine a first weight of the current running data according to the current running data;
[0264] A second weight of the historical access heat is determined according to the first weight and a preset value.
[0265] In a possible implementation manner, the first determining module 402 is specifically configured to:
[0266] Analyze the current running data to obtain data read and write records, input the data read and write records into the weight prediction model, and determine the first weight of the current running data; or,
[0267] According to the current operation data, a load value corresponding to the storage system is determined, and according to the load value and a preset mapping relationship, a first weight of the current operation data is determined.
[0268] In a possible implementation manner, the current operation data includes a read and write frequency, and the second determination module 403 is specifically configured to:
[0269] Determine a first product between the read / write frequency and the first weight;
[0270] Determine a second product between the historical access popularity and the second weight;
[0271] The sum of the first product and the second product is determined as the current access heat.
[0272] For the description of the features in the embodiment corresponding to the cache management device, please refer to the relevant description of the embodiment corresponding to the cache management method, which will not be repeated here.
[0273] Figure 5 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 5 As shown, the electronic device 500 provided in this embodiment includes: at least one processor 501 and a memory 502. Optionally, the electronic device 500 further includes a communication component 503. The processor 501, the memory 502 and the communication component 503 are connected via a bus 504.
[0274] In a specific implementation process, at least one processor 501 executes the computer execution instructions stored in the memory 502, so that at least one processor 501 executes the above-mentioned cache management method embodiment.
[0275] The specific implementation process of the processor 501 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0276] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the application may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0277] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (NVM), such as at least one disk storage.
[0278] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0279] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above cache management method embodiments when running.
[0280] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0281] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above cache management method embodiments are implemented.
[0282] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned cache management method embodiments are implemented.
[0283] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0284] The above is a detailed introduction to a cache management method provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A cache management method, characterized in that: include: Acquire current operation data of the storage system in a current cycle and historical access heats of a plurality of data blocks, wherein the plurality of data blocks are stored in the storage system; Determine, according to the current running data, a first weight of the current running data and a second weight of the historical access popularity; For any data block, determine the current access heat of the data block in the current cycle according to the current running data, the historical access heat, the first weight and the second weight; According to the current access heat and the historical access heat of each data block, the data blocks in the target cache are updated, and the target cache is used to store hot data.
2. The cache management method according to claim 1, characterized in that: According to the current access popularity and historical access popularity of each data block, the data blocks in the target cache are updated, including: Determining a plurality of first data blocks from the plurality of data blocks according to the current access popularity of each data block; Determining a plurality of second data blocks from the plurality of data blocks according to the current access popularity and the historical access popularity of each data block; Determine a plurality of update data blocks of the target cache according to the plurality of first data blocks, the plurality of second data blocks, and a plurality of current data blocks in the target cache; The data blocks in the target cache are updated according to the multiple updated data blocks.
3. The cache management method according to claim 2, characterized in that: Updating the data blocks in the target cache according to the multiple updated data blocks includes: Determining data capacity corresponding to the plurality of update data blocks; Determine whether the remaining capacity of the cache corresponding to the target cache is greater than the data capacity; If so, storing the multiple updated data blocks into the cache space corresponding to the target cache; If not, obtain the historical access data corresponding to each current data block, determine at least one data block to be deleted from the multiple current data blocks based on the historical access data corresponding to each current data block and the current access popularity of each current data block, delete the at least one data block to be deleted, and store the multiple updated data blocks in the cache space corresponding to the target cache.
4. The cache management method according to claim 3, characterized in that: Determining at least one data block to be deleted from the multiple current data blocks according to the historical access data corresponding to each current data block and the current access popularity of each current data block, including: Obtaining the remaining capacity of the cache corresponding to the target cache; Determining a capacity difference between the cache remaining capacity and the data capacity; Determining the number of data blocks to be deleted according to the capacity difference; According to the historical access data corresponding to each current data block and the current access popularity of each current data block, the to-be-deleted data blocks corresponding to the number of data blocks are determined from the multiple current data blocks.
5. The cache management method according to claim 4, characterized in that: Determining the to-be-deleted data blocks corresponding to the number of data blocks from the multiple current data blocks according to the historical access data corresponding to each current data block and the current access popularity of each current data block includes: Determine, among the multiple current data blocks, multiple candidate data blocks whose current access heat is lower than a first threshold; Determine the last access time of each candidate data block according to the historical access data corresponding to each candidate data block; Sort multiple candidate data blocks according to the order of the last access time from far to near to obtain a first sequence; The first n to-be-selected data blocks in the first sequence are determined as the to-be-deleted data blocks, where n is the number of the data blocks.
6. The cache management method according to claim 4, characterized in that: Determining the to-be-deleted data blocks corresponding to the number of data blocks from the multiple current data blocks according to the historical access data corresponding to each current data block and the current access popularity of each current data block includes: Determine the last access time corresponding to each current data block according to the historical access data corresponding to each current data block; Sorting the multiple current data blocks according to the order of the last access time of each current data block from far to near to obtain a second sequence; Determine the first m current data blocks in the second sequence as third data blocks, where m is the sum of the number of the data blocks and the first preset number; Sorting the plurality of third data blocks in ascending order of the current access popularity of each third data block to obtain a third sequence; The first n third data blocks in the third sequence are determined as data blocks to be deleted, where n is the number of data blocks and n is less than m.
7. The cache management method according to any one of claims 2 to 6, characterized in that: Determining a plurality of first data blocks from the plurality of data blocks according to the current access heat of each data block includes: Sorting the plurality of data blocks in descending order of the current access popularity of each data block to obtain a fourth sequence; The first a data blocks in the fourth sequence are determined as a plurality of first data blocks, where a is a second preset number.
8. The cache management method according to any one of claims 2 to 6, characterized in that: Determining a plurality of second data blocks from the plurality of data blocks according to the current access heat and the historical access heat of each data block includes: Predicting a second threshold value according to the historical access popularity; Among the multiple data blocks, multiple data blocks whose current access heat is greater than the second threshold are determined as multiple second data blocks.
9. The cache management method according to any one of claims 2 to 6, characterized in that: Determining a plurality of update data blocks of the target cache according to the plurality of first data blocks, the plurality of second data blocks, and a plurality of current data blocks in the target cache comprises: Determine a first set, wherein the first set includes the plurality of first data blocks and the plurality of second data blocks; In the first set, determining at least one fourth data block, the fourth data block being the same as any current data block; Deleting the at least one fourth data block from the first set to obtain a target set; The multiple update data blocks are determined according to the target set.
10. The cache management method according to any one of claims 1 to 6, characterized in that: Determining, according to the current running data, a first weight of the current running data and a second weight of the historical access heat, includes: Determining a first weight of the current running data according to the current running data; A second weight of the historical access popularity is determined according to the first weight and a preset value.
11. The cache management method according to claim 10, characterized in that: Determining a first weight of the current running data according to the current running data includes: Analyze the current running data to obtain data read and write records, input the data read and write records into a weight prediction model, and determine a first weight of the current running data; or, A load value corresponding to the storage system is determined according to the current operation data, and a first weight of the current operation data is determined according to the load value and a preset mapping relationship.
12. The cache management method according to any one of claims 1 to 6, characterized in that: The current operation data includes a read and write frequency, and determining the current access heat of the data block in the current cycle according to the current operation data, the historical access heat, the first weight, and the second weight includes: Determine a first product between the read / write frequency and the first weight; Determine a second product between the historical access popularity and the second weight; The sum of the first product and the second product is determined as the current access heat.
13. An electronic device, characterized in that: include: Memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the cache management method according to any one of claims 1 to 12.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the cache management method according to any one of claims 1 to 12.
15. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the cache management method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Method for replacing cache files, device and system thereof
CN102511043A
Cache updating method, device and equipment of storage system, medium and platform
CN117235088A
Method and system for adaptively setting validity period of buffer data, equipment and medium
CN117421338A
Hot data real-time recommendation method and system, electronic equipment and storage medium
CN117633355A
Cross-level data prefetching method and device, equipment and medium
CN119003387A
Cited By
Data manager, data management method, electronic equipment and storage medium
CN120335731A
Data pre-reading method, storage medium and electronic equipment
CN120596038A
Storage position adjusting method and device, equipment, storage medium and program product
CN120631276A