Hybrid In-Memory Key-Value Data Layout Method Based on Local and CXL Extensions
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2026-08-11
AI Technical Summary
由于NVM与CXL内存的设备特性并不相同,许多针对于NVM做出的代码结构修改,存储结构的修改,对于CXL并不适合
[0048](1)本发明在DRAM与CXL上设置独立哈希表和独立LRU,避免了在哈希拉链中存在两种介质的反复读取,降低读取速度,也避免了在CXL上驱逐数据时需要对DRAM上哈希链上锁;
Smart Images

Figure CN117806552B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer storage technology, and in particular to a hybrid memory key-value data layout method based on local and CXL extensions. Background Technology
[0002] With the emergence of the next-generation CXL bus technology, the computer field has ushered in new opportunities and challenges. The CXL bus introduces a crucial feature: the ability to mount various types of memory (such as volatile and persistent memory) to the host via the CXL interface, achieving high flexibility independent of the underlying storage technology. Simultaneously, CXL.mem transactions support byte-level addressing and possess load / store transaction capabilities similar to DDR memory. This emerging technology provides a completely new solution for memory expansion; through the CXL memory pool, the CPU can access a wider range of memory, including different types of memory cells.
[0003] However, the introduction of CXL technology has also brought unprecedented challenges to in-memory storage systems. Traditional in-memory key-value stores (such as Memcached and Redis) have shown significant shortcomings in adapting to CXL memory. True CXL memory has higher latency, fewer memory channels (leading to lower throughput), and varying transmission efficiency under different operations. This makes in-memory key-value databases, characterized by microsecond-level latency, extremely sensitive to the increased latency of CXL memory. If existing solutions are directly applied to CXL memory, performance and throughput may decrease by up to 40% compared to using DDR5 memory.
[0004] To more efficiently utilize CXL memory in in-memory key-value stores, innovative solutions are urgently needed. These solutions should adjust data distribution based on data frequency levels to maximize the use of CXL memory's vast capacity while mitigating the impact of CXL memory latency. New in-memory key-value stores should address this issue by optimizing data management and access to achieve efficient utilization of CXL memory, thus meeting the strong demand for low latency.
[0005] In conclusion, with the new possibilities of CXL technology, memory key-value storage systems face unprecedented opportunities and challenges. To address the increased memory latency of CXL, designing entirely new memory key-value storage solutions is imperative, paving the way for the future development of computer storage systems.
[0006] In recent years, research on memory key-value storage systems based on hybrid storage media has primarily focused on DRAM and NVM. Current hybrid memory key-value storage systems are mostly designed for DRAM and NVM scenarios. However, with the development of CXL technology and the increasing prevalence of commercial CXL devices, memory key-value storage systems specifically for DRAM and CXL are becoming increasingly important. Because NVM and CXL memory have different device characteristics, many code and storage structure modifications made for NVM are not suitable for CXL. Therefore, research is needed on a memory key-value storage system technology based on hybrid DRAM and CXL storage media to address the optimization of memory key-value storage systems in hybrid CXL and DRAM scenarios, thereby simultaneously leveraging the advantages of both DRAM and CXL memory. Summary of the Invention
[0007] The purpose of this invention is to overcome the problems of the prior art and propose a hybrid memory key-value data layout method based on local and CXL extensions. By identifying hot and cold data, the cache data is laid out reasonably, placing frequently accessed hot data in DRAM and less frequently accessed but larger space-consuming cold data in CXL, thereby giving full play to the advantages of each of the two storage media.
[0008] The present invention adopts the following technical solution:
[0009] A hybrid memory key-value data layout method based on local and CXL extensions includes: a cold data migration step S104 in DRAM and a hot data migration step S105 in CXL;
[0010] The cold data migration step S104 in the DRAM includes:
[0011] S1041, when the memory in DRAM has been consumed to the first preset threshold, the cold data eviction step of the Segmented LRU in DRAM is invoked; the matching item is searched for from the tail in the WARM LRU; based on the cold and hot data identification, it is determined whether to put it back into the WARM LRU or evict it to the COLD LRU in CXL. If it is evicted to the COLD LRU in CXL, go to S1042; otherwise, go to S1044.
[0012] S1042, copy the item data to CXL, insert the item into the hash chain of CXL, and simultaneously insert it into the LRU of CXL; update multiple bits of the Bloom filter on CXL using the positions calculated by multiple hashes;
[0013] S1043, delete the item in DRAM and remove it from the hash chain and LRU chain; free up the space and put it back into the free list;
[0014] S1044, Repeat the above steps until the memory occupied in DRAM is lower than the first preset threshold;
[0015] The hot data migration step S105 in CXL includes:
[0016] S1051, when frequently accessed items are detected in CXL, it is determined that the data is hot data. The popularity of the data is checked through a Bloom filter, and the hot data with the second preset threshold in the Bloom filter is migrated back to DRAM.
[0017] S1052, copy the item data to DRAM, insert the item into the hash chain of DRAM, and simultaneously insert it into the LRU of DRAM; update the Bloom filter;
[0018] S1053, delete the item in CXL and remove it from the hash chain and LRU chain; free up the space and put it back into the free list.
[0019] Preferably, the hybrid in-memory key-value data layout method based on local and CXL extensions further includes an initialization step S101, as follows:
[0020] S1011, initializes the internal metadata of Memcached, including the hash table on DRAM and the hash table on CXL.
[0021] S1012, initialize and set all slab classes on DRAM, and set the same slab classes on CXL accordingly;
[0022] S1013 allocates the corresponding DRAM size and CXL memory size according to the initialization configuration information;
[0023] S1014, Initialize the Bloom filter based on heat recognition for each slab class on CXL;
[0024] S1015, initialize the metadata for item replacement and eviction policies.
[0025] Preferably, the hybrid in-memory key-value data layout method based on local and CXL extensions further includes a data writing step S102, as follows:
[0026] S1021, parses the data uploaded by the client via the TCP protocol, and configures the data into the corresponding item structure;
[0027] S1022, data is directly written to the slab corresponding to DRAM, and an item space is allocated from the corresponding slab to store the data. If the DRAM space is insufficient, the slab eviction process and the item eviction process will be triggered.
[0028] S1023, Calculate the hash value, set the corresponding hash item, and insert it into the corresponding hash chain using the head insertion method;
[0029] S1024, insert the item into the Segmented LRU queue of the corresponding slab class for management.
[0030] Preferably, the hybrid in-memory key-value data layout method based on local and CXL extensions further includes a data reading step S103, as follows:
[0031] S1031, parses the data uploaded by the client via the TCP protocol, and configures the data into the corresponding item structure;
[0032] S1032, Calculate the hash value. First, search for the corresponding key value in the hash table in DRAM. If the corresponding key value is not found in the corresponding hash chain, the data is not in DRAM, and proceed to process S1034. If the corresponding key value is found, it means that the data is in DRAM, and proceed to process S1033.
[0033] S1033, Read the corresponding item data from DRAM and update the item metadata; transfer process S1036;
[0034] S1034, by searching the hash table based on Bulk chaining, identify whether the corresponding key value exists on CXL. If it does not exist, return "No such item" and proceed to process S1037; if the corresponding key value exists, proceed to process S1035.
[0035] S1035, search for the corresponding key value on the CXL hash chain. If the corresponding key value is found, read the corresponding item data from CXL, update the item metadata, update the Bloom filter, and proceed to process S1036; otherwise, it means that the key value does not exist in either DRAM or CXL, and proceed to process S1037.
[0036] S1036, Return the found data and send it to the client via TCP protocol, ending the data reading step;
[0037] S1037, No corresponding key value found, directly return no such item, end the data reading step.
[0038] Preferably, in step S1035, updating the Bloom filter specifically includes:
[0039] The information of the Bloom filter for heat identification of the slab class corresponding to the item is updated by using multiple hash algorithms. Based on the positions calculated by multiple hashes, multiple bits of the Bloom filter are updated.
[0040] Preferably, in step S1035, before the transition process S1036, the following steps are also included:
[0041] Based on the item's metadata, the access popularity is calculated. If the access popularity of an item exceeds the threshold for CXL to be promoted to WARM LRU, the item will be relinked to WARM LRU.
[0042] Preferably, the hybrid memory key-value data layout method based on local and CXL extensions further includes DRAM slab reallocation and slab eviction steps S106, as follows:
[0043] S1061, selects a slabclass as a candidate for expulsion using CXL LRU;
[0044] S1062, by scanning the K sliding windows of the slabclass header, select the slab with the fewest items on HOTLRU;
[0045] S1063, the memcpy process is copied into CXL via the data stream accelerator DSA;
[0046] S1064, Refactor the metadata on CXL.
[0047] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0048] (1) The present invention sets up independent hash tables and independent LRU on DRAM and CXL, which avoids repeated reading of two media in the hash chain, reducing the reading speed, and also avoids locking the hash chain on DRAM when evicting data on CXL.
[0049] (2) The present invention employs a novel replacement algorithm in DRAM and an optimized replacement algorithm based on Segmented LRU in CXL, which can improve the identification rate of hot and cold data and separate hot and cold data.
[0050] (3) The present invention uses an optimized Bloom filter as a tool for heat identification, which can reduce the computational overhead of statistical access data and comparison of heat values;
[0051] (4) This invention identifies hot and cold data and performs data migration on DRAM and CXL, which can optimize the data layout, make full use of the space of CXL expanded memory, and avoid interference with the performance of memory key-value storage system. Attached Figure Description
[0052] Figure 1 A diagram illustrating the hash table for native Memcached data requests;
[0053] Figure 2 This is a layout structure diagram of an embodiment of the present invention;
[0054] Figure 3 This is a schematic diagram of a Bloom filter based on heat recognition according to an embodiment of the present invention;
[0055] Figure 4 This is a flowchart of the data reading steps in an embodiment of the present invention;
[0056] Figure 5 This is a diagram of the CXL hash index structure according to an embodiment of the present invention;
[0057] Figure 6 This is a schematic diagram of data migration according to an embodiment of the present invention. Detailed Implementation
[0058] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Furthermore, it should be understood that after reading the teachings of this invention, those skilled in the art can make various alterations or modifications to the invention, and these equivalent forms also fall within the scope defined by the appended claims.
[0059] like Figure 1 As shown, for the native Memcached (a distributed high-speed caching system), simply mixing DRAM and CXL memory will cause a serious degrade in system performance. The presence of both DRAM and CXL entries in the same hash chain, and multiple CXL entries with high latency, will slow down single-lookup speeds. Therefore, it is necessary to separate hot and cold data, placing hot data in DRAM and cold data in CXL. The two parts of data have a corresponding relationship, such as... Figure 2 As shown, there are slab classes from 1 to n in DRAM, and there are also slab classes from 1 to n in CXL. Data will be transferred between two slab classes with the same number.
[0060] Specifically, this embodiment provides a hybrid in-memory key-value data layout method based on local and CXL extensions, which includes the following steps.
[0061] S101, Initialization steps, implemented as follows.
[0062] S1011, such as Figure 2 As shown, internal metadata needs to be initialized, including hash tables on DRAM and hash tables on CXL;
[0063] S1012, initialize and set all slab classes on DRAM, and set the same slab classes on CXL accordingly;
[0064] S1013 allocates the corresponding DRAM size and CXL memory size according to the initialization configuration information;
[0065] S1014, initialize the Bloom filter based on heat recognition for each slab class, which requires... Figure 3 The Bloom filter shown is set to zero;
[0066] S1015, initialize the metadata for item replacement and eviction policies.
[0067] S102, data writing step, data writing and updating only update the DRAM, CXL only serves as a response in the case of reading, as follows.
[0068] S1021, based on the data uploaded by the client via the TCP protocol, parses the data and configures the data into the corresponding item structure;
[0069] S1022, data is written directly to the slab corresponding to the DRAM. An item space is allocated from the corresponding slab to store the data. If the space is insufficient, the eviction and reallocation of the slab and the eviction process of the item will be triggered.
[0070] S1023, Calculate the hash value, set the corresponding hash item, and insert it into the corresponding hash chain using the head insertion method;
[0071] S1024, insert the item into the LRU queue of the corresponding slab class for management. Each slab class has a queue like this. Figure 6 The Segmented LRU queue shown.
[0072] S103, Data reading steps, are implemented as follows.
[0073] S1031, such as Figure 4 As shown in the flowchart, the data uploaded by the client via the TCP protocol is parsed and configured into the corresponding item structure.
[0074] S1032, as shown Figure 2As shown, calculating the hash value first involves searching for the corresponding key value in the hash table of DRAM; if the corresponding key value is not found in the corresponding hash chain, the data is not in DRAM, and the process proceeds to step S1034; if the corresponding key value is found, it means the data is in DRAM, and the process proceeds to step S1033.
[0075] S1033, Read the corresponding item data from DRAM, update the item metadata, and proceed to process S1036;
[0076] S1034, since there is no corresponding data in DRAM and the amount of data in DRAM is small, the lookup cost of hash chaining is low. Next, a longer hash chain will be used in the larger CXL space to reduce the lookup cost. First, it will be done through... Figure 2 The bucket chain hash table shown (the structure of the bucket chain hash table is as follows) Figure 5 (As shown), check if the key value exists on CXL. If it does not exist, return "No such item" and proceed to process S1037; if the key value exists, proceed to process S1035.
[0077] S1035, find the corresponding key value on the CXL hash chain. If the corresponding key value is found, read the corresponding item data from CXL and update the item metadata for popularity statistics. Simultaneously, update the Bloom filter information for the slab class corresponding to the item using multiple hash algorithms. Based on the positions calculated from multiple hashes, update multiple bits of the Bloom filter, then proceed to process S1036. At the same time, based on the data access popularity of the sampling counter based on the Bloom filter, decide whether to link the data to the WARM LRU (e.g., ...). Figure 6 (as shown in the item promotion section); if the corresponding key value is not found, it means that the key value does not exist on either DRAM or CXL, and proceed to process S1037;
[0078] S1036, Return the found data and send it to the client via TCP protocol, ending the data reading step;
[0079] S1037, No corresponding key value found, directly return no such item, end the data reading step.
[0080] S104, the cold data migration steps in DRAM are implemented as follows.
[0081] S1041, when the memory in DRAM is basically exhausted (with 95% as the waterline mark), the cold data eviction step of the Segmented LRU in DRAM is invoked; the matching item is searched for from the tail in the WARM LRU; if the access mark of an item is active, it is put back into the WARM LRU; if an item is cold data and the corresponding Bloom filter identifies the data as cold data, the item is directly migrated to the corresponding slab of CXL;
[0082] S1042, the item data is copied to CXL, the item is inserted into the hash chain of CXL, and simultaneously inserted into the LRU of CXL; multiple bits of the Bloom filter on CXL are updated based on the positions calculated by multiple hashes;
[0083] S1043, delete the item in DRAM and remove it from the hash chain and LRU chain; free up the space and put it back into the free list;
[0084] S1044, Repeat the above steps until the memory usage in DRAM is below 95%.
[0085] The hot data migration steps in S105 and CXL are as follows.
[0086] S1051, as Figure 6 As shown, when a frequently accessed item is detected in CXL, only the data on the WARM LRU will be scanned. If hot data is detected, it needs to be evaluated and then put back into DRAM. Figure 6 The process of promoting items in the process; the popularity of the data is viewed through a Bloom filter, and only the top 20% of the hot data in the Bloom filter will be migrated back to DRAM;
[0087] S1052, the item data is copied to DRAM, the item is inserted into the hash chain of DRAM, and simultaneously inserted into the LRU of DRAM; multiple bits of the Bloom filter on DRAM are updated based on the position calculated by multiple hashes;
[0088] S1053, delete the item in CXL and remove it from the hash chain and LRU chain; free up the space and put it back into the free list.
[0089] S106, the slab reallocation step in DRAM is implemented as follows.
[0090] like Figure 6The slab reallocation process illustrated, by using the LRUs on the CXL as a shadow queue of the DRAM LRUs, reflects which slab class in the DRAM has the least impact on the DRAM hit rate. Therefore, we can use the slab class with the fewest hits in the CXL LRUs as the basis for DRAM slab eviction.
[0091] S1061, selects a slabclass as a candidate for expulsion using CXL LRU;
[0092] S1062, by scanning the K sliding windows of the slabclass header, select the slab with the fewest items on the HOT LRU from the DRAM;
[0093] S1063, copied to CXL via the memcpy process accelerated by Intel DSA;
[0094] S1064, reconstruct the metadata on CXL, including the LRU chain pointers, and insert the item into the CXL hash table;
[0095] S1065, deletes data on DRAM, and reclaims space for reallocation.
[0096] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A hybrid in-memory key-value data layout method based on local and CXL extensions, characterized in that, include: Cold data migration step S104 in DRAM and hot data migration step S105 in CXL; The cold data migration step S104 in the DRAM includes: S1041, when the memory in DRAM has been consumed to the first preset threshold, the cold data eviction step of the Segmented LRU in DRAM is invoked; the matching item is searched for from the tail in the WARM LRU; based on the cold and hot data identification, it is determined whether to put it back into the WARM LRU or evict it to the COLD LRU in CXL. If it is evicted to the COLD LRU in CXL, go to S1042; otherwise, go to S1044. S1042, copy the item data to CXL, insert the item into the hash chain of CXL, and simultaneously insert it into the LRU of CXL; update multiple bits of the Bloom filter on CXL using the positions calculated by multiple hashes; S1043, delete the item in DRAM and remove it from the hash chain and LRU chain; free up space and put it back into the free list; S1044, Repeat the above steps until the memory occupied in DRAM is lower than the first preset threshold; The hot data migration step S105 in CXL includes: S1051, when frequently accessed items are detected in CXL, it is determined that the data is hot data. The popularity of the data is checked through a Bloom filter, and the hot data with the second preset threshold in the Bloom filter is migrated back to DRAM. S1052, copy the item data to DRAM, insert the item into the hash chain of DRAM, and simultaneously insert it into the LRU of DRAM; update the Bloom filter; S1053, delete the item in CXL and remove it from the hash chain and LRU chain; free up the space and put it back into the free list.
2. The hybrid in-memory key-value data layout method based on local and CXL extensions according to claim 1, characterized in that, It also includes initialization step S101, as follows: S1011, initializes the internal metadata of Memcached, including the hash table on DRAM and the hash table on CXL. S1012, initialize and set all slab classes on DRAM, and set the same slab classes on CXL accordingly; S1013 allocates the corresponding DRAM size and CXL memory size according to the initialization configuration information; S1014, Initialize the Bloom filter based on heat recognition for each slab class on CXL; S1015, initialize the metadata for item replacement and eviction policies.
3. The hybrid in-memory key-value data layout method based on local and CXL extensions according to claim 1, characterized in that, It also includes the data writing step S102, as follows: S1021, parses the data uploaded by the client via the TCP protocol, and configures the data into the corresponding item structure; S1022, data is directly written to the slab corresponding to DRAM, and an item space is allocated from the corresponding slab to store the data. If the DRAM space is insufficient, the slab eviction process and the item eviction process will be triggered. S1023, Calculate the hash value, set the corresponding hash item, and insert it into the corresponding hash chain using the head insertion method; S1024, insert the item into the Segmented LRU queue of the corresponding slab class for management.
4. The hybrid in-memory key-value data layout method based on local and CXL extensions according to claim 1, characterized in that, It also includes a data reading step S103, as follows: S1031, parses the data uploaded by the client via the TCP protocol, and configures the data into the corresponding item structure; S1032, Calculate the hash value. First, search for the corresponding key value in the hash table in DRAM. If the corresponding key value is not found in the corresponding hash chain, the data is not in DRAM, and proceed to process S1034. If the corresponding key value is found, it means that the data is in DRAM, and the process starts in step S1033; S1033: Read the corresponding item data from DRAM and update the item metadata; Transformation process S1036; S1034, by searching the hash table based on Bulk chaining, identify whether the corresponding key value exists on CXL. If it does not exist, return "No such item" and proceed to process S1037; if the corresponding key value exists, proceed to process S1035. S1035, search for the corresponding key value on the CXL hash chain. If the corresponding key value is found, read the corresponding item data from CXL, update the item metadata, update the Bloom filter, and proceed to process S1036; otherwise, it means that the key value does not exist in either DRAM or CXL, and proceed to process S1037. S1036, Return the found data and send it to the client via TCP protocol, ending the data reading step; S1037, No corresponding key value found, directly return no such item, end the data reading step.
5. The hybrid in-memory key-value data layout method based on local and CXL extensions according to claim 4, characterized in that, In step S1035, updating the Bloom filter specifically includes: The information of the Bloom filter for heat identification of the slab class corresponding to the item is updated by using multiple hash algorithms. Based on the positions calculated by multiple hashes, multiple bits of the Bloom filter are updated.
6. The hybrid in-memory key-value data layout method based on local and CXL extensions according to claim 4, characterized in that, Before the transition process S1036 in step S1035, the following steps are also included: Based on the item's metadata, the access popularity is calculated. If the access popularity of an item exceeds the threshold for CXL to be promoted to WARM LRU, the item will be relinked to WARM LRU.
7. The hybrid in-memory key-value data layout method based on local and CXL extensions according to claim 1, characterized in that, It also includes slab reallocation and slab eviction steps S106 in DRAM, as detailed below: S1061, selects a slabclass as a candidate for expulsion using CXL LRU; S1062, by scanning the K sliding windows of the slabclass header, select the slab with the fewest items on the HOT LRU list; S1063, the memcpy process is copied into CXL via the data stream accelerator DSA; S1064, Refactor the metadata on CXL.
Citation Information
Patent Citations
Memory system based on hybrid memory architecture
CN110532200A
High performance scalable hash index based on hybrid storage
CN117112557A