A hybrid storage read cache design method based on elastic memory

Through the combination of two-level cache and cache elimination strategies, the read efficiency of SSD-HDD hybrid storage is optimized by using elastic memory strategies, and the problem of read cache design not using memory space and post-power outage reconstruction in the existing technology is solved, achieving efficient Read request response and memory resource management.

CN118535089BActive Publication Date: 2024-11-22QINGHAI NORMAL UNIV
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202410522766.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-28
Publication Date
2024-11-22
Estimated Expiration
2044-04-28

AI Technical Summary

Technical Problem

The existing read cache design of hybrid storage is mainly concentrated on SSD, which does not fully utilize the memory space and lacks support for read cache reconstruction after power outage, resulting in low read efficiency.

Method used

Adopting a two-level cache design, the first-level cache and second-level cache are managed through the LFU and LRU cache elimination strategy, the elastic memory strategy is used to dynamically adjust the cache size, ensuring the full utilization of memory space, and quickly reconstruct the first-level cache through the second-level cache.

Benefits of technology

It significantly improves read request response time and cache hit rate, reduces access to low-speed HDDs, avoids waste and overflow of memory resources, and ensures efficient operation of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535089B_ABST
    Figure CN118535089B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of high-performance storage systems and computer architecture, and specifically discloses a hybrid storage read cache design method based on elastic memory. First, hot data can be effectively stored through two-level cache, and the system's access to low-speed HDDs can be reduced as much as possible. Secondly, the size of the first-level cache is controlled by elastic memory to fully and safely utilize the memory space. Finally, the first-level cache and the second-level cache are managed respectively by the cache elimination strategies of LFU and LRU. Finally, the second-level cache can help the first-level cache improve the efficiency of reconstruction. The present invention dynamically opens up a first-level cache space in the memory. The larger the remaining memory space, the larger the first-level cache space; the smaller the remaining memory space, the smaller the first-level cache space. This can avoid the waste of memory resources and prevent memory overflow caused by excessive cache space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of hybrid storage read cache, and in particular to a hybrid storage read cache design method based on elastic memory. Background Art

[0002] With the continuous development of computer applications, the demand for data storage is increasing. Traditional mechanical hard disks (HDDs) can provide large storage space, but there are some bottlenecks in performance, especially when dealing with a large number of random access and high concurrent read / write operations. The emergence of solid-state drives (SSDs) can well solve this performance defect. SSDs have high read and write speeds, low latency, and good random access performance, making them an ideal choice for improving the overall performance of the system. However, SSDs are relatively expensive and have limited capacity. In order to find a balance between performance and cost, researchers and engineers have proposed a hybrid storage solution, which uses SSDs as cache for HDDs to give full play to the respective advantages of SSDs and HDDs.

[0003] However, there are still problems in optimizing the read cache of hybrid storage. First, most hybrid storage cache solutions focus more on optimizing the write cache. Second, the design and optimization of the read cache are mainly concentrated on the SSD, and a large amount of memory space is not used. They only retain the smallest possible index information in the memory. Third, there is no effective support for read cache reconstruction after power failure. Therefore, a new method that can solve the above problems and optimize the read efficiency of SSD-HDD hybrid storage is urgently needed. Summary of the invention

[0004] In order to solve the problems existing in the prior art, the present invention provides a hybrid storage read cache design method based on elastic memory, which is used to optimize the read efficiency of SSD-HDD hybrid storage. First, the two-level cache can effectively store hot data and minimize the system's access to the low-speed HDD. Secondly, the size of the first-level cache is controlled by elastic memory to fully and safely utilize the memory space. Finally, the first-level cache and the second-level cache are managed separately by the cache elimination strategies of LFU and LRU. Finally, the second-level cache can help the first-level cache improve the efficiency of reconstruction; solving the problems mentioned in the above background technology.

[0005] To achieve the above object, the present invention provides the following technical solution: a hybrid storage read cache design method based on elastic memory, comprising the following steps:

