A memory hotspot elimination method based on memory classification and memory compression
By optimizing memory distribution through memory tiering and compression technology, performance issues caused by memory hotspots in cloud computing servers are resolved, memory hotspots in the host machine are quickly eliminated, and memory utilization efficiency and user service stability are improved.
Patent Information
- Application Number
- CN202311716158.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2043-12-14
AI Technical Summary
Performance issues caused by memory hotspots in cloud computing servers are difficult to solve effectively, and traditional virtual machine migration methods suffer from migration failures and long migration times.
By adopting memory tiering and memory compression technology, it monitors memory usage in real time, compresses inactive memory pages and decompresses them when needed, optimizes memory distribution, avoids virtual machine migration, and achieves closed-loop elimination of host machine memory hotspots.
It achieves the rapid elimination of host machine memory hotspots, avoids virtual machine migration failures and long delays, and improves memory utilization efficiency and the stability and security of user services.
Smart Images

Figure CN117873637B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud computing servers, and in particular to a method for eliminating memory hotspots based on memory grading and memory compression. Background Art
[0002] With the development of the digital age, people generate more and more data in their daily lives, and the data processing volume of current large-scale user businesses is also increasing. This poses a huge challenge to the memory resources of cloud computing servers. In response, cloud computing server operators have introduced the concept of memory overselling, that is, the total amount of memory sold exceeds the actual total amount that can be sold to meet the large-scale memory needs of user businesses.
[0003] Memory hierarchy is divided according to different memory types and uses. The following are common memory hierarchies: Main Memory: This usually refers to a computer's RAM (random access memory), which stores running programs and data and can be quickly read and written. Main memory is generally divided into two types: DRAM (dynamic random access memory) and SRAM (static random access memory). Cache Memory: A cache is a small-capacity memory located between the CPU and main memory, used to temporarily store recently used data and instructions. Cache is divided into multiple levels, including L1, L2, and L3. L1 cache is the fastest and has the smallest capacity, while L3 cache is the slowest and has the largest capacity. Cache can significantly improve computer performance by reducing the delay in reading data from main memory. Auxiliary Storage: Auxiliary storage usually refers to storage devices such as hard drives, solid-state drives (SSDs), optical disks, and floppy disks. They are usually used to store large amounts of data for a long time. Compared to main memory, secondary memory is slower to access but less expensive, making it suitable for storing large amounts of infrequently accessed data. Registers: Registers are small-capacity memories located within the CPU that store data and instructions. Registers can be accessed very quickly and are suitable for temporarily storing frequently used data.
[0004] The host memory usage process in a cloud computing server cluster is usually divided into two processes: memory allocation and memory occupation. Memory allocation occurs in the memory sales stage. After the user virtual machine specifications are determined, the server cluster assigns a specific host machine to allocate its memory to the business virtual machine; memory occupation occurs during the operation of the user business virtual machine. Each user business virtual machine can occupy and release its allocated memory resources at any time. When there is a short-term peak in user business demand or a tidal effect of user business, memory hotspots may appear on some host machines, affecting the performance of user business.
[0005] Virtual machine scheduling is to schedule newly created virtual machines to specific hosts or select specific virtual machines to schedule to specific hosts based on specific scheduling algorithms or policies. Virtual machine scheduling can flexibly allocate limited resources on the host to different virtual machines to ensure the service quality of the business within the virtual machine.
[0006] Memory hotspots occur when a computer program frequently accesses certain memory areas during execution, causing them to become hotspots of high memory usage. These hotspots may be critical data structures, variables, or caches. Frequent access and modification of these hotspots can lead to abnormally high memory usage and potentially cause performance issues.
[0007] Memory hotspots may be caused by poorly designed data structures, inefficient algorithms, or memory management issues within a program. By analyzing and optimizing memory hotspots, you can effectively improve program performance and memory efficiency. To address these issues, you can employ the following methods: Optimize data structures: Redesign program data structures to reduce frequent memory accesses and modifications. For example, you can use more efficient data structures such as hash tables, trees, or graphs instead of traditional data structures like arrays or linked lists. Optimize algorithms: Optimize program algorithms to reduce memory usage and access frequency. For example, you can use more efficient sorting, searching, or computational algorithms to improve program performance. Cache optimization: Use caches within your program to store frequently accessed data, reducing memory access frequency. At the same time, pay attention to the cache size and the rationality of the caching strategy to avoid cache overflows and cache invalidation. Optimize memory management: Allocate and release memory appropriately to avoid memory leaks and memory fragmentation. For example, you can use smart pointers, RAII, and other technologies to automatically manage memory allocation and deallocation. Use memory analysis tools: Use specialized memory analysis tools to detect and analyze memory hotspots in your program, thereby identifying optimization directions and entry points. For example, you can use tools such as Valgrind and Massif to monitor your program's memory usage.
[0008] Eliminating host memory hotspots involves reducing memory usage on hosts experiencing memory hotspots. Generally speaking, when some hosts in a cloud service cluster experience memory hotspots, administrators use virtual machine scheduling to migrate virtual machine workloads from the hotspot hosts to non-hotspot hosts, thereby reducing memory pressure on the hotspot hosts. However, virtual machine migration methods carry risks such as lengthy migration times and migration failures.
[0009] Memory compression is a technology that compresses memory pages to reduce the actual memory usage of page memory. When the compressed page memory in the host machine is accessed, the compressed memory is decompressed and made available to the process on the host machine. Currently, mainstream versions of Windows and Linux systems support memory compression technology. Memory compression is a data compression technology that is mainly used to compress data stored in computer memory. Its principle is to compress data into a smaller volume through a certain algorithm to save memory space and improve data transmission efficiency. Memory compression can be divided into lossless compression and lossy compression. Lossless compression means that no information is lost when compressing data and the original data can be completely restored. Lossless compression loses some data but has a higher compression ratio. It is suitable for some situations where data quality requirements are not particularly high. Memory compression technology has a wide range of applications. For example, it is widely used in database management systems, file compression, network communications and other fields. Memory compression can effectively reduce data storage space, increase data transmission speed, and reduce storage and transmission costs. At the same time, memory compression can also improve system performance, reduce the number of I / O operations, and shorten response time. Summary of the Invention
[0010] Based on the current memory hierarchy of large-scale host clusters, this paper utilizes memory compression technology to design a method for eliminating host memory hotspots without requiring virtual machine scheduling. Through memory allocation and compression algorithms, this method achieves the rational allocation and recycling of host memory, reducing host memory pressure while also avoiding potential migration failures and time-consuming migrations that can occur during virtual machine migration. This method eliminates memory hotspots within a closed loop within a single host machine, ensuring the security and performance of user services.
[0011] In order to achieve the above effects, the present invention provides the following technical solution: a method for eliminating memory hot spots based on memory classification and memory compression, comprising the steps of:
[0012] S1. The memory hotspot elimination scheduling system monitors the host machine memory status in real time.
[0013] S2. When the host machine's memory usage exceeds the host machine's memory hotspot threshold, the memory compression process is triggered to compress the inactive memory pages in the host machine.
[0014] S3. When the compressed memory in the host machine is accessed by a process or there is a compressed page on the host machine and the host machine memory usage is less than the host machine memory hotspot threshold, the memory decompression process is triggered to decompress the compressed memory of the host machine.
[0015] S4. Set a memory swap timing interval to trigger the memory swap process at a fixed time, such as triggering a memory swap every 1 second, to swap different levels of memory on the host machine.
[0016] Furthermore, the following steps are included: according to the operation steps in S1-4, the three parts of the memory compression process, the memory exchange process and the memory decompression process are triggered by a unified memory hotspot elimination scheduling system.
[0017] Further, the following steps are included: According to the operation steps in S2, the memory compression process includes
[0018] S201. Memory compression obtains access status of memory pages through an internal interface of the operating system, sorts the memory pages according to the number of times they have been recently accessed, and sets a fixed threshold.
[0019] S202: Mark a memory page whose recent access count is greater than a fixed threshold as an active memory page, for example, mark a memory page whose recent access count is greater than 3 as an active memory page.
[0020] S203: When the memory of the host machine reaches a certain hotspot threshold, compression is started from the memory page with the lowest number of recent accesses in the host machine memory according to the sorted memory page order.
[0021] S204: When the host machine memory usage is lower than the host machine memory hotspot threshold, the memory marked as active memory page does not perform memory compression operation.
[0022] Furthermore, the following steps are included: according to the operation steps in S3, the memory decompression process is divided into passive decompression and active decompression.
[0023] Furthermore, the following steps are included: according to the operation steps in S3, the passive decompression means that when a process on the host machine accesses a compressed memory page, the accessed memory page is decompressed.
[0024] Furthermore, the following steps are included: according to the operation steps in S3, when the host machine memory usage is greater than the total host machine memory, the memory decompression program triggers the operating system to force memory recovery or memory swap to the SWAP partition to ensure that the host machine memory can support the decompression operation of the accessed memory page.
[0025] Furthermore, the following steps are included: according to the operation steps in S3, the host machine memory usage is less than the total host machine memory and greater than the host machine memory hotspot threshold. At this time, the memory decompression program triggers the memory compression program to eliminate the memory hotspot of the current host machine.
[0026] Further, the following steps are included: according to the operation steps in S3, the host machine memory usage is less than the host machine memory hotspot threshold, and no additional operation is required.
[0027] Furthermore, the following steps are included: according to the operation steps in S3, the active decompression means that when there are compressed memory pages in the host memory, if the host memory occupancy is lower than the host memory hotspot threshold, then while ensuring that the host memory occupancy is less than the host memory hotspot threshold, the compressed memory pages are decompressed in descending order according to the number of recent accesses, until all compressed memories are decompressed or the memory hotspot threshold is reached.
[0028] Further, according to the operation steps in S4, the memory exchange process includes:
[0029] S401. Memory exchange uses the host memory information to classify the host's available memory pool according to access latency. For example, DRAM with the lowest access latency is classified as the first-level memory, PMem with the second-lowest access latency is classified as the second-level memory, and so on.
[0030] S402: Obtain the host machine memory pool classification information, and provide a host machine memory page (including compressed memory) allocation scheme on different levels of memory in a manner that prioritizes loading memory with lower access latency from most recent access times to least recent access times.
[0031] S403: Compare the allocation of the host machine's current memory pages on different levels of memory, and perform memory swapping on memory pages that need to be adjusted, so that memory pages with a higher number of recent accesses are stored on memory with a lower access latency.
[0032] The present invention provides a method for eliminating memory hotspots based on memory grading and memory compression, which has the following beneficial effects:
[0033] (1) The memory hotspot elimination method proposed in the present invention can achieve closed-loop memory hotspot elimination of a single host machine within a certain range, avoiding the virtual machine migration failure that may occur in traditional virtual machine scheduling and ensuring the security of user services.
[0034] (2) The memory hotspot elimination method proposed in the present invention only involves the process call of the host machine, and can achieve a certain degree of host machine memory hotspot elimination within milliseconds. Compared with the traditional virtual machine scheduling method that requires memory hotspot elimination in seconds or minutes, it greatly reduces the delay of memory hotspot elimination and ensures the stability of user services.
[0035] (3) The memory hotspot elimination method proposed in the present invention optimizes the memory page distribution through memory grading, which can better improve the memory utilization efficiency of the host machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1This is a schematic diagram of the architecture of a method for eliminating memory hotspots based on memory grading and memory compression according to the present invention;
[0037] Figure 2 The present invention is a flowchart of a method for eliminating memory hotspots based on memory classification and memory compression. DETAILED DESCRIPTION
[0038] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to specific embodiments.
[0039] Example 1, please refer to Figure 1-2 :A memory hotspot elimination method based on memory classification and memory compression, comprising the following steps:
[0040] Step 1: Memory compression obtains the access status of memory pages through the internal interface of the operating system, sorts the memory pages according to the number of times they have been recently accessed, and sets a fixed threshold. Memory pages with a recent access count greater than the fixed threshold are marked as active memory pages. For example, memory pages with a recent access count greater than 3 are marked as active memory pages. When the host machine's memory reaches a certain hotspot threshold, compression starts from the memory page with the lowest recent access count in the host machine's memory according to the sorted memory page order, until the host machine's memory occupancy is lower than the host machine's memory hotspot threshold. The memory marked as active memory page does not perform memory compression operations.
[0041] Step 2: Memory Swapping: Using host memory information, the host's available memory pool is classified according to access latency. For example, DRAM, with the lowest access latency, is classified as first-level memory, and PMem, with the next lowest access latency, is classified as second-level memory. This hierarchy is then used to determine the host memory pool. A plan is then developed to allocate host memory pages (including compressed memory) across different memory levels, prioritizing the most recently accessed memory. The allocation of the host's current memory pages across different memory levels is compared, and memory pages that require adjustment are swapped. This allows pages with higher recent access counts to be stored in memory with lower access latency. PMem (persistent memory) can be considered second-level memory. It is a non-volatile memory that retains stored data even after the computer is shut down. Compared to traditional RAM (random access memory), PMem has higher storage density and faster access speeds. The emergence of PMem allows computers to access and manipulate large amounts of data more quickly while reducing the risk of data loss. It is widely used in application scenarios that require high performance and persistence, such as high-performance computing, data centers, and databases. Although PMem has many advantages, its manufacturing cost is relatively high and it cannot currently completely replace traditional RAM. Therefore, PMem is often used as a second-level memory, working alongside traditional RAM to provide higher system performance and larger storage capacity.
[0042] Step 3: The memory hotspot elimination scheduling system monitors the host machine's memory status in real time. When the host machine's memory usage is greater than the host machine's memory hotspot threshold, memory compression is triggered to compress the inactive memory pages in the host machine. When the compressed memory in the host machine is accessed by a process or there are compressed pages on the host machine and the host machine's memory usage is less than the host machine's memory hotspot threshold, memory decompression is triggered to decompress the host machine's compressed memory. A memory swap timing interval is set to trigger memory swap at fixed intervals, such as triggering memory swap once every 1 second, to swap different levels of host machine memory.
[0043] Step 4: Memory decompression is divided into passive decompression and active decompression.
[0044] Passive decompression means that when a process on the host machine accesses a compressed memory page, the accessed memory page is decompressed. After the accessed memory page is decompressed, it can be divided into three situations.
[0045] The host machine's memory usage is greater than the total host machine memory. At this time, the memory decompression program triggers the operating system to force memory recovery or memory swap to the SWAP partition to ensure that the host machine's memory can support the decompression operation of the accessed memory page. The SWAP partition is a special hard disk space, also known as virtual memory. When the physical memory is insufficient, it can virtualize a part of the hard disk space into memory, thereby solving the problem of insufficient memory capacity. The size of the SWAP partition is generally set to twice the size of the physical memory, but it can also be adjusted according to actual conditions. In the Linux operating system, the SWAP partition can be used as an extension of the memory. When the physical memory is exhausted, the system will automatically use the SWAP partition to replace the physical memory to maintain the stable operation of the system. The advantages of the SWAP partition mainly include: Expanded memory space: The SWAP partition can be used as an extension of the memory. When the physical memory is insufficient, a part of the hard disk space can be virtualized into memory, thereby solving the problem of insufficient memory capacity and improving system performance: By using the SWAP partition, the problem of system performance degradation caused by insufficient memory can be reduced. When physical memory is exhausted, the system automatically uses the SWAP partition to replace physical memory to maintain stable system operation. It reduces costs: Compared with adding physical memory, creating a SWAP partition is less expensive because the SWAP partition is virtual memory using hard disk space, requiring no additional hardware costs. It also enhances stability: The SWAP partition can help the system be more stable when encountering problems such as memory overflow. When physical memory is insufficient, the system automatically uses the SWAP partition, thus avoiding system crashes or data loss caused by memory problems.
[0046] The host machine's memory usage is less than the host machine's total memory but greater than the host machine's memory hotspot threshold. At this time, the memory decompression program triggers the memory compression program to eliminate the memory hotspot of the current host machine.
[0047] The host memory usage is less than the host memory hotspot threshold, and no additional operation is required.
[0048] Active decompression means that when there are compressed memory pages in the host memory, if the host memory usage is lower than the host memory hotspot threshold, the compressed memory pages are decompressed in descending order according to the number of recent accesses, while ensuring that the host memory usage is lower than the host memory hotspot threshold, until all compressed memory is decompressed or the memory hotspot threshold is reached.
[0049] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A memory hotspot elimination method based on memory classification and memory compression, characterized in that: The following steps are included: S1, the memory hotspot elimination scheduling system monitors the host machine memory status in real time; S2. When the host machine's memory usage exceeds the host machine's memory hotspot threshold, the memory compression process is triggered to compress the host machine's inactive memory pages. According to the operation steps in S2, the memory compression process includes: S201, memory compression obtains access status of memory pages through an internal interface of the operating system, sorts the memory pages according to the number of times they have been recently accessed, and sets a fixed threshold; S202: Mark memory pages whose recent access counts are greater than a fixed threshold as active memory pages; S203: When the host machine's memory reaches a certain hotspot threshold, compression begins with the memory page with the lowest recent access count in the host machine's memory according to the sorted memory page order. S204: When the host machine memory usage is lower than the host machine memory hotspot threshold, the memory marked as active memory page does not perform memory compression operation; S3. When the compressed memory in the host machine is accessed by a process or there is a compressed page on the host machine and the host machine memory occupancy is less than the host machine memory hotspot threshold, the memory decompression process is triggered to decompress the compressed memory of the host machine. The memory decompression process is divided into passive decompression and active decompression. Passive decompression refers to decompressing the accessed memory page when the process on the host machine accesses the compressed memory page. Active decompression refers to decompressing the accessed memory page when there is a compressed memory page in the host machine memory. If the host machine memory occupancy is lower than the host machine memory hotspot threshold at this time, the compressed memory pages are decompressed in descending order according to the number of recent accesses, while ensuring that the host machine memory occupancy is less than the host machine memory hotspot threshold, until all compressed memory is decompressed or the memory hotspot threshold is reached; S4. Set the memory swap timer interval to trigger the memory swap process at a fixed time interval; According to the operation steps in S4, the memory exchange process includes: S401. Memory exchange uses host memory information to classify the host's available memory pool according to access latency. DRAM with the lowest access latency is classified as first-tier memory, PMem with the next highest access latency is classified as second-tier memory, and so on. S402: Obtaining the hierarchical information of the host memory pool, and providing a plan for allocating the host memory pages to different memory levels by prioritizing the memory with the lowest access latency based on the number of recent accesses. S403: Compare the allocation of the host machine's current memory pages on different levels of memory, and perform memory swapping on memory pages that need to be adjusted, so that memory pages with a higher number of recent accesses are stored on memory with a lower access latency.
2. The memory hotspot elimination method based on memory grading and memory compression according to claim 1, characterized in that: The following steps are involved: According to the operation steps in S1-4, the three parts of the memory compression process, the memory swap process and the memory decompression process are triggered by a unified memory hotspot elimination scheduling system.
3. The method for eliminating memory hotspots based on memory grading and memory compression according to claim 1, characterized in that: The following steps are involved: According to the operation steps in S3, when the host machine memory usage is greater than the total host machine memory, the memory decompression program triggers the operating system to force memory recovery or memory swap to the SWAP partition to ensure that the host machine memory can support the decompression operation of the accessed memory page.
4. The method for eliminating memory hotspots based on memory grading and memory compression according to claim 1, characterized in that: The following steps are involved: According to the operation steps in S3, the host machine memory usage is less than the total host machine memory and greater than the host machine memory hotspot threshold. At this time, the memory decompression program triggers the memory compression program to eliminate the memory hotspot of the current host machine.
5. The method for eliminating memory hotspots based on memory grading and memory compression according to claim 1, characterized in that: The following steps are involved: According to the operation steps in S3, the host machine memory usage is less than the host machine memory hotspot threshold, and no additional operation is required.
Citation Information
Patent Citations
Virtual machine memory optimization processing method and related device
CN111651236A
Memory management method and device, equipment and storage medium
CN114253873A