Transparent large page performance monitoring method and electronic device
By acquiring and displaying transparent huge page performance data in kernel mode and user mode, the problem of the inability to effectively monitor transparent huge page performance in existing technologies is solved, and accurate monitoring and real-time optimization of transparent huge page performance are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING LINX SOFTWARE CORP
- Filing Date
- 2026-05-22
- Publication Date
- 2026-06-23
AI Technical Summary
Existing technologies cannot effectively monitor the overall performance of transparent large pages, which may lead to other performance degradation issues while reducing the number of TLB misses.
By acquiring performance data on memory consolidation, direct memory reclamation, transparent big page splitting, page table cache misses, and contiguous free blocks in kernel and user modes respectively, and then performing correlation display and backup storage after the sampling period ends, accurate monitoring of transparent big page performance can be achieved.
It improves the real-time performance and usability of transparent large page performance monitoring, ensures the accuracy and usability of monitoring results, and enables timely adjustment of transparent large page related strategies to optimize performance.
Smart Images

Figure CN122261963A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a transparent large-page performance monitoring method and electronic device. Background Technology
[0002] In modern computer architectures, the operating system provides an abstract address space for applications through virtual memory management technology. The Central Processing Unit (CPU) performs the translation from virtual addresses to physical addresses through the memory management unit. To improve translation efficiency, the CPU integrates a dedicated cache called the Translation Lookaside Buffer (TLB), also known as the page table cache. The Linux operating system uses a 4KB page size by default. As server memory capacity has rapidly expanded from the GB level to the TB level, the traditional 4KB small page mechanism faces significant performance challenges. In memory mapping scenarios involving hundreds of GB, using only 4KB pages requires maintaining a huge number of page table entries. This not only increases page table storage overhead but also, due to the limited TLB capacity, restricts the range of addresses it can simultaneously cover under small page mapping, easily leading to an increase in TLB misses.
[0003] A Transparent Big Page (TLB) is a hardware cache with limited capacity, typically storing only a few hundred to a few thousand address translation entries. When a program performs intermittent random memory accesses, the limited TLB capacity often cannot cover the application's working set, resulting in numerous TLB misses. Each TLB miss may trigger a page table traversal, requiring the CPU to access a multi-level page table structure in memory. This process incurs significantly higher latency than a direct address translation hit, causing brief processor pauses and reducing instruction execution efficiency. Therefore, Transparent Big Page technology was developed to address this issue.
[0004] Transparent Huge Page (THP) technology aims to improve application memory access performance by reducing TLB miss rates through the use of memory pages of 2MB or larger. However, the THP mechanism often introduces significant performance issues in practice.
[0005] When system physical memory is severely fragmented, the kernel often needs to trigger memory consolidation operations to free up contiguous space by migrating pages in order to meet allocation requests for 2MB big pages. If the available free memory in the system falls below a set threshold (i.e., the memory level is low), it may further trigger synchronous direct memory reclamation. These operations may occur on the critical memory allocation paths of application threads, causing business threads to be blocked or experiencing latency jitter. In addition, transparent big pages may be split in certain scenarios, which will consume CPU resources and incur additional synchronization overhead.
[0006] It is evident that while transparent large pages reduce the number of TLB misses, they may also lead to other performance degradations. Therefore, it is necessary to monitor the overall performance of transparent large pages in order to optimize and adjust related strategies. Summary of the Invention
[0007] Based on the above analysis, the embodiments of the present invention aim to provide a transparent large page performance monitoring method and electronic device to solve the problem that the prior art cannot monitor the overall performance of the transparent large page.
[0008] On one hand, embodiments of the present invention provide a transparent huge page performance monitoring method, which includes: in each sampling period, in kernel mode, acquiring and storing memory consolidation performance data in a mapping through memory consolidation start event tracking points and memory consolidation end event tracking points; acquiring and storing direct memory reclamation performance data in the mapping through direct memory reclamation start event tracking points and direct memory reclamation end event tracking points; and acquiring and storing huge page splitting performance data in the mapping through transparent huge page splitting monitoring using probes. In each sampling period, in user mode, a user-mode program collects and records page table cache miss performance data through system calls; the user-mode program reads and records continuous free block performance data from a file; wherein the size of the free block corresponding to the continuous free block performance data is an integer multiple of the transparent huge page size. After the sampling period ends, the user-mode program reads the memory consolidation performance data, the direct memory reclamation performance data, and the huge page splitting performance data from the mapping, and associates and displays them with the page table cache miss performance data and the continuous free block performance data.
[0009] Based on a further improvement to the above method, after reading the memory consolidation performance data, the direct memory reclamation performance data, and the large page splitting performance data from the mapping, the method further includes: the user-space program backing up and storing the memory consolidation performance data, the direct memory reclamation performance data, and the large page splitting performance data locally, and clearing the corresponding data in the mapping; after the sampling period ends, the method further includes: the user-space program backing up and storing the page table cache miss performance data and the continuous free block performance data, and clearing the page table cache miss performance data and the continuous free block performance data originally collected by the user-space program.
[0010] Based on a further improvement of the above method, the memory warping performance data includes the total memory warping time, the cumulative number of memory warping occurrences, and the maximum time for a single memory warping operation. The method for obtaining the memory warping performance data includes: when a memory warping start event occurs, the memory warping start event tracking point is triggered, and the start time of memory warping and the process identifier executing the memory warping are recorded; when a memory warping end event occurs, the memory warping end event tracking point is triggered, the end time of memory warping and the process identifier of memory warping are obtained, the time spent on memory warping is obtained according to the start time and the end time corresponding to the process identifier, the total memory warping time, the cumulative number of memory warping occurrences, and the maximum time spent on a single memory warping operation in the mapping are updated through atomic operations, and the start time and the process identifier recorded in this memory warping operation are deleted.
[0011] Based on a further improvement of the above method, the direct memory reclamation performance data includes the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences; the method for obtaining the direct memory reclamation performance data includes: when a direct memory reclamation start event occurs, the direct memory reclamation start event tracking point is triggered, and the start time of direct memory reclamation and the process identifier executing the direct memory reclamation are recorded; when a direct memory reclamation end event occurs, the direct memory reclamation end event tracking point is triggered, the end time of direct memory reclamation and the process identifier of direct memory reclamation are obtained, the time spent on direct memory reclamation is obtained according to the start time and the end time corresponding to the process identifier, the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences in the mapping are updated through atomic operations, and the start time and the process identifier recorded in this direct memory reclamation are deleted.
[0012] Based on a further improvement of the above method, the large page splitting performance data includes the number of transparent large page splits, which is used to characterize the number of times the underlying large page object corresponding to the transparent large page is split into multiple basic pages; the step of monitoring and obtaining the large page splitting performance data through probes and storing it in the mapping includes: attaching probes to the kernel functions related to the transparent large page splitting as basic pages, obtaining the splitting event of the underlying large page object being split into multiple basic pages, and atomically incrementing the number of transparent large page splits in the mapping.
[0013] Based on a further improvement of the above method, the page table cache miss performance data includes the number of data page table cache misses or the number of page faults; the user-mode program collects and records the page table cache miss performance data through system calls, including: the user-mode program accesses the CPU's performance monitoring unit through the perf_event_open system call to collect the number of data page table cache misses; wherein, if the hardware does not support the collection of the number of data page table cache misses, then the number of page faults is collected.
[0014] Based on a further improvement of the above method, the continuous free block performance data includes the number of 2MB continuous free blocks and the number of 4MB continuous free blocks; the user-space program reads and records the continuous free block performance data through a file, including: reading the / proc / buddyinfo file and reading the number of Order 9 and Order 10 in the Normal memory area in real time; wherein, the number of Order 9 represents the number of 2MB continuous free blocks and the number of Order 10 represents the number of 4MB continuous free blocks.
[0015] Based on a further improvement of the above method, the method further includes: summarizing and analyzing the memory consolidation performance data, direct memory reclamation performance data, large page splitting performance data, page table cache miss performance data, and continuous free block performance data for each sampling period within a preset time period, and obtaining and displaying the summary analysis results.
[0016] Based on further improvements to the above method, the summary analysis results include at least one of the following results: The preset time period includes the cumulative number of memory consolidation events, total memory consolidation time, maximum single memory consolidation time, total direct memory reclamation time, cumulative number of direct memory reclamation events, number of transparent large page splits, average frequency of transparent large page splits, periodic changes in the number of transparent large page splits, average number of data page table cache misses or page faults per sampling period, rate of change of the average number of data page table cache misses or page faults per sampling period relative to the baseline value, periodic changes in the number of data page table cache misses or page faults, average number of consecutive free blocks per sampling period, minimum number of consecutive free blocks per sampling period, and periodic changes in the number of consecutive free blocks.
[0017] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the transparent large page performance monitoring method as described above.
[0018] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the transparent large page performance monitoring method as described above.
[0019] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the transparent large page performance monitoring method as described above.
[0020] The transparent huge page performance monitoring method and electronic device provided by this invention acquire memory consolidation performance data, direct memory reclamation performance data and huge page splitting performance data in kernel mode during the sampling period, acquire page table cache miss performance data and continuous free block performance data in user mode, and display them in association after sampling ends. This achieves accurate acquisition of transparent huge page performance monitoring results and improves the real-time performance and practicality of transparent huge page performance monitoring.
[0021] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0022] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. Figure 1 This is a flowchart illustrating the transparent large-page performance monitoring method provided by the present invention.
[0023] Figure 2 A schematic diagram of the physical structure of an electronic device is provided. Detailed Implementation
[0024] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0025] Figure 1 This is a flowchart illustrating the transparent large-page performance monitoring method provided by the present invention. Figure 1 As shown, the method includes: Step S1: In each sampling period, in kernel mode, memory consolidation performance data is obtained and stored in the mapping through memory consolidation start event tracking point and memory consolidation end event tracking point; direct memory reclamation performance data is obtained and stored in the mapping through direct memory reclamation start event tracking point and direct memory reclamation end event tracking point; and large page splitting performance data is obtained and stored in the mapping through transparent large page splitting monitoring using probes.
[0026] This invention employs eBPF technology to monitor key memory management paths related to transparent huge pages in the Linux kernel through two types of monitoring and attachment methods: for memory consolidation and direct memory reclamation processes, monitoring programs are attached to trace points; for transparent huge page splitting processes, monitoring programs are attached to probes (kprobes).
[0027] In each sampling cycle, in kernel mode, memory compaction performance data is acquired and stored in a map via the memory compaction start event tracepoint (mm_compaction_begin) and memory compaction end event tracepoint (mm_compaction_end). The memory compaction start and end event tracepoints allow monitoring of the start and end of a memory compaction process. The memory compaction performance data reflects the synchronization wait cost incurred to satisfy large page allocations.
[0028] In each sampling period, within kernel mode, direct memory reclamation performance data is acquired and stored in maps via the direct memory reclamation start event tracepoint (mm_vmscan_direct_reclaim_begin) and direct memory reclamation end event tracepoint (mm_vmscan_direct_reclaim_end). These tracepoints allow monitoring of the start and end of a direct memory reclamation process. The performance data reflects the impact of memory pressure on the latency of application threads. Maps are data structures that store data in key-value pair format, accessible from both user and kernel modes.
[0029] During each sampling period, in kernel mode, transparent large page splitting performance data is acquired and stored in a map via a probe for monitoring transparent large page splitting operations. This probe reflects the frequency with which transparent large pages are split under the current workload.
[0030] The performance data for memory consolidation, direct memory reclamation, and large page splitting reflect the "cost" or "price" required to adopt transparent large pages.
[0031] Step S2: In each sampling period, in user mode, the user-mode program collects and records page table cache miss performance data through system calls, and the user-mode program reads and records continuous free block performance data through file reading; wherein, the block size of the free block corresponding to the continuous free block performance data is an integer multiple of the page size of the transparent big page.
[0032] During each sampling period, in user space, the user-space program collects and records page table cache miss performance data via system calls. This performance data reflects the page table cache miss rate. The initial goal of using transparent big pages is to increase the page table cache hit rate, thus aiming to reduce the number of page table cache misses. The page table cache miss performance data reflects the "benefits" obtained after adopting transparent big pages.
[0033] During each sampling period, in user space, the user-space program reads and records contiguous free block performance data from a file. The size of the free blocks corresponding to the contiguous free block performance data satisfies the memory allocation requirements of transparent huge pages, and the block size of the free blocks is an integer multiple of the page size of the transparent huge pages. The contiguous free block performance data reflects the supply of large free memory blocks in the system that meet the memory allocation requirements of transparent huge pages, thus providing context for determining whether memory fragmentation exists.
[0034] Step S3: After the sampling period ends, the user-space program reads the memory consolidation performance data, the direct memory reclamation performance data, and the large page splitting performance data from the mapping, and displays them in association with the page table cache miss performance data and the continuous free block performance data.
[0035] At the end of each sampling period, the user-space program reads memory consolidation performance data, direct memory reclamation performance data, and large page splitting performance data from the mapping, and correlates them with page table cache miss performance data and contiguous free block performance data collected by the user-space program in the same sampling period to form a unified performance monitoring result. The correlated display involves displaying memory consolidation performance data, direct memory reclamation performance data, large page splitting performance data, page table cache miss performance data, and contiguous free block performance data from the same sampling period as a single data entry.
[0036] Based on the performance monitoring results, we can perform correlation analysis on the performance data reflecting costs, performance data reflecting benefits, and contextual data after the adoption of transparent big page technology, thereby clarifying the performance of transparent big page.
[0037] Among them, the memory consolidation performance data, direct memory reclamation performance data, and big page splitting performance data are statistical results obtained from a sampling period in kernel space. They are the result of aggregating the original event data and providing statistical results to user space through mapping, thereby reducing the overhead caused by the frequent uploading of original event data to user space and the statistical analysis by user space, and improving the real-time performance and practicality of transparent big page performance monitoring.
[0038] The transparent huge page performance monitoring method provided by this invention acquires memory consolidation performance data, direct memory reclamation performance data, and huge page splitting performance data in kernel mode during the sampling period, and acquires page table cache miss performance data and continuous free block performance data in user mode, and displays them in association after the sampling is completed. This achieves accurate acquisition of transparent huge page performance monitoring results and improves the real-time performance and practicality of transparent huge page performance monitoring.
[0039] According to a transparent big page performance monitoring method provided by the present invention, after reading the memory consolidation performance data, the direct memory reclamation performance data, and the big page splitting performance data from the mapping, the method further includes: the user-space program backing up and storing the memory consolidation performance data, the direct memory reclamation performance data, and the big page splitting performance data locally, and clearing the corresponding data in the mapping; after the sampling period ends, the method further includes: the user-space program backing up and storing the page table cache miss performance data and the continuous free block performance data, and clearing the page table cache miss performance data and the continuous free block performance data originally collected by the user-space program.
[0040] After the sampling period ends, the user-space program reads memory consolidation performance data, direct memory reclamation performance data, and big page splitting performance data from the mapping, backs up and stores the memory consolidation performance data, direct memory reclamation performance data, and big page splitting performance data locally, and clears the corresponding data in the mapping. The memory consolidation performance data, direct memory reclamation performance data, and big page splitting performance data collected in kernel mode are used as the data for the next sampling period.
[0041] After the sampling period ends, the user-mode program backs up the page table cache miss performance data and the continuous free block performance data, and clears the page table cache miss performance data and the continuous free block performance data originally collected by the user-mode program. The page table cache miss performance data and the continuous free block performance data collected by the user-mode program are then used as the data for the next sampling period.
[0042] The transparent big-page performance monitoring method provided by this invention ensures accurate acquisition of performance data for each sampling period by having the user-mode program read and back up the performance data collected in the kernel mode, clear the relevant data in the mapping, and back up its own collected data and clear it as well.
[0043] According to a transparent big page performance monitoring method provided by the present invention, the memory consolidation performance data includes the total memory consolidation time, the cumulative number of memory consolidation occurrences, and the maximum time for a single memory consolidation. The method for obtaining the memory consolidation performance data includes: when a memory consolidation start event occurs, the memory consolidation start event tracking point is triggered, and the start time of memory consolidation and the process identifier of the process executing the memory consolidation are recorded; when a memory consolidation end event occurs, the memory consolidation end event tracking point is triggered, the end time of memory consolidation and the process identifier of the memory consolidation are obtained, the time of memory consolidation is obtained according to the start time and the end time corresponding to the process identifier, the total time of memory consolidation, the cumulative number of memory consolidation occurrences, and the maximum time for a single memory consolidation are updated in the mapping through atomic operations, and the start time and the process identifier recorded in the current memory consolidation are deleted.
[0044] Memory warping performance data includes total memory warping time, cumulative number of memory warping occurrences, and maximum time for a single memory warping operation. Since user-mode programs read the kernel-level memory warping performance data collected during the current sampling period from the mapping after the sampling period ends, the total memory warping time represents the total time spent on memory warping within the current sampling period, the cumulative number of memory warping occurrences represents the total number of memory warping operations within the current sampling period, and the maximum time for a single memory warping operation represents the maximum time spent on any single memory warping operation within the current sampling period.
[0045] The following explains how to obtain the total time taken for memory warping, the cumulative number of memory warping events, and the maximum time taken for a single memory warping event.
[0046] When a memory warp start event occurs, a memory warp start event tracking point is triggered, recording the start time of the memory warp and the process identifier executing it. The start time and process identifier can be stored in a mapped start time record table, using the process identifier as the key and the nanosecond timestamp of the memory warp start as the value. The start time record table is used to temporarily record the start time of a monitored event. Since multiple processes may trigger memory warping simultaneously, using the process identifier as the key distinguishes the start time for different processes. This record is deleted after the memory warp event ends.
[0047] When the memory consolidation completion event occurs, the memory consolidation completion event tracking point is triggered. The end time and process identifier of the memory consolidation are obtained. Based on the current process identifier, the start time corresponding to that process identifier is searched in the start time record table. If a corresponding start time is found, it means the start time of this memory consolidation has been recorded. The duration of this memory consolidation is obtained by subtracting the start time from the end time. Atomic operations are used to update the total memory consolidation time, the cumulative number of memory consolidations, and the maximum single memory consolidation time in the mapping, avoiding errors caused by simultaneous data modification. After updating the total memory consolidation time, the cumulative number of memory consolidations, and the maximum single memory consolidation time in the mapping using atomic operations, the start time and process identifier of this memory consolidation are deleted from the record.
[0048] The transparent big page performance monitoring method provided by this invention enables accurate acquisition of the total time spent on memory consolidation, the cumulative number of memory consolidation occurrences, and the maximum time spent on a single memory consolidation.
[0049] According to a transparent big page performance monitoring method provided by the present invention, the direct memory reclamation performance data includes the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences. The method for obtaining the direct memory reclamation performance data includes: when a direct memory reclamation start event occurs, the direct memory reclamation start event tracking point is triggered, and the start time of direct memory reclamation and the process identifier executing the direct memory reclamation are recorded; when a direct memory reclamation end event occurs, the direct memory reclamation end event tracking point is triggered, the end time of direct memory reclamation and the process identifier of direct memory reclamation are obtained, the time spent on direct memory reclamation is obtained according to the start time and the end time corresponding to the process identifier, the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences in the mapping are updated through atomic operations, and the start time and the process identifier recorded in the current direct memory reclamation are deleted.
[0050] Direct memory reclamation performance data includes the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences. Since user-mode programs read the direct memory reclamation performance data collected by the kernel during the current sampling period from the mapping after the sampling period ends, the total time spent on direct memory reclamation represents the total time spent on direct memory reclamation within the current sampling period, and the cumulative number of direct memory reclamation occurrences represents the total number of direct memory reclamation occurrences within the current sampling period.
[0051] The following explains how to obtain the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences.
[0052] When a Direct Reclamation (DRC) start event occurs, a DRC start event tracking point is triggered, recording the start time of the DRC and the process identifier executing it. The start time and process identifier of the DRC can be stored in the aforementioned start time record table in a mapping, using the process identifier as the key and the nanosecond timestamp of the DRC start time as the value. Since the same process will not perform memory warping and reclamation simultaneously, the data for memory warping and reclamation can be recorded in the same table without distinguishing between event types.
[0053] When a direct memory reclamation (DMR) ends, a DMR trace point is triggered. The DMR's end time and process identifier are retrieved. Based on the current process identifier, the start time corresponding to that process identifier is searched in the start time record table. If a corresponding start time is found, it means the start time of this DMR has been recorded. The end time of the DMR is subtracted from the start time to obtain the duration of this DMR, i.e., the time taken for this DMR. The total DMR duration and cumulative DMR count in the mapping are updated using atomic operations to avoid errors caused by simultaneous data modifications. After updating the total DMR duration and cumulative DMR count in the mapping using atomic operations, the start time and process identifier of this DMR are deleted from the record.
[0054] The transparent big page performance monitoring method provided by this invention enables accurate acquisition of the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences.
[0055] According to the present invention, a transparent large page performance monitoring method is provided, wherein the large page splitting performance data includes the number of transparent large page splits, which is used to characterize the number of times the underlying large page object corresponding to the transparent large page is split into multiple basic pages; the step of monitoring and acquiring the large page splitting performance data through a probe and storing it in the mapping includes: attaching a probe to the kernel function related to the transparent large page splitting as a basic page, acquiring the splitting event of the underlying large page object being split into multiple basic pages, and atomically incrementing the number of transparent large page splits in the mapping.
[0056] A probe is attached to the kernel functions related to the transparent huge page splitting, which are based on the underlying huge page object, to obtain the splitting event when the underlying huge page object is split into multiple base pages. The current implementation is compatible with different kernel versions and can attach the probe to `split_huge_page_to_list` or `split_huge_page_to_list_to_order`. When a splitting event is detected where the underlying huge page object is split into multiple base pages, the number of transparent huge page splits is atomically incremented.
[0057] Memory consolidation performance data, direct memory reclamation performance data, and big page splitting performance data collected in kernel mode can be stored in a global statistics table within a mapping, using the index of the statistical item as the key and the value of each statistical item as the value. The statistical items include total memory consolidation time, cumulative number of memory consolidation occurrences, maximum time for a single memory consolidation, total direct memory reclamation time, cumulative number of direct memory reclamation occurrences, and number of transparent big page splits. The global statistics table is a fixed-size array mapping used to store the accumulated statistical values since the last user-mode read.
[0058] The __sync_fetch_and_add atomic operation can be used to cumulatively update the corresponding statistical items in the global statistics table to avoid overwriting when multiple cores concurrently update the same statistical item, thus ensuring the correctness of the results.
[0059] The transparent large page performance monitoring method provided by this invention enables accurate acquisition of the number of times the transparent large page is split.
[0060] According to a transparent big page performance monitoring method provided by the present invention, the page table cache miss performance data includes the number of data page table cache misses or the number of page faults; the user-mode program collects and records the page table cache miss performance data through system calls, including: the user-mode program accesses the CPU's performance monitoring unit through the perf_event_open system call to collect the number of data page table cache misses; wherein, if the hardware does not support the collection of the number of data page table cache misses, the number of page faults is collected instead.
[0061] The `perf_event_open` system call is used to access the CPU's Performance Monitoring Unit (PMU). This embodiment primarily focuses on the impact of transparent big pages on data memory access paths. In most business scenarios where memory data access is the primary function, Data TLB Misses (DTLBMisses) more directly reflect the address translation benefits brought by transparent big pages; Instruction TLB Misses (ITLB Misses) mainly affect the instruction fetch path and are usually not the primary concern in the performance benefit / cost analysis of transparent big pages. Therefore, this embodiment collects the number of Data TLB Misses. If the hardware does not support the collection of Data TLB Misses, it automatically downgrades to collecting the number of Page Faults to reflect changes in address translation overhead from the hardware side.
[0062] Hardware performance counters can be used to count page table cache misses. User-space programs enable the corresponding hardware performance counters for each CPU, and at the end of each sampling period, read the current count result and reset it to zero, thereby obtaining the incremental data within that sampling period.
[0063] The transparent big page performance monitoring method provided by this invention enables accurate acquisition of the number of data page table cache misses or page faults.
[0064] According to a transparent big page performance monitoring method provided by the present invention, the continuous free block performance data includes the number of 2MB continuous free blocks and the number of 4MB continuous free blocks; the user-space program reads and records the continuous free block performance data through a file, including: reading the / proc / buddyinfo file and reading the number of Order9 and Order10 in the Normal memory area in real time; wherein, the number of Order9 represents the number of 2MB continuous free blocks and the number of Order10 represents the number of 4MB continuous free blocks.
[0065] The size of the free blocks corresponding to the performance data of contiguous free blocks meets the memory allocation requirements of transparent huge pages. If the transparent huge page is 2MB, then free blocks of 2MB or 4MB will both meet the memory allocation requirements of transparent huge pages.
[0066] User-space programs read the ` / proc / buddyinfo` file to obtain the number of Order 9 and Order 10 blocks in the Normal memory region in real time. The number of Order 9 blocks represents the number of contiguous 2MB free blocks, and the number of Order 10 blocks represents the number of contiguous 4MB free blocks. The number of 4MB contiguous free blocks can be multiplied by 2 to convert to the number of 2MB contiguous free blocks and then combined with the number of contiguous free blocks of its own size (2MB). Alternatively, the number of 4MB and 2MB contiguous free blocks can be counted separately. Here, 4MB and 2MB refer to the number of individual free blocks within a contiguous free block.
[0067] The transparent huge page performance monitoring method provided by this invention can accurately obtain the number of 2MB contiguous free blocks and the number of 4MB contiguous free blocks that meet the transparent huge page memory allocation requirements.
[0068] According to a transparent big page performance monitoring method provided by the present invention, the method further includes: summarizing and analyzing the memory consolidation performance data, direct memory reclamation performance data, big page splitting performance data, page table cache miss performance data, and continuous free block performance data of each sampling period within a preset time period, and obtaining and displaying the summary analysis results.
[0069] Based on continuous monitoring, performance data such as memory consolidation, direct memory reclamation, big page splitting, page table cache misses, and continuous free blocks from multiple sampling periods can be aggregated to form a summary output, which can be used to evaluate the overall benefits and costs of the transparent big page mechanism in the target business.
[0070] The transparent large-page performance monitoring method provided by this invention summarizes and analyzes performance data within a preset time period, obtains and displays the summary analysis results, improves the comprehensiveness of the monitoring results, and provides more targeted analysis basis.
[0071] According to the transparent large-page performance monitoring method provided by the present invention, the summarized analysis results include at least one of the following results: The preset time period includes the cumulative number of memory consolidation events, total memory consolidation time, maximum single memory consolidation time, total direct memory reclamation time, cumulative number of direct memory reclamation events, number of transparent large page splits, average frequency of transparent large page splits, periodic changes in the number of transparent large page splits, average number of data page table cache misses or page faults per sampling period, rate of change of the average number of data page table cache misses or page faults per sampling period relative to the baseline value, periodic changes in the number of data page table cache misses or page faults, average number of consecutive free blocks per sampling period, minimum number of consecutive free blocks per sampling period, and periodic changes in the number of consecutive free blocks.
[0072] There are two ways to output the monitoring results.
[0073] 1. Real-time output At the end of each sampling period, the user-mode program outputs a real-time log line to the console, which includes some or all of the following metrics: (1) Time: Current system time.
[0074] (2) Total time spent on memory consolidation.
[0075] (3) Cumulative number of times memory consolidation occurs.
[0076] (4) Maximum time taken for memory consolidation in a single operation.
[0077] (5) Total time spent on direct memory reclamation.
[0078] (6) The cumulative number of times direct memory reclamation has occurred.
[0079] (7) Number of times the transparent large page is split.
[0080] (8) Number of times the data page table cache was missed or the number of page faults occurred.
[0081] (9) The number of consecutive free blocks of 2MB.
[0082] Analysis Example: If the number of consecutive 2MB free blocks is consistently low, memory consolidation time increases, and the number of data page table cache misses does not improve significantly, it indicates that the system may be trading high memory management costs for limited transparent big page benefits. If consolidation and reclamation times are both low, but the number of transparent big page splits continues to increase and the number of data page table cache misses increases significantly, it indicates that transparent big pages may be split frequently under the current load, thus affecting address translation efficiency.
[0083] 2. Summary Output The summary may include some or all of the following indicators: (1) The cumulative number of memory consolidation events within a preset time period.
[0084] (2) Total time spent on memory consolidation within the preset time period.
[0085] (3) Maximum time taken for memory consolidation in a single operation within a preset time period.
[0086] (4) Total time spent on direct memory reclamation within the preset time period.
[0087] (5) The cumulative number of direct memory reclamation events within the preset time period.
[0088] (6) Number of times the transparent large page is split within the preset time period.
[0089] (7) Average frequency of transparent large page splitting within a preset time period; wherein, the average frequency of transparent large page splitting in each sampling period can be obtained and the average value can be calculated to obtain the average frequency of transparent large page splitting.
[0090] (8) Periodic variation of the number of times the transparent large page is split; wherein, the periodic variation of the number of times the transparent large page is split is obtained based on the number of times the transparent large page is split in each sampling period. (9) The average number of data page table cache misses or page faults per sampling period.
[0091] (10) The rate of change of the average number of data page table cache misses or page faults per sampling period relative to the baseline value; wherein, the baseline values corresponding to the number of data page table cache misses and page faults can be preset respectively.
[0092] (11) The periodic changes in the number of data page table cache misses or page faults; wherein, the periodic changes in the number of data page table cache misses are obtained based on the number of data page table cache misses in each sampling period; and the periodic changes in the number of page faults are obtained based on the number of page faults in each sampling period.
[0093] (12) The average number of consecutive free blocks in each sampling period; where the number of free blocks of size 4MB can be converted into the number of free blocks of size 2MB to obtain the average number of consecutive free blocks of size 2MB in each sampling period; or the average number of consecutive free blocks of size 2MB and the average number of consecutive free blocks of size 4MB can be obtained respectively in each sampling period.
[0094] (13) The minimum number of consecutive free blocks in each sampling period; where the number of free blocks of size 4MB can be converted into the number of free blocks of size 2MB to obtain the minimum number of consecutive free blocks of size 2MB in each sampling period; or the minimum number of consecutive free blocks of size 2MB and the minimum number of consecutive free blocks of size 4MB can be obtained respectively in each sampling period.
[0095] (14) Periodic variation of the number of consecutive free blocks. The number of 4MB free blocks can be converted into the number of 2MB free blocks, and the periodic variation of the number of 2MB free blocks can be obtained based on the number of consecutive 2MB free blocks in each sampling period; or the periodic variation of the number of 2MB free blocks and the periodic variation of the number of 4MB free blocks can be obtained separately.
[0096] The cumulative number of memory consolidation occurrences, total memory consolidation time, maximum single memory consolidation time, total direct memory reclamation time, and cumulative direct memory reclamation occurrences are used to assess the memory management costs incurred in acquiring or maintaining large pages. The number of transparent large page splits, the average frequency of transparent large page splits, and the periodic variation of the number of transparent large page splits are used to assess the stability of transparent large pages under the current load. The average number of data page table cache misses or page faults per sampling period, the rate of change of the average number of data page table cache misses or page faults per sampling period relative to the baseline value, and the periodic variation of the number of data page table cache misses or page faults are used to help determine the address translation benefits brought by transparent large pages. The average number of consecutive free blocks per sampling period, the minimum number of consecutive free blocks per sampling period, and the periodic variation of the number of consecutive free blocks are used to help determine the degree of physical memory fragmentation.
[0097] Based on the combined changes of the above indicators, an analytical basis is provided for determining whether the transparent big page strategy is suitable for the current business load.
[0098] Summary analysis example: If, over a prolonged period, it is observed that memory consolidation and direct memory reclamation take a long time, the improvement in data page table cache misses is limited, or transparent big page splits are frequent and data page table cache misses continue to increase, it indicates that the transparent big page mechanism may not have brought the expected benefits to the current business, but instead introduced additional memory management overhead. In this case, it is advisable to further consider adjusting the relevant parameters of transparent big pages or optimizing the program's memory usage strategy.
[0099] The transparent large page performance monitoring method provided by this invention can realize rich and comprehensive transparent large page performance summary analysis.
[0100] This invention proposes a transparent huge page performance monitoring method. By constructing an event capture and aggregation mechanism in the kernel space and combining it with hardware performance acquisition in the user space, a relatively comprehensive monitoring of the operating status of the transparent huge page mechanism can be achieved.
[0101] 1. Achieve microsecond-level monitoring of memory defragmentation and reclamation latency. This invention uses eBPF technology to capture the start and end events of memory consolidation and direct memory reclamation in real time, and uses mapping to record the start time and calculate the single time at the end, thereby improving the monitoring accuracy of related memory management behaviors and making it easier to locate the specific links that cause system latency fluctuations.
[0102] 2. Construct a low-overhead kernel-mode data aggregation mechanism This invention addresses the additional performance overhead associated with high-frequency event monitoring. Traditional tools often send a large number of raw events to user space for processing, while this invention directly updates statistical values in kernel space using mapping, with user space only reading the aggregated statistical results. This "kernel-space aggregation, user-space periodic reading" model reduces the additional burden on the monitoring process itself, making it more suitable for continuous operation in production environments.
[0103] 3. Monitoring view linking "TLB revenue" and "memory management cost" This invention addresses the difficulty of evaluating the overall effectiveness of transparent huge pages (DTLB) through single-dimensional monitoring. It integrates software-level memory management events (DTLB splitting, direct memory reclamation, and memory consolidation) with hardware-level performance metrics (DTLB misses) and memory fragmentation information into a single sampling period for joint monitoring. By synchronously reading hardware performance counters, buddyinfo information, and kernel-level statistics in user space, it enables correlation analysis of the benefits and costs of DTLB, providing a basis for adjusting the DTLB strategy.
[0104] The present invention has the following advantages: 1. Strong ability to accurately acquire data: By attaching eBPF programs to the entry points of kernel events related to memory consolidation, direct memory reclamation, and transparent big page splitting, this invention can accurately capture the time consumption and frequency information of various transparent big page related events, providing quantitative basis for analysis and optimization.
[0105] 2. Low-load operation, suitable for production environment: This invention adopts eBPF technology to update the statistical values of transparent big page related events in kernel space, without the need to transmit a large amount of raw event data to user space. This can reduce the additional CPU and I / O overhead brought by the monitoring tool itself, and is suitable for continuous operation in production environment.
[0106] 3. Precise and efficient decision support: This invention collects DTLB miss indicators in user space and reads / proc / buddyinfo to obtain continuous free big page information. It correlates and displays the memory management costs brought by transparent big pages (time spent on memory consolidation, time spent on direct memory reclamation, and number of transparent big page splits) with the address translation benefits (number of DTLB misses), providing operation and maintenance personnel with intuitive analysis basis.
[0107] Figure 2 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 2 As shown, the electronic device may include a processor 210, a communications interface 220, a memory 230, and a communication bus 240, wherein the processor 210, the communications interface 220, and the memory 230 communicate with each other via the communication bus 240. The processor 210 can call logical instructions in the memory 230 to execute the transparent big-page performance monitoring method provided in the above embodiments.
[0108] Furthermore, the logical instructions in the aforementioned memory 230 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0109] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the transparent large page performance monitoring method provided in the above embodiments.
[0110] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the transparent big-page performance monitoring method provided in the above embodiments.
[0111] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0112] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0113] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
[0115] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for monitoring the performance of transparent large pages, characterized in that, include: In each sampling period, in kernel mode, memory consolidation performance data is obtained and stored in the mapping through memory consolidation start event tracking point and memory consolidation end event tracking point; direct memory reclamation performance data is obtained and stored in the mapping through direct memory reclamation start event tracking point and direct memory reclamation end event tracking point; and large page splitting performance data is obtained and stored in the mapping through transparent large page splitting monitoring by probe. In each sampling period, in user mode, the user-mode program collects and records page table cache miss performance data through system calls, and the user-mode program reads and records continuous free block performance data through file reading; wherein, the block size of the free block corresponding to the continuous free block performance data is an integer multiple of the page size of the transparent big page; After the sampling period ends, the user-space program reads the memory consolidation performance data, the direct memory reclamation performance data, and the large page splitting performance data from the mapping, and displays them in association with the page table cache miss performance data and the continuous free block performance data.
2. The transparent large-page performance monitoring method according to claim 1, characterized in that, After reading the memory compaction performance data, the direct memory reclamation performance data, and the large page splitting performance data from the mapping, the method further includes: The user-space program backs up and stores the memory consolidation performance data, the direct memory reclamation performance data, and the big page splitting performance data locally, and clears the corresponding data in the mapping to zero. After the sampling period ends, the method further includes: The user-mode program backs up and stores the page table cache miss performance data and the continuous free block performance data, and clears the page table cache miss performance data and the continuous free block performance data originally collected by the user-mode program.
3. The transparent large-page performance monitoring method according to claim 1, characterized in that, The memory flattening performance data includes the total time spent on memory flattening, the cumulative number of memory flattening events, and the maximum time spent on a single memory flattening event. The method for obtaining the memory warping performance data includes: When the memory warping start event occurs, the memory warping start event tracking point is triggered, and the start time of memory warping and the process identifier that performs the memory warping are recorded. When the memory consolidation completion event occurs, the memory consolidation completion event tracking point is triggered, the memory consolidation completion time and the memory consolidation process identifier are obtained, the memory consolidation time is obtained according to the start time and the end time corresponding to the process identifier, the total memory consolidation time, the cumulative number of memory consolidation occurrences and the maximum single memory consolidation time in the mapping are updated through atomic operations, and the start time and the process identifier of this memory consolidation are deleted.
4. The transparent large-page performance monitoring method according to claim 3, characterized in that, The direct memory reclamation performance data includes the total time spent on direct memory reclamation and the cumulative number of direct memory reclamation occurrences. The method for obtaining direct memory reclamation performance data includes: When a direct memory reclamation start event occurs, the direct memory reclamation start event tracking point is triggered, and the start time of direct memory reclamation and the process identifier executing the direct memory reclamation are recorded. When a direct memory reclamation end event occurs, the direct memory reclamation end event tracking point is triggered, the end time of the direct memory reclamation and the process identifier of the direct memory reclamation are obtained, the time consumed by the direct memory reclamation is obtained according to the start time and the end time corresponding to the process identifier, the total time consumed by the direct memory reclamation and the cumulative number of direct memory reclamation occurrences in the mapping are updated through atomic operations, and the start time and the process identifier of the current direct memory reclamation record are deleted.
5. The transparent large-page performance monitoring method according to claim 4, characterized in that, The large page splitting performance data includes the number of transparent large page splits, which is used to characterize the number of times the underlying large page object corresponding to the transparent large page is split into multiple basic pages; The process of monitoring and acquiring transparent large-page splitting through probes and storing large-page splitting performance data in the mapping includes: By attaching probes to kernel functions related to the transparent large page splitting as the base page, the splitting event of the underlying large page object being split into multiple base pages is obtained, and the number of transparent large page splits in the mapping is atomically incremented.
6. The transparent large-page performance monitoring method according to claim 5, characterized in that, The page table cache miss performance data includes the number of data page table cache misses or the number of page faults. The user-mode program collects and records page table cache miss performance data through system calls, including: The user-space program accesses the CPU's performance monitoring unit through the perf_event_open system call to collect the number of data page table cache misses; If the hardware does not support the collection of the number of data page table cache misses, then the number of page faults is collected.
7. The transparent large-page performance monitoring method according to claim 6, characterized in that, The performance data for consecutive free blocks includes the number of consecutive free blocks of 2MB and the number of consecutive free blocks of 4MB. The user-space program reads and records continuous free block performance data from a file, including: Read the / proc / buddyinfo file to read the number of Order 9 and Order 10 blocks in the Normal memory region in real time; where the number of Order 9 blocks represents the number of contiguous 2MB free blocks and the number of Order 10 blocks represents the number of contiguous 4MB free blocks.
8. The transparent large-page performance monitoring method according to claim 7, characterized in that, The method further includes: By summarizing and analyzing the memory consolidation performance data, direct memory reclamation performance data, large page splitting performance data, page table cache miss performance data, and continuous free block performance data for each sampling period within a preset time period, the summary analysis results are obtained and displayed.
9. The transparent large-page performance monitoring method according to claim 8, characterized in that, The summary analysis results include at least one of the following: The preset time period includes the cumulative number of memory consolidation events, total memory consolidation time, maximum single memory consolidation time, total direct memory reclamation time, cumulative number of direct memory reclamation events, number of transparent large page splits, average frequency of transparent large page splits, periodic changes in the number of transparent large page splits, average number of data page table cache misses or page faults per sampling period, rate of change of the average number of data page table cache misses or page faults per sampling period relative to the baseline value, periodic changes in the number of data page table cache misses or page faults, average number of consecutive free blocks per sampling period, minimum number of consecutive free blocks per sampling period, and periodic changes in the number of consecutive free blocks.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the transparent large page performance monitoring method as described in any one of claims 1 to 9.