[0006] S1. Obtain the free memory size and initialize the first-level cache metadata information according to the free memory space;

[0007] S2. Search the metadata information of the secondary cache. If the metadata information exists in the secondary cache, construct the primary cache through the secondary cache. If the metadata information does not exist in the secondary cache, initialize the metadata information of the secondary cache.

[0008] S3, the hybrid storage system monitors the read I / O requests accessed by users;

[0009] S4. After a read request is completed, the hybrid storage system obtains the remaining memory space and then executes the elastic memory policy.

[0010] Preferably, in step S1, the obtaining of the free memory size is to obtain the remaining memory space size through the sysconf() system function; the initialization of the first-level cache metadata information specifically includes: managing the first-level cache through the LFU cache replacement algorithm, wherein each cached data is managed by a node, and this node is called the LFU node; the LFU node information includes the logical block number of the HDD, a pointer to the cached data, and the number of cache hits; at the same time, the LFU node information is effectively queried and recorded through the structure of a hash table and a multi-level linked list, wherein the hash table is used to quickly query the LFU node, and the multi-level linked list is used to distinguish the number of visits to the LFU node, and the higher the level of the linked list, the more times the LFU node under the linked list is visited.

[0011] Preferably, in step S2, the initialization of the secondary cache metadata information specifically includes: managing the secondary cache through the LRU cache replacement algorithm, in which each cached data is managed by a node, and this node is called the LRU node; the LRU node information includes the logical block number of the HDD, the logical block number of the SSD, a pointer to the previous node and a pointer to the next node; at the same time, constructing an effective query of the secondary cache through a hash table and a bidirectional linked list and recording the information of the LRU node.

[0012] Preferably, in step S3, after the read I / O request of the user access arrives, the first-level cache is queried to see whether there is matching metadata in the first-level cache. If the metadata matching the read request is stored in the first-level cache, the data is read from the memory and returned to the user, and the LFU node information is updated;

[0013] If the first-level cache query fails, that is, there is no matching metadata, then the second-level cache is queried to see if there is metadata matching the read request. If the query succeeds, the data is read from the SSD and returned to the user, and the LRU node information is updated;

[0014] If the L2 cache query fails, the data needs to be read from the HDD and returned to the user and stored in the L1 cache, and the L1 cache space needs to be checked to see if it is full;

[0015] If the L1 cache space is not full, the data is directly stored in the memory and the LFU node and metadata are updated; if the L1 cache is full, the data in the L1 cache is eliminated according to the LFU strategy and then the data is stored in the memory, and the L2 cache space is checked to see if it is full;

[0016] If the L2 cache space is not full, the data eliminated from the L1 cache will be stored in the SSD; if the L2 cache is full, the data in the L2 cache will be eliminated according to the LRU strategy before being stored in the SSD.

[0017] Preferably, in step S4, the elastic memory strategy specifically includes: when the first-level cache space is greater than or equal to 20% of the free memory, the first-level cache space is reduced to 10% of the free memory; when the first-level cache space is less than or equal to 10% of the free memory, the first-level cache space is expanded to 10% of the free memory.

[0018] The beneficial effects of the present invention are:

[0019] (1) Faster read request response time of the present invention: The two-level cache can effectively cache hot data and ensure a high cache hit rate. The user's read request will access the memory and SSD more frequently, which greatly reduces the response time of the heterogeneous storage system. In particular, when the read request hits the first-level cache, the latency can be kept at the microsecond level and the throughput is also at the GB / s level. It is far better than HDD.

[0020] (2) Make better use of memory space: In order to leave more memory space for other applications, heterogeneous systems usually set up cache in SSDs and only store a small amount of index information in memory. This design dynamically opens up a first-level cache space in memory. The larger the remaining memory space, the larger the first-level cache space; the smaller the remaining memory space, the smaller the first-level cache space. This can avoid wasting memory resources and prevent memory overflow caused by excessive cache space. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is a structural architecture diagram of a hybrid storage read cache design based on elastic memory in the present invention;

