Memory allocation mechanism for reducing page migration of delay-sensitive application

By designing application type classifiers and memory compression mechanisms in the operating system, distinguishing delay-sensitive applications from other applications and avoiding their page migration, the problem of frequent page migration of delay-sensitive applications in the existing technology is solved, and the service quality and system performance are improved.

CN119576551AActive Publication Date: 2025-03-07BEIHANG UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411638004.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-03-07
Estimated Expiration
2044-11-15

AI Technical Summary

Technical Problem

The existing operating system memory page allocation mechanism cannot distinguish between delay-sensitive applications and other applications, resulting in frequent migration of pages of delay-sensitive applications by memory compression operations, and degradation of service quality.

Method used

A memory allocation mechanism is designed to distinguish delay-sensitive applications from other applications through application type classifiers, and to skip pages of delay-sensitive applications when memory compression is performed to avoid page migration.

Benefits of technology

Significantly reduces the frequency of page migration for latency-sensitive applications, improves their service quality, and thus improves overall system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576551A_ABST
    Figure CN119576551A_ABST
Patent Text Reader

Abstract

The invention provides a memory allocation mechanism for reducing page migration of a delay-sensitive application, which comprises (1) an application type classifier for distinguishing the delay-sensitive application (high priority) from other applications (low priority); and (2) a memory allocation mechanism, which mainly comprises a delay sensitive application page allocation mechanism and an other application page allocation mechanism. And (3) a memory compression mechanism, which can cooperate with the memory allocation mechanism of the method, so that the page of the delay-sensitive application is prevented from being migrated when the memory pressure of the system is high, and the page of the delay-sensitive application is prevented from being migrated when the memory pressure of the system is high. And the service quality is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an operating system memory (OS) memory page allocation mechanism, and in particular to an operating system memory page allocation mechanism that reduces memory allocation operations for delay-sensitive application page migration and significantly improves its quality of service (Quality of Service, QoS for short). Background Art

[0002] The memory system plays an important role in the cloud environment and is the key to improving the quality of cloud application services and the overall performance of the system. The current memory management mechanism usually relies on various memory granularities for memory management, such as 4KB small pages and 2MB / 1GB large pages. Using various memory granularities can improve system performance, specifically: (1) TLB (Translation Lookaside Buffer) misses have a great impact on system performance. For example, Google's internal tests show that about 20% of CPU cycles are blocked by TLB misses. Using 2MB or 1GB large pages can significantly reduce the number of TLB misses, thereby improving the overall performance of the system. (2) Using memory pages with smaller granularity can reduce the load of allocating pages. For example, when allocating 4KB small pages, the operating system usually randomly selects pages from the physical memory pool for allocation. Therefore, this allocation method has a low performance overhead. The allocation of 2MB or 1GB large pages depends on operations such as memory compression, which has a large system overhead. Memory compression is used to merge scattered large pages in the system when the system memory is fragmented and maintain continuous physical memory for allocating large pages.

[0003] It can be seen that allocating memory pages of various granularities has many benefits for system performance. The following first introduces the existing operating system page allocation mechanism, and then analyzes the problems existing in the existing page allocation through experimental observation.

[0004] In a typical cloud server, the system will have both delay-sensitive applications and other applications. However, we have observed that the existing memory allocation mechanism in modern operating systems (such as Linux, FreeBSD) cannot utilize the application characteristics of the process to which the page belongs (delay-sensitive applications or other applications). The existing system indiscriminately allocates memory to applications with different characteristics and treats page allocation requests from delay-sensitive applications and other applications equally.

