Cache elimination method based on frequency driving
By distinguishing the memory cache into high -frequency and low -frequency areas, and managing the caching entry according to the access frequency, the problem of low cache rate and difficulty in cost control in the existing technology has been solved, and more efficient cache data management and cost control have been achieved.
Patent Information
- Application Number
- CN202411285973.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-09-13
AI Technical Summary
In the prior art, when processing cached data queries in large-capacity storage systems, it is difficult to effectively identify and retain hot data, resulting in low cache hit rate and difficulty in cost control.
Adopt a frequency-driven cache elimination method to divide the memory cache into high-frequency areas and low-frequency areas. Cache entries are inserted or moved to the corresponding cache area according to their access frequency, and are eliminated when the cache space is full and have not been accessed for the longest time. data.
It has improved the response time of reading requests and an eager hit rate, effectively controlled the storage cost, ensured that thermal data was retained in high -frequency zones, and cold data was eliminated in the low -frequency area.
Smart Images

Figure CN119357088A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of storage systems, and in particular to a cache elimination method based on frequency driving. Background Art
[0002] Large-capacity storage systems are becoming an indispensable part of today's data centers. Large-capacity storage systems can store massive amounts of data. Depending on the storage scale, each large-capacity storage system cluster has dozens to thousands of nodes, and each node consists of hundreds of disks and several solid-state drive caches. Each node is usually measured in TB (terabyte) or PB (petabyte).
[0003] Memory cache systems can provide more effective support for large-capacity storage systems. The most classic cache eviction algorithms are LRU (least recently used) and LFU (least frequently used). LRU works better for workloads with strong temporal locality, but sudden large-scale sequential accesses may cause cache pollution. LFU is suitable for workloads where certain data is frequently accessed and the access frequency is relatively stable, but high-frequency historical data will be retained even if it is not accessed for a long time, resulting in less and less liquid cache data, which is not conducive to the identification of subsequent hot data. In order to effectively handle cache data queries in large-capacity storage systems, we need to give the memory cache system an efficient cache eviction method. Summary of the invention
[0004] In order to solve the problems existing in the prior art, the present invention provides a frequency-driven cache elimination method, which divides the memory cache into a high-frequency area and a low-frequency area, which share the total cache space. The high-frequency area is at most 1.5 times the low-frequency area. The two cache areas are divided by the average access frequency p. When the access frequency of the cache entry is less than or equal to p, it is inserted into the low-frequency area, and vice versa. Secondly, the data in the high-frequency area and the low-frequency area can be exchanged according to the average frequency, which is helpful to identify hot data. Ultimately, the global hot data and the hot data in the most recently accessed stage will be stored in the high-frequency area as much as possible. Cold data and hot data in the least recently accessed stage are stored in the low-frequency area. In this way, hot data can be effectively distinguished, solving the problems mentioned in the above background technology.
[0005] To achieve the above object, the present invention provides the following technical solution: a frequency-driven cache elimination method, comprising the following steps:
[0006] S1, initialize cache space information;
[0007] S2, monitor the read request of the user access and determine whether the cache entry is hit in the memory cache system;
[0008] S3. If it is judged as a miss, the backend storage is accessed, the data is read from the bottom layer, and converted into a cache entry and inserted into the memory cache system. When a cache entry is added to the memory cache, it is first inserted into the low-frequency area, and then it is determined whether the cache space is full.
[0009] S4. If the cache space occupancy rate reaches 100%, it means that the cache is full and the data needs to be eliminated.
[0010] S5. If it is judged to be a hit, the memory cache system is directly accessed to find the corresponding cache block *p according to the LBA; when the cache entry is hit, its Freq is increased by 1; then it is determined whether the updated cache entry access frequency Freq is greater than the average frequency;
[0011] S6. If the updated Freq value is greater than or equal to the average frequency, the cache entry is moved to the first position in the high frequency area; if the updated Freq value is less than the average frequency, the cache entry is moved to the first position in the low frequency area;
[0012] S7. After the search is completed, the number of successful queries is increased by 1, and then it is determined whether the number of successful queries is greater than the average access frequency threshold p. If it is greater, the average frequency of the memory cache is recalculated and updated; the new average frequency is equal to the total access frequency divided by the total number of cache entries, and the number of successful queries is reset to 0.
[0013] S8. When the next read request arrives, start the next round of cache elimination operation according to steps S1 to S7.
[0014] Preferably, in step S1, the total memory size is set to 128GB, the memory cache space size is set to 25% of the total memory size, i.e. 32GB; the cache block size is 512KB; the cache entry average access frequency threshold p=65536; the initial average frequency is set to 1; and the number of successful queries is set to 0.
[0015] Preferably, in step S1, the memory cache is divided into a high-frequency area and a low-frequency area, which share the total cache space; the two cache areas are separated by an average access frequency threshold p of cache entries, wherein the high-frequency area is 1.5 times the low-frequency area.
[0016] Preferably, the cache entry includes three fields: LBA represents the logical block number of the underlying storage device; *p represents the cache block address pointer; Freq represents the frequency at which the cache entry is accessed.
[0017] Preferably, in step S4, when eliminating data, if the space occupied by the high-frequency area is greater than or equal to 1.5 times the space occupied by the low-frequency area, the data that has not been accessed for the longest time in the high-frequency area is eliminated; if the space occupied by the high-frequency area is less than 1.5 times the space occupied by the low-frequency area, the data that has not been accessed for the longest time in the low-frequency area is eliminated.
[0018] The beneficial effects of the present invention are:
[0019] 1) Faster read request response time: The frequency-driven cache elimination algorithm can cache hot data more effectively and ensure a high cache hit rate. Users' read requests will access memory more frequently. When a read request hits the memory cache, the latency can be maintained at the ns level and the throughput is also at the GB / s level. This greatly reduces the response time of large-capacity storage systems.
[0020] 2) More effective cost control: As time goes by, more and more hot data will accumulate in the memory, but storing hot data that is no longer accessed will result in ineffective costs. Therefore, the frequency-driven cache eviction algorithm ensures that hot data is more likely to be retained than cold data, and can continuously evict hot data that is no longer accessed. This helps control costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 Schematic diagram of the process of cache elimination method based on frequency drive in an embodiment of the present invention;
[0022] Figure 2 Schematic diagram of a frequency-driven cache elimination method in an embodiment of the present invention. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] The present invention provides a technical solution: a cache elimination method based on frequency drive, such as Figure 1 and 2 As shown, the implementation steps include the following:
[0025] (1) Initialize cache space information. The total memory size is 128GB. Set the memory cache space size to 25% of the total memory size (32GB). The cache block size is 512KB. The initial average frequency is set to 1. The number of successful queries is set to 0. Set the cache entry average access frequency threshold p = 65536 (32GB / 512KB). Divide the memory cache into a high-frequency area and a low-frequency area, which share the total cache space. The two cache areas are separated by the cache entry average access frequency threshold p, where the high-frequency area is 1.5 times the low-frequency area.
[0026] (2) The memory cache system starts monitoring read requests from users.
[0027] (3) If the requested cache is not in the memory cache, the data is read from the bottom layer and converted into a cache entry and inserted into the memory cache system. The cache entry includes three fields: LBA represents the logical block number of the bottom storage device; *p represents the cache block address pointer; Freq represents the frequency of cache entry access.
[0028] (4) When a cache entry is added to the memory cache, it is first inserted into the low-frequency area.
[0029] (5) If the cache space occupancy rate reaches 100%, the data needs to be eliminated.
[0030] (6) If the space occupied by the high-frequency area is greater than or equal to 1.5 times the space occupied by the low-frequency area, the data in the high-frequency area that has not been accessed for the longest time will be eliminated.
[0031] (7) If the space occupied by the high-frequency area is less than 1.5 times the space occupied by the low-frequency area, the data in the low-frequency area that has not been accessed for the longest time will be eliminated.
[0032] (8) If the read request is cached in the memory cache, directly access the memory cache system. Find the corresponding cache block *p according to the LBA. When the cache entry is hit, add one to its Freq, and then determine whether the updated cache entry access frequency Freq is greater than the average frequency;
[0033] (9) If the updated Freq value is greater than or equal to the average frequency, the cache entry is moved to the first position in the high frequency area.
[0034] (10) If the updated Freq value is less than the average frequency, the cache entry is moved to the first position in the low-frequency area.
[0035] (11) After the search is completed, the number of successful queries is increased by 1, and then it is determined whether the number of successful queries is greater than the average access frequency threshold p;
[0036] (12) If the number of successful queries is greater than or equal to the frequency update threshold, the average frequency of the memory cache is recalculated and updated. The new average frequency is equal to the total access frequency divided by the total number of cache entries, and the number of successful queries is reset to 0.
[0037] After (13) is completed, when the next read request arrives, the next round of caching operation is started according to steps (1)-(12).
[0038] At this point, the frequency-driven cache elimination method described in the present invention is completely completed.
[0039] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0040] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0041] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0042] The "first\second" mentioned in the embodiments is only to distinguish similar objects, and does not represent a specific order for the objects. It is understandable that the "first\second" can be interchanged with the specific order or sequence where permitted. It should be understood that the objects distinguished by "first\second" can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.
[0043] Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A frequency-driven cache elimination method, characterized in that: The steps include: S1, initialize cache space information; S2, monitor the read request of the user access and determine whether the cache entry is hit in the memory cache system; S3. If it is judged as a miss, the backend storage is accessed, the data is read from the bottom layer, and converted into a cache entry and inserted into the memory cache system. When a cache entry is added to the memory cache, it is first inserted into the low-frequency area, and then it is determined whether the cache space is full. S4. If the cache space occupancy rate reaches 100%, it means that the cache is full and the data needs to be eliminated. S5. If it is judged to be a hit, the memory cache system is directly accessed to find the corresponding cache block *p according to the LBA; when the cache entry is hit, its Freq is increased by 1; then it is determined whether the updated cache entry access frequency Freq is greater than the average frequency; S6. If the updated Freq value is greater than or equal to the average frequency, the cache entry is moved to the first position in the high frequency area; if the updated Freq value is less than the average frequency, the cache entry is moved to the first position in the low frequency area; S7. After the search is completed, the number of successful queries is increased by 1, and then it is determined whether the number of successful queries is greater than the average access frequency threshold p. If it is greater, the average frequency of the memory cache is recalculated and updated; the new average frequency is equal to the total access frequency divided by the total number of cache entries, and the number of successful queries is reset to 0. S8. When the next read request arrives, start the next round of cache elimination operation according to steps S1 to S7.
2. The frequency-driven cache elimination method according to claim 1, characterized in that: In step S1, the total memory size is set to 128GB, and the memory cache space size is set to 25% of the total memory size, i.e., 32GB; the cache block size is 512KB; the cache entry average access frequency threshold p=65536; the initial average frequency is set to 1; and the number of successful queries is set to 0.
3. The frequency-driven cache elimination method according to claim 1, characterized in that: In step S1, the memory cache is divided into a high-frequency area and a low-frequency area, which share the total cache space; the two cache areas are separated by an average access frequency threshold p of cache entries, where the high-frequency area is 1.5 times the low-frequency area.
4. The frequency-driven cache elimination method according to claim 1, characterized in that: The cache entry includes three fields: LBA represents the underlying storage device logical block number; *p represents the cache block address pointer; Freq represents the frequency at which the cache entry is accessed.
5. The frequency-driven cache elimination method according to claim 1, characterized in that: In step S4, when eliminating data, if the space occupied by the high-frequency area is greater than or equal to 1.5 times the space occupied by the low-frequency area, the data that has not been accessed for the longest time in the high-frequency area is eliminated; if the space occupied by the high-frequency area is less than 1.5 times the space occupied by the low-frequency area, the data that has not been accessed for the longest time in the low-frequency area is eliminated.
Citation Information
Patent Citations
Data storage method and device
CN101794259A
Caching method and device based on two-layer cache structure
CN115563029A
Flash memory device
US20110191521A1
Replacement of cache entries in a set-associative cache
US20200310969A1
Sedram-based stacked cache system and device and controlling method therefor
US20220276969A1
Cited By
Method and system for caching web interface data
CN120301946A