[0022] Figure 2 The present invention is a flow chart of the steps of a hybrid storage read cache design method based on elastic memory. 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] Example 1

[0025] The embodiment of the present invention provides a technical solution: a hybrid storage read cache design method based on elastic memory. First, the method designs a two-level read cache area to store hot data, such as Figure 1 As shown, the first-level cache data is stored in the memory, and the second-level cache data is stored in the SSD. When the user program accesses the underlying HDD, if the first-level cache is hit, the data is obtained from the memory; if the second-level cache is hit, the data is obtained from the SSD to improve the user's access speed. Secondly, in the management of the first-level cache, the present invention adopts a flexible memory strategy to obtain the size of the free memory every once in a while. If there is more free memory, the size of the first-level cache is expanded, and if there is less free memory, the size of the first-level cache is reduced. This can effectively avoid server downtime due to insufficient memory while making full use of the memory. Finally, even if the host device loses power, causing the first-level cache in the memory to fail, the present invention can still use the second-level cache to quickly reconstruct the first-level cache.

[0026] In the first-level cache, the cache data is managed by the LFU (Least Frequently Used) cache elimination strategy, because the present invention hopes that the first-level cache has a higher hit rate. When the first-level cache space is full, LFU will give priority to eliminating the cache data with the least number of accesses. In the second-level cache, the cache data is managed by the LRU (The Least Recently Used) cache elimination strategy, because the present invention hopes that the second-level cache can eliminate the least recently used data as soon as possible, giving it a chance to enter the first-level cache. When the second-level cache space is full, LRU will give priority to eliminating the cache data that has not been accessed for the longest time.

[0027] A hybrid storage read cache design method based on elastic memory, such as Figure 2 As shown, the following steps are included:

[0028] Get the free memory size through the system function. Initialize the L1 cache size and metadata information based on the free memory space.

[0029] Search the metadata information of the L2 cache, and if there is cache data in the L2 cache, use it to build the L1 cache. If not, initialize the L2 cache size and metadata information according to the SSD space.

[0030] The hybrid storage system monitors read requests from user access.

[0031] First, the first-level cache is queried. If the data required for the read request is stored in the first-level cache, the data is read from the memory and the LFU node information is updated.

[0032] If the query fails in the first-level cache, the second-level cache is searched for the data required / matched by the read request. If the query succeeds, the data is read from the SSD and the LRU node information is updated.

[0033] If the L2 cache query fails, the required information needs to be read from the HDD. The data read from the HDD must first be returned to the user and secondly be stored in the L1 cache.

[0034] If the L1 cache space is not full, the data is directly stored in the memory and the LFU node and metadata are updated (update the L1 cache metadata information). If the L1 cache is full, the data in the L1 cache is eliminated according to the LFU strategy, and the data is stored in the memory after the L1 cache metadata information is updated.

[0035] If the L2 cache space is not full, the L2 cache metadata information is updated and the data eliminated from the L1 cache is stored in the SSD. If the L2 cache is full, the data in the L2 cache is eliminated according to the LRU strategy, and the L2 cache metadata information is updated before the data is stored in the SSD.

[0036] After a read request is completed, the hybrid storage system will obtain the remaining memory space. When the first-level cache space is greater than or equal to 20% of the free memory, the elastic memory policy will be executed and the first-level cache space will be reduced to 10% of the free memory. When the first-level cache space is less than or equal to 10% of the free memory, the first-level cache space will be expanded to 10% of the free memory.

[0037] Example 2

[0038] The present invention provides a hybrid storage read cache design method based on elastic memory, comprising the following implementation steps:

[0039] (1) Get the remaining memory size through the sysconf() system function. Usually the first-level cache size is set to 10% of the remaining memory size.