[0005] Usually, when the operating system has low memory pressure, it allocates large pages to applications, making full use of the characteristics of large pages to reduce the number of system TLB misses and improve system performance. However, large pages will cause memory expansion problems to the system. When the system memory pressure is high and it is difficult to allocate large pages, the operating system will block the operation of allocating memory to applications due to the high overhead of operations such as memory compression. Therefore, when the operating system memory pressure is high, the operating system allocates small pages to applications and triggers memory compression operations at the same time to reserve continuous physical memory for future large page allocations. It is necessary for the system to allocate small pages to applications, but the small pages allocated by the system to applications usually involve memory compression and migration operations with high overhead. For Linux, memory compression usually requires the use of two pointers to scan the physical memory area, one of which scans the memory from front to back and collects the allocated movable pages; the other pointer scans the memory from back to front and collects the unallocated pages. When the two scan pointers meet, all movable pages will be copied and migrated to unallocated pages. This can reserve continuous memory space for physical memory for future large page allocation. However, this memory compression method cannot determine whether the migrated pages belong to latency-sensitive applications or other applications. Therefore, pages of latency-sensitive applications are often migrated by the memory compression operation of the operating system kernel, resulting in a decrease in the service quality of latency-sensitive applications.

[0006] To further study this phenomenon, we run a mixed load of latency-sensitive applications and other applications on a typical cloud server with 128GB DDR4 memory. The latency-sensitive application is Redis (90GB) and the other application is Fluidanimate (20GB). During the 1400 seconds of the test, about 896,000 4KB small pages belonging to latency-sensitive applications were migrated by memory compression. Therefore, page migration occurs frequently in the address space of latency-sensitive applications, and more than 3.4GB of small pages belonging to latency-sensitive applications are migrated, accounting for 10.4% of all small pages of latency-sensitive applications. We further show the fluctuation of the service quality of latency-sensitive applications due to small page migration. Figure 2The page migration and service quality changes of the latency-sensitive application Redis during runtime are shown. We use the 99th percentile latency of Redis as an indicator of service quality. It can be seen that during the period of 0-400 seconds, since the system has sufficient continuous memory space for large page allocation, memory compression does not occur, no Redis page is migrated, and the service quality of Redis remains stable. After 400 seconds, when the operating system cannot allocate large page memory, the operating system triggers the memory compression operation. Since memory compression involves complex memory page migration, when memory migration occurs, we can clearly see that the 99th percentile latency of Redis has increased significantly. When a larger memory system is used in a cloud environment, more page migration operations may be involved, and the service quality of latency-sensitive applications may fluctuate and decline more.

[0007] Through the above description, we found that the existing operating system memory page allocation operation cannot distinguish whether the allocated page belongs to a delay-sensitive application (high priority) or other applications (low priority), resulting in many pages belonging to delay-sensitive applications being frequently migrated by memory compression operations. This migration operation will cause a sharp decline in the service quality of delay-sensitive applications, thereby affecting the overall performance of the system. Summary of the invention

[0008] In view of the problems existing in the above methods, the present invention provides a memory allocation mechanism for reducing the page migration of delay-sensitive applications, which is used to reduce the migration of pages of delay-sensitive applications by memory compression operations as much as possible, reduce the frequent page migration of pages of delay-sensitive applications, and significantly improve their service quality, thereby further improving the overall performance of the system. During operation, the present invention first distinguishes between different types of applications, namely the delay-sensitive applications and other applications mentioned above. Then, we found that the small pages allocated by the operating system have different properties, and the small pages around the immovable pages (for example, operating system kernel pages, GPU and other acceleration device pages) should be allocated to delay-sensitive applications; and the small pages in other locations are allocated to other applications. Finally, when the operating system triggers memory migration, the present invention avoids the migration of pages of delay-sensitive applications by memory compression operations by marking the 2MB area around the immovable pages and making the memory compression skip these areas. Compared with the methods in existing operating systems (such as Linux), the present invention takes into account the specific characteristics of the application to which the page belongs when allocating pages, can distinguish pages more carefully, and allocate pages that will not be migrated in the future to delay-sensitive applications, avoiding frequent blocking of delay-sensitive applications due to page migration operations, and improving their service quality. Meanwhile, other applications are relatively insensitive to page migration operations, so the present invention has limited impact on the performance of such applications. In general, the present invention can effectively improve system performance.

