A Wear-Aware Space Allocation Method for Persistent Memory File System Based on Multi-Level Bitmap
By constructing a multi-level bitmap index structure and a conditional wear inheritance mechanism, the problems of low wear leveling accuracy and high performance overhead in persistent memory file systems are solved, achieving higher accuracy wear leveling and performance improvement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUIZHOU UNIV
- Filing Date
- 2023-03-31
- Publication Date
- 2026-05-26
AI Technical Summary
Existing persistent memory file systems are inadequate in terms of wear leveling accuracy and performance overhead, especially in terms of poor performance and external fragmentation during multi-granularity allocation requests.
A multi-granularity allocation method based on multi-level bitmaps is adopted. By constructing a multi-level bitmap index structure, the allocatable heap can be found quickly. A conditional wear inheritance mechanism is introduced to avoid redundant cutting and redundant calculation of remaining blocks when inserting large blocks.
It achieves higher precision wear leveling, reduces external fragmentation, and improves file system performance and the lifespan of persistent memory.
Smart Images

Figure CN116360698B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of memory, specifically relating to a wear-aware space allocation method for a persistent memory file system based on a multi-level bitmap. Background Technology
[0002] In recent years, numerous new types of persistent memory (PM) have emerged, offering advantages such as low latency, non-volatility, byte-addressability, low power consumption, and high storage density. Examples include Phase Change Memory (PCM), Resistive RAM (ReRAM), and 3D-Xpoint. These persistent memories can be directly connected to the memory bus via DIMM slots, providing high-speed byte-addressable data access while persistently storing data like a hard disk. Furthermore, the CPU can directly access persistent memory using load / store instructions. The continuous development of high-capacity persistent memory technology has driven advancements in the field of storage system software optimization research. In recent years, numerous persistent memory file systems (PMS) using persistent memory as storage devices have also emerged, such as BPFS, SCMFS, PMFS, SIMFS, NOVA, and HiNFS. These file systems fully leverage the advanced features of new persistent memory in their software design philosophy. By optimizing the organization of file data and data consistency mechanisms, they greatly improve the performance of the file system, enabling file access throughput to reach the GB / s level.
[0003] However, large-capacity persistent memory generally suffers from read-write asymmetry, meaning that write latency / power consumption is higher than read latency / power consumption. It also generally has low write tolerance (PCM's write tolerance is approximately 10). 8 For example, when the number of write operations to a PCM storage unit reaches 10... 8 When the wear and tear on a small number of storage units is significant, the data in the entire file system becomes unreliable, severely shortening the lifespan of persistent memory. Therefore, it is necessary to distribute the large number of write operations to a few storage units across other storage spaces, ensuring that the wear and tear on each storage unit is relatively even, thereby improving the lifespan of persistent memory.
[0004] Existing persistent memory file systems, such as PMFS, typically use 4KB physical pages to organize file data and linked lists to manage free or allocated memory blocks. To support multi-granularity allocation, each node in the linked list represents several contiguous pages, i.e., a contiguous segment of physical space. When allocating free blocks, PMFS needs to traverse the linked list to find a suitable free block node; when reclaiming pages, PMFS also needs to traverse the linked list to find adjacent blocks for merging. NOVA, on the other hand, allocates a memory pool for each CPU and uses a red-black tree to sort the memory pool addresses to reduce the overhead of merging free blocks. Furthermore, to achieve fast allocation, NOVA allocates the head node for each ordinary page allocation, while allocating superpages requires traversing the linked list to find a suitable free block node.
[0005] In 2013, Iulian Moraru et al. from Carnegie Mellon University proposed NVMalloc, an allocator that considers write wear in persistent memory, to address the problems of traditional memory allocators not considering persistent memory write wear and the significant performance overhead caused by hardware-based wear leveling. In 2015, Professor Xiao Nong's team at the National University of Defense Technology proposed Walloc, an allocator that considers write wear in persistent memory, to address the problems of severe wear imbalance in persistent memory and a large number of write operations due to space allocation metadata caused by traditional memory allocators. In 2017, Professor Shu Jiwu's team at Tsinghua University proposed SanGuo, a free page allocation technique that considers file data page wear, to address the severe wear imbalance problem in the existing space management strategy of PMFS. In 2018, Professor Zhuge Qingfeng's team at Chongqing University proposed Dynamic Wear-Aware Range Management (DWARM) to address the deficiency of existing persistent memory file systems that do not consider the low write tolerance of the underlying persistent memory. In 2020, Professor Liu Duo's team at Chongqing University proposed a wear-leveling-aware multi-grained allocator (WMAlloc) to address the problem that existing space allocators for persistent memory file systems that consider write wear only support single-granularity allocation and have high wear leveling overhead.
[0006] Existing research on persistent memory space management optimization considering write wear has achieved a certain degree of wear leveling by prioritizing the allocation of low-wear pages, but it still suffers from low wear leveling accuracy and high overhead. The following explanation uses DWARM and WMAlloc as examples.
[0007] Figure 1The diagram illustrates the overall design of DWARM. First, to record the wear status of each page, DWARM reserves a contiguous space after the superblock to maintain an 8-byte write counter for each page. This write counter can be quickly accessed by accessing array elements; when data is written to a page, the corresponding write counter value increments by one. Second, DWARM divides all free pages in persistent memory into several groups based on their write counters. Pages with wear levels within the same range are grouped together, and all free pages belonging to the same group are linked by a singly linked list. To reduce the overhead of locating the corresponding group, DWARM constructs a linked list in DRAM to manage all groups, setting the maximum wear level of pages within a group as a threshold for that group's wear range. All groups are arranged from lowest to highest wear range threshold. The Key of a DRAM linked list node is the group wear threshold, Ptr is a pointer to the group, and Next is a pointer to the next node in the linked list. Then, DWARM employs a least-used-first-out (LFO) strategy, always allocating the first page of the group with the least wear, or reclaiming free pages at the end of the corresponding group based on the write counter.
[0008] Finally, DWARM proposes an adaptive wear range determination algorithm to dynamically adjust the wear range of all groups. When the number of free pages in a group exceeds α times the total number of free pages in persistent memory, the group will be split. During splitting, DWARM first finds the median page wear in the group and splits pages with wear less than the median and pages with wear greater than the median into two subgroups. If the number of pages in the subgroup still meets the splitting condition, the subgroups are recursively split until the number of pages in the subgroup is less than α times the total number of pages. The adaptive wear range determination algorithm ensures that the pages with the smallest wear in the first α times are allocated first, greatly improving the accuracy of wear leveling. In addition, DWARM creates a temporary linked list to organize the reclaimed pages. Only when the number of free pages in the temporary linked list reaches a threshold are the free pages in the linked list migrated by the background thread to the group linked list corresponding to the wear range, thereby reducing the overhead of file system resource contention.
[0009] While DWARM achieves a certain level of wear leveling accuracy by selecting low-wear pages for each allocation request, it still suffers from two problems: First, wear leveling accuracy and performance overhead are closely related to the set grouping; the larger the group wear range, the more unbalanced the wear in persistent memory, and the smaller the group wear range, the greater the metadata management overhead for wear leveling. Second, DWARM is a single-granularity allocator that can only allocate one 4KB page at a time. For a multi-granularity allocation request, multiple allocation operations are required, which severely reduces DWARM performance and exacerbates wear in its log area.
[0010] Figure 2The diagram illustrates the overall design of the Wear-Leveling-Aware Multi-Grained Allocator (WMAlloc). WMAlloc comprises three key technologies: Multi-Grained Allocation Heap (MGAH), Wear-Aware Reclaimed Forest (WARF), and Wear-Leveled Node Migration (WBNM). First, to provide multi-granularity allocation while achieving wear leveling, WMAlloc constructs 11 min-heap trees (numbered from 0 to 10) to manage free blocks, quickly locating the free block with the lowest average wear in the heap. For the i-th min-heap tree, if i is less than 10, the block node in this heap represents a block consisting of 2i consecutive pages; if i equals 10, the block size managed by this min-heap tree exceeds 512 consecutive pages. Therefore, except for the 10th min-heap tree, each min-heap tree uses the number of pages contained in its nodes as the granularity of the allocation heap. When the requested block size is less than or equal to 512 pages, WMAlloc only needs to allocate the head node from the corresponding min-heap tree, completing the request in a single allocation, greatly improving file system performance. To address the issue of uneven wear between heaps, WMAlloc proposes a wear-leveling node migration mechanism, swapping nodes in the heap tree with the least wear with nodes in the heap tree with the most wear. Furthermore, WMAlloc's wear-aware reclamation forest mechanism temporarily divides released blocks into multiple red-black tree groups based on page write counters to accelerate block merging operations. During migration, WMAlloc always migrates blocks from the least worn red-black tree to the min-heap.
[0011] While WMAlloc achieves higher wear leveling accuracy and file system performance than DWARM through the three key technologies mentioned above, it still has two problems. First, when the number of free blocks in a min-heap tree is less than a set threshold, larger free blocks in other min-heap trees or red-black trees will be split into multiple sub-blocks and then migrated to that min-heap tree. During this splitting, the wear rate of each sub-block needs to be recalculated, which incurs significant performance overhead. For example, assuming a block containing 15 consecutive pages in a red-black tree will be migrated to the 3rd min-heap tree, this block will be split into four sub-blocks containing 8, 4, 2, and 1 consecutive pages respectively, and inserted into the 3rd, 2nd, 1st, and 0th min-heap trees respectively. Even worse, this practice of actively cutting large blocks to make the sub-block size suitable for the allocation heap granularity generates more external fragmentation, which severely degrades file system performance and exacerbates wear on the file system log area. Second, when the allocation block granularity is larger than the request block granularity, the remaining blocks generated by the allocation need to have their average wear rate recalculated and then inserted back into the multi-granularity allocation heap. However, calculating the average wear rate requires traversing every page of the remaining blocks, which can lead to significant performance overhead when the remaining blocks are large in granularity. Summary of the Invention
[0012] To address the shortcomings of existing technologies, this invention proposes a wear-aware space allocation method for persistent memory file systems based on multi-level bitmaps, in order to solve the problems of low wear leveling accuracy and high overhead in implementing wear leveling in existing persistent memory allocators.
[0013] The mechanism aims to solve two main technical problems:
[0014] 1) Bitmap-based multi-granularity heap. By constructing a multi-level bitmap index structure to quickly find allocatable heaps, the granularity distribution of the allocation heap can be diversified. The new multi-granularity allocation heap can accommodate blocks of arbitrary granularity, thereby avoiding redundant cutting when inserting large blocks into the allocation heap and recalculating the average wear of sub-blocks, reducing external fragmentation, and improving file system performance and persistent memory wear leveling accuracy.
[0015] 2) Conditional wear inheritance mechanism. This mechanism limits the huge overhead of traversing the remaining blocks to a reasonable range.
[0016] The present invention solves the above-mentioned technical problems through the following technical solution:
[0017] A wear-aware space allocation method for a persistent memory file system based on multi-level bitmaps, wherein the multi-granularity allocation method includes:
[0018] Based on the number of consecutive pages contained in the free block, construct a fine-grained multi-granularity allocation heap;
[0019] Based on the availability of the min-heap, construct an index structure based on a multi-level bitmap;
[0020] Based on the granularity requested by the upper-layer application, the first available min-heap with a granularity greater than or equal to the requested granularity is quickly located using the multi-level bitmap-based index structure, and the free block with the lowest average wear is allocated from this min-heap.
[0021] Preferably, the method further includes denoting the size of the original block corresponding to the allocation request as T, the size of the requested block as Q, and the ratio γ as the inheritance threshold; using Q / T to represent the wear fluctuation caused by the allocation request; if Q / T≤γ, it is considered that the average wear of the remaining blocks will not fluctuate drastically, and the remaining blocks directly inherit the average wear of the original blocks; otherwise, the average wear of the remaining blocks is recalculated.
[0022] The beneficial effects of this invention are:
[0023] 1. This invention can achieve higher precision wear leveling while significantly improving the performance of persistent memory file systems.
[0024] 2. This invention constructs a multi-level bitmap index structure to support fast lookup of allocable heaps, making the granularity distribution of the allocation heap more diverse. The new multi-granularity allocation heap can accommodate blocks of any granularity, thereby avoiding redundant cutting when inserting large blocks into the allocation heap, reducing external fragmentation, and improving the performance of the file system and the accuracy of persistent memory wear leveling.
[0025] 3. This invention limits the huge overhead generated by traversing the remaining blocks to a reasonable range through the conditional wear inheritance mechanism, thereby further improving the performance of the file system. Attached Figure Description
[0026] Figure 1 This is a schematic diagram of the existing persistent memory file system wear leveling awareness allocation architecture.
[0027] Figure 2 This is a schematic diagram of an efficient, multi-granularity allocation architecture for persistent memory file systems in existing technologies;
[0028] Figure 3 This is a flowchart of a wear-aware space allocation method for a persistent memory file system based on a multi-level bitmap according to an embodiment of the present invention.
[0029] Figure 4 This is a schematic diagram of a bitmap-based index structure according to an embodiment of the present invention. Detailed Implementation
[0030] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0031] Common heap structures include max-heap, min-heap, Fibonacci wedge heap, left-handed heap, and skew heap. In this invention, the metadata of min-heap nodes is redefined to enable the rapid identification of nodes with minimal wear. Therefore, all heaps in this invention refer to min-heaps. For ease of description, some embodiments of this invention will simply refer to the min-heap as a heap.
[0032] To facilitate understanding, the key technical aspects of this invention will be explained first: Firstly, this invention provides a bitmap-based multi-granularity heap that enables multi-granularity allocation, significantly improving system performance. Finally, the conditional wear inheritance mechanism employed in this invention effectively solves the redundancy overhead problem present in the aforementioned mechanisms, further enhancing the performance and wear leveling accuracy of traditional WMAlloc.
[0033] In some embodiments, the present invention can also utilize the traditional WMAlloc wear-aware recycling forest mechanism (WARF) and wear-leveling node migration mechanism (WBNM) to achieve high-precision wear leveling. Specifically, for the wear-aware recycling forest mechanism (WARF), the present invention can construct a wear-aware red-black tree forest based on existing technology to temporarily manage recently released free blocks. Each red-black tree represents a wear range group, and newly released free blocks are inserted into the corresponding red-black tree according to their wear level, and can be quickly merged with their neighboring blocks. When the total number of free blocks in the min-heap is less than a threshold, the migration of the first portion of low-wear blocks in the red-black tree forest to the min-heap will be triggered for future allocation. For the wear-leveling node migration mechanism (WBNM), due to the uneven granularity of upper-layer application requests, some heaps have blocks that have never been allocated, while blocks in other heaps are frequently allocated, resulting in severe wear imbalance between heaps. Therefore, the present invention can employ a block node migration mechanism between min-heaps based on existing technology.
[0034] Figure 3 This is a flowchart of a wear-aware space allocation method for a persistent memory file system based on a multi-level bitmap, according to an embodiment of the present invention; Figure 3 As shown, the method includes:
[0035] 101. Construct a fine-grained multi-granularity allocation heap based on the number of consecutive pages contained in the free block;
[0036] 102. Based on the availability of the min-heap, construct an index structure based on a multi-level bitmap;
[0037] 103. Based on the granularity requested by the upper-layer application, the first available min-heap with a granularity greater than or equal to the requested granularity is quickly located using the multi-level bitmap-based index structure, and the free block with the lowest average wear is allocated from the min-heap.
[0038] In traditional techniques, WMAlloc can efficiently perform multi-granularity allocation tasks with O(1) complexity using a multi-granularity allocation heap MAGH. However, WMAlloc incurs significant redundancy overhead when free blocks in the red-black tree or residual blocks generated by allocation are migrated / inserted back into the min-heap. Specifically, in a multi-granularity allocation heap, due to the 2n nature of heap management... i When migrating a block containing 511 pages from a red-black tree, the MGAH splits it into nine sub-blocks containing 256, 128, 64, 32, 16, 8, 4, 2, and 1 consecutive pages respectively, and inserts them one by one into the corresponding min-heap. Similarly, when allocating 200 pages from a block with 711 pages, the remaining block is also split into nine sub-blocks, and the above insertion process is performed.
[0039] This mechanism degrades WMAlloc performance in two ways. First, large blocks are fragmented into several discrete smaller blocks, leading to a scarcity of future allocatable large blocks. Therefore, MGAH needs to allocate several smaller blocks for large-granularity allocation requests. Worse still, since every allocation operation must be logged in the log area, a large number of small-granularity allocations severely degrade system performance and the durability of the log area. Second, to ensure wear leveling accuracy, when a large block is fragmented into smaller blocks, the write counters of all pages within that sub-block need to be traversed to recalculate the average wear of each sub-block, introducing significant overhead and unpredictable long-tail latency.
[0040] To avoid these redundant splits, this invention proposes a bitmap-based multi-granularity heap tree (BMT) to replace the original MGAH. The basic idea of BMT is to refine the granularity of the min-heap by constructing a fine-grained multi-granularity allocation heap to accommodate the remaining sub-blocks and thwart recursive splits. A block node in the min-heap consists of a fixed number of contiguous pages, and the number of contiguous pages is defined as the granularity of the min-heap. M min-heaps of different granularities are used to organize free blocks, with the granularity of the i-th min-heap being i+1; i≤M, M≥64. Using a bitmap-based multi-granularity heap tree, multiple layers of bitmaps are constructed for the min-heap. Taking i=511 as an example, BMT can extend the number of min-heaps to 512, numbered from 0 to 511. The i-th min-heap records a block containing i+1 contiguous pages, instead of the 2 in MGAH. i Each block is a single page. All blocks exceeding 512 pages are recorded in the last min-heap. Based on this design, migration blocks of each granularity can be directly inserted into the corresponding min-heap without splitting. Although allocation from large blocks may still result in splitting, the remaining sub-blocks will also be directly inserted into the corresponding min-heap without further splitting.
[0041] In traditional techniques, when the application block granularity is N and the first... When a heap is empty, WMAlloc needs to traverse backwards to find the next allocatable heap with a larger granularity. To solve this inefficient location problem, this invention proposes a bitmap-based indexing structure, BMT. Each bit in the bottom-level bitmap directly indicates the availability of a min-heap. A multi-granularity heap tree based on bitmaps is used to construct multi-level bitmaps for the min-heaps. If the i-th min-heap is available, the i-th bit in the bottom-level bitmap is set to 1, otherwise it is set to 0. Each bit j in other levels indicates the availability of the min-heap represented by the m bits in the next level bitmap. If an available min-heap exists, the bit j is set to 1, otherwise it is set to 0. Each m bit in the multi-level bitmap is grouped into a group and all are recorded in the integer array bmp to indicate the availability of each min-heap. The information of the bottom-level bitmap is recorded in the 0th to nbth integers of bmp, the information of the second-level bitmap is recorded in the nb+1th to nb+1+sbth integers of bmp, and so on. The information of the top-level bitmap is recorded in the last integer tb of bmp. Where m≤64, nb=M / m, sb=(nb+1) / m.
[0042] like Figure 4 As shown in (a), BMT constructs a three-level bitmap on 512 min-heaps. The top-level bitmap occupies one byte, while the second-level and bottom-level bitmaps occupy 8 and 64 bytes respectively. The i-th bit in the 64-byte (512-bit) bottom-level bitmap indicates the availability of the i-th min-heap; that is, if the i-th min-heap is empty, the corresponding i-th bit is 0, otherwise it is 1.
[0043] Each bit in the second-level bitmap indicates the availability of the eight min-heaps represented by every eight bits in the lower-level bitmap. Specifically, if a bit in the second-level bitmap is 0, then all eight bits in its corresponding lower-level bitmap are 0, meaning that all eight corresponding min-heaps are empty; otherwise, the eight bits in the corresponding lower-level bitmap are not all 0, meaning that at least one of the eight min-heaps is available. Similarly, the top-level bitmap uses one byte to indicate the availability of the entire space. If a bit in the top-level bitmap is 0, then all eight bits in the corresponding second-level bitmap and all 64 bits in the lower-level bitmap are 0, meaning that all 64 heaps are empty; otherwise, it indicates that the eight bits in the second-level bitmap and all 64 bits in the lower-level bitmap are not all 0, meaning that there is a usable heap.
[0044] To facilitate storage and indexing, this invention records the three-layer bitmap in an integer array bmp. Integers 0 to 63 of bmp record the bottom-layer bitmap, integers 64 to 71 record the second-layer bitmap, and integer 72 records the top-layer bitmap. Initially, the entire PM space is a contiguous block, recorded in the last min-heap, i.e., the 511th min-heap. Therefore, initially, bit 511 of the bottom-layer bitmap, bit 63 of the middle-layer bitmap, and bit 7 of the top-layer bitmap are set to 1, and the remaining bits are 0. That is, the values of bmp
[63] , bmp
[71] , and bmp
[72] are all set to 128, and the values of the remaining bmp elements are 0. The bitmap-based indexing structure can quickly locate the available fine-grained min-heap with minimal maintenance cost.
[0045] In this embodiment of the invention, the operation of the index structure of the multi-level bitmap includes inserting a free block into the min-heap and updating the multi-level bitmap (block node insertion); deleting a free block from the min-heap and updating the multi-level bitmap (block node deletion); and using the multi-level bitmap to quickly locate the available min-heap (c) quickly locate the available min-heap).
[0046] a) Block node insertion
[0047] The process of inserting a free block into a min-heap and updating the multi-level bitmap includes the following steps: When inserting a free block into the i-th min-heap, if the min-heap was empty before the insertion, the integer array bmp needs to be updated after the insertion. First, the corresponding bit position of the i-th min-heap in the bottom-level bitmap of the integer array bmp is set to 1, that is, the i%m position of the blb=i / m integer in bmp is set to 1, indicating that the i-th min-heap is now non-empty. If the value of bmp[blb] was 0 before the insertion, the corresponding bit position of the i-th min-heap in the second-level bitmap of bmp is set to 1, that is, the blb%m position of the slb=nb+1+blb / m element in bmp is set to 1. If bmp[slb] was 0 before the insertion, the third-level bitmap also needs to be modified, and so on, until the top-level bitmap is updated. At this time, the corresponding bit position of the last integer tb in bmp is set to 1.
[0048] Taking a three-level bitmap as an example, when inserting a free block into the i-th min-heap, if the heap was empty before insertion, then bmp needs to be updated after insertion. First, set the corresponding bit position of the i-th heap in the bottom-level bitmap of bmp to 1, that is, set the i%8 bit of the i / 8-th element of bmp to 1, indicating that the i-th min-heap is now non-empty. If the value of bmp[i / 8] was 0 before insertion, then the corresponding bit position of the i-th heap in the second-level bitmap of bmp also needs to be set to 1. Because the element position of the i-th heap in the bottom-level bitmap of bmp is blb = i / 8, then the element position of the heap in the second-level bitmap of bmp is slb = 64 + blb / 8. Therefore, it is only necessary to set the blb%8 bit of the slb-th element in bmp to 1. Similarly, if bmp[slb] was 0 before insertion, then the top-level bitmap also needs to be modified, that is, the slb%8 bit of the 72nd element of bmp needs to be updated to 1.
[0049] b) Block node deletion
[0050] The process of removing free blocks from the min-heap and updating the multi-level bitmap includes: when the last free block in the i-th min-heap is allocated, setting the i%m bit of the i / m-th element in bmp to 0; checking if the value of bmp[i / m] is 0; if so, also modifying the corresponding bit in the second-level bitmap of bmp for the i-th min-heap to 0; checking bmp[i / m]... 2 Whether it is 0 determines whether further modifications to the parent bitmap are needed, up to the top-level bitmap.
[0051] Taking a three-level bitmap as an example, the block node deletion process is basically similar to the block node insertion process. The difference is that block node deletion sets a bit in the bitmap from 1 to 0, while block node insertion sets it from 0 to 1. When the last free block in the i-th min-heap is allocated, the i%8 bit of the i / 8-th element in bmp needs to be set to 0. Then check if the value of bmp[i / 8] is 0. If it is, the corresponding bit in the second-level bitmap of the i-th min-heap needs to be modified to 0, similar to the insertion operation. Finally, check if bmp[i / 64] is 0 to determine if further modification of the top-level bitmap is needed. Note that if the modified element was already greater than 0 before block insertion, or is still greater than 0 after deletion, no operation on the upper-level bitmap is required; furthermore, since the height of BMT is only 3, bit-by-bit modification is limited to a maximum of 3 times. Therefore, the maintenance overhead of BMT is controllable and acceptable.
[0052] c) Quickly locate the available min-heap
[0053] In this invention, when the allocation request contains a free block of P consecutive pages, a multi-level bitmap-based method is used to quickly locate the available min-heap; the BMT first checks whether the corresponding min-heap N = P - 1 is empty. If it is not empty, it directly returns heap N as the target heap. If not empty, the min-heap with granularity N is returned directly as the target heap; otherwise, the m nearest min-heaps are searched through the bottom-level bitmap. By calculating B = bmp[N / m] >> (N % m), min-heaps with granularity less than P are excluded. If B is not 0, the min-heap with number N+m[B&(-B)] is returned directly as the target heap; otherwise, the bit corresponding to the available heap is determined by searching the second-level bitmap, and then the bottom-level bitmap corresponding to that bit is searched to finally determine the target heap; if the target heap is not found in the second level, the upper-level bitmap is searched recursively until the top-level bitmap representing the entire free memory space is searched, and the target heap is returned; if the target heap is not found after the recursive search, it means that there is no allocatable heap, and the allocation request cannot be completed in one allocation; where / means rounding, % means modulo, and >> means right shift operator.
[0054] Taking a three-layer bitmap and m=8 as an example, BMT will check if the target heap exists among the 8 nearby min-heaps using the bottom-layer bitmap bmp[N / 8]. Specifically, BMT first executes B=bmp[N / 8]>>(N%8) to exclude min-heaps with a granularity smaller than N. Then, it obtains the value corresponding to the least significant bit 1 in the binary representation of B by calculating B&(-B), where the least significant bit 1 in the binary representation of B indicates the distance from the target heap to heap N. To map the relationship between the value of the least significant bit 1 and its position, BMT preconstructs a mapping table m. For i∈[0,7], m[2 i The value of ] is set to i. In this way, when B is not equal to 0, BMT directly returns the min-heap with index N+m[B&(-B)] as the target heap.
[0055] When B is 0 but not the last bottom-level bitmap, BMT needs to check for a distributable heap among the 64 nearby min-heaps using the second-level bitmap. Since there is no distributable heap among the 8 min-heaps near heap N, BMT sets p = N / 8 + 1, so the second-level bitmap B = bmp[64 + p / 8]. Similar to the bottom-level bitmap search, BMT shifts B right by p%8 and calculates B & (-B) to determine if there is a distributable heap under the second-level bitmap. If so, BMT will perform a search on the bottom-level bitmap represented by p + m[B & (-B)] to finally determine the location of the distributable heap. Otherwise, it means there is no distributable heap among the 64 nearby min-heaps. In this case, if N / 64 is not equal to 7 (meaning there is still an unsearched second-level bitmap), BMT also needs to search from the 512 heaps using the top-level bitmap B = bmp
[72] . BMT sets q = p / 8 + 1 and shifts B right by q%8. If B is not equal to 0, a second-level bitmap search will be performed on q+m[B&(-B)]. Otherwise, it means that there is no allocatable heap and the request cannot be completed in one allocation.
[0056] Figure 4 Three examples illustrate BMT's fast location of allocatable heaps. This is illustrated when allocating a block containing two contiguous pages, such as... Figure 4 As shown in (b), BMT first accesses min-heap 1 to look for a free block. Unfortunately, this min-heap is empty (because its corresponding bit is 0), so BMT needs to search for an allocatable heap in its 8 neighboring min-heaps (from bit 0 to bit 7). First, the first byte B of the underlying bitmap is right-shifted by (2-1)%8=1 and B&(-B) is calculated to get 0x0001000. Then, the sequence number of its lowest bit is found to be 3 from the mapping table. Finally, 1+3=4 is returned, indicating that the target min-heap has been found.
[0057] Figure 4 The example in (c) is more complex. Since the BMT cannot allocate a block with six consecutive pages under the first underlying bitmap, it instead searches the nearest 64 min-heaps through the corresponding second-level bitmap. After similar calculations, it finds an allocatable heap in the 4th bit of the second-level bitmap. Therefore, it further searches using the 4th byte of the underlying bitmap, finally locating an allocatable heap with sequence number 34.
[0058] Figure 4 (d) shows the worst-case scenario for locating the allocatable heap. It cannot find a feasible min-heap in either the bottom or second-level bitmap probing. Therefore, the BMT checks the top-level bitmap and finds the least significant bit 1 in the second bitmap. The BMT then searches down the corresponding second-level bitmap to locate the target bottom-level bitmap. Guided by the third bit in the second second-level bitmap (sequence number 19), the BMT enters the 19th bottom-level bitmap to search for the allocatable heap, finally locating the allocatable heap with sequence number 154.
[0059] Based on the above example, it can be observed that BMT only requires a few bitmap calculations to find a suitable min-heap. Even in the worst case, the maximum number of calculations is only five. Therefore, compared to large-scale traversal, BMT significantly reduces the overhead of locating an allocable min-heap.
[0060] In this embodiment of the invention, when the granularity of the selected min-heap is greater than the requested granularity, the allocated free block will be split into two sub-blocks. One sub-block is used as the requested block for allocation, and the other sub-block is inserted back into the multi-granularity min-heap as the remaining block. To address the significant redundancy overhead caused by recalculating the average wear of the remaining blocks, this invention proposes a conditional wear inheritance mechanism to reduce overhead while ensuring good wear accuracy.
[0061] First, let T denote the size of the original block, P the size of the requested block, and γ the ratio as a threshold. Then, P / T represents the wear fluctuation caused by the allocation request. If P / T ≤ γ, it is assumed that the average wear of the remaining blocks will not fluctuate drastically; therefore, the remaining blocks directly inherit the average wear of the original blocks. Otherwise, it indicates that the remaining blocks only account for a small portion of the original blocks, and therefore, it is necessary to recalculate the average wear of the remaining blocks. Since the remaining blocks are much smaller than the original blocks, the computational overhead is significantly reduced.
[0062] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include ROM, RAM, disk, or optical disk, etc.
[0063] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A wear-aware space allocation method for a multi-level bitmap-based persistent memory file system, the method comprising: The method includes: Based on the number of consecutive pages contained in the free block, a fine-grained multi-granularity allocation heap is constructed. The construction of the fine-grained multi-granularity allocation heap includes a fixed number of consecutive pages in the block nodes of the min-heap, and the number of consecutive pages is defined as the granularity of the min-heap. M min-heaps with different granularities are used to organize the free block, and the granularity of the i-th min-heap is i+1; i≤M, M≥64. Based on the availability of min-heaps, a multi-level bitmap-based index structure is constructed. This construction involves using a multi-granularity heap tree based on bitmaps to build a multi-level bitmap for the min-heap. Each bit in the bottom-level bitmap directly indicates the availability of a min-heap. If the i-th min-heap is available, the i-th bit in the bottom-level bitmap is set to 1; otherwise, it is set to 0. Each bit in other levels indicates the availability of the min-heap represented by the m bits in the next level bitmap. If an available min-heap exists, the bit is set to 1; otherwise, it is set to 0. Each m bit in the multi-level bitmap is grouped and recorded in an integer array `bmp` to indicate the availability of each min-heap. The information of the bottom-level bitmap is recorded in the 0th to nbth integers of `bmp`, the information of the second-level bitmap is recorded in the nb+1th to nb+1+sbth integers of `bmp`, and the information of the top-level bitmap is recorded in the last integer `tb` of `bmp`. Where m ≤ 64, nb = M / m, and sb = (nb+1) / m. Based on the granularity of the upper-layer application request, the first available min-heap with a granularity greater than or equal to the request granularity is quickly located using the multi-level bitmap-based index structure. The free block with the lowest average wear is then allocated from this min-heap. The process of quickly locating the first available min-heap with a granularity greater than or equal to the request granularity using the multi-level bitmap-based index structure includes, when the allocation request contains free blocks of P consecutive pages, checking if the min-heap numbered N is empty (N = P - 1); if not empty, directly returning the min-heap numbered N as the target heap; otherwise, searching the nearby m min-heaps through the lower-level bitmap, and calculating B = bmp[N / m] >> (N... The algorithm uses %m) to exclude min-heaps with a granularity smaller than P. If B is not 0, the min-heap with the number N+m[B&(-B)] is returned directly as the target heap. Otherwise, the algorithm searches the second-level bitmap to determine the bit corresponding to the available heap, and then searches the lower-level bitmap corresponding to that bit to finally determine the target heap. If the target heap is not found in the second level, the algorithm recursively searches the upper-level bitmap until it searches the top-level bitmap representing the entire free memory space, and then returns the target heap. If the target heap is not found after the recursive search, it means that there is no allocatable heap, and the allocation request cannot be completed in one allocation. Here, / means rounding, % means modulo, and >> means right shift operator.
2. The wear-aware space allocation method for a multi-level bitmap-based persistent memory file system according to claim 1, wherein, The operations on the index structure of the multilevel bitmap include inserting a free block into the min-heap and updating the multilevel bitmap; deleting a free block from the min-heap and updating the multilevel bitmap. A multi-level bitmap is used to quickly locate the available min-heap.
3. The wear-aware space allocation method for a multi-level bitmap-based persistent memory file system according to claim 2, wherein, The process of inserting a free block into a min-heap and updating the multi-level bitmap includes the following steps: When inserting a free block into the i-th min-heap, if the min-heap was empty before the insertion, the integer array bmp needs to be updated after the insertion. First, the corresponding bit position of the i-th min-heap in the bottom-level bitmap of the integer array bmp is set to 1, that is, the i%m position of the blb=i / m integer in bmp is set to 1, indicating that the i-th min-heap is now non-empty. If the value of bmp[blb] was 0 before the insertion, the corresponding bit position of the i-th min-heap in the second-level bitmap of bmp is set to 1, that is, the blb%m position of the slb=nb+1+blb / m element in bmp is set to 1. If bmp[slb] was 0 before the insertion, the third-level bitmap also needs to be modified, until the top-level bitmap is updated at most. At this time, the corresponding bit position of the last integer tb in bmp is set to 1.
4. The wear-aware space allocation method for a multi-level bitmap-based persistent memory file system according to claim 2, wherein, The deleting the free block from the minimum heap and updating the multi-level bitmap includes setting the i%m bit of the i / m element in the bmp to 0 when the last free block in the i-th minimum heap is allocated; checking whether the value of bmp[i / m] is 0; if yes, further modifying the corresponding bit of the i-th minimum heap in the second layer bitmap of the bmp to 0; checking whether bmp[i / m 2 ] is 0 to determine whether further modification of the bitmap of the upper level is needed, until at most the bitmap of the top level is modified.
5. The wear-aware space allocation method for a multi-level bitmap-based persistent memory file system according to any one of claims 1-4, characterized in that, The method further includes denoting the size of the original block corresponding to the allocation request as T, the size of the requested block as Q, and the ratio γ as the inheritance threshold; using Q / T to represent the wear fluctuation caused by the allocation request; if Q / T≤γ, it is considered that the average wear of the remaining blocks will not fluctuate drastically, and the remaining blocks directly inherit the average wear of the original blocks; otherwise, the average wear of the remaining blocks is recalculated.