[0040] (2) Initialize the metadata information of the first-level cache: The first-level cache is managed by the LFU cache replacement algorithm. Each cached data is managed by a node, which we call an LFU node. The LFU node information includes the logical block number of the HDD, a pointer to the cached data, and the number of cache hits. At the same time, the information of the LFU node can be effectively queried and recorded through the structure of the hash table and the multi-level linked list. The hash table is used to quickly query the LFU node, and the multi-level linked list is used to distinguish the number of times the LFU node is accessed. The higher the level of the linked list, the more times the LFU node under the linked list is accessed.

[0041] (3) If the L2 cache metadata has been constructed and an LRU node exists, the most recently accessed data in the L2 cache (i.e., the data at the head of the bidirectional linked list) is written into the L1 cache. At the same time, the LRU node of the L2 cache metadata is converted to the LFU node of the L1 cache and recorded in the metadata of the L1 cache.

[0042] (4) If the L2 cache metadata is not constructed, initialize the L2 cache metadata information: manage the L2 cache through the LRU cache replacement algorithm. Each cached data is managed by a node, which we call the LRU node. The LRU node information includes the logical block number of the HDD, the logical block number of the SSD, the pointer to the previous node, and the pointer to the next node. At the same time, constructing the L2 cache through a hash table and a bidirectional linked list can effectively query and record the information of the LRU node.

[0043] (5) After the read I / O request arrives, suppose data D0 is to be read. The heterogeneous storage system will obtain the logical address and offset of the HDD where D0 is located. Based on this information, it can calculate which HDD block to access and represent the address of the block with LBA0.

[0044] (6) Use the hash table of the first-level cache to query whether there is an LFU node storing cache data about D0. If the logical block number of the HDD stored on a node is equal to LBA0, it means that there is an LFU node for data D0. The first-level cache will retrieve the cache data from the corresponding memory address through the pointer of the cache data and return it to the user, and increase the cache hit count of the node by one. At the same time, the LFU node is upgraded in the multi-level linked list to indicate that the node has been recently accessed.

[0045] (7) If there is no corresponding LFU node, the hash table of the secondary cache is used to query whether there is an LRU node storing cache data about D0. If the logical block number of the HDD stored on a certain node is equal to LBA0, it means that there is an LRU node for data D0. The secondary cache retrieves the cache data from the SSD according to the logical block number of its SSD and returns it to the user and moves the node to the head of the bidirectional linked list to indicate that the node has been recently accessed.

[0046] (8) If there is no corresponding LRU node, data D0 needs to be read from the HDD according to LBA0. D0 is returned to the upper-level user and then stored in the first-level cache.

[0047] (9) If the first-level cache space is full, the cache data with the least number of accesses in the first-level cache space is eliminated, assuming it is D1, and D1 is placed in the second-level cache.

[0048] (10) If the L1 cache space is not full, create an LFU node for D0 and insert it into the hash table and multi-level linked list of the L1 cache.

[0049] (11) If the L2 cache space is full, the cached data that has not been accessed for the longest time in the L2 cache is eliminated, assuming it is D2.

[0050] (12) If the L2 cache space is not full, create an LRU node for D1 and insert it into the hash table and bidirectional linked list of the L2 cache. Write D1 to the SSD.

[0051] (13) The metadata backup of the first-level cache and the second-level cache is stored in the SSD to ensure its persistence and effectiveness.

[0052] (14) After the read operation is completed, the remaining memory space size is obtained again through the sysconf() system function. If the first-level cache space is greater than or equal to 20% of the free memory or less than or equal to 10% of the free memory, the first-level cache space is changed to 10% of the free memory. If the first-level cache is reduced and causes data overflow, execute (9) to eliminate the overflowed data. If the first-level cache data is not full after the first-level cache is expanded, fill the first-level cache through (3).

[0053] (15) When the next read request arrives, the operation is still performed according to steps (5)-(14).