[0009] Specifically, the present invention consists of three parts and works in a pipeline manner. (1) The present invention designs a classifier that distinguishes application types, which is used to distinguish delay-sensitive applications (high priority) from other applications (low priority). (2) The present invention designs a memory pool dedicated to delay-sensitive applications, which is used to allocate small pages that will not be migrated in the future to delay-sensitive applications. For delay-sensitive applications, the operating system allocates memory from the memory pool, while for other applications, the allocation logic of the existing operating system is used. (3) The present invention redesigns the memory compression mechanism of the operating system. During memory compression, the present invention marks the small pages of delay-sensitive applications, so that memory compression skips the pages of delay-sensitive applications, thereby avoiding the migration of delay-sensitive application pages.

[0010] The working process of each component is as follows:

[0011] (I) Application Type Classifier

[0012] 1. The application type classifier distinguishes a large number of applications running in the operating system and runs in the operating system kernel;

[0013] 2. There are mainly two types of applications in the system, namely delay-sensitive applications and other applications. The application classifier designed by the present invention is mainly classified based on the static priority defined by the user, where delay-sensitive applications are high-priority applications, and other applications running in the system are low-priority applications. The user specifies the priority of each application in advance through the Linux built-in command nice / renice, and the value range is from -20 (highest priority) to 19 (lowest priority). In the application classifier, the priority value specified by the user is read, and the threshold of the high-priority application can be specified by the user in the application classifier, providing sufficient flexibility.

[0014] 3. Using the application type classifier, the operating system can more accurately classify the numerous applications running in the system and distinguish the pages of latency-sensitive applications from those of other applications, so that pages that will not be migrated in the future can be allocated to latency-sensitive applications during the subsequent page allocation process, and pages of latency-sensitive applications can be skipped during memory compression.

[0015] (II) Page Allocation Mechanism

[0016] 1. The memory allocation mechanism of the present invention is mainly divided into a delay-sensitive application page allocation mechanism and other application page allocation mechanism.

[0017] 2. For page allocation requests from high-priority delay-sensitive applications, the present invention does not randomly select small pages in the physical memory pool (such as the partner system in Linux) for allocation. The present invention first allocates small pages located around the immovable pages for allocation. Since the immovable pages cannot be migrated, the memory blocks containing the immovable pages cannot be used for the allocation of large pages. The pages of delay-sensitive applications are allocated around the immovable pages, which can avoid complex memory compression and memory migration operations. During memory compression, the memory compression operation of the present invention will skip the movable pages around these immovable pages. However, the memory pool designed by the present invention for delay-sensitive applications will not hinder the operation of the operating system to promote the small pages of delay-sensitive applications to large pages, which is conducive to further improving the service quality of delay-sensitive applications. In addition, the present invention also designs an immovable memory pool, which stores other pages that will not be migrated by the page compression operation. When all the movable pages located around the immovable pages are allocated, the present invention will allocate pages for delay-sensitive applications from this immovable pool, thereby further avoiding the migration of pages of delay-sensitive applications by memory compression operations.

[0018] 3. For page allocation requests from other low-priority applications, the present invention uses the page allocation mechanism of the existing operating system. For example, in Linux, suitable small pages are randomly selected on the partner system for allocation. These pages may be migrated by memory compression when the memory pressure of the operating system is high in the future. However, since these applications are not sensitive to page migration operations, the memory allocation mechanism of the present invention can improve system performance as a whole.

[0019] (III) Memory Compression Mechanism

[0020] The present invention redesigns the memory compression mechanism of the existing operating system so that the memory compression mechanism can work in conjunction with the memory allocation mechanism of the present invention. During memory compression, the present invention uses two pointers to scan the specified memory area. During the scanning process, the two pointers designed by the present invention to scan the memory area skip pages from delay-sensitive applications, thereby avoiding the migration of pages of delay-sensitive applications. Therefore, the memory compression mechanism designed by the present invention completely avoids the migration of pages of delay-sensitive applications, thereby improving their service quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 This is a flow chart of a memory allocation mechanism for reducing page migration of delay-sensitive applications proposed by the present invention.

