Method for reducing write amplification and write stall of LSM tree based on NVM
By compressed operations from the fine -grained L0 to the L1 layer in the LSM tree, equivalent to expanding the capacity of each layer and changing the storage structure of the L1 layer, using the NVM characteristics to solve the problem of LSM tree writing amplification and stalls, improved Systems read and write efficiency.
Patent Information
- Application Number
- CN202411343492.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-09-25
AI Technical Summary
The existing LSM tree architecture has high write amplification and write stall problems in compression operations from L0 to L1.
通过将LSM树中L0层到L1层之间的压缩细粒度化,等比扩大每一层的容量,并改变L1层的存储结构,利用NVM的特性降低写放大和写失速。
有效降低了LSM树压缩过程中的写失速与写放大,提高了读写效率。
Smart Images

Figure CN119376618A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a method for reducing LSM tree write amplification and write stall based on NVM. Background Art
[0002] Since the emergence of key-value storage technology, key-value storage systems have played a vital role in large-scale, high-performance, data-intensive application scenarios, and LSM trees, as their core data structure, have played a key role. Thanks to write optimization, LSM trees have excellent write performance and are very suitable for write-intensive scenarios, while the structure of hierarchical sorting of data also retains good read performance.
[0003] However, the current LSM architecture uses SSTable as its basic compression unit, and a large amount of data is involved in the compression operation from L0 layer to L1 layer at one time, so there are problems of high write amplification and write stall. The present invention discloses a method for reducing LSM tree write amplification and write stall based on NVM. Summary of the invention
[0004] In order to solve the problems existing in the prior art, the present invention provides a method for reducing write amplification and write stall of LSM tree based on NVM. The method of the present invention fine-grains the compression between the L0 layer and the L1 layer in the LSM tree, proportionally expands the capacity of each layer of the LSM tree, and changes the storage structure of the L1 layer. It can reduce the write stall and write amplification in the compression process of the LSM tree, and improve the reading and writing efficiency, thereby solving the problems mentioned in the above background technology.
[0005] To achieve the above object, the present invention provides the following technical solution: a method for reducing LSM tree write amplification and write stall based on NVM, comprising the following steps:
[0006] S1, initialize the storage system;
[0007] S2, accept user input;
[0008] S3, if the accepted operation is a read operation, execute step S4; otherwise, execute step S5;
[0009] S4, query the target data in the order of MemTable, Immutable MemTable, L0 to Ln layers until the search is successful;
[0010] S5. If the accepted operation is a write operation, execute step S6; otherwise, execute step S7;
[0011] S6. The system writes the data into the MemTable in memory.
[0012] S7. If MemTable is full, execute step S8; otherwise, execute step S9;
[0013] S8, converting the MemTable into an Immutable MemTable, generating metadata through the ImmutableMemTable and inserting it into the L0 layer metadata group when the system is idle;
[0014] S9, when the amount of data contained in the L0 layer reaches the threshold, execute step S10; otherwise, execute step S11;
[0015] S10, select multiple key ranges from the L0 layer metadata group, and logically compress all key-value pairs contained therein into the supplementary table of the corresponding Block table;
[0016] S11. When the amount of data in the Key range of the L0 layer metadata group reaches the threshold, execute step S12; otherwise, execute step S13;
[0017] S12, compress all data within this key range to the L1 layer;
[0018] S13. If the Block table is too large, execute step S14; otherwise, execute step S15;
[0019] S14, split the overly large Block table into multiple Block tables, and change the key range in the L0 layer metadata group;
[0020] S15. If there is a Li (n>i>0) layer and the amount of data contained therein reaches the threshold, execute step S16; otherwise, execute step S17;
[0021] S16, compressing data from the Li (n>i>0) layer to the Li+1 layer, and executing step S15;
[0022] S17, when the storage system life cycle ends, the key-value storage program is completed.
[0023] Preferably, in step S1, the storage system includes a memory part, an NVM part, and an SSD part; the memory part includes MemTable and Immutable MemTable; the NVM part includes log, L0 layer, and L1+ layer, wherein the L1+ layer represents the part of the L1 layer in the NVM; the SSD part includes L1 to Ln layers, wherein the Ln layer is the deepest level that the LSM tree can reach.
[0024] Preferably, the L0 layer is organized into multiple Log tables, each Log table is directly converted from Log, the key-value pairs in each Log table are logically ordered by the metadata in the metadata group, the metadata group is divided into multiple key ranges, each key range corresponds to and is the same as the key range of each Block table in the L1 layer, and each key range contains multiple metadata;
[0025] The L1 layer located in the SSD consists of multiple block groups, each block group contains multiple blocks for storing ordered key-value pairs; the L1+ layer located in the NVM consists of multiple supplementary tables, a supplementary table is also used to store ordered key-value pairs, each supplementary table corresponds to a block group one by one, and a pair of block groups and supplementary tables constitute a block table.
[0026] Preferably, in step S4, when reading, first query the MemTable and ImmutableMemTable in the memory, if there is no hit, then continue to query the L0 to Ln layers in sequence;
[0027] When querying the L0 layer, first use binary search to confirm a key range in the metadata group, and then use the Bloom filter of each metadata to filter and query the target data;
[0028] When querying the L1 layer, first determine the Block table where the target key-value pair is located through binary search, and then query the target data from the Block group and supplementary table through metadata.
[0029] Preferably, in step S8, when generating metadata, each Immutable MemTable needs to generate multiple metadata separately according to the key range in the L0 layer metadata group, and then insert each metadata into the metadata group in the L0 layer according to the key range to which it belongs. At the same time, the corresponding Log logic is converted into a Log table and inserted into the L0 layer.
[0030] Preferably, the Block table includes three parts: key-value data in the SSD, key-value data in the NVM, and metadata; wherein the metadata and the key-value data in the NVM are stored together in the supplementary table, and the key-value data in the SSD is organized into blocks and stored in the Block group.
[0031] Preferably, in step S12, the key space of the L1 layer is divided into multiple continuous key ranges by the minimum key of all Block tables, wherein the first two key ranges are the key ranges of the first Block table, and each key range thereafter corresponds to each subsequent Block table in sequence; if the L1 layer is empty, it is regarded as the only empty Block table containing an infinite key range.
[0032] The beneficial effects of the present invention are:
[0033] 1) Less write amplification: A large amount of write amplification will occur when the LSM tree is compressed. The present invention implements an LSM tree with a lower number of layers and a delayed compressed L1 layer, which effectively reduces the write amplification caused by the compression operation;
[0034] 2) Fewer write stalls: Usually, a large amount of data is involved at one time when the L0 layer is compressed to the L1 layer. The present invention realizes the decomposition of the compression from the L0 layer to the L1 layer, thereby reducing the tail delay during the operation of the LSM tree;
[0035] 3) Faster reading speed: NVM has a faster reading speed than SSD. The present invention realizes an LSM tree with a faster reading speed by using NVM. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 This is an architecture diagram of a method for reducing LSM tree write amplification and write stall based on NVM in an embodiment of the present invention;
[0037] Figure 2 This is a data storage structure diagram of the Block table in an embodiment of the present invention;
[0038] Figure 3 This is a flow chart of a method for reducing LSM tree write amplification and write stall based on NVM in an embodiment of the present invention. DETAILED DESCRIPTION
[0039] 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.
[0040] See also Figure 1-Figure 3 The present invention provides a technical solution: a method for reducing write amplification and write stall of LSM tree based on NVM, which fine-grains the compression between L0 layer and L1 layer in LSM tree, proportionally expands the capacity of each layer of LSM tree, and changes the storage structure of L1 layer, so as to reduce write stall and write amplification in the compression process of LSM tree. The method includes overall structure, reading, writing and compression.
[0041] Overall structure: The storage system of the present invention includes a memory part, an NVM part, and an SSD part. Figure 1As shown, the memory part includes MemTable and Immutable MemTable; the NVM part includes log, L0 layer, L1+ layer, where L1+ layer represents the part of L1 layer in NVM; the SSD part includes L1 to Ln layers, where Ln layer is the deepest layer that can be reached by the LSM tree in the present invention. The modified data capacity of each layer of the present invention is much higher than the data capacity of each layer in the traditional LSM tree, and the number of layers of the LSM tree is reduced.
[0042] The memory part maintains the same design as the traditional LSM tree.
[0043] The L0 layer is organized into multiple Log tables, each of which is directly converted from Log without modification. The key-value pairs in each Log table are logically ordered by the metadata in the metadata group. The metadata group is divided into multiple key ranges, each of which corresponds to and is the same as the key range of each Block table in the L1 layer, and each key range contains multiple metadata.
[0044] The L1 layer in the SSD consists of multiple Block groups, each of which contains multiple blocks for storing ordered key-value pairs. The L1+ layer in the NVM consists of multiple complement tables, each of which is also used to store ordered key-value pairs. Each complement table corresponds to a Block group one by one, and a pair of Block groups and complement tables constitute a Block table. Figure 2 As shown in the figure, the Block table contains three parts: key-value data in the SSD, key-value data in the NVM, and metadata, where the metadata and key-value data in the NVM are stored together in the supplementary table, and the key-value data in the SSD is organized into blocks and stored in the Block group. All Block tables are kept in order and non-overlapping, and each block within the Block table is also kept in order and non-overlapping, and the key-value pairs in the Block table are logically sorted by the metadata. The key space of the L1 layer is divided into multiple continuous key ranges by the minimum key of all Block tables, where the first two key ranges are the key ranges of the first Block table, and each key range thereafter corresponds to each subsequent Block table in sequence. If the L1 layer is empty, it is regarded as the only empty Block table containing an infinite key range.
[0045] Finally, the Li (n ≥ i > 1) layer maintains the same layout as the traditional LSM tree and is stored in the SSD in the format of SSTable.
[0046] Reading: When reading, first query the MemTable and Immutable MemTable in memory. If there is no hit, continue to query the L0 to Ln layers in sequence.
[0047] When querying the L0 layer, first use binary search to confirm a key range in the metadata group, and then filter and query the target data through the Bloom filter of each metadata. When querying the L1 layer, first use binary search to determine the Block table where the target key-value pair is located, and then query the target data from the Block group and the supplement table through metadata. Querying the Li (n ≥ i > 1) layer is consistent with the query method of the traditional LSM tree.
[0048] Writing and compression: When writing, data is first written to MemTable and Log. When MemTable is full, it is converted to an Immutable MemTable and used to generate metadata. When generating metadata, each Immutable MemTable needs to generate multiple metadata separately according to the key range in the metadata group of the L0 layer, and then insert each metadata into the metadata group in the L0 layer according to the key range to which it belongs. At the same time, the corresponding Log logic is converted into a Log table and inserted into the L0 layer.
[0049] When the amount of data contained in the L0 layer reaches the threshold, the data compression from the L0 layer to the L1 layer is triggered. At this time, multiple key ranges are selected from the L0 layer metadata group, and all the key-value pairs contained therein are logically compressed into the corresponding Block table's supplementary table, and compressed and sorted by updating the metadata in the Block table. If the Block table is too large, the oversized Block table is split into multiple Block tables, and the key range in the L0 layer metadata group is changed. If the amount of data within the Key range in the L0 layer metadata group reaches the threshold, the compression operation from the L0 layer to the L1 layer is also triggered, and all data within this key range is compressed to the L1 layer.
[0050] When the amount of data in the L1 layer reaches the threshold, data compression from the L1 layer to the L2 layer is triggered. During compression, multiple Block tables are first selected from the L1 layer, and then the SSTables overlapping with these Block tables are selected from the L2 layer. The selected tables are read out and sorted together, and finally organized into SSTables and written back to the L2 layer, and the key range in the L0 layer metadata group is changed.
[0051] The compression of the Li(n>i>1) layer is the same as that of the traditional LSM tree.
[0052] The present invention provides a method for reducing LSM tree write amplification and write stall based on NVM, such as Figure 3 As shown, the implementation steps include:
[0053] (1) Initialize the storage system;
[0054] (2) Accept user input;
[0055] (3) If the received operation is a read operation, execute step (4); otherwise, execute step (5);
[0056] (4) Search for target data in the order of MemTable, Immutable MemTable, L0 to Ln layers until the search is successful;
[0057] (5) If the accepted operation is a write operation, execute step (6); otherwise, execute step (7);
[0058] (6) The system writes the data to the MemTable in memory;
[0059] (7) If MemTable is full, execute step (8); otherwise, execute step (9);
[0060] (8) Convert the MemTable to an Immutable MemTable, generate metadata through the ImmutableMemTable when the system is idle, and insert it into the L0 layer metadata group;
[0061] (9) When the amount of data contained in the L0 layer reaches the threshold, execute step (10); otherwise, execute step (11);
[0062] (10) Select multiple key ranges from the L0 layer metadata group, and logically compress all key-value pairs contained therein into the corresponding block table's complement table;
[0063] (11) When the amount of data within the Key range in the L0 layer metadata group reaches the threshold, execute step (12); otherwise, execute step (13);
[0064] (12) All data within this key range is compressed to the L1 layer;
[0065] (13) If the Block table is too large, execute step (14); otherwise, execute step (15);
[0066] (14) Split the overly large Block table into multiple Block tables and change the key range in the L0 metadata group;
[0067] (15) If there is a Li (n>i>0) layer that satisfies the requirement that the amount of data contained therein reaches the threshold, then execute step (16); otherwise, execute step (17);
[0068] (16) Compress data from the Li (n>i>0) layer to the Li+1 layer and execute step (15);
[0069] (17) If the storage system life cycle ends, the key-value storage program is completed, otherwise return to step (2).
[0070] At this point, all the implementation steps of the method for reducing LSM tree write amplification and write stall based on NVM described in the present invention are completed.
[0071] In the embodiments provided in the embodiments of the present invention, it should be noted that, in this article, the terms "include", "comprise" or any other variants 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. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0072] 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.
[0073] 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.
[0074] 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.
[0075] 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.
[0076] 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 method for reducing LSM tree write amplification and write stall based on NVM, characterized in that: The steps include: S1, initialize the storage system; S2, accept user input; S3, if the accepted operation is a read operation, execute step S4; otherwise, execute step S5; S4, query the target data in the order of MemTable, Immutable MemTable, L0 to Ln layers until the search is successful; S5. If the accepted operation is a write operation, execute step S6; otherwise, execute step S7; S6. The system writes the data into the MemTable in memory. S7. If MemTable is full, execute step S8; Otherwise, execute step S9; S8, converting the MemTable into an Immutable MemTable, generating metadata through the ImmutableMemTable and inserting it into the L0 layer metadata group when the system is idle; S9, when the amount of data contained in the L0 layer reaches a threshold, execute step S10; Otherwise, execute step S11; S10, select multiple key ranges from the L0 layer metadata group, and logically compress all key-value pairs contained therein into the supplementary table of the corresponding Block table; S11, when the amount of data within the Key range in the L0 layer metadata group reaches a threshold, execute step S12; Otherwise, execute step S13; S12, compress all data within this key range to the L1 layer; S13. If the Block table is too large, execute step S14; Otherwise, execute step S15; S14, split the overly large Block table into multiple Block tables, and change the key range in the L0 layer metadata group; S15. If there is a Li (n>i>0) layer and the amount of data contained therein reaches the threshold, execute step S16; otherwise, execute step S17; S16, compressing data from the Li (n>i>0) layer to the Li+1 layer, and executing step S15; S17, when the storage system life cycle ends, the key-value storage program is completed.
2. The method for reducing LSM tree write amplification and write stall based on NVM according to claim 1, characterized in that: In step S1, the storage system includes a memory part, an NVM part, and an SSD part; the memory part includes MemTable and Immutable MemTable; the NVM part includes log, L0 layer, and L1+ layer, wherein the L1+ layer represents the part of the L1 layer in the NVM; the SSD part includes L1 to Ln layers, wherein the Ln layer is the deepest level that the LSM tree can reach.
3. The method for reducing LSM tree write amplification and write stall based on NVM according to claim 2, characterized in that: The L0 layer is organized into multiple Log tables, each of which is directly converted from Log. The key-value pairs in each Log table are logically ordered by the metadata in the metadata group. The metadata group is divided into multiple key ranges, where each key range corresponds to and is the same as the key range of each Block table in the L1 layer, and each key range contains multiple metadata; The L1 layer located in the SSD consists of multiple block groups, each of which contains multiple blocks for storing ordered key-value pairs; The L1+ layer in the NVM is composed of multiple complement tables. A complement table is also used to store ordered key-value pairs. Each complement table corresponds to a Block group one by one. A pair of Block groups and a complement table constitute a Block table.
4. The method for reducing LSM tree write amplification and write stall based on NVM according to claim 1, characterized in that: In step S4, when reading, first query the MemTable and Immutable MemTable in the memory. If there is no hit, continue to query the L0 to Ln layers in sequence. When querying the L0 layer, first use binary search to confirm a key range in the metadata group, and then use the Bloom filter of each metadata to filter and query the target data; When querying the L1 layer, first determine the Block table where the target key-value pair is located through binary search, and then query the target data from the Block group and supplementary table through metadata.
5. The method for reducing LSM tree write amplification and write stall based on NVM according to claim 1, characterized in that: In step S8, when generating metadata, each Immutable MemTable needs to generate multiple metadata separately according to the key range in the L0 layer metadata group, and then insert each metadata into the metadata group in the L0 layer according to the key range to which it belongs. At the same time, the corresponding Log logic is converted into a Log table and inserted into the L0 layer.
6. The method for reducing LSM tree write amplification and write stall based on NVM according to claim 1, characterized in that: The Block table includes three parts: key-value data in the SSD, key-value data in the NVM, and metadata; the metadata and the key-value data in the NVM are stored together in the supplementary table, while the key-value data in the SSD is organized into blocks and stored in the Block group.
7. The method for reducing LSM tree write amplification and write stall based on NVM according to claim 1, characterized in that: In step S12, the key space of the L1 layer is divided into multiple continuous key ranges by the minimum key of all Block tables, where the first two key ranges are the key ranges of the first Block table, and each subsequent key range corresponds to each subsequent Block table in sequence; If the L1 layer is empty, it is considered to be the only empty Block table containing an infinite key range.
Citation Information
Patent Citations
Key value storage system based on NVM and SSD hybrid storage structure
CN110347336A
Cache optimization method for reading performance of KV storage system based on LSM-tree
CN114398007A
Log merge tree key value storage system and related method and related equipment
CN114840134A
Method for reducing LSM write blocking and read-write amplification based on NVM and B + tree
CN115982169A
Key value storage write optimization method based on nonvolatile memory
CN117908755A