[0054] At this point, all the steps of a hybrid storage read cache design method based on elastic memory in an embodiment of the present invention are completed. The present invention can effectively cache hot data through two-level cache to ensure a high cache hit rate. The user's read request will access the memory and SSD more, which greatly reduces the response time of the heterogeneous storage system. In particular, when the read request hits the first-level cache, the delay can be kept at the microsecond level, and the throughput is also at the GB / s level. It is far better than HDD.

[0055] 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 hybrid storage read cache design method based on elastic memory, characterized in that: The steps include: S1. Get the free memory size and initialize the first-level cache metadata information according to the free memory space; S2. Search the metadata information of the secondary cache. If the metadata information exists in the secondary cache, construct the primary cache through the secondary cache. If the metadata information does not exist in the secondary cache, initialize the metadata information of the secondary cache. S3, the hybrid storage system monitors the read I / O requests accessed by users; When a read I / O request from a user arrives, the first-level cache is queried to see if there is any matching metadata in the first-level cache. If the metadata matching the read request is stored in the first-level cache, the data is read from the memory and returned to the user, and the LFU node information is updated; If the first-level cache query fails, that is, there is no matching metadata, then the second-level cache is queried to see if there is metadata matching the read request. If the query succeeds, the data is read from the SSD and returned to the user, and the LRU node information is updated; If the L2 cache query fails, the data needs to be read from the HDD and returned to the user and stored in the L1 cache, and the L1 cache space needs to be checked to see if it is full; If the L1 cache space is not full, the data is directly stored in the memory and the LFU node and metadata are updated; if the L1 cache is full, the data in the L1 cache is eliminated according to the LFU strategy and then the data is stored in the memory, and the L2 cache space is checked to see if it is full; If the L2 cache space is not full, the data that will be eliminated from the L1 cache will be stored in the SSD; If the L2 cache is full, the data in the L2 cache will be eliminated according to the LRU strategy before being stored in the SSD; S4: After a read request is completed, the hybrid storage system obtains the remaining memory space and then executes the elastic memory policy; The elastic memory strategy specifically includes: when the first-level cache space is greater than or equal to 20% of the free memory, the first-level cache space is reduced to 10% of the free memory; When the L1 cache space is less than or equal to 10% of the free memory, the L1 cache space will be expanded to 10% of the free memory.

2. The hybrid storage read cache design method based on elastic memory according to claim 1 is characterized in that: In step S1, the free memory size is obtained by the sysconf() system function to obtain the remaining memory space size; the initialization of the first-level cache metadata information specifically includes: managing the first-level cache through the LFU cache replacement algorithm, each cache data is responsible for a node, and this node is called the LFU node; the LFU node information includes the logical block number of the HDD, a pointer to the cache data and the number of cache hits; at the same time, the LFU node information is effectively queried and recorded through the structure of a hash table and a multi-level linked list, wherein the hash table is used to quickly query the LFU node, and the multi-level linked list is used to distinguish the number of visits to the LFU node, and the higher the level of the linked list, the more times the LFU node under the linked list is visited.

3. The hybrid storage read cache design method based on elastic memory according to claim 1 is characterized in that: In step S2, the secondary cache metadata information is initialized, specifically including: managing the secondary cache through the LRU cache replacement algorithm, in which each cached data is managed by a node, which is called the LRU node; the LRU node information includes the logical block number of the HDD, the logical block number of the SSD, a pointer to the previous node and a pointer to the next node; at the same time, constructing an effective query of the secondary cache through a hash table and a bidirectional linked list and recording the information of the LRU node.

Citation Information

Patent Citations

  • PCM and DRAM-based hybrid memory system and management method thereof

    CN108762671A

  • Metadata storage method, device and apparatus, and computer-readable storage medium

    CN109376125A

  • Distributed file system metadata caching method and device, terminal and storage medium

    CN113688107A

  • NVMe acceleration method and device based on multi-level cache and feedback algorithm

    CN117785063A

  • Distributed multi-stage buffer storage system suitable for object network storage

    CN1852318A