Memory allocator metadata alternating mapping method and system based on persistent memory

By using metadata alternating mapping method in the memory allocator, continuous memory block bits are mapped to different cache lines, which solves the problem of repeated cache refresh and significantly improves the performance of persistent memory allocation.

CN114510439BActive Publication Date: 2024-11-08ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210101732.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-27
Publication Date
2024-11-08
Estimated Expiration
2042-01-27

AI Technical Summary

Technical Problem

The existing memory allocator has a performance bottleneck due to repeated refresh of caches in persistent memory scenarios. This is mainly because the memory block allocation state is recorded in the form of a bitmap, resulting in continuous memory block bits being mapped to the same cache line, causing repeated refresh of cache lines.

Method used

Using the memory allocator metadata alternating mapping method based on persistent memory, the allocable memory area metadata is divided into multiple sub-bitmaps. Each sub-bitmap size is greater than or equal to the cache line size, and the continuous memory block bits are stored alternately to make them Map to different cache lines; thread private cache metadata uses multiple sub-cache storage, accessing different sub-caches in order to avoid repeated refresh of cache lines.

Benefits of technology

By modifying the metadata layout mode, repeated refresh of cache lines is avoided, and the performance of persistent memory allocation is significantly improved. The experimental results show that the performance is 2.6 times higher than that of existing memory allocators.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114510439B_ABST
    Figure CN114510439B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for alternating mapping metadata of a memory allocator based on persistent memory. The present invention uses multiple sub-bitmaps to store metadata of an allocable memory area, and the size of each sub-bitmap is greater than or equal to the size of a cache line. The bits of continuous memory blocks are stored in different sub-bitmaps in an alternating manner, so that when the memory allocator allocates continuous memory blocks, the bits of continuous memory blocks will be mapped to different cache lines. Multiple sub-caches are used to store thread-private cache metadata, and the number of sub-caches is equal to the number of sub-bitmaps. Each sub-cache only stores the bits of memory blocks located in the same sub-bitmap, and all sub-caches have an access order. By modifying the layout mode of the metadata, the modification of the bitmap by continuous memory allocation is made to fall into different cache lines as much as possible, thereby avoiding the problem of repeated refresh of cache lines and improving the performance of persistent memory allocation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer science memory management, and in particular to a method and system for memory metadata layout based on persistent memory. Background Art

[0002] The emerging persistent memory (PM) has the characteristics of low latency, high capacity, and 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. In the persistent memory scenario, in order to ensure that data is not lost during power failure, it is necessary to explicitly execute the CPU cache line refresh instruction. However, due to the hardware design of the CPU cache line, the cost of repeated refresh is very high, which can easily become a performance bottleneck for persistent memory programs.

[0003] Existing memory allocators often cause cache to be repeatedly refreshed when performing small memory allocations. There are two main reasons for this.

[0004] First, the allocation status of memory block allocation is recorded in the form of a bitmap, and the allocator stores it continuously at the head of the allocatable memory area (slab). Therefore, the bits corresponding to consecutive memory blocks in the bitmap will be mapped to the same cache line. When allocating consecutive memory blocks to users, modifications to the bitmap will cause repeated refreshes of the cache line.

[0005] Second, the memory allocator maintains a thread local cache (tcache) for each thread, which records the addresses of free memory blocks. Each time memory is allocated, the allocator will first search for a suitable memory block from the tcache to allocate to the user to reduce the contention overhead between multiple threads. Since the tcache manages the memory block addresses in the last-in-first-out order, the continuous allocation and release of memory blocks from the tcache may also modify the continuous bits in the bitmap, causing repeated refreshes of cache lines.

[0006] Based on the above reasons, the metadata layout of the existing memory allocator is prone to cause repeated cache refreshes, which in turn leads to a decrease in the access performance to the persistent memory. Summary of the invention

[0007] In order to solve the problem of repeated cache refresh caused by traditional metadata layout, the present invention proposes a method and system for alternating mapping of memory allocator metadata based on persistent memory.

[0008] The technical solution adopted by the present invention is:

[0009] A method for alternating mapping of memory allocator metadata based on persistent memory, wherein the memory allocator metadata includes allocatable memory area metadata and thread-private cache metadata; the allocatable memory area metadata is stored in a plurality of sub-bitmaps, the size of each sub-bitmap is greater than or equal to the size of a cache line, and the bits of continuous memory blocks (i.e., metadata of continuous memory blocks in the allocatable memory area) are sequentially stored in different sub-bitmaps in an alternating manner, so that when the memory allocator allocates continuous memory blocks, the bits of the continuous memory blocks are mapped to different cache lines.

[0010] Furthermore, the thread-private cache metadata is stored in multiple sub-caches, the number of sub-caches is equal to the number of sub-bitmaps, each sub-cache only stores the bits of the memory blocks located in the same sub-bitmap, and all sub-caches have an access order, so that the memory allocator accesses different sub-caches in sequence when searching for multiple suitable memory blocks for allocation, and the bits of the memory blocks located in the same sub-bitmap are mapped to different cache lines.

[0011] Furthermore, the access order of all sub-caches is: access the sub-caches in order of their numbers, and after the last sub-cache is accessed, the first sub-cache is accessed to perform a loop.

[0012] A persistent memory-based memory allocator metadata alternating mapping system comprises one or more processors for executing any of the persistent memory-based memory allocator metadata alternating mapping methods described above.

[0013] The beneficial effect of the present invention is that by modifying the layout mode of metadata, the modification of the bitmap by continuous memory allocation is made to fall within different cache lines as much as possible, thereby avoiding the problem of repeated refresh of cache lines and improving the performance of persistent memory allocation. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 (a) is a schematic diagram showing a conventional bitmap sequential mapping layout mode;

[0015] Figure 1 (b) is a schematic diagram showing a sub-bitmap alternating mapping mode of the present invention;

[0016] Figure 2 A schematic diagram showing a sub-cache layout mode of the present invention;

[0017] Figure 3 The figure shows the performance comparison between the present invention and other existing memory allocators under four different typical allocator loads. DETAILED DESCRIPTION

[0018] The present invention will be further described below in conjunction with the accompanying drawings and specific examples.

[0019] The present invention provides a method for alternating mapping of memory allocator metadata based on persistent memory, wherein the memory allocator metadata includes allocatable memory area metadata and thread private cache metadata; the allocatable memory area metadata is stored using a plurality of sub-bitmaps (stripes), the size of each sub-bitmap is greater than or equal to the size of a cache line, and the bits of continuous memory blocks are sequentially stored in different sub-bitmaps in an alternating storage manner, so that when the memory allocator allocates continuous memory blocks, the bits of the continuous memory blocks will be mapped to different cache lines.

[0020] Figure 1 (a) represents the traditional bitmap sequential mapping layout mode. As shown in the figure, assuming that the cache line size is 4 bits, it can be seen that the bits in the bitmap are sequentially mapped to the memory blocks, that is, the continuous bits M0, M1, M2, and M3 correspond to the continuous memory blocks B0, B1, B2, and B3 respectively. The allocation status of B0 (allocated or free) is recorded by M0. At this time, M0, M1, M2, and M3 will be mapped to the same cache line cache line#0. If the user requests 4 consecutive memory allocations, the allocator allocates memory blocks B0, B1, B2, and B3 to the user, so it is necessary to modify M0, M1, M2, and M3 in the same cache line, resulting in repeated refreshes of the same cache line, which will cause high overhead for persistent memory allocation.

[0021] The present invention designs a metadata alternating mapping mode, such as Figure 1 As shown in (b), assuming that the cache line size is 4 bits, M0, M1, M2, and M3 are divided into different sub-bitmaps, so that these bits are mapped to 4 different cache lines. Therefore, when the memory blocks B0, B1, B2, and B3 are continuously allocated, the modification of the bits will only cause the regular refresh of 4 different cache lines, avoiding the high overhead of repeated cache line refreshes.

[0022] Furthermore, as a preferred implementation scheme, multiple sub-caches (sub-tcaches) can be used to store the thread-private cache metadata, where the number of sub-caches is equal to the number of sub-bitmaps, and each sub-cache only stores the bits of memory blocks located in the same sub-bitmap, and all sub-caches have an access order, so that the memory allocator accesses different sub-caches in sequence when searching for multiple suitable memory blocks for allocation, and the bits of memory blocks located in the same sub-bitmap are mapped to different cache lines.

[0023] Because when the memory allocator uses the thread private cache for memory allocation, it adopts the last in first out (LIFO) management order, such as Figure 1As shown in (a), if the user first applies for 8 memory blocks B0 to B7 in succession, and then releases them in the order of B0, B4, B1, B5, B2, B6, B3, and B7, when the user applies for 8 memory blocks of the same size again in succession, the corresponding memory blocks will be obtained in the same order as the memory blocks released by the user. It can be found that although the alternating mapping of the metadata of the allocable memory area has been designed at this time, the modification of the bitmap in this case will still cause repeated refresh of the cache lines. In the preferred embodiment of the present invention, since each sub-cache only stores the bits of the memory blocks located in the same sub-bitmap, and all sub-caches have an access order, it can be guaranteed that the bits of the memory blocks located in the same sub-bitmap are mapped to different cache lines. The access order only needs to be different from the sub-cache accessed previously each time. As shown Figure 2 As shown, assuming that tcache is filled with memory block addresses corresponding to M0 to M15, and the size of the cache line is 4 units, in this mode, the memory blocks whose bits are located in the same cache line are mapped to the same sub-cache, and a pointer to the sub-cache currently allocated is maintained, and after each allocation is completed, it points to the next sub-cache, so that when each sub-cache is not empty, continuous memory allocation will not modify the bits mapped to the same cache line, avoiding repeated refresh of the cache line. Preferably, the sub-caches are accessed in sequence according to the numbering order, and the first sub-cache is accessed after the last sub-cache is accessed to loop, such as Figure 2 The order shown by the arrow in the middle can ensure the maximum access time interval of the same sub-cache, which has a better effect.

[0024] In order to verify the performance improvement effect of the present invention on the memory allocator for persistent memory, a test was conducted under 64 threads. The specific experiment is as follows:

[0025] The experimental hardware configuration is two Intel Xeon Gold 5218R CPUs, each CPU is equipped with 64GB DRAM and two Intel Optane DIMM memory sticks, each with a size of 128GB. The pair of DIMMs connected to the CPU is configured in AppDirect mode and mounted with the Ext4-DAX file system. To avoid the impact of NUMA, numactl is used for thread binding.

[0026] In the experiment, the present invention is compared with the existing memory allocator PMDK. The experiment is carried out for one thousand rounds, with one million allocations and releases in each round. The allocation size is 64 bytes. The test results are shown in Figure 3 As shown, it can be seen that the performance of the present invention is improved by 2.6 times compared with PMDK.

[0027] Corresponding to the aforementioned embodiment of the memory allocator metadata alternating mapping method based on persistent memory, the present invention also provides an embodiment of the memory allocator metadata alternating mapping system based on persistent memory.

[0028] A persistent memory-based memory allocator metadata alternating mapping system provided by an embodiment of the present invention includes one or more processors for implementing the persistent memory-based memory allocator metadata alternating mapping method in the above-mentioned embodiment.

[0029] The implementation process of the functions and effects of each unit in the above system is specifically described in the implementation process of the corresponding steps in the above method, which will not be repeated here.

[0030] 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 method for alternating mapping of memory allocator metadata based on persistent memory, wherein the memory allocator metadata includes allocatable memory area metadata and thread private cache metadata; characterized in that: The allocatable memory area metadata is stored in a plurality of sub-bitmaps, the size of each sub-bitmap is greater than or equal to the size of a cache line, and the bits of continuous memory blocks are stored in different sub-bitmaps in sequence in an alternating manner, so that when a memory allocator allocates continuous memory blocks, the bits of continuous memory blocks are mapped to different cache lines; the thread-private cache metadata is stored in a plurality of sub-caches, the number of sub-caches is equal to the number of sub-bitmaps, each sub-cache only stores the bits of memory blocks located in the same sub-bitmap, and all sub-caches have an access order, so that when a memory allocator searches for a plurality of suitable memory blocks for allocation, different sub-caches are accessed in sequence, and the bits of memory blocks located in the same sub-bitmap are mapped to different cache lines; the access order of all sub-caches is: access in sequence in the order of sub-caches numbers, and after the last sub-cache is accessed, the first sub-cache is accessed for a loop.

2. A memory allocator metadata alternating mapping system based on persistent memory, characterized in that: It includes one or more processors for executing any persistent memory-based memory allocator metadata alternating mapping method as described in claim 1.