Method for reducing LSM write blocking and read-write amplification based on NVM and B+ tree

By using a B+ tree to manage L0 layer data in the LSM structure and leveraging NVM features, the problems of write blocking and read/write amplification in LSM are solved, resulting in faster query speeds, higher system throughput, improved disk space utilization, and enhanced system stability.

CN115982169BActive Publication Date: 2025-11-04SHANGHAI JIAOTONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310015544.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-04
Publication Date
2025-11-04
Estimated Expiration
2043-01-04

AI Technical Summary

Technical Problem

The existing LSM architecture cannot effectively select leaf nodes during the data compaction process, resulting in write blocking and read/write amplification issues. Existing technologies cannot efficiently manage the write pressure of LSM storage systems.

Method used

B+ trees are used to manage the L0 layer data of the LSM structure. Taking advantage of the characteristics of NVM, the data is compacted in units of leaf nodes. Through multi-threaded processing, leaf nodes with high data proportions are selected for data compaction. A max-heap structure is designed to allow direct deletion of leaf nodes and reduce splitting.

Benefits of technology

It significantly reduces write blocking, improves system throughput and query speed, enhances disk space utilization, reduces log overhead, and ensures the system operates normally under high load.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115982169B_ABST
    Figure CN115982169B_ABST
Patent Text Reader

Abstract

The application discloses a method for reducing LSM write blocking and read-write amplification based on NVM and B+ tree, specifically, leaf nodes of B+ tree are taken as units when L0 layer data is compacted in an LSM structure, and the L0 layer data compacted leaf nodes are selected based on data proportion of the leaf nodes. Intel's proud persistent memory has the characteristics of no data loss after power failure, byte addressing, high-speed reading rate and the like, the B+ leaf nodes are set to multiples of 256 bytes, and multiple threads are started to read the read-only memory table according to ranges and insert the read-only memory table into the B+ tree leaf nodes located on the NVM, so that the LSM write blocking is reduced and the throughput is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a technology in the field of information processing, specifically a method for reducing write blocking and read / write amplification in Log Structured Merge Tree (LSM) based on non-volatile memory (NVM) and B+ trees. Background Technology

[0002] Modern NoSQL storage systems widely employ the LSM (Localized Storage Model) index structure with its off-site update strategy, transforming random disk writes into sequential writes and significantly improving data write performance. However, the L0 layer data compaction process in existing LSM architectures operates on SSTables. These SSTables are flushed directly from read-only memory tables to disk by the system. The range of data within a single table can fluctuate greatly, potentially intersecting with all SSTables in the L1 layer of the LSM structure in the worst-case scenario. This can lead to a large amount of disk I / O during a single data compaction, preventing the system from promptly detecting the flushing of read-only memory tables and causing write blocking.

[0003] A search of existing technologies revealed that Chinese patent document CN111475508A, published on July 31, 2020, discloses an efficient indexing method for optimizing leaf node merging operations. This method first divides the index into a buffer B-tree stored in DRAM and a base B-tree stored in NVM. During a write operation, the data is first written to the log file of the buffer B-tree, and then the buffer B-tree is modified. When the capacity of the buffer B-tree exceeds a threshold, the buffer B-tree is merged into the base B-tree on the NVM using an in-situ merge operation, leveraging the leaf node structure design of the base B-tree. Dirty data is then efficiently persisted to the NVM using the WBINVD instruction. After the in-situ merge operation is complete, the buffer B-tree and the log file on the NVM are cleared, completing the indexing process for the write operation. However, this existing technology cannot select leaf nodes during LSM data compression, making it impossible to directly delete leaf nodes. It requires locating the parent node of the leaf node from the root node before deleting it from the B-tree, resulting in low indexing efficiency and poor performance. Summary of the Invention

[0004] To address the aforementioned shortcomings of existing technologies, this invention proposes a method based on NVM and B+ trees to reduce LSM write blocking and read / write amplification. Specifically, during L0 layer data compaction in the LSM structure, the leaf nodes of the B+ tree are used as units, and the selection of L0 layer data compaction leaf nodes is based on the data proportion of the leaf nodes. Leveraging the characteristics of Intel's Optane persistent memory, such as data retention under power failure, byte addressing, and high-speed read rates, the B+ leaf nodes are set to multiples of 256 bytes, and multiple threads are used to read the read-only memory table by range and insert the data into the B+ leaf nodes located in the NVM, thereby reducing LSM write blocking and improving throughput.

[0005] This invention is achieved through the following technical solution:

[0006] This invention relates to a method for reducing LSM write blocking and read / write amplification based on NVM and B+ tree. Initially, the application writes key-value pair data into a memory table in dynamic memory. When the memory table is full, its permissions are set to read-only and it is written into the leaf node of the B+ tree in NVM and managed by the B+ tree. At the same time, a new memory table is created in dynamic memory.

[0007] Preferably, when the memory table is full and the system is idle, the read-only memory table is written to the B+ tree of the leaf node in the NVM using multiple threads.

[0008] The read-only memory table and the data in the memory table are entirely stored in DRAM.

[0009] The B+ tree comprises: internal nodes located in DRAM and leaf nodes located in NVM, wherein the leaf node size, which contains indirect indexes and data ratios, is a multiple of 256 bytes;

[0010] When the memory table is full and the read-only memory table has not yet been written to the B+ tree, the application directly writes the key-value pair data to the B+ tree located in the NVM, i.e., direct access. Since the memory table cannot be set to read-only at this time, the system will be blocked. Therefore, the application is adjusted to write the key-value pair data directly to the B+ tree to alleviate the blocking.

[0011] When the NVM space utilization is greater than half, data compaction is performed on the L0 layer data. Specifically, the leaf nodes of the B+ tree are used as units, and the selection is based on the data proportion of the leaf nodes. Leaf nodes with high data proportions are selected for data compaction first, so as to control the amount of data introduced in one data compaction process and reduce the occurrence of B+ tree splits.

[0012]

[0013] Technical effect

[0014] This invention compacts data at the L0 layer of an LSM structure, using B+ tree leaf nodes as units. The selection of B+ tree leaf nodes is based on their data percentage. By designing the element structure in the max-heap to include pointers to leaf nodes and their parent nodes, it allows direct deletion of a leaf node from the B+ tree. Compared to existing technologies, this invention controls the data range involved in each compaction, reducing write blocking in the LSM system; and by selecting leaf nodes with a large data percentage, it reduces the occurrence of B+ tree splits. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the invention;

[0016] Figure 2 This is a flowchart of the present invention;

[0017] Figure 3 This is a diagram of the data storage structure based on a B+ tree on layer L0 in the embodiment;

[0018] Figure 4 This is a schematic diagram of the working principle of a large heap. Detailed Implementation

[0019] like Figure 1 As shown in the figure, this embodiment relates to a method for reducing LSM write blocking and read / write amplification based on NVM and B+ tree, which includes the following steps:

[0020] Step 1: The application writes data into a memory table in dynamic memory. When the memory table is full, its permissions are set to read-only. When the system is idle, the read-only memory table is written to the B+ tree with leaf nodes in NVM in a multi-threaded manner, so as to realize that the L0 layer data is completely stored on NVM and managed through B+ tree.

[0021] like Figure 3 As shown, the B+ tree includes: internal nodes located in DRAM and leaf nodes located in NVM, wherein the leaf node size, which contains indirect indexes and data ratios, is a multiple of 256 bytes.

[0022] Step 2: When the system encounters a situation where the memory table is full but the read-only memory table has not yet been written to the B+ tree, adjust the application to directly write the data to the B+ tree where the leaf nodes are located in NVM. This enables direct access and reduces log overhead.

[0023] Step 3: Perform data compaction on the L0 level data, using the leaf nodes of the B+ tree as units. This means selecting leaf nodes based on their data percentage, prioritizing those with higher percentages for data compaction. Specifically, this includes:

[0024] 3.1) At the start of L0 layer data compaction, scan the leaf nodes of B+ layer to construct a max-heap based on the proportion of leaf data.

[0025] The max-heap includes: data percentage, pointers to leaf nodes, and pointers to the parent nodes of the leaf nodes;

[0026] 3.2) Select the leaf node with the largest data proportion from the max-heap, i.e., the top element of the heap;

[0027] 3.2) Delete the pointer to the current leaf node from the parent node of the leaf node of the top element of the heap, find the left sibling node of the leaf node through the parent node, and set the tail pointer of the left sibling node of the current leaf node to the leaf node pointed to by the tail pointer of the current leaf node.

[0028] 3.3) Perform data compaction on the leaf node of the top element in step 3.2. That is, select the data table in L1 layer that has a range intersection with the data of the leaf node, merge the leaf node data and the data table data with the range intersection into a globally ordered data table, delete duplicate and invalid data, and release the NVM space occupied by the leaf node after the data compaction process is completed.

[0029] This invention controls the scope introduced in each data compaction, reducing the time required for each compaction cycle. To minimize the overhead of B+ tree splitting, a leaf node selection strategy based on data percentage is proposed, prioritizing leaf nodes with more data for compaction. Furthermore, to ensure the feasibility of directly selecting leaf nodes, a heap element structure of a max-heap based on data percentage is designed, storing pointers to each leaf node and their parent nodes, allowing direct deletion of leaf nodes from the B+ tree.

[0030] Compared to the traditional LSM-tree architecture, this invention achieves faster query speeds: The L0 layer is stored on an NVM, and the NVM's large capacity and near-memory read / write speeds allow for faster response to application query requests, improving system throughput; it significantly reduces write blocking: a more refined L0 layer data compaction strategy controls each L0 data compaction operation to a single leaf node of the B+ tree, reducing the amount of data introduced and the time occupied by data compaction. This ensures timely flushing of the read-only memory table to the NVM's B+ tree without blocking the system; it significantly reduces LSM storage engine read / write amplification, improving disk space utilization: L0 data is globally ordered after being managed by a B+ tree, removing some redundant data at the L0 level. Furthermore, the large capacity of the NVM allows for storing more data at the L0 level, reducing the number of LSM layers.

[0031] Furthermore, this invention can withstand higher loads: when the insertion load is particularly high and the read-only memory table is not refreshed in time, it allows data to be written directly to the leaf nodes located on the B+ tree of the NVM, ensuring normal system operation; lower log overhead: the NVM is persistent, and direct data insertion into the NVM can eliminate log overhead, making the response to application requests faster and improving system throughput; improved NVM data space utilization: the internal read / write unit of the NVM is 256 bytes, and this invention sets the leaf node size to a multiple of 256 bytes and compacts data in leaf node blocks, improving the space utilization of the NVM; faster refresh speed of the read-only memory table in memory: the read-only memory table is written directly to the NVM instead of the disk, and the data write speed of the NVM is several orders of magnitude higher than that of the disk. The faster refresh allows the system to use idle CPUs to compact data on the disk, improving system concurrency.

[0032] The above-described specific implementations can be partially adjusted by those skilled in the art in different ways without departing from the principles and purpose of the present invention. The scope of protection of the present invention is defined by the claims and is not limited to the above-described specific implementations. All implementation schemes within the scope of the claims are bound by the present invention.

Claims

1. A method for reducing LSM write blocking and read / write amplification based on NVM and B+ trees, characterized in that, Initially, the application writes key-value pair data into a memory table in dynamic memory. When the memory table is full, its permissions are set to read-only and it is written into the leaf node of the NVM B+ tree and managed by the B+ tree. At the same time, a new memory table is created in dynamic memory. The read-only memory table and the data in the memory table are entirely stored in DRAM; The B+ tree comprises: internal nodes located in DRAM and leaf nodes located in NVM, wherein the leaf node size, which contains indirect indexes and data ratios, is a multiple of 256 bytes; When the NVM space utilization is greater than half, data compaction is performed on the L0 layer data. Specifically, the leaf nodes of the B+ tree are used as units, and the selection is based on the data proportion of the leaf nodes. Leaf nodes with high data proportions are selected for data compaction first, so as to control the amount of data introduced in one data compaction process and reduce the occurrence of B+ tree splits. The NVM space utilization rate = ; The percentage of leaf node data = .

2. The method for reducing LSM write blocking and read / write amplification based on NVM and B+ tree according to claim 1, characterized in that, When the memory table is full and the system is idle, multiple threads write the read-only memory table to the leaf nodes located on the B+ tree of NVM.

3. The method for reducing LSM write blocking and read / write amplification based on NVM and B+ tree according to claim 1, characterized in that, When the memory table is full and the read-only memory table has not yet been written to the B+ tree, the application directly writes the key-value pair data to the B+ tree located in the NVM, i.e., direct access.

4. The method for reducing LSM write blocking and read / write amplification based on NVM and B+ tree according to claim 1, characterized in that, The aforementioned data compaction specifically includes: 3.1) At the start of L0 layer data compaction, scan the leaf nodes of B+ layer to construct a max-heap based on the proportion of leaf data. The max-heap includes: data percentage, pointers to leaf nodes, and pointers to the parent nodes of the leaf nodes; 3.2) Select the leaf node with the largest data proportion from the max-heap, i.e., the top element of the heap; 3.2) Delete the pointer to the current leaf node from the parent node of the leaf node of the top element of the heap, find the left sibling node of the leaf node through the parent node, and set the tail pointer of the left sibling node of the current leaf node to the leaf node pointed to by the tail pointer of the current leaf node. 3.3) Perform data compaction on the leaf node of the top element in step 3.

2. That is, select the data table in L1 layer that has a range intersection with the data of the leaf node, merge the leaf node data and the data table data with the range intersection into a globally ordered data table, delete duplicate and invalid data, and release the NVM space occupied by the leaf node after the data compaction process is completed.

Citation Information

Patent Citations

  • Efficient indexing method for optimizing leaf node merging operation

    CN111475508A

  • Staggered merging in log-structured merge forests

    CN112236759A