[0022] Figure 2 This is a schematic diagram of the adverse effects of the existing Linux page allocation mechanism on the service quality of delay-sensitive applications detected by the present invention.

[0023] Figure 3 A page allocation strategy for delay-sensitive applications designed for the present invention.

[0024] Figure 4 A memory compression mechanism designed for the present invention. Specific implementation methods

[0026] The present invention will be further described in detail with reference to the accompanying drawings.

[0027] like Figure 1 and Figure 2 The present invention is mainly composed of two mechanisms, namely, a page allocation mechanism for different applications and a page compression mechanism when the system memory pressure is high, and the two work together. The page allocation mechanism includes a page allocation mechanism for delay-sensitive applications and a page allocation mechanism for other applications. The two are respectively for the allocation process of delay-sensitive application pages and other application pages. When an application requests a page from the operating system, the present invention first uses an application type classifier to distinguish between applications, classifying high-priority applications as delay-sensitive applications and low-priority applications as other applications. The present invention originally proposes a page allocation strategy for delay-sensitive applications. Figure 3 As shown, the present invention sets up a delay-sensitive application memory pool for allocating small pages that will not be migrated in the future for delay-sensitive applications when the operating system cannot allocate large pages. The memory pool first uses small pages around the immovable pages for allocation. Figure 3 The 2MB memory block containing non-movable pages cannot be used for large page allocation, so the compression operation of the memory block cannot sort out continuous physical memory. Therefore, the compression of this part of the memory should be avoided. The present invention takes advantage of this feature and allocates small pages of delay-sensitive applications around non-movable pages, thereby avoiding the migration of pages of delay-sensitive applications. The allocatable pages around non-movable pages are limited. When all these pages are allocated, the present invention uses an non-movable memory pool to interact with the operating system memory pool, and further allocates pages for delay-sensitive applications from the non-movable memory pool. This non-movable memory pool can move pages back to the operating system memory pool when there are sufficient pages, and move pages from the operating system memory pool to the non-movable memory pool when there are insufficient pages.

[0028] During page compression, the memory compression mechanism designed by the present invention can skip pages of delay-sensitive applications (pages around the immovable pages and pages allocated from the immovable memory pool), such as Figure 4As shown, the memory compression mechanism of the present invention uses two pointers to scan the specified memory area. During the scanning period, the pointers will skip the 2MB area around the immovable page. When the two pointers meet, the movable page on one side is migrated to the free page on the other side, thereby reserving continuous physical memory for the system to allocate large pages. In this way, the memory compression mechanism designed by the present invention avoids frequent migration of delay-sensitive application pages.

[0029] A memory allocation mechanism for reducing page migration of delay-sensitive applications includes the following steps: Step 1, establishing an application type classifier for distinguishing delay-sensitive applications from other applications, wherein the delay-sensitive applications are of high priority and the other applications are of low priority; Step 2, establishing a memory allocation mechanism, including a page allocation mechanism for delay-sensitive applications and a page allocation mechanism for other applications; Step 3, establishing a memory compression mechanism, so that the memory compression mechanism and the memory allocation mechanism work together to avoid the migration of pages of delay-sensitive applications when the system memory pressure is high, thereby improving the system service quality.

[0030] Step 1.1, the application type classifier distinguishes a large number of applications running in the operating system and runs in the operating system kernel; Step 1.2, the application type classifier classifies based on user-defined static priorities. The user pre-specifies the priority of each application through the Linux built-in command nice / renice. The value ranges from -20 for the highest priority to 19 for the lowest priority. In the application type classifier, the user-specified priority value is read, and the threshold of the high-priority application can be specified by the user in the application type classifier, providing sufficient flexibility; Step 1.3, using the application type classifier, the operating system can more accurately divide the many applications running in the system and distinguish the pages of delay-sensitive applications from other applications, so that in the subsequent page allocation process, the pages that will not be migrated in the future can be allocated to delay-sensitive applications, avoiding the impact of frequent page migration operations on their service quality.

[0031] Step 2 includes the following steps: Step 2.1, the memory allocation mechanism is located in the operating system kernel and is triggered when a page fault occurs in the operating system. When the operating system has high memory pressure and cannot allocate large pages, small pages are allocated to the application; Step 2.2, according to the result of the application type classifier, the pages in the system can also be classified into two types, namely: pages of delay-sensitive applications and pages of other applications. Both types of applications will request memory from the operating system. Before the operating system allocates pages, it will obtain the result of the application type allocator; Step 2.3, for page allocation requests from high-priority delay-sensitive applications, small pages located around immovable pages are first allocated for allocation. Since immovable pages cannot be migrated, memory blocks containing immovable pages cannot be used for large page allocation. Allocating pages of delay-sensitive applications around immovable pages can avoid complex memory compression and memory migration operations. Allocatable pages are limited. When all pages are allocated, an immovable memory pool is used to interact with the operating system memory pool to further allocate pages from the immovable memory pool for delay-sensitive applications. When pages are sufficient, the immovable memory pool can move pages back to the operating system memory pool. When pages are insufficient, pages are moved from the operating system memory pool to the immovable memory pool, and small pages allocated from the periphery of the immovable pages and small pages allocated from the immovable memory pool are recorded so that these areas can be skipped during subsequent memory compression. Step 2.4: For page allocation requests from other low-priority applications, the page allocation mechanism of the existing operating system is used, including in Linux, where appropriate small pages are randomly selected on the partner system for allocation. These pages may be migrated by memory compression when the operating system memory pressure is high in the future. However, since these applications are not sensitive to page migration operations, the memory allocation mechanism can generally improve system performance.

[0032] Step 3 includes the following steps: Step 3.1, the memory compression mechanism is also located in the operating system kernel. When the system memory pressure is high and large pages cannot be allocated, the operating system allocates small pages to the application and triggers the memory compression mechanism at the same time. The memory compression mechanism works together with the memory allocation mechanism to prevent pages belonging to delay-sensitive applications from being migrated; Step 3.2, during memory compression, two pointers are used to scan the specified memory area, one of which scans the memory from front to back and collects the allocated movable pages therein; the other pointer scans the memory from back to front and collects the unallocated pages therein; during the scanning process, the two scanning pointers skip pages from delay-sensitive applications. When the two scanning pointers meet, all movable pages will be copied and migrated to unallocated pages. This can reserve continuous memory space for physical memory for use in future large page allocation. When memory compression is performed, pages of delay-sensitive applications are skipped to avoid migration of pages of delay-sensitive applications.

[0033] The present invention provides a memory allocation mechanism for reducing the page migration of delay-sensitive applications, including: (1) an application type classifier for distinguishing delay-sensitive applications (high priority) from other applications (low priority). (2) a memory allocation mechanism, mainly including a delay-sensitive application page allocation mechanism and other application page allocation mechanisms. The pages of delay-sensitive applications are allocated around immovable pages, thereby avoiding frequent migration operations of the pages of delay-sensitive applications in the future. (3) a memory compression mechanism, which can work in conjunction with the memory allocation mechanism of the present method to avoid the migration of pages of delay-sensitive applications when the system memory pressure is high, thereby improving its service quality.

Claims

1. A memory allocation mechanism for reducing page migration of delay-sensitive applications, characterized in that: The following steps are involved: Step 1, establishing an application type classifier for distinguishing delay-sensitive applications from other applications, wherein the delay-sensitive applications are high priority and the other applications are low priority; Step 2: Establish a memory allocation mechanism, including a page allocation mechanism for delay-sensitive applications and other application page allocation mechanisms; Step 3, establish a memory compression mechanism, so that the memory compression mechanism and the memory allocation mechanism work together to avoid the migration of pages of delay-sensitive applications when the system memory pressure is high, thereby improving the system service quality.

2. A memory allocation mechanism for reducing delay-sensitive application page migration according to claim 1, characterized in that: Step 1 includes the following steps: Step 1.1, the application type classifier distinguishes a large number of applications running in the operating system and runs in the operating system kernel; Step 1.2, the application type classifier performs classification based on the static priority defined by the user. The user pre-specifies the priority of each application through the Linux built-in command nice / renice. The value ranges from -20 (highest priority) to 19 (lowest priority). In the application type classifier, the priority value specified by the user is read, and the threshold of the high priority application can be specified by the user in the application type classifier, which provides sufficient flexibility. Step 1.3, using the application type classifier, the operating system can more accurately divide the numerous applications running in the system and distinguish the pages of delay-sensitive applications from those of other applications, so that in the subsequent page allocation process, pages that will not be migrated in the future can be allocated to delay-sensitive applications, avoiding the impact of frequent page migration operations on their service quality.

3. A memory allocation mechanism for reducing delay-sensitive application page migration according to claim 1, characterized in that: Step 2 includes the following steps: Step 2.1: The memory allocation mechanism is located in the operating system kernel and is triggered when a page fault occurs in the operating system. When the operating system has high memory pressure and cannot allocate large pages, small pages are allocated to the application. Step 2.2: Based on the result of the application type classifier, the pages in the system can also be classified into two types: pages of delay-sensitive applications and pages of other applications. Both types of applications will request memory from the operating system. Before the operating system allocates pages, it will obtain the result of the application type allocator. Step 2.3, for page allocation requests from high-priority delay-sensitive applications, first allocate small pages located around the immovable pages for allocation. Since the immovable pages cannot be migrated, the memory blocks containing the immovable pages cannot be used for large page allocation. Allocating pages of delay-sensitive applications around the immovable pages can avoid complex memory compression and memory migration operations. The allocatable pages around the immovable pages are limited. When all these pages are allocated, an immovable memory pool is used to interact with the operating system memory pool to further allocate pages for delay-sensitive applications from the immovable memory pool. This immovable memory pool can move pages back to the operating system memory pool when there are enough pages; and when there are not enough pages, move pages from the operating system memory pool to the immovable memory pool, and record the small pages allocated from the immovable pages and the small pages allocated from the immovable memory pool so that these areas can be skipped during subsequent memory compression. Step 2.4, for page allocation requests from other low-priority applications, use the page allocation mechanism of the existing operating system, including in Linux, directly randomly selecting appropriate small pages on the partner system for allocation. These pages may be migrated by memory compression when the operating system memory pressure is high in the future, but because these applications are not sensitive to page migration operations, the memory allocation mechanism can improve system performance overall.

4. A memory allocation mechanism for reducing delay-sensitive application page migration according to claim 1, characterized in that: Step 3 includes the following steps: Step 3.1: The memory compression mechanism is also located in the operating system kernel. When the system memory pressure is high and large pages cannot be allocated, the operating system allocates small pages to the application and triggers the memory compression mechanism. The memory compression mechanism works together with the memory allocation mechanism to prevent the pages of delay-sensitive applications from being migrated. Step 3.2, during memory compression, two pointers are used to scan the specified memory area, one of which scans the memory from front to back and collects the allocated movable pages therein; the other pointer scans the memory from back to front and collects the unallocated pages therein; during the scanning process, the two scanning pointers skip pages from delay-sensitive applications. When the two scanning pointers meet, all movable pages will be copied and migrated to unallocated pages. This can reserve continuous memory space for physical memory for future large page allocation, and skip pages of delay-sensitive applications during memory compression, thereby avoiding the migration of pages of delay-sensitive applications.

Citation Information

Patent Citations

  • Memory management method and related equipment

    CN110377527A

  • Memory allocation method, electronic equipment and storage medium

    CN116719752A

  • Operating system memory page changing mechanism for reducing memory page IO operation of delay sensitive application program

    CN117492847A

  • Memory management method, host machine, electronic equipment, storage medium and program product

    CN118819871A

  • Method, system and computer program product for dynamically allocating large memory pages of different sizes

    US6182089B1