Persistent memory metadata management method and device based on log structure
By adopting a metadata management method based on log structure in persistent memory, the problem of random write performance degradation caused by random distribution of metadata in traditional technology is solved, and more efficient memory allocation performance is achieved.
Patent Information
- Application Number
- CN202210194862.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-01
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2042-03-01
AI Technical Summary
When traditional persistent memory allocators allocate large blocks of memory, metadata is randomly distributed, resulting in the performance of random writes of small-scale data degraded, becoming a performance hotspot.
The persistent memory metadata management method based on the log structure is adopted, and the core data of the memory block metadata is appended and written to the log file of the persistent memory in the form of log entries, and the log group metadata is saved in DRAM, and allocated and unallocated memory block metadata is managed through red and black trees and linked lists.
By modifying the layout pattern of metadata, the distribution of persistent memory metadata is more localized, reducing the random writes of small-scale data, and improving the allocation performance of persistent memory.
Smart Images

Figure CN114546662B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer science memory programming, and in particular to a persistent memory metadata management method and device based on a log structure. Background Art
[0002] The emerging persistent memory (PM) has the characteristics of low latency, high capacity and no data loss during power failure, and has become one of the research hotspots in academia. Memory allocators for persistent memory are also widely used in transactional memory, KV storage and other fields. When traditional persistent memory allocators allocate large blocks of memory, they place memory allocation metadata at the head of each memory block. After a series of memory allocation and release operations, the metadata will be randomly distributed in the memory address space. One of the characteristics of persistent memory is that the random write performance is significantly lower than the sequential write performance when writing small-scale data. Therefore, the modification operation of memory allocation metadata is likely to become a performance hotspot for memory allocation. Summary of the invention
[0003] In order to solve the random writing problem caused by the traditional metadata layout, the present invention proposes a persistent memory metadata management method and device based on a log structure.
[0004] The technical solution adopted by the present invention is:
[0005] A memory block metadata management method for persistent memory based on a log structure, comprising:
[0006] The memory block metadata of the persistent memory is stored in DRAM, and the core data of the memory block metadata is appended to the log file of the persistent memory in the form of log entries according to the status update of the memory block; the log file is divided into multiple log groups to store log entries, and the header of the log file stores the metadata of the log file: including a linked list pointer pointing to the allocated log group, a linked list pointer pointing to the linked list used only in space recovery, and a bit for indicating the linked list in use; the log group metadata stored in the header of each log group includes the log group number, a flag indicating whether the log group is available, and a pointer to the next allocated log group.
[0007] At the same time, the log group metadata is saved in the DRAM. The log group metadata is a bitmap indicating the log group allocation status. The allocated log group metadata is managed through a red-black tree, and the released log group metadata is managed through a linked list.
[0008] Furthermore, three linked lists (active linked list, recycled linked list, and retained linked list) are used in DRAM to manage the memory block metadata of the persistent memory, where:
[0009] The metadata corresponding to the allocated memory blocks are stored in the active linked list, the metadata corresponding to the memory blocks released by the user are stored in the reclaimed linked list, and the metadata corresponding to the memory blocks whose physical memory is released and only the virtual addresses are retained are stored in the retained linked list.
[0010] Furthermore, the core data of the memory block metadata is appended to the log file of the persistent memory in the form of log entries according to the status update of the memory block, specifically:
[0011] When a memory block is allocated, a normal log entry is appended to the log file of the persistent memory. When a memory block is released, a tombstone log entry is appended to the log file of the persistent memory. The tombstone entry points to the normal log entry corresponding to the memory block. The normal log entry contains three attributes: memory block size, starting address, and log type.
[0012] Furthermore, it also includes the recovery of space occupied by the log group metadata; the space recovery method includes fast space recovery and slow space recovery, which are as follows:
[0013] Fast space recovery: Scan the log group metadata stored in the red-black tree. If the bitmap of the log group metadata is empty, move the log group metadata into the linked list.
[0014] Slow space recovery: The linked list of allocated log groups at the head of the log file is recorded as list old , another empty linked list (a linked list used only in space recovery) is recorded as list new . Scan list old , according to the bitmap in the log group metadata, add the assigned log group to the list new After the scan is completed, modify the alt bit to indicate the currently used linked list and list old Release the log group in.
[0015] Furthermore, a space reclamation method is selected according to the size of the log file. The larger the file size, the more suitable it is to select slow space reclamation.
[0016] A memory block metadata management device for a persistent memory based on a log structure comprises one or more processors for implementing the above-mentioned memory block metadata management method for a persistent memory based on a log structure.
[0017] The beneficial effect of the present invention is that by modifying the layout mode of metadata, the distribution of persistent memory metadata is made more localized, the random writing of small-scale data is reduced, and the allocation performance of persistent memory is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 Diagram showing the log-based memory metadata management model
[0019] Figure 2 A two-layer structure diagram showing the memory metadata layout
[0020] Figure 3 A performance comparison diagram showing the present invention and other existing memory allocators under two different loads;
[0021] Figure 4 It is a structural schematic diagram of a memory block metadata management device of a persistent memory based on a log structure of the present invention. DETAILED DESCRIPTION
[0022] The present invention will be further described below in conjunction with the accompanying drawings and specific examples.
[0023] The present invention provides a memory block metadata management method for persistent memory based on log structure, such as Figure 1 As shown, the memory block metadata (Virtual Extent Header, VEH) of the persistent memory is stored in DRAM, and the core data of the memory block metadata is updated according to the status of the memory block in the form of log entries (log entry, LE) and appended to the log file of the persistent memory; the log file is divided into multiple log groups (chunks) to store log entries.
[0024] At the same time, the log group metadata (vchunk) is saved in DRAM. The log group metadata is a bitmap indicating the log group allocation status. The allocated log group metadata is managed through a red-black tree, and the released log group metadata is managed through a linked list.
[0025] In DRAM, the memory block metadata of persistent memory is managed in the form of a linked list, where:
[0026] The metadata corresponding to the allocated memory blocks are stored in the activated list, the metadata corresponding to the memory blocks released by the user are stored in the reclaimed list, and the metadata corresponding to the memory blocks whose physical memory is released and only the virtual addresses are retained are stored in the retained list.
[0027] like Figure 1As shown in the figure, VEH1 and VEH4 are VEHs corresponding to the currently allocated memory blocks, which are stored in the activated list and correspond to LE1 and LE4 in the persistent memory log file, while there are no log entries corresponding to the VEHs in other linked lists. LE1 and LE4 correspond to memory blocks 1 and 4 on the persistent memory. The log file is written sequentially. When the memory blocks are allocated and released, the modified metadata is only appended to the end of the file.
[0028] In the management method of the present invention, the metadata layout of the memory block is designed as a two-layer structure according to the persistent memory and DRAM, and its structure is as follows Figure 2 As shown:
[0029] The first layer is the layout of the memory block metadata in the persistent memory: a log entry (LE) is maintained for each updated memory block, which contains three attributes: memory block size, starting address, and log type, and the size is about 8B. The memory allocator maintains a log file in the persistent memory. The file is divided into multiple log groups (chunks), and multiple log entries are stored in each log group chunk (for example: the size is 1KB, corresponding to 128 log entries). The header of the log file stores the metadata of the log file, including a pointer to a linked list that stores the allocated log group chunk, a pointer to a linked list that is only used in space recovery, and a bit used to indicate the linked list in use. Each chunk contains two parts: the chunk header and log data. The metadata stored in the chunk header includes the log group chunk number, a flag indicating whether the log group chunk is available, and a pointer to the next log group chunk.
[0030] The second layer is the layout of metadata in DRAM: a corresponding log group metadata (virtual chunk, vchunk) is maintained for each log group chunk in persistent memory, a bitmap indicating the allocation of log group chunks is saved, the allocated log group metadata vchunk is managed through a red-black tree, and the released log group chunk is managed through a linked list.
[0031] It can also be seen from the figure that vchunk and chunk are one-to-one corresponding. For example, the allocated chunk1 corresponds to vchunk1 in the red-black tree, and the unallocated chunk2 corresponds to vchunk2 in the free list.
[0032] Furthermore, based on the management method of the present invention, the steps of updating metadata are as follows:
[0033] Step 1: Modify the corresponding VEH stored in DRAM according to the status of the memory block (allocated or released).
[0034] Step 2: Write the core data to the log file of persistent memory in the form of log entries. This writing is sequential, that is, the new entries are directly appended to the end of the file. A normal log entry is appended when a memory block is allocated, and a tombstone log entry is appended when a memory block is released. The tombstone entry points to the normal log entry corresponding to the memory block.
[0035] Step 3: Modify the corresponding bits of the bitmap in vchunk.
[0036] In addition, the method of the present invention also includes reclaiming the space occupied by the log group metadata; the space reclaiming method includes fast space reclaiming and slow space reclaiming, which are as follows:
[0037] Fast space recovery: Scan the log group metadata stored in the red-black tree. If the bitmap of the log group metadata is empty, move the log group metadata into the linked list.
[0038] Slow space recovery: The linked list of allocated log groups at the head of the log file is recorded as list old , another empty linked list is denoted as list new . Scan list old , according to the bitmap in the log group metadata, add the assigned log group to the list new After the scan is completed, modify the alt bit to indicate the currently used linked list and list old Release the log group in.
[0039] The space recovery method is selected according to the size of the log file. The larger the log file size, the more suitable it is to select slow space recovery. You can choose according to the actual situation.
[0040] The present invention makes the distribution of persistent memory metadata more localized by modifying the layout mode of metadata, reduces random writing of small-scale data, and improves the allocation performance of persistent memory.
[0041] In order to verify the performance improvement effect of the present invention on the memory allocator for persistent memory, tests were conducted under two loads, Larson-large and DBMStest. The specific experiments are as follows:
[0042] The experimental hardware configuration is two Intel Xeon Gold 5218R CPUs, each CPU is equipped with 64GB DRAM and two Intel Optane DIMMs, each DIMM size is 128GB. The pair of DIMMs connected to the CPU is configured in App Direct mode and mounted with the Ext4-DAX file system. To avoid the impact of NUMA, numactl is used for thread binding. The experimental comparison objects are the existing memory allocators PMDK, nvm_alloc, PAllocator and Makalu.
[0043] Test results see Figure 3 As shown, it can be seen that the performance of the present invention is improved by 40 times, 18 times, 55 times, and 57 times respectively compared with PMDK, nvm_malloc, PAllocator, and Makalu.
[0044] Corresponding to the aforementioned embodiment of the memory block metadata management method of the persistent memory based on the log structure, the present invention also provides an embodiment of the memory block metadata management device of the persistent memory based on the log structure.
[0045] See also Figure 4 A memory block metadata management device for a persistent memory based on a log structure is provided in an embodiment of the present invention, and includes one or more processors for implementing the memory block metadata management method for a persistent memory based on a log structure in the above embodiment.
[0046] The embodiment of the memory block metadata management device of the persistent memory based on the log structure of the present invention can be applied to any device with data processing capability, and the any device with data processing capability can be a device or apparatus such as a computer.
[0047] The device embodiment can be implemented by software, hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of any device with data processing capability reading the corresponding computer program instructions in the non-volatile memory into the memory and running it. From the hardware level, Figure 4 As shown, it is a hardware structure diagram of any device with data processing capability where the memory block metadata management device of the persistent memory based on the log structure of the present invention is located, except Figure 4 In addition to the processor, memory, network interface, and non-volatile memory shown, any device with data processing capabilities in which the apparatus in the embodiments is located may also include other hardware, generally based on the actual functions of the device with data processing capabilities, which will not be described in detail.
[0048] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0049] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of the present invention. Ordinary technicians in this field can understand and implement it without paying creative work.
[0050] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A memory block metadata management method for persistent memory based on a log structure, characterized in that: include: The memory block metadata of the persistent memory is stored in DRAM, and the core data of the memory block metadata is appended to the log file of the persistent memory in the form of log entries according to the status update of the memory block; The log file is divided into multiple log groups to store log entries, and the header of the log file stores the metadata of the log file, which includes a pointer to a linked list storing the allocated log group, a pointer to a linked list used only in space recovery, and a bit for indicating the linked list in use; each log group header stores the log group metadata, which includes the log group number, a flag indicating whether the log group is available, and a pointer to the next allocated log group; At the same time, the log group metadata is saved in DRAM. The log group metadata is a bitmap indicating the log group allocation status. The allocated log group metadata is managed through a red-black tree, and the released log group metadata is managed through a linked list.
2. The method according to claim 1, characterized in that In DRAM, the memory block metadata of persistent memory is managed in the form of a linked list, where: The metadata corresponding to the allocated memory blocks are stored in the active linked list, the metadata corresponding to the memory blocks released by the user are stored in the reclaimed linked list, and the metadata corresponding to the memory blocks whose physical memory is released and only the virtual addresses are retained are stored in the retained linked list.
3. The method according to claim 1, characterized in that The core data of the memory block metadata is appended to the log file of the persistent memory in the form of log entries according to the status update of the memory block, specifically: When a memory block is allocated, a normal log entry is appended to the log file of the persistent memory. When a memory block is released, a tombstone log entry is appended to the log file of the persistent memory. The tombstone entry points to the normal log entry corresponding to the memory block. The normal log entry contains three attributes: memory block size, starting address, and log type.
4. The method according to claim 1, characterized in that: It also includes the recovery of space occupied by the log group metadata; the space recovery method includes fast space recovery and slow space recovery, as follows: Fast space recovery: Scan the log group metadata stored in the red-black tree. If the bitmap of the log group metadata is empty, move the log group metadata into the linked list. Slow space recovery: The linked list of allocated log groups at the head of the log file is recorded as list old , another empty linked list is denoted as list new; Scan list old , according to the bitmap in the log group metadata, add the assigned log group to the list new After the scan is completed, modify the alt bit to indicate the currently used linked list, and list old Release the log group in.
5. The method according to claim 4, characterized in that Select the space reclamation method based on the log file size. The larger the file size, the more suitable it is to select slow space reclamation.
6. A memory block metadata management device for a persistent memory based on a log structure, comprising one or more processors, for implementing the memory block metadata management method for a persistent memory based on a log structure as described in any one of claims 1-5.
Citation Information
Patent Citations
Method and device for performing file layout extraction on parallel file system
CN102164161A
Persistent memory object storage system
CN111240588A