Data monitoring method and system of application program and electronic equipment
By monitoring the attribute value of idle memory in the operating system platform and the execution memory recovery time, determining the delay time when the application applies for memory, the problem of inability to effectively monitor the delay time in the prior art is solved, and effective avoidance of delay jitter is achieved.
Patent Information
- Application Number
- CN202311843491.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2025-06-27
AI Technical Summary
The prior art is difficult to effectively monitor the delay time of applications when applying for memory on the operating system platform, resulting in delay jitter problems.
By monitoring the memory space in the operating system platform that is in an idle state, if the attribute value is below the threshold, perform memory recovery operations and record the duration of memory recovery to determine the delay time of the application.
It realizes effective monitoring of the delay time when the application applies for memory, avoiding jitter caused by memory allocation delay.
Smart Images

Figure CN120216280A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular, to a method, a system, and an electronic device for monitoring data of an application program. Background Art
[0002] Currently, during the running of an application program, if the operating system (OS) generates a page fault exception or the like, it is necessary to allocate memory from the kernel (Linux) system of the OS. However, if there is insufficient memory, it is necessary to perform memory recycling to obtain sufficient memory, which will cause situations such as application program latency, and further lead to problems such as latency jitter in the application program, affecting the continuity of services for the application program. Therefore, during the running of the application program, it is very important to monitor the process of the application program applying for memory in real time and solve the latency jitter and other situations caused in this process.
[0003] However, in the Linux system in the related art, the health of the entire application program is usually measured from the perspective of the overall machine resources. However, the above method has low pertinence to the latency consumption situation of the application program and is prone to misjudgment and other situations. Therefore, there is still a technical problem that the latency duration when the application program applies for memory cannot be effectively detected.
[0004] For the above problems, no effective solution has been proposed yet. Summary of the Invention
[0005] Embodiments of the present application provide a method, a system, and an electronic device for monitoring data of an application program, so as to at least solve the technical problem that the latency duration when the application program applies for memory cannot be effectively monitored.
[0006] According to one aspect of the embodiments of the present application, a method for monitoring data of an application program is provided. The method may include: during the running of the application program, in response to a memory application instruction generated by the application program on the operating system platform, monitoring the memory space in the idle state in the operating system platform; if the attribute value of the memory space in the idle state is lower than the attribute threshold, controlling the operating system platform to perform at least one memory recycling operation, where the attribute value is used to represent the storage amount that the memory space in the idle state allows for storage operations; obtaining the duration consumed by the operating system platform for performing the memory recycling operation; and determining, based on the duration, the latency duration of the application program for applying for the required memory from the operating system platform.
[0007] According to another aspect of the embodiments of the present application, a method for monitoring the delay duration of an application program's memory application is provided. The method may include: responding to a data monitoring instruction on an operation interface to determine the application program to be monitored; responding to a program running instruction on the operation interface to control the running of the application program; in response to a memory application instruction generated by the application program on the operating system platform, displaying on the operation interface the memory space in the idle state in the operating system platform; if the attribute value of the memory space in the idle state is lower than an attribute threshold, controlling the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity that the memory space in the idle state allows for storage operations; displaying on the operation interface the delay duration for which the application program delays in applying for the required memory from the operating system platform, where the delay duration is determined based on the duration consumed by the operating system platform for performing the memory recovery operation.
[0008] According to another aspect of the embodiments of the present application, a method for monitoring data of an application program's memory application is provided. The method may include: determining the identification information of the application program to be monitored by calling a first interface, where the first interface includes a first parameter, and the parameter value of the first parameter is the identification information; during the running of the application program, based on the identification information, in response to a memory application instruction generated by the application program on the operating system platform, monitoring the memory space in the idle state in the operating system platform; if the attribute value of the memory space in the idle state is lower than an attribute threshold, controlling the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity that the memory space in the idle state allows for storage operations; obtaining the duration consumed by the operating system platform for performing the memory recovery operation; based on the duration, determining the delay duration for which the application program delays in applying for the required memory from the operating system platform; outputting the delay duration by calling a second interface, where the second interface includes a second parameter, and the parameter value of the second parameter is the delay duration.
[0009] According to another aspect of the embodiments of the present application, a data monitoring system for an application program is further provided. The system may include: a terminal device for uploading the identification information of the application program to be monitored; a server for, during the running of the application program, in response to a memory application instruction generated by the application program on the operating system platform, monitoring the memory space in the idle state in the operating system platform; if the attribute value of the memory space in the idle state is lower than an attribute threshold, controlling the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity that the memory space in the idle state allows for storage operations; obtaining the duration consumed by the operating system platform for performing the memory recovery operation; based on the duration, determining the delay duration for which the application program delays in applying for the required memory from the operating system platform.
[0010] According to another aspect of the embodiments of the present application, an electronic device is further provided. The electronic device may include a memory and a processor: the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the data monitoring method of the application program in any one of the above is implemented.
[0011] According to another aspect of the embodiments of the present application, a processor is further provided. The processor is used to run a program. When the program is running, the data monitoring method of the application program in any one of the above is executed.
[0012] According to another aspect of the embodiments of the present application, a computer-readable storage medium is further provided. The computer-readable storage medium includes a stored program. When the program is running, the device where the storage medium is located is controlled to execute the data monitoring method of the application program in any one of the above.
[0013] In the embodiments of the present application, the running process of the application program can be monitored in real time to monitor whether a memory application instruction is generated on the operating system platform associated with the application program. If there is no memory application instruction, it can be explained that the current application program has no need to apply for memory. At this time, the application program can continue to be monitored. If there is, it can be explained that the current application program has a need to apply for memory. At this time, based on the memory application instruction, the state of the memory space in the operating system platform can be monitored to determine whether there is a free memory space in the included memory space. If there is a memory space in the free state, the storage capacity size allowed for storage operations of this memory space can be determined, that is, the size judgment of the attribute value and the attribute threshold. If the attribute value is lower than the attribute threshold, at this time, the time required for the operating system platform to perform the memory recovery operation needs to be determined. And according to this time, the delay time that the application program needs to delay for the memory applied based on the memory application instruction to the operating system platform can be determined. Since it is considered that the related technology only measures the health of the application program from the perspective of the overall machine resources, there will be situations such as misjudgment and low accuracy. However, the embodiments of the present application can design a special delay metric for determining the application of memory by the application program, that is, determine the delay time, to accurately measure the delay problem when the application program applies for memory, so as to achieve the purpose of effectively avoiding the jitter situation caused by memory allocation delay, and further realize the technical effect of being able to effectively monitor the delay time when the application program applies for memory, and solve the technical problem that the delay time when the application program applies for memory cannot be effectively monitored.
[0014] It is easy to note that the above general description and the following detailed description are only for exemplifying and explaining the present application, and do not constitute a limitation to the present application. Brief Description of the Drawings
[0015] The accompanying drawings described herein are used to provide a further understanding of the present application and form a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0016] Figure 1 is a schematic diagram of an application scenario of a data monitoring method for an application program according to an embodiment of the present application;
[0017] Figure 2 is a structural block diagram of a computing environment of a data monitoring method for an application program according to an embodiment of the present application;
[0018] Figure 3 is a flowchart of a data monitoring method for an application program according to an embodiment of the present application;
[0019] Figure 4 is a flowchart of a method for monitoring the latency of an application program's memory application according to an embodiment of the present application;
[0020] Figure 5 is a flowchart of a data monitoring method for an application program's memory application according to an embodiment of the present application;
[0021] Figure 6 is a schematic diagram of a data monitoring system for an application program according to an embodiment of the present application;
[0022] Figure 7 is a flowchart of a method for allocating page frames in the kernel of an operating system platform according to an embodiment of the present application;
[0023] Figure 8 is a schematic diagram of a method for measuring the latency of a heap memory application by a kernel application of an operating system platform according to an embodiment of the present application;
[0024] Figure 9 is a schematic diagram of visually displaying the latency according to an embodiment of the present invention;
[0025] Figure 10 is a schematic diagram of a data monitoring device for an application program according to an embodiment of the present application;
[0026] Figure 11 is a schematic diagram of a device for monitoring the latency of an application program's memory application according to an embodiment of the present application;
[0027] Figure 12 is a schematic diagram of a data monitoring device for an application program's memory application according to an embodiment of the present application;
[0028] Figure 13 is a structural block diagram of a computer terminal according to an embodiment of the present application;
[0029] Figure 14 is a block diagram of an electronic device for a data monitoring method of an application program according to an embodiment of the present application;
[0030] Figure 15 is a hardware structure block diagram of a computer terminal (or mobile device) for implementing a data monitoring method of an application program according to an embodiment of the present application. Detailed implementation manners
[0031] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0033] First, some nouns or terms that appear in the process of describing the embodiments of the present application are applicable to the following explanations:
[0034] Memory area list (zonelist) and memory area (zone). In the Linux kernel, the memory manager divides the physical memory of the system into different areas (zones), and each area has an associated zonelist. The zonelist is a doubly linked list that contains multiple zones / ZONEs. Each zone represents a continuous area of physical memory; each zone has different characteristics and uses. For example, the direct memory access area (ZONE_DMA), the general area (ZONE_NORMAL), and the high memory area (ZONE_HIGHMEM). These areas may have different access permissions, mapping methods, or available memory sizes, etc.;
[0035] Direct memory reclaim: During the slow memory allocation process in the Linux kernel, when page frames cannot be allocated from all zones in the zonelist and memory compaction is performed but still fails to allocate page frames, a memory reclaim that blocks the application process is performed on all zones in the zonelist.
[0036] Page fault exception: When the processor fetches an instruction or data, the memory management unit of the processor needs to convert the virtual address into a physical address. If the physical page corresponding to the virtual address is not found or there is no access permission, the processor will generate a page fault exception, which is called a page fault.
[0037] Embodiment 1
[0038] According to an embodiment of the present application, a method for monitoring data of an application program is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0039] According to one aspect of an embodiment of the present application, a method for monitoring data of an application program is provided. As an alternative implementation, the above method for monitoring data of an application program can be but is not limited to being applied to Figure 1 the application scenario shown below. Figure 1 FIG. is a schematic diagram of an application scenario of a method for monitoring data of an application program according to an embodiment of the present application. As Figure 1 shown, in the application scenario, the terminal device 102 can communicate with the server 106 through the network 104, and the server 106 can perform operations on the database 108, such as write data operations or read data operations. The above terminal device 102 can include but is not limited to a human-computer interaction screen, a processor, and a memory. The above human-computer interaction screen can be used to display, for example, the identification information of the application program to be monitored on the terminal device 102. The above processor can be used to respond to the above human-computer interaction operations, execute corresponding operations, or generate corresponding instructions and send the generated instructions to the server 106. The above memory is used to store relevant processing data, such as the identification information of the application program to be monitored, the memory application instructions generated by the application program, the memory space in the operating system platform, and the delay duration of the memory delay required by the application program.
[0040] As an alternative approach, the following steps of the data monitoring method for the application program can be executed on the server 106: Step S102, during the running of the application program, in response to a memory application instruction generated by the application program on the operating system platform, monitor the memory space in the idle state in the operating system platform; Step S104, if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to execute at least one memory recovery operation, where the attribute value is used to represent the storage capacity that the memory space in the idle state allows for storage operations; Step S106, obtain the duration consumed by the operating system platform to execute the memory recovery operation; Step S108, based on the duration, determine the delay duration for which the application program is delayed in applying for the required memory from the operating system platform.
[0041] By adopting the above method, the running process of the application program can be monitored in real time to monitor whether there is a memory application instruction generated on the operating system platform associated with the application program. If so, it can indicate that the current application program has a need to apply for memory. At this time, based on the memory application instruction, the status of the memory space in the operating system platform can be monitored to determine whether there is a memory space in the idle state among the included memory spaces. If there is a memory space in the idle state, the storage capacity size that the memory space allows for storage operations can be determined, that is, the comparison between the attribute value and the attribute threshold is judged. If the attribute value is lower than the attribute threshold, at this time, it is necessary to determine the duration consumed by the operating system platform to execute the memory recovery operation. And based on this duration, the delay duration for which the application program is delayed in applying for the memory based on the memory application instruction from the operating system platform can be determined. Since a special method for determining the delay metric when the application program applies for memory can be designed, that is, determining the delay duration, to accurately measure the delay problem when the application program applies for memory, so as to achieve the purpose of effectively avoiding the jitter situation caused by memory allocation delay, and then realizing the technical effect of effectively monitoring the delay duration when the application program applies for memory, and solving the technical problem of being unable to effectively monitor the delay duration when the application program applies for memory.
[0042] Figure 2 is a structural block diagram of a computing environment for a method of determining layout information of a sensing device according to an embodiment of the present application, as Figure 2 shown, the computing environment 201 includes multiple (shown as 210-1, 210-2,... in the figure) computing nodes (such as servers) running on a distributed network. Each computing node includes local processing and memory resources, and the end user 202 can remotely run application programs or store data in the computing environment 201. The application programs can be provided as multiple services 220-1, 220-2, 220-3, and 220-4 in the computing environment 201, representing services "A", "D", "E", and "H" respectively.
[0043] The end - user 202 can provide and access services through a web browser or other software applications on the client. In some embodiments, the provision and / or request of the end - user 202 can be provided to the ingress gateway 230. The ingress gateway 230 can include a corresponding proxy to handle the provision and / or request for services (one or more services provided in the computing environment 201).
[0044] Services are provided or deployed according to various virtualization technologies supported by the computing environment 201. In some embodiments, services can be provided based on virtual machine (VM) - based virtualization, container - based virtualization, and / or similar means. VM - based virtualization can be achieved by initializing virtual machines to simulate real computers and execute programs and applications without directly accessing any actual hardware resources. While virtualizing machines with virtual machines, according to container - based virtualization, containers can be launched to virtualize the entire operating system so that multiple workloads can run on a single operating system instance.
[0045] In one embodiment of container - based virtualization, several containers of a service can be assembled into a Pod (e.g., Kubernetes Pod). For example, as Figure 2 shown, service 220 - 2 can be equipped with one or more Pods 240 - 1, 240 - 2, …, 240 - N (collectively referred to as Pods). A Pod can include a proxy 245 and one or more containers 242 - 1, 242 - 2, …, 242 - M (collectively referred to as containers). One or more containers in the Pod handle requests related to one or more corresponding functions of the service, and the proxy 245 generally controls network functions related to the service, such as routing, load balancing, etc. Other services can also be equipped with Pods similar to this one.
[0046] During operation, executing a user request from the end - user 202 may require invoking one or more services in the computing environment 201, and executing one or more functions of a service may require invoking one or more functions of another service. As Figure 2 shown, service "A" 220 - 1 receives a user request from the end - user 202 from the ingress gateway 230. Service "A" 220 - 1 can invoke service "D" 220 - 2, and service "D" 220 - 2 can request service "E" 220 - 3 to execute one or more functions.
[0047] The above computing environment may be a cloud computing environment, where the allocation of resources is managed by a cloud service provider, allowing the development of functions without considering the implementation, adjustment, or expansion of servers. This computing environment allows developers to execute code in response to events without building or maintaining complex infrastructure. Services can be segmented into a set of functions that can be automatically scaled independently, rather than expanding a single hardware device to handle potential loads.
[0048] Under the above operating environment, the present application provides a method for monitoring data of an application as shown in Figure 3 . It should be noted that the method for monitoring data of the application in this embodiment can be executed by Figure 1 the mobile terminal shown in the embodiment. Figure 3 FIG. is a flowchart of a method for monitoring data of an application according to an embodiment of the present application. As shown in Figure 3 , the method may include the following steps:
[0049] Step S302, during the running of the application, in response to a memory application instruction generated by the application on the operating system platform, monitor the memory space in the idle state in the operating system platform.
[0050] In the technical solution provided in step S302 of the present application above, during the running of the application, it is possible to monitor in real time whether the application generates a memory application instruction on the operating system platform. After monitoring that the application generates a memory application instruction during the running process on the operating system platform, the memory application instruction can be used to monitor the memory space in the idle state in the operating system platform. Herein, the application can also be referred to as an app. The operating system platform can be used to allocate memory for the application and can be an OS system. The OS system may include an OS kernel, which can also be referred to as Linux. The memory application instruction can be used to represent a memory application sent by the application to the operating system platform. For example, it can be an instruction to apply for heap memory for the application. The kernel in the operating system platform may include a memory manager. The idle state, and the memory space in the idle state can also be referred to as free memory. The memory space can also be referred to as memory or memory page
[0051] Optionally, during the running of the application, it is possible to monitor in real time the instructions triggered on the application. If there is a need to apply for memory, corresponding operations can be executed to generate a memory application instruction. When monitoring the memory application instruction on the application, the application can be controlled to send the memory application instruction to the corresponding operating system platform.
[0052] Optionally, during the operation of an application, when the operating system platform receives a memory application instruction from a certain application, it can monitor the situation of the memory space in the operating system platform in real time. For example, it can detect whether there is free memory space in the memory space for the application to apply for.
[0053] For example, through the kernel in the operating system platform, it can monitor in real time whether a memory application instruction from an application is received.
[0054] Optionally, the memory manager can divide the physical memory of the operating system platform into different zones, and each zone has an associated zonelist. The zonelist is a doubly linked list and can contain multiple zones. Each zone represents a continuous area in a section of physical memory. Each zone has different characteristics and uses. For example, the direct memory access zone (zone_DMA), the general zone (zone_Normal), and the high memory zone (zone_highmem). These zones may have different access permissions, mapping methods, or available memory sizes, etc. It should be noted that the zones, characteristics, and uses included in the above internal space are only for illustrative purposes and are not specifically limited here.
[0055] Optionally, when it is monitored that the operating system platform receives a memory application instruction from an application, at this time, the memory list included in the operating system platform can be detected to determine the status of the memory zones included in the memory list, that is, to determine whether there is a free memory zone in the memory zone.
[0056] For example, all memory zones in the kernel can be traversed to determine the status of each memory zone during the traversal process, and the memory zones in the free state can be determined as zone free.
[0057] Step S304, if the attribute value of the free memory space is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity allowed for storage operations of the free memory space.
[0058] In the technical solution provided in step S304 of the present application, after monitoring the memory space in the idle state in the operating system platform in response to a memory application instruction, if the attribute value of the memory space in the idle state is lower than the attribute threshold, at least one memory recovery operation can be controlled to be executed on the operating system platform. Among them, the attribute value can be used to characterize the size of the storage capacity allowed for storage operations in the memory space in the idle state. The attribute value can be the number of free pages, and can also be referred to as the number of free page frames or the number of idle page frames. The attribute threshold can also be referred to as the memory waterline, memory water level, memory low-level waterline, memory low water level, etc., and can be used to indicate whether the memory space is sufficient. For example, if the attribute value is lower than the attribute threshold, it can indicate that the memory space in the idle state is insufficient; if the attribute value is greater than or equal to the attribute threshold, it can indicate that the memory space in the idle state is sufficient. The memory recovery operation can also be referred to as a memory recovery behavior, and can include an asynchronous memory recovery stage, a memory compression (memory compaction) stage, and a memory direct recovery stage. It should be noted that the number of stages included in the above memory recovery operation and the operations performed in each stage are only for illustrative purposes and are not specifically limited here.
[0059] Optionally, after determining the memory space in the idle state from the kernel of the operating system platform, the number of pages of the memory space in the idle state can be determined, that is, the size of the attribute value, and the relationship between the attribute value and the attribute threshold can be judged. If the attribute value is less than the attribute threshold, it can indicate that the current idle memory is insufficient. At this time, corresponding memory recovery operations need to be executed to increase the memory.
[0060] Step S306, obtain the duration consumed by the operating system platform to execute the memory recovery operation.
[0061] In the technical solution provided in step S306 of the present application, after determining that the attribute value of the memory space in the idle state is lower than the attribute threshold and controlling the operating system platform to execute at least one memory recovery operation, the duration consumed by the operating system platform during the execution of the memory recovery operation can be obtained. Among them, the duration consumed by the execution of the memory recovery operation can be used to represent the delay consumption situation in each recovery stage of the memory recovery operation, and can also be referred to as the memory recovery delay.
[0062] Optionally, after it is monitored that the number of free pages in the memory range is lower than the memory low-level water level, the process of starting the memory recovery operation can be initiated, that is, the asynchronous memory recovery phase, the memory compaction phase, and the direct memory recovery phase can be entered. During this process, the tracking of the corresponding memory recovery-related functions can be started through the Extended Berkeley Packet Filter (EBPF for short) to calculate the duration consumed when performing the memory recovery operation. Among them, each phase included in the memory recovery operation includes an entry tracepoint and an exit tracepoint (tracepoint), and the entry tracepoint and the exit tracepoint can be collectively referred to as the entry / exit tracepoint.
[0063] It should be noted that the above process and method for calculating the duration consumed by the memory recovery operation are only for illustrative purposes and are not specifically limited here. As long as it is a process and method for calculating the duration consumed by the memory recovery operation to determine the latency consumption, it is within the protection scope of the embodiments of the present application.
[0064] For example, in the memory compaction phase, fragmented and discontinuous small memory pages can be migrated and merged into continuous larger memory pages. This phase is time-consuming. The entry / exit tracepoints of memory compression can be tracked and the corresponding latency consumption can be determined.
[0065] Step S308: Based on the duration, determine the latency duration for the application to apply for the required memory from the operating system platform.
[0066] In the technical solution provided in step S308 of the present application, after obtaining the duration consumed by the operating system platform when performing the memory recovery operation, the latency duration for the application to apply for the required memory from the operating system platform can be determined based on the duration. Among them, the latency duration can be used to represent the process memory application latency of the application, and can also be referred to as the process application latency metric or the process application memory latency metric.
[0067] Optionally, according to the duration consumed by each memory recovery phase determined in the memory recovery operation, the overall latency duration when the application applies for the required memory from the operating system platform can be determined. For example, the memory recovery latencies determined in the three memory recovery phases can be accumulated to obtain the final process memory application latency. It should be noted that the above process and method for determining the process memory application latency are only for illustrative purposes and are not specifically limited here. As long as it is a process and method that can quantitatively determine the latency duration based on the duration consumed by the memory recovery operation, it is within the protection scope of the embodiments of the present application.
[0068] Optionally, visualize the obtained memory latency metrics for the process.
[0069] In the related art, the Linux system does not have specific metrics to measure the latency consumption when an application requests memory during operation. In the actual operation of the application, due to the Linux memory allocation latency, application jitter problems may occur. In the related art, a weakly associated method can also be used to analyze the application. Through this method, the health of a single application can be measured from the perspective of the overall machine resources. However, this method is prone to problems such as misjudgment. Therefore, there is still a technical problem of low accuracy in determining the latency consumption of the Linux system.
[0070] However, in the embodiments of the present application, the free memory in the normal zone of the memory in Linux and the corresponding memory waterlines can be monitored regularly. Then, when memory is reclaimed, the latency consumption can be determined for stages such as asynchronous memory reclaim, memory compression, and direct memory reclaim. Since it is considered that the latency consumption can be obtained when memory is reclaimed, during the operation of the application, not only can it be determined whether latency consumption occurs when the application requests memory, but also how much latency consumption is generated when the application requests memory. Thus, the purpose of being able to quantitatively measure the latency consumption with a specific metric is achieved, and furthermore, the technical effect of improving the accuracy of determining the latency consumption of the Linux system is realized.
[0071] Since the OS needs to adopt the principle of deferred allocation when allocating memory to applications, the actual memory application occurs when the application needs to access memory. The OS generates a page fault exception, and then allocates memory page frames from the OS kernel memory subsystem. Generally, when there is sufficient memory, the application latency caused by the memory allocation process can be ignored. However, when there is insufficient memory, sufficient memory page frames can only be obtained through memory recycling, and the application latency caused by this may reach the millisecond or even second level. In this case, it will cause the technical problem of latency jitter for the application. However, in the embodiments of the present application, considering the above problems, during the monitoring of the running process of the application, the metrics of the latency consumed by the application's memory application can be visualized. During the running process of the application, when a memory application instruction is detected, the number of free pages in the normal zone memory range in the operating system platform can be monitored, and the number of free pages is compared with the memory low-level waterline. When it is lower than the memory low water level, the tracing of the memory recycling related functions can be started through EBPF, the latency of each memory recycling stage during the execution of the memory recycling operation can be calculated, and the final latency duration of the application's request for the required memory from the operating system platform can be determined, thus achieving the purpose of visualizing the latency metrics of the process's memory application, and further realizing the technical effect of avoiding latency jitter for the application.
[0072] Through the above steps S302 to S308 of the present application, the running process of the application can be monitored in real time to monitor whether a memory application instruction is generated on the operating system platform associated with the application. If there is no memory application instruction, it can be indicated that the current application has no need to apply for memory. At this time, the application can continue to be monitored. If there is, it can be indicated that the current application has a need to apply for memory. At this time, based on the memory application instruction, the status of the memory space in the operating system platform can be monitored to determine whether there is a free memory space in the included memory space. If there is a memory space in the free state, the storage capacity size allowed for storage operations by this memory space can be determined, that is, the comparison between the attribute value and the attribute threshold. If the attribute value is lower than the attribute threshold, at this time, the time consumed by the operating system platform to perform the memory recovery operation needs to be determined. And according to this time, the delay time that the application needs to delay when applying for memory from the operating system platform based on the memory application instruction can be determined. The embodiment of the present application can design a special delay metric for determining the delay when the application applies for memory, that is, the delay time, to accurately measure the delay problem when the application applies for memory, so as to achieve the purpose of effectively avoiding the jitter situation caused by memory allocation delay, and further achieve the technical effect of effectively monitoring the delay time when the application applies for memory, and solve the technical problem of being unable to effectively monitor the delay time when the application applies for memory.
[0073] The above method of this embodiment will be further introduced below.
[0074] As an optional implementation manner, in step S304, if the attribute value of the memory space in the free state is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, including: if the attribute value of the memory space in the free state is lower than the attribute threshold, control the operating system platform to call a memory recovery function to control the operating system platform to perform the memory recovery operation.
[0075] In this embodiment, if the attribute value of the memory space in the free state is lower than the attribute threshold, the operating system platform can be controlled to call a memory recovery function to perform the memory recovery operation, where the memory recovery function can be a function related to memory recovery.
[0076] Optionally, when the operating system platform receives a memory application instruction from an application, it can monitor the state of the memory space included in the operating system platform and determine the memory space in the idle state from its memory space. And it can judge the size relationship between the attribute value of the memory space in the idle state and the attribute threshold. If the attribute value is less than the attribute threshold, it can indicate that the memory in the operating system platform is insufficient at this time. At this time, it is necessary to control the operating system platform to perform corresponding memory recovery operations so that the memory required by the operating system platform based on the current memory application instruction is sufficient for the application to apply. If the attribute value is greater than or equal to the attribute threshold, the memory space in the idle state can be directly provided to the corresponding application.
[0077] Optionally, when it is determined that the attribute value of the memory space in the idle state is lower than the attribute threshold, at this time, the operating system platform can be controlled to start a memory recovery function through eBPF, and the memory recovery function is used to control the operating system platform to execute relevant stages in the memory recovery operation. And in the corresponding stage, the memory recovery function is used to track the tracepoints where the operating system platform is located.
[0078] For example, the number of free pages in the normal zone memory range and the memory low-level waterline can be monitored. If the number of free pages is lower than the memory low-level waterline, at this time, the system platform can be controlled to execute the asynchronous memory recovery stage, the memory compaction stage, and the direct memory recovery stage in the memory recovery operation. In this process, the tracking of memory recovery-related functions can be started through eBPF, and the entry tracepoints and exit tracepoints corresponding to the asynchronous memory recovery stage, the memory compaction stage, and the direct memory recovery stage in the memory recovery operation can be monitored.
[0079] It should be noted that the above process and method for controlling the operating system platform to execute the memory recovery operation, as well as the memory recovery function used, are only for illustrative purposes and are not specifically limited here. As long as it is a process and method that can monitor the duration consumed during the memory recovery operation, it is within the protection scope of the embodiments of the present application.
[0080] As an optional implementation manner, step S306 of obtaining the duration consumed by the operating system platform to execute the memory recovery operation includes: tracking the call process of the memory recovery function to obtain a first tracking result; and determining the duration consumed by the operating system platform to execute the memory recovery operation based on the first tracking result.
[0081] In this embodiment, the call process of the memory recycling function can be traced to obtain a first tracing result, and based on the first tracing result, the duration consumed by the memory recycling operation performed by the operating system platform can be determined, where the first tracing result can be used to represent the tracing of the exit tracing points and entry tracing points corresponding to each stage included in the memory recycling operation.
[0082] Optionally, for different stages in the memory recycling operation, corresponding memory recycling functions can be used for control. That is, by calling the corresponding memory recycling function, the operating system platform can be controlled to execute the stages in the corresponding memory recycling operation. The call process of the memory recycling function can be traced, that is, the tracing of the memory recycling-related functions can be started through eBPF, so as to obtain the first tracing result.
[0083] Optionally, if the operating system platform needs to execute the asynchronous memory recycling stage in the memory recycling operation, considering the blocking points in this asynchronous memory recycling stage, this stage can be divided into two cases: Integrated Recovery Unit (IRU) recycling and slab recycling. It is necessary to trace the above two cases respectively to obtain the final first tracing result, and respectively judge the duration consumed by the above two cases, so as to obtain the duration consumed by the entire asynchronous memory recycling stage.
[0084] Optionally, if the operating system platform needs to execute the memory compaction stage in the memory recycling operation, in this memory compaction stage, the discontinuous small memory pages in the operating system platform can be migrated and merged into continuous larger memory pages. This stage is time-consuming, and the first tracing result during memory compaction in this stage can be determined, that is, the exit tracing point and entry tracing point of memory compaction are traced, and based on the time of the above two tracing points, the duration consumed by the entire memory compaction stage is determined.
[0085] Optionally, if the operating system platform needs to execute the direct memory recycling stage in the memory recycling operation, the memory recycling time cost and recycling intensity of this direct memory recycling stage are higher than those of the asynchronous memory recycling stage and the memory compaction stage. Therefore, the latency consumption of the direct memory recycling stage is also higher than that of the asynchronous memory recycling stage and the memory compaction stage. The first tracing result during direct memory recycling in this stage can be determined, that is, the exit tracing point and entry tracing point of direct memory recycling are traced, and based on the time of the above two tracing points, the duration consumed by the entire direct memory recycling stage is determined.
[0086] As an alternative implementation, the first tracking result includes a first moment when the memory recovery operation starts to be executed and a second moment when the memory recovery operation ends. Among them, by tracking the calling process of the memory recovery function, the first tracking result is obtained, including: obtaining the process running state of the application; if the running state is the process blocked state, during the calling process of the memory recovery function, tracking the first moment when the memory recovery operation starts to be executed and the second moment when the memory recovery operation ends.
[0087] In this embodiment, during the process of tracking the calling process of the memory recovery function to obtain the first tracking result, the process running state of the application can be obtained, and it can be determined whether the process running state is the process blocked state. If so, during the calling process of the memory recovery function, the first moment when the memory recovery operation starts to be executed and the second moment when the memory recovery operation ends can be tracked, so as to obtain the first tracking result. Among them, the first tracking result may include the first moment and the second moment included in each stage during the execution of the memory recovery operation. The first moment may be the entry tracking point. The second moment may be the exit tracking point.
[0088] Optionally, if the operating system platform is in the asynchronous memory recovery stage during the execution of the memory recovery operation, this stage is essentially an asynchronous behavior and will not block the process of the application. However, possible blocking points need to be considered. For example, IRU recovery and slab recovery.
[0089] Optionally, when reclaiming memory pages in the IRU inactive (inactive integrated recovery unit) linked list, the application process may be blocked due to waiting for I / O. Therefore, it is necessary to use the memory recovery function of io_schedule for tracking, and the delay caused by IRU recovery can be obtained by finally screening the call stack of the data.
[0090] For example, for IRU recovery, the situation before and after the operation of this recovery stage can be tracked through the kernel debugging tool (kprobe), and the entry tracking point and the exit tracking point of this memory recovery stage can be tracked. That is, the entry tracking point is kprobe / io_schedule, the exit tracking point is retkprobe / io_schedule, the first moment corresponding to the entry tracking point is T1, and the second moment corresponding to the exit tracking point is T2.
[0091] Optionally, during the process of reclaiming some slabs, it will cause the situation of blocking the process of the application. Therefore, the entry tracking point and the exit tracking point of slab recovery can be tracked to obtain the final delay of this slab recovery stage.
[0092] For example, for slab recycling, the situations before and after the recycling stage can be monitored. Eventually, the entry tracepoint and the exit tracepoint of the slab recycling stage are traced. That is, the entry tracepoint is tracepoint / trace_mm_shrink_slab_start, and the first moment corresponding to the entry tracepoint can be T3. The exit tracepoint can be tracepoint / trace_mm_shrink_slab_end, and the second moment corresponding to the exit tracepoint can be T4.
[0093] It should be noted that the functions used to trace the entry tracepoint and the exit tracepoint as described above, and the setting of the corresponding tracepoint names are only for illustrative purposes and are not specifically limited here.
[0094] As an optional implementation, based on the first tracing result, determining the duration consumed by the operating system platform for performing the memory recycling operation includes: obtaining the interval duration between the second moment and the first moment; and determining the interval duration as the duration consumed by the operating system platform for performing the memory recycling operation.
[0095] In this embodiment, after obtaining the first moment and the second moment, the interval duration between the second moment and the first moment can be determined according to the first moment and the second moment, and the interval duration can be determined as the duration consumed by the operating system platform in the corresponding stage of performing the memory recycling operation.
[0096] Optionally, for the IRU recycling stage in the asynchronous memory recycling stage, the difference between the second moment and the first moment of this stage can be determined as the latency generated by the operating system platform when performing the IRU recycling stage, that is, the duration consumed.
[0097] For example, the first moment of the IRU recycling stage is T1, and the second moment is T2. Then (T2 - T1) can be determined as the latency generated by the IRU recycling, that is, the duration consumed by the IRU recycling stage.
[0098] Optionally, for the slab recycling stage in the asynchronous memory recycling stage, the difference between the second moment and the first moment of this stage can be determined as the latency generated by the operating system platform when performing the slab recycling stage, that is, the duration consumed.
[0099] For example, the first moment of the slab recycling stage is T3, and the second moment is T4. Then (T4 - T3) can be determined as the latency generated by the slab recycling, that is, the duration consumed by the slab recycling stage.
[0100] Optionally, for the memory compaction stage, the difference between the second moment and the first moment of this stage can be determined as the latency generated by the operating system platform when executing the memory compaction stage, that is, the duration consumed.
[0101] For example, if the first moment of the memory compaction stage is T5 and the second moment is T6, (T6 - T5) can be determined as the latency generated by the memory compaction stage, that is, the duration consumed by the memory compaction stage.
[0102] Optionally, for the memory direct reclaim stage, the difference between the second moment and the first moment of this stage can be determined as the latency generated by the operating system platform when executing the memory direct reclaim stage, that is, the duration consumed.
[0103] For example, if the first moment of the memory direct reclaim stage is T7 and the second moment is T8, (T8 - T7) can be determined as the latency generated by the memory direct reclaim stage, that is, the duration consumed by the memory direct reclaim stage.
[0104] As an optional implementation manner, during the call process of the memory reclaim function, the first moment when the memory reclaim operation starts to execute and the second moment when the memory reclaim operation ends are traced, including: tracing the entry trace point during the call process of the memory reclaim function to obtain the first moment; tracing the exit trace point during the call process of the memory reclaim function to obtain the second moment.
[0105] In this embodiment, the entry trace point during the call process of the memory reclaim function can be traced to obtain the first moment, or the exit trace point during the call process of the memory reclaim function can be traced to obtain the second moment. Among them, the entry trace point can be used to represent the time point when the corresponding stage of the memory reclaim operation starts to execute. The exit trace point can be used to represent the time point when the corresponding stage of the memory reclaim operation ends.
[0106] Optionally, for each stage in the memory reclaim operation executed by the operating system platform, the time point at which the moment when each stage starts to execute is located can be determined as the entry trace point, and this moment can be recorded as the first moment. The time point at which the moment when the corresponding stage ends is located can be determined as the exit trace point, and this moment can be recorded as the second moment.
[0107] Optionally, if the operating system is in the memory compaction stage of the memory reclaim operation, it can detect the situation before and after the memory compaction operation is executed in this stage. The operation of starting to execute the memory compaction can be determined as the entry trace point. That is, the entry trace point is tracepoint / trace_mm_compaction_begin, the exit trace point can be tracepoint / trace_mm_compaction_end, and the first moment corresponding to the entry trace point can be T5, and the second moment corresponding to the exit trace point can be T6.
[0108] Optionally, if the operating system is in the internal direct reclaim stage of the memory reclaim operation, it can detect the situation before and after the internal direct reclaim operation is executed in this stage. The operation of starting to execute the direct memory reclaim can be determined as the entry trace point. That is, the first moment corresponding to the entry trace point can be set as T7, and the entry trace point can be set as tracepoint / trace_mm_vmscan_direct_reclaim_begin. The exit trace point can be set as tracepoint / trace_mm_vmscan_direct_reclaim_end, and the second moment corresponding to the exit trace point can be determined as T8.
[0109] As an optional implementation manner, step S308, determining the delay duration for which the application delays in applying for the required memory from the operating system platform based on the duration, includes: obtaining the overlapping duration among the multiple durations corresponding to multiple memory reclaim operations; filtering out the overlapping duration from the multiple durations; and determining the delay duration based on the filtered multiple durations.
[0110] In this embodiment, in the process of determining the delay duration for which the application delays in applying for the required memory from the operating system platform according to the duration, the overlapping duration among the multiple durations corresponding to multiple memory reclaim operations can be obtained, the overlapping duration can be filtered out from the multiple durations, and the delay duration can be determined based on the filtered multiple durations. Among them, the overlapping duration can be the overlapping data in the memory reclaim operation process. For example, it can be the overlapping data between the asynchronous memory reclaim stage and the memory direct reclaim stage. The operation of filtering out the overlapping duration from the multiple durations can be a data cleaning operation.
[0111] Optionally, data cleaning operations can be performed on the durations obtained in the asynchronous memory recycling phase to filter out overlapping durations from the multiple obtained durations. That is, for the durations in the asynchronous memory recycling phase, it can be determined whether there are durations overlapping with those in the direct memory recycling phase among the determined durations. If there are, the overlapping durations can be excluded from the durations in the asynchronous memory recycling phase, and the latency duration can be determined from the remaining durations.
[0112] Optionally, obtain the IRU recycling call stack information and the slab recycling call stack information. Based on the above two call stack information, part of the data with call stacks containing direct memory recycling can be filtered out, and the filtered asynchronous memory recycling latency can be determined.
[0113] For example, by obtaining the data call stack captured in the asynchronous memory recycling phase, part of the data containing the direct memory recycling function in the call stack can be filtered out, so as to obtain the filtered latency duration, that is, T4 - T3 + T2 - T1. It should be noted that the above process and method of data cleaning are only for illustrative purposes and are not specifically limited here. As long as it is a process and method that can exclude the durations overlapping with those in the direct memory recycling phase from the durations obtained in the asynchronous memory recycling phase, it is within the protection scope of the embodiments of the present application.
[0114] As an optional implementation manner, based on the filtered multiple durations, determining the latency duration includes: accumulating the filtered multiple durations to obtain an accumulated duration; determining the latency duration based on the accumulated duration.
[0115] In this embodiment, the filtered durations can be accumulated to obtain an accumulated duration, and the accumulated duration can be determined as the latency duration, where the accumulated duration can also be referred to as latency data.
[0116] Optionally, the duration of the asynchronous memory recycling phase obtained after data cleaning can be accumulated with the duration of the memory compaction phase and the duration consumed in the direct memory recycling phase to obtain the final latency duration.
[0117] For example, the duration consumed in the asynchronous memory recycling phase is (T4 - T3 + T2 - T1), the duration consumed in the memory compaction phase is (T6 - T5), and the duration consumed in the direct memory recycling phase is (T8 - T7). Accumulating the durations consumed in the above three phases of the memory recycling operation, that is, accumulating all the memory recycling latencies, can obtain T8 - T7 + T6 - T5 + (T4 - T3 + T2 - T1).
[0118] As an alternative implementation, determining the delay duration based on the accumulated duration includes: determining, in the accumulated duration, the abnormal duration during which the application is in the major page fault state; and filtering out the abnormal duration from the accumulated duration to obtain the delay duration.
[0119] In this embodiment, during the process of determining the delay duration based on the accumulated duration, the abnormal duration during which the application is in the major page fault state can be determined from the accumulated duration, and the abnormal duration can be filtered out from the accumulated duration to obtain the final delay duration. Among them, the abnormal duration in the major page fault state can be the data of the process that has a major page fault.
[0120] In the embodiment of the present application, since it is necessary to ensure the accuracy of the determined delay duration, it is necessary to consider whether the accumulated duration is accurate, that is, whether there is a duration corresponding to the major page fault in the accumulated duration. If so, the abnormal duration corresponding to the major page fault state can be excluded, and thus the final accumulated duration after exclusion can be determined as the delay duration. Since the accuracy of the accumulated duration can be ensured, the technical effect of improving the accuracy of determining the delay duration can be achieved.
[0121] For example, the data of the process that has a major page fault can be screened out, and the process memory application delay of the application is T8 - T7 + T6 - T5 + (T4 - T3 + T2 - T1).
[0122] As an alternative implementation, the method further includes: determining the storage area where the memory space is located in the operating system platform; and determining an attribute threshold matching the storage area, where the attribute threshold is used to represent the minimum storage amount allowed for storage operations in the storage area.
[0123] In this embodiment, the storage area where the memory control is located in the operating system platform can be determined, and an attribute threshold matching the storage area can be determined. Among them, the attribute threshold can be used to represent the minimum storage amount allowed for storage operations in the storage area.
[0124] Optionally, the attribute threshold matching the threshold is determined from the size of the storage area in the kernel of the operating system platform.
[0125] For example, the attribute threshold can be determined based on the low memory water level value and the reserved memory.
[0126] For another example, the memory low level water line = low memory water level value + reserved memory.
[0127] As an alternative embodiment, the method further includes: calling a memory application function to apply for the memory required by the application program from the operating system platform; tracing the calling process of the memory application function to obtain a second tracing result; in response to the failure to obtain the duration consumed by the operating system platform for performing the memory recovery operation, determining the delay duration based on the second tracing result.
[0128] In this embodiment, a memory application function can be called to apply for the memory required by the application program from the operating system platform, the calling process of the memory application function can be traced to obtain a second tracing result, and when the duration consumed by the operating system platform for performing the memory recovery operation fails to be obtained, the delay duration can be determined based on the second tracing result, where the second tracing result can be used to represent the tracing of the entry and exit of the memory application function in the kernel by calling the memory application function.
[0129] In the embodiment of the present application, the second tracing result can be directly obtained by tracing the entry and exit of the memory application function in the kernel, that is, the entry tracing point and the exit tracing point of the calling process of the memory application function are traced, and the first moment corresponding to the entry tracing point and the second moment corresponding to the exit tracing point can be determined, and the delay duration can be determined by the difference between the second moment and the first moment.
[0130] In the embodiment of the present application, two methods can be designed to determine the delay duration. The first method can trace the calling process of the memory recovery function, determine the first moment and the second moment corresponding to each stage in the calling process, determine the duration consumed by each stage, and then accumulate to obtain the final delay duration. However, considering that if an exception occurs during the execution of the above method, for example, the calculation of the duration consumed by the memory recovery operation fails, the second method can be used to calculate the delay duration instead. That is, the entry and exit of the memory application function in the kernel of the operating system platform can be directly traced to obtain the memory application delay. However, although the second method is simple to operate and easy to implement, memory application is a hot path in the system, and there is an overhead of several tenths of a microsecond or even several microseconds at the tracing point itself, which will reduce the performance under normal memory application. Therefore, the second method can be set as a backup solution, and when the first method is abnormal, the second method can be urgently called to replace it to ensure the efficiency during the memory application process.
[0131] As an alternative embodiment, the method further includes: displaying the delay duration on the operation interface; and / or outputting a prompt message corresponding to the delay duration.
[0132] In this embodiment, the delay duration can be displayed on the operation interface, or a prompt message corresponding to the delay duration can be displayed on the operation interface, where the prompt message is used to issue an alarm.
[0133] Optionally, corresponding alarm rules can be configured for the operating system platform in advance. If a delay is detected, corresponding prompt messages can be sent on the operation interface of the terminal device corresponding to the application program to indicate the existence of a delay at this time.
[0134] Optionally, in order to more clearly display the measurement index for whether there is a delay consumption when applying for memory during the operation of the application program, it can be designed in a visual presentation manner. That is, the obtained delay duration can be transmitted to the operation interface for display through visual design. For example, the delay duration can be processed in various image forms and an image under a coordinate can be displayed on the operation interface, such as a line chart, etc.; or the delay duration can be displayed in digital form on the operation interface.
[0135] It should be noted that the above forms and methods for displaying the delay duration on the operation interface are only for illustrative purposes and are not specifically limited here. As long as the delay duration can be determined and visualized on the operation interface, the processes and methods are within the protection scope of the embodiments of the present application.
[0136] As an optional embodiment, at least one memory recycling operation includes at least one of the following: asynchronous memory recycling operation; memory compaction operation; memory direct recycling operation.
[0137] In this embodiment, at least one memory recycling operation may include at least one of the following: asynchronous memory recycling operation; memory compaction operation and memory direct recycling operation. Among them, the asynchronous memory recycling operation can be executed in the asynchronous memory recycling stage. The memory compaction operation can be executed in the memory compaction stage. The memory direct recycling operation can be executed in the memory direct recycling stage.
[0138] Optionally, in the case of memory recycling, the allocation memory page frame delay is generally at the level of a few tenths of a microsecond or a few microseconds, and its impact can be ignored. The allocation delay can be considered zero. When it comes to memory recycling, there will be non-negligible delays. Therefore, the embodiments of the present application need to calculate the delays brought during the memory recycling operation as the delays for the operating system platform to allocate memory for the application program.
[0139] Optionally, based on the above analysis, in order to ensure the accuracy of the calculation of the delay during the execution of the memory recycling operation, it is necessary to focus on considering the operations included in the memory recycling operation. That is, during the stages included in the execution of the memory recycling operation, it is necessary to determine the duration consumed by each stage, so as to accumulate the duration consumed by the entire memory recycling operation, and further ensure the accuracy of the determined delay duration.
[0140] An embodiment of the present application also provides a method for monitoring the latency duration of an application's memory application from the human-computer interaction side. Figure 4 FIG. Figure 4 is a flowchart of a method for monitoring the latency duration of an application's memory application according to an embodiment of the present application. As Figure 4 shown, the method may include the following steps:
[0141] Step S402, in response to a data monitoring instruction acting on the operation interface, determine the application to be monitored.
[0142] In the technical solution provided in step S402 of the present application above, according to the need to monitor whether there is a latency consumption when an application applies for memory from the operating system platform, corresponding operations may be performed on the operation interface to generate corresponding data monitoring instructions to determine the application to be monitored.
[0143] Optionally, if it is detected that a data monitoring instruction is generated on the operation interface, the applications associated with the current operating system platform may be monitored to detect whether the application has a need to start running, that is, it may be detected whether the application sends a program running instruction. When the program running instruction is detected, it may indicate that the application starts to run.
[0144] Step S404, in response to a program running instruction acting on the operation interface, control the application to run.
[0145] In the technical solution provided in step S404 of the present application above, when the program running instruction on the operation interface is detected, the application may be controlled to run.
[0146] Optionally, during the running of the application, it may be detected whether the application has a need to apply for memory space from the operating system platform associated with it, that is, it may be detected whether the application sends a memory application instruction to the operating system platform.
[0147] Step S406, in response to a memory application instruction generated by the application on the operating system platform, display the memory space in the idle state in the operating system platform on the operation interface.
[0148] In the technical solution provided in step S406 of the present application above, when the memory application instruction generated by the application on the operating system platform is detected, the memory space in the idle state in the operating system platform may be displayed on the operation interface.
[0149] Optionally, when it is monitored that the operating system platform receives a memory application instruction of an application, at this time, the memory list included in the operating system platform may be detected to determine the status of the memory areas included in the memory list, that is, to determine whether there is an idle memory area in the memory area.
[0150] Optionally, if the memory space in the idle state is determined based on the memory application instruction in the operating system platform, the memory space in the idle state can be displayed on the operation interface.
[0151] Step S408: If the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity that the memory space in the idle state allows for storage operations.
[0152] In the technical solution provided in step S408 of the present application, if the attribute value of the memory space in the idle state is lower than the attribute threshold, the operating system platform can be controlled to perform at least one memory recovery operation, where the attribute value can be used to represent the storage capacity that the memory space in the idle state allows for storage operations.
[0153] Optionally, after determining the memory space in the idle state from the kernel of the operating system platform, the number of pages of the memory space in the idle state can be determined, that is, the size of the attribute value, and the relationship between the attribute value and the attribute threshold can be judged. If the attribute value is less than the attribute threshold, it can indicate that the current idle memory is insufficient. At this time, corresponding memory recovery operations need to be performed to increase the memory.
[0154] In the embodiments of the present application, the idle memory in the normal zone of the memory in Linux and the corresponding memory waterlines can be monitored regularly. Then, when performing memory recovery, the delay consumption is determined for stages such as asynchronous memory recovery, memory compression, and direct memory recovery. Since it is considered that the delay consumption can be obtained when performing memory recovery, during the operation of the application program, not only can it be determined whether delay consumption occurs when the application program applies for memory, but also the amount of delay consumption generated can be determined when the application program applies for memory, thereby achieving the purpose of being able to quantitatively measure the delay consumption with a specific measurement index, and further realizing the technical effect of improving the accuracy of determining the delay consumption of the Linux system.
[0155] Step S410: Display on the operation interface the delay duration of the application program's delay in applying for the required memory from the operating system platform, where the delay duration is determined based on the duration consumed by the operating system platform to perform the memory recovery operation.
[0156] In the technical solution provided in step S410 of the present application, the delay duration of the application program's delay in applying for the required memory from the operating system platform can be displayed on the operation interface, where the delay duration can be determined based on the duration consumed by the operating system platform to perform the memory recovery operation.
[0157] Optionally, after detecting that the number of free pages in the memory range is lower than the memory low-level watermark, the process of starting the memory recycling operation can be initiated, that is, the asynchronous memory recycling phase, the memory compaction phase, and the direct memory recycling phase can be entered. During this process, the tracing of the corresponding memory recycling-related functions can be started through eBPF to calculate the duration consumed when performing the memory recycling operation.
[0158] Optionally, based on the determined duration consumed in each memory recycling phase during the execution of the memory recycling operation, the overall latency duration when the application program requests the required memory from the operating system platform can be determined. For example, the memory recycling latencies determined in the three memory recycling phases can be accumulated to obtain the final process memory application latency.
[0159] Optionally, after determining the latency duration based on the above steps, it can be sent to the operation interface and visually displayed on the operation interface.
[0160] Through the above steps S402 to S410 of this application, in response to the data monitoring instruction on the operation interface, the application program to be monitored is determined; in response to the program running instruction on the operation interface, the application program is controlled to run; in response to the memory application instruction generated by the application program on the operating system platform, the memory space in the idle state in the operating system platform is displayed on the operation interface; if the attribute value of the memory space in the idle state is lower than the attribute threshold, the operating system platform is controlled to perform at least one memory recycling operation, where the attribute value is used to represent the storage capacity that the memory space in the idle state allows for storage operations; the latency duration of the application program's request for the required memory from the operating system platform is displayed on the operation interface, where the latency duration is determined based on the duration consumed by the operating system platform to perform the memory recycling operation, thereby achieving the technical effect of being able to effectively monitor the latency duration when the application program applies for memory, and solving the technical problem of being unable to effectively monitor the latency duration when the application program applies for memory.
[0161] The embodiment of this application also provides a data monitoring method for an application program to apply for memory. Figure 5 It is a flowchart of a data monitoring method for an application program to apply for memory according to an embodiment of this application, as Figure 5 shown, this method may include the following steps:
[0162] Step S502, determine the identification information of the application program to be monitored by calling the first interface, where the first interface includes a first parameter, and the parameter value of the first parameter is the identification information.
[0163] In the technical solution provided in step S502 of the present application, the identification information of the application to be monitored can be determined by calling the first interface. The first interface may include a first parameter, and the parameter value of the first parameter may be a representation information. The identification information can be used to mark different applications. For example, each application can be numbered. It should be noted that the above identification information is only for illustrative purposes and is not specifically limited here.
[0164] Optionally, each application can be numbered in advance to obtain the corresponding identification information. Through the identification information, the memory application requirements of different applications and the operation requirements of different applications can be reflected.
[0165] Step S504, during the running of the application, based on the identification information, in response to the memory application instruction generated by the application on the operating system platform, monitor the memory space in the idle state in the operating system platform.
[0166] In the technical solution provided in step S504 of the present application, during the running of the application, it can be monitored in real time whether the application generates a memory application instruction on the operating system platform.
[0167] Optionally, by detecting the obtained identification information, information such as the running state of the application and whether there is a need for memory application can be determined. If it is determined through the identification information that the application is in the running state, the application can be monitored to determine whether a memory application instruction is generated on the operating system platform.
[0168] Optionally, during the running of the application, if there is a need to apply for memory, corresponding operations can be executed to generate a memory application instruction. And the application can be controlled to send the memory application instruction to the corresponding operating system platform.
[0169] Optionally, during the running of the application, real-time monitoring can be performed through the kernel in the operating system platform to determine whether a memory application instruction of a certain application is received.
[0170] Optionally, after it is monitored that a memory application instruction is generated by the application on the operating system platform during the running of the application, based on the memory application instruction, monitor the memory space in the idle state in the operating system platform.
[0171] Optionally, when it is monitored that the operating system platform receives a memory application instruction of an application, at this time, the memory list included in the operating system platform can be detected to determine the state of the memory area included in the memory list, that is, to determine whether there is an idle memory area in the memory area.
[0172] Optionally, all memory zones in the kernel can be traversed to determine the status of each memory zone during the traversal process, and the memory zones in the idle state can be determined as zone free.
[0173] Step S506, if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recycling operation, where the attribute value is used to characterize the storage capacity that the memory space in the idle state allows for storage operations.
[0174] In the technical solution provided in step S506 of the present application above, after monitoring the memory space in the idle state in the operating system platform in response to a memory application instruction, if the attribute value of the memory space in the idle state is lower than the attribute threshold, the operating system platform can be controlled to perform at least one memory recycling operation.
[0175] Optionally, after determining the memory space in the idle state from the kernel of the operating system platform, the number of pages of the memory space in the idle state can be determined, that is, the size of the attribute value, and the relationship between the attribute value and the attribute threshold can be judged. If the attribute value is less than the attribute threshold, it can be explained that the current memory in the idle state is insufficient. At this time, corresponding memory recycling operations need to be performed to increase the memory to ensure that there is memory of the required size that matches the received memory application instruction.
[0176] Step S508, obtain the duration consumed by the operating system platform to perform the memory recycling operation.
[0177] In the technical solution provided in step S508 of the present application above, after determining that the attribute value of the memory space in the idle state is lower than the attribute threshold and controlling the operating system platform to perform at least one memory recycling operation, the duration consumed by the operating system platform during the execution of this memory recycling operation can be obtained.
[0178] Optionally, after monitoring that the number of free pages in the memory range is lower than the memory low-level water level, the process of performing the memory recycling operation can be started, that is, the asynchronous memory recycling stage, the memory compaction stage, and the direct memory recycling stage can be entered. During this process, the tracing of the corresponding memory recycling-related functions can be started through EBPF to calculate the duration consumed when performing the memory recycling operation.
[0179] Step S510, based on the duration, determine the delay duration for the application program to apply for the required memory from the operating system platform.
[0180] In the technical solution provided in step S510 of the present application, after obtaining the duration consumed by the operating system platform when performing memory recycling operations, the delay duration for the application to apply to the operating system platform for the required memory can be determined based on the duration.
[0181] Optionally, according to the duration consumed by each memory recycling stage in the determined memory recycling operation, the overall delay duration when the application applies to the operating system platform for the required memory can be determined. For example, the memory recycling delays determined in the three memory recycling stages can be accumulated to obtain the final process memory application delay.
[0182] Step S512, output the delay duration by calling the second interface, where the second interface includes a second parameter, and the parameter value of the second parameter is the delay duration.
[0183] In the technical solution provided in step S512 of the present application, the delay duration can be output by calling the second interface, where the second interface can include a second parameter, and the parameter of the second parameter can be the delay duration.
[0184] Optionally, the delay duration can be passed to the operation interface through the second interface, and the delay duration can be visually presented on the operation interface.
[0185] Through steps S502 to S512 of the present application, the identification information of the application to be monitored is determined by calling the first interface, where the first interface includes a first parameter, and the parameter value of the first parameter is the application; during the operation of the application, based on the identification information, in response to the memory application instruction generated by the application on the operating system platform, monitor the memory space in the operating system platform that is in the idle state; if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recycling operation, where the attribute value is used to represent the storage amount that the memory space in the idle state allows for storage operations; obtain the duration consumed by the operating system platform to perform the memory recycling operation; based on the duration, determine the delay duration for the application to apply to the operating system platform for the required memory; output the delay duration by calling the second interface, where the second interface includes a second parameter, and the parameter value of the second parameter is the delay duration, thereby achieving the technical effect of being able to effectively monitor the delay duration when the application applies for memory, and solving the technical problem of being unable to effectively monitor the delay duration when the application applies for memory.
[0186] Embodiment 2
[0187] According to the embodiments of the present application, an embodiment of an application data monitoring system is also provided. Figure 6Schematic diagram of a data monitoring system for an application program according to an embodiment of the present application, as Figure 6 shown, the data monitoring system 600 of the application program may include: a terminal device 601 and a server 602.
[0188] The terminal device 601 is used to upload the identification information of the application program to be monitored.
[0189] In this embodiment, the identification information of the application program to be monitored can be uploaded through the terminal device 601.
[0190] Optionally, an application program with unique identification information can be deployed in the terminal device. Through the one-to-many association between the terminal device and the server, the server can monitor the identification information uploaded by the terminal device to analyze whether the application program corresponding to the received identification information is in a running state and whether it has a need to apply for memory from the operating system platform.
[0191] The server 602 is used to, during the running of the application program, in response to a memory application instruction generated by the application program on the operating system platform, monitor the memory space in the operating system platform that is in an idle state; if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity of the memory space in the idle state that allows storage operations; obtain the duration consumed by the operating system platform to perform the memory recovery operation; and based on the duration, determine the delay duration of the application program's delay in applying for the required memory from the operating system platform.
[0192] In this embodiment, after the server 602 receives the identification information sent by the terminal device 601, it can analyze whether the application program corresponding to the identification information is in a running process. If it is in a running process, it can monitor whether the application program has a memory application instruction on the operating system platform. If so, it can, based on the memory application instruction, monitor the memory space in the operating system platform that is in an idle state. And it can monitor the attribute value of the memory space in the idle state to determine whether the attribute value is lower than the attribute threshold. If the attribute value is lower than the attribute threshold, it can indicate that the memory is insufficient at this time, and it can control the operating system platform to perform the corresponding memory recovery operation to increase the memory in the operating system platform, and can obtain the duration consumed by performing the memory recovery operation, and thus can determine the delay duration.
[0193] Optionally, during the running of the application program, if there is a need to apply for memory, corresponding operations can be executed to generate a memory application instruction. And it can control the application program to send the memory application instruction to the corresponding operating system platform.
[0194] Optionally, the memory manager can divide the physical memory of the operating system platform into different zones, and each zone has an associated zonelist. The zonelist is a doubly linked list and can contain multiple zones. Each zone represents a continuous area in a segment of physical memory. Each zone has different characteristics and uses. For example, the direct memory access zone (zone_DMA), the normal zone (zone_Normal), and the high memory zone (zone_highmem). These zones may have different access permissions, mapping methods, or available memory sizes, etc.
[0195] Optionally, when it is detected that the operating system platform receives a memory application instruction from an application, the memory list included in the operating system platform can be detected at this time to determine the status of the memory areas included in the memory list, that is, to determine whether there are free memory areas in the memory area.
[0196] Optionally, after determining the free memory space in the kernel of the operating system platform, the number of pages of the free memory space can be determined, that is, the size of the attribute value, and the relationship between the attribute value and the attribute threshold can be judged. If the attribute value is less than the attribute threshold, it can be explained that the current free memory is insufficient. At this time, corresponding memory recycling operations need to be performed to increase the memory.
[0197] Optionally, after detecting that the number of free pages in the memory range is lower than the low-level watermark of the memory, the process of performing the memory recycling operation can be started, that is, the asynchronous memory recycling stage, the memory compaction stage, and the direct memory recycling stage can be entered. During this process, the tracing of the corresponding memory recycling-related functions can be started through EBPF to calculate the duration consumed when performing the memory recycling operation.
[0198] Optionally, according to the duration consumed in each memory recycling stage determined in the memory recycling operation, the overall delay duration when the application program applies for the required memory from the operating system platform can be determined. For example, the memory recycling delays determined in the three memory recycling stages can be accumulated to obtain the final process memory application delay.
[0199] In this embodiment, a data monitoring system for an application program is provided. The identification information of the application program to be monitored is uploaded through a terminal device; during the running of the application program by a server, the memory application instructions generated by the application program on the operating system platform are monitored; in response to the memory application instructions, the memory space in the idle state in the operating system platform is monitored; if the attribute value of the memory space in the idle state is lower than the attribute threshold, the operating system platform is controlled to perform at least one memory recovery operation, where the attribute value is used to represent the storage amount that the memory space in the idle state allows for storage operations; the duration consumed by the operating system platform to perform the memory recovery operation is obtained; based on the duration, the delay duration of the application program to apply for the required memory from the operating system platform is determined, thereby achieving the technical effect of being able to effectively monitor the delay duration when the application program applies for memory, and solving the technical problem that the delay duration when the application program applies for memory cannot be effectively monitored.
[0200] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application, for example, the data for verification, are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.
[0201] Embodiment 3
[0202] Currently, there is no specific measurement index in the Linux system to measure the delay consumption when an application applies for memory during operation. In the actual operation and maintenance process, due to the application jitter problem caused by the kernel memory allocation delay, the existing analysis method is to adopt a weakly associated method, that is, to measure the health of a single application from the perspective of the overall machine resources, which is prone to misjudgment. Therefore, there is still a technical problem that the delay duration when the application program applies for memory cannot be effectively monitored.
[0203] During the running of an application, the application's request for heap memory is a relatively frequent operation. Generally, the OS allocates memory to the application following the principle of deferred allocation. Therefore, the actual memory request occurs when the application needs to access memory, causing a page fault exception in the system, and then allocating a memory page frame from the OS kernel memory subsystem. Generally, when there is sufficient memory, the application latency caused by this allocation process can be ignored. However, in the case of insufficient memory, enough memory page frames can only be obtained after memory recycling, and the resulting application latency may reach the millisecond or even second level. In this case, it will bring the problem of application latency jitter, affecting service continuity. Therefore, in the daily monitoring of application running processes, visualizing the application memory request latency consumption metric is quite important.
[0204] In related technologies, there is currently no specific metric in the Linux system to measure whether there is latency consumption and how much latency consumption is generated when an application requests memory during its running process. Even in actual operation and maintenance processes, the existing analysis method uses a weakly correlated approach. For example, when an application is abnormal, then check whether the overall machine memory water level has dropped or suddenly risen, or check whether there are memory recycling-related statistical counts in the corresponding time interval (at the 10-minute level) through system monitoring commands. If so, it is considered that the abnormality may be caused by insufficient memory and memory recycling. This discrimination method measures the health of a single application from the perspective of the overall machine resources and is prone to misjudgment because when the system performs memory recycling, the application may not have a memory request requirement, so the abnormality may be caused by other reasons. Therefore, there is still a technical problem that the latency duration when an application requests memory cannot be effectively monitored.
[0205] Furthermore, this application provides a method for measuring the latency of a Linux system application's request for heap memory. This method solves the technical problem that the latency duration when an application requests memory cannot be effectively monitored. Different from the traditional solution that only measures the health of an application from the perspective of the overall machine resources, there will be situations such as misjudgment and low accuracy, and it solves the technical problem that the latency duration when an application requests memory cannot be effectively monitored.
[0206] In an embodiment of the present application, the running process of an application can be monitored in real time to monitor whether a memory application instruction is generated on the operating system platform associated with the application. If so, it can indicate that the current application has a need to apply for memory. At this time, based on the memory application instruction, the status of the memory space in the operating system platform can be monitored to determine whether there is a memory space in the idle state in the included memory space. If there is a memory space in the idle state and the attribute value of the memory space in the idle state is lower than the attribute threshold, it is necessary to determine the time required for the operating system platform to perform the memory recovery operation at this time. And according to this time, the delay time that the application needs to delay when applying for the memory from the operating system platform based on the memory application instruction can be determined. The embodiment of the present application can design a delay metric specifically for determining the delay when an application applies for memory, that is, the delay time, to accurately measure the delay problem when the application applies for memory, so as to achieve the purpose of effectively avoiding the jitter caused by memory allocation delay, and then realize the technical effect of effectively monitoring the delay time when the application applies for memory, and solve the technical problem that the delay time when the application applies for memory cannot be effectively monitored.
[0207] The above method of this embodiment will be further introduced below.
[0208] In this embodiment, Figure 7 is a flowchart of a method for allocating page frames in the kernel of an operating system platform according to an embodiment of the present application, as Figure 7 shown, the method may include the following steps:
[0209] Step S701, traverse the memory area in the operating system platform to obtain the memory area in the idle state.
[0210] In the technical solution provided in step S701 of the present application above, the memory area in the operating system platform can be traversed to determine the memory area in the idle state.
[0211] Optionally, during the running process of the application, if there is a need to apply for memory, corresponding operations can be executed to generate a memory application instruction. And the application can be controlled to send the memory application instruction to the corresponding operating system platform.
[0212] Optionally, when it is monitored that the operating system platform receives a memory application instruction of an application, the memory list included in the operating system platform can be detected at this time to determine the status of the memory area included in the memory list, that is, to determine whether there is a memory area in the idle state in the memory area.
[0213] Optionally, all memory zones in the kernel of the operating system platform can be traversed to determine the status of each memory zone during the traversal, and the memory zones in the free state can be determined as zone free.
[0214] Step S702, determine whether the number of free page frames is less than the memory water level.
[0215] In the technical solution provided in step S702 of the present application, it can be determined whether the number of free page frames in the free memory space is less than the memory water level. If so, step S703 can be executed; otherwise, step S713 can be executed.
[0216] Optionally, the memory low-level water line = low-level memory water level value + reserved memory, that is, the memory water level is the sum of the low-level water level and the reserved memory.
[0217] Step S703, start memory recycling.
[0218] In the technical solution provided in step S703 of the present application, since the number of free page frames < memory water level, it can be indicated that the memory in the operating system platform is insufficient at this time. Then, more memory can be recalled by starting the memory recycling operation to provide it to the corresponding application programs.
[0219] Step S704, determine whether the number of free page frames is greater than the memory water level.
[0220] In the technical solution provided in step S704 of the present application, after starting the memory recycling process, it can be monitored whether the number of free page frames corresponding to the memory in the free state after memory recycling is greater than the memory water level. If so, step S713 can be executed; otherwise, step S705 can be executed.
[0221] Step S705, whether the memory area has been traversed.
[0222] In the technical solution provided in step S705 of the present application, it can be detected whether the memory area in the operating system platform has been traversed. If so, step S706 can be executed; otherwise, the traversal can be continued for the untraversed memory area, that is, step S710 can be executed.
[0223] Step S706, memory compaction operation.
[0224] In the technical solution provided in step S706 of the present application, during the memory compaction stage, fragmented and discontinuous small memory pages can be migrated and merged into continuous larger memory pages. This stage is time-consuming. The inlets and outlets of memory compression can be traced by tracepoint points, and the corresponding latency consumption can be determined.
[0225] Optionally, if the operating system performs memory compaction during the memory reclaim operation, it can detect the situation before and after the memory compaction operation is executed in this stage. The operation of starting to execute memory compaction can be determined as the entry tracepoint, that is, the entry tracepoint is tracepoint / trace_mm_compaction_begin, and the exit tracepoint can be tracepoint / trace_mm_compaction_end. Moreover, the first moment corresponding to the entry tracepoint can be T5, and the second moment corresponding to the exit tracepoint can be T6.
[0226] Step S707, whether a memory page is obtained.
[0227] In the technical solution provided in step S707 of the present application, it can be monitored whether a memory page is obtained. If so, it can end. Otherwise, step S708 can be executed.
[0228] Step S708, memory direct reclaim operation.
[0229] In the technical solution provided in step S708 of the present application, if the operating system platform needs to execute the memory direct reclaim stage in the memory reclaim operation, the memory reclaim time cost and the reclaim intensity in this memory direct reclaim stage are higher than those in the asynchronous memory reclaim stage and the memory compaction stage. Therefore, the latency consumption in the memory direct reclaim stage is also higher than that in the asynchronous memory reclaim stage and the memory compaction stage. It can be determined to trace the exit tracepoint and the entry tracepoint during the memory direct reclaim in this stage, and based on the times of the above two tracepoints, the duration consumed by the entire memory direct reclaim stage can be determined.
[0230] Step S709, whether a memory page is obtained.
[0231] In the technical solution provided in step S709 of the present application, it can be monitored whether a memory page is obtained. If so, it can end. Otherwise, step S710 can be executed.
[0232] Step S710, release memory.
[0233] In the technical solution provided in step S710 of the present application, at this time, the memory is out of memory (abbreviated as OOM), and the memory in the operating system platform needs to be released.
[0234] Step S711, determine whether there are no killable processes.
[0235] In the technical solution provided in step S711 of the present application, it is possible to detect whether there is no process to be killed in the application. If so, step S712 can be executed; otherwise, step S713 can be executed.
[0236] Step S712: Send a message indicating a kernel error.
[0237] In the technical solution provided in step S712 of the present application, it indicates a kernel error in the operating system platform at this time. Corresponding prompt information can be sent to prompt the kernel error situation at this time, facilitating relevant staff to troubleshoot and solve the kernel error in the operating system platform.
[0238] Step S713: Obtain memory pages.
[0239] In the technical solution provided in step S713 of the present application, memory pages can be obtained, that is, according to the memory size requirement for applying memory of the corresponding application, the corresponding memory pages are obtained.
[0240] In this embodiment, Figure 8 is a schematic diagram of a method for measuring the heap memory application delay of the kernel of an operating system platform according to an embodiment of the present application. As Figure 8 shown, the method may include the following steps:
[0241] Step S801: Monitor whether the memory area in the idle state is lower than the memory water level.
[0242] In the technical solution provided in step S801 of the present application, it is possible to monitor whether the memory area in the idle state is lower than the memory digit, that is, it is possible to monitor the number of free pages in the normal zone memory area and the memory low-level water line. When the number of free pages is lower than the memory low-level water level, the tracking of the memory recovery-related function can be started through EBPF, that is, the process of the memory recovery operation can be determined, and step S703 can be executed. And during the process of the application applying for memory, the major pagefault count of the specified process can be monitored.
[0243] Step S802: Start EBPF to track memory recovery-related functions.
[0244] In the technical solution provided in step S802 of the present application, after it is monitored that the number of free pages in the memory range is lower than the memory low-level water level, the process of starting and executing the memory recovery operation can be achieved by controlling the EBPF to trace the memory recovery-related functions. That is to say, the asynchronous memory recovery stage, the memory compaction stage, and the direct memory recovery stage can be entered. During this process, the corresponding memory recovery-related functions can be traced by EBPF to calculate the duration consumed when executing the memory recovery operation.
[0245] Optionally, as Figure 8 shown, if it is necessary to execute the asynchronous memory recovery stage in the memory recovery operation on the control operating system platform, considering the blocking points in this asynchronous memory recovery stage, this stage can be divided into two cases: IRU recovery and slab recovery. It is necessary to trace the above two cases separately to obtain the final first moment and second moment.
[0246] Optionally, as Figure 8 shown, for IRU recovery, the situation before and after the operation of this recovery stage can be traced through the kernel debugging tool (kprobe), and the entry tracepoint and exit tracepoint of this memory recovery stage can be traced. That is, the entry tracepoint is kprobe / io_schedule, the exit tracepoint is retkprobe / io_schedule, the first moment corresponding to the entry tracepoint is T1, and the second moment corresponding to the exit tracepoint is T2.
[0247] Optionally, as Figure 8 shown, for slab recovery, the situation before and after the operation of this recovery stage can be monitored, and finally the entry tracepoint and exit tracepoint of this slab recovery stage can be obtained. That is, the entry tracepoint is tracepoint / trace_mm_shrink_slab_start, and the first moment corresponding to the entry tracepoint can be T3, the exit tracepoint can be tracepoint / trace_mm_shrink_slab_end, and the second moment corresponding to the exit tracepoint can be T4.
[0248] Optionally, as Figure 8As shown, if the operating system is in the internal direct reclaim phase of the memory reclaim operation, it can detect the situation before and after the internal direct reclaim operation in this phase. The moment when the direct memory reclaim operation starts can be determined as the entry trace point. That is, the entry trace point can be set to tracepoint / trace_mm_vmscan_direct_reclaim_begin, and the first moment corresponding to the entry trace point can be set to T7. The second moment corresponding to the exit trace point can be determined as T8, and the exit trace point can be set to tracepoint / trace_mm_vmscan_direct_reclaim_end.
[0249] Optionally, two methods are designed to determine the delay duration. The first method can trace the call process of the memory reclaim function. By determining the first moment and the second moment corresponding to each phase in this call process, the duration consumed by each phase is determined, and then the final delay duration is obtained by accumulation. However, considering that if an exception occurs during the execution of the above method, for example, the calculation of the duration consumed by the memory reclaim operation fails, the second method can be used to calculate the delay duration instead. That is, the entry and exit of the memory application function in the kernel of the operating system platform can be directly traced to obtain the memory application delay. However, although the second method is simple to operate and easy to implement, memory application is a hot path in the system, and the trace point itself has an overhead of several tenths of a microsecond or even several microseconds, which will reduce the performance under normal memory application. Therefore, the second method can be set as an alternative solution, and in the case of an exception in the first method, the second method can be urgently called to replace it to ensure the efficiency during the memory application process.
[0250] Optionally, obtain the IRU reclaim call stack information and the slab reclaim call stack information. Based on the above two call stack information, the part of the data in the call stack that contains direct memory reclaim can be filtered out, and the asynchronous memory reclaim delay after filtering can be determined.
[0251] Step S803, data cleaning in the asynchronous memory reclaim phase.
[0252] In the technical solution provided in step S803 of the present application, data cleaning operations can be performed on the duration obtained in the asynchronous memory reclaim phase to filter out the overlapping duration from the obtained multiple durations. That is, for the duration in the asynchronous memory reclaim phase, it can be determined whether there is a duration that overlaps with the direct memory reclaim phase among the determined durations. If so, the overlapping duration can be removed from the duration in the asynchronous memory reclaim phase, and the delay duration can be determined from the remaining duration.
[0253] Optionally, as Figure 8As shown, obtain the IRU recycling call stack information, obtain the slab recycling call stack information. Based on the above two call stack information, part of the data with the call stack containing direct memory recycling can be filtered out, and the filtered asynchronous memory recycling latency can be determined.
[0254] For example, obtaining the data call stack captured during the asynchronous memory recycling phase can filter out part of the data in the call stack that contains the direct memory recycling function, thereby obtaining the filtered latency duration, that is, T4 - T3 + T2 - T1. It should be noted that the above process and method of data cleaning are only for illustrative purposes and are not specifically limited here. As long as the process and method can eliminate the duration overlapping with the duration in the direct memory recycling phase from the duration obtained during the asynchronous memory recycling phase, they are within the protection scope of the embodiments of this application.
[0255] Optionally, the duration consumed during the asynchronous memory recycling phase is (T4 - T3 + T2 - T1), the duration consumed during the memory compaction phase is (T6 - T5), and the duration consumed during the direct memory recycling phase is (T8 - T7). Adding up the durations consumed in the above three phases of the memory recycling operation, that is, adding up all the memory recycling latencies, can obtain T8 - T7 + T6 - T5 + (T4 - T3 + T2 - T1).
[0256] Step S804, determine the memory recycling latency.
[0257] In the technical solution provided in step S804 of this application above, the memory recycling latency can be determined, that is, the latency time of the memory recycling latency.
[0258] Step S805, monitor the specified process to count the major page fault processes.
[0259] In the technical solution provided in step S805 of this application above, the counting situation of the specified process for the major page fault processes can be monitored. That is, during the process of determining the latency duration based on the accumulated duration, the abnormal duration when the application program is in the major page fault state can be determined from the accumulated duration, and the abnormal duration can be filtered out from the accumulated duration to obtain the final latency duration.
[0260] Step S806, filter out the latency data with the process context being the specified process.
[0261] In the technical solution provided in step S806 of this application above, the latency quantity with the process context being the specified process can be filtered out.
[0262] Step S807, determine the process memory application latency.
[0263] In the technical solution provided in step S807 of the present application, based on the above-mentioned delay quantity and the memory recovery delay, the final process memory application delay can be obtained.
[0264] For example, the data of the process with a major page fault exception can be filtered out, and the process memory application delay of the application program is T8 - T7 + T6 - T5 + (T4 - T3 + T2 - T1).
[0265] Optionally, the process memory application delay can be presented in a visual manner on the operation interface. That is, the obtained delay duration can be transmitted to the operation interface for display through visual design. For example, the delay duration can be processed in various image forms and an image under a coordinate can be displayed on the operation interface, such as a line chart.
[0266] For example, Figure 9 is a schematic diagram of visually displaying the delay duration according to an embodiment of the present invention. As Figure 9 shown, if the application program is Mysql, the Mysql application OS memory delay can be displayed on the operation interface, and the data of the process memory application delay of the application program within a period of time can be depicted in a grid-shaped horizontal and vertical coordinate graph. The abscissa is the time when the delay occurs, for example, from 00:00 on September 5, 2023 to 00:00 on September 9, 2023, and the ordinate is the duration of the delay, for example, 0ms, 1ms, 2ms, 3ms, and 4ms. During the operation of Mysql, if it needs to apply for memory from the OS, the corresponding line chart can be recorded and drawn in this image. For example, at 09:00:00 on September 5, 2023, a memory delay occurred, and the memory delay was specifically 2ms long. After recording the memory delay situation for a period of time, the minimum value (Min), average value (Mean), and maximum value (Max) of the memory delay within this period can be calculated. For example, Figure 9 within the 5 days when Mysql runs in , the minimum value of the memory delay is 0ms, the average value is 0.00628ms, and the maximum value is 2.30ms.
[0267] It should be noted that the above forms and methods of displaying the delay duration on the operation interface are only for illustrative purposes and are not specifically limited here. As long as the delay duration can be determined and visualized on the operation interface, the processes and methods are within the protection scope of the embodiments of the present application.
[0268] In an embodiment of the present application, the running process of an application can be monitored in real time to monitor whether a memory application instruction is generated on the operating system platform associated with the application. If there is no memory application instruction, it can be indicated that the current application has no need to apply for memory, and at this time, the application can continue to be monitored. If there is, it can be indicated that the current application has a need to apply for memory. At this time, based on the memory application instruction, the state of the memory space in the operating system platform can be monitored to determine whether there is a free memory space in the included memory space. If there is a memory space in the free state, the storage capacity allowed for storage operations by this memory space can be determined, that is, the comparison between the attribute value and the attribute threshold. If the attribute value is lower than the attribute threshold, at this time, it is necessary to determine the duration required for the operating system platform to perform the memory recovery operation. And according to this duration, the delay duration that the application needs to delay when applying for memory from the operating system platform based on the memory application instruction can be determined. Since it is considered that the related technology only measures the health of the application from the perspective of the overall machine resources, there will be situations such as misjudgment and low accuracy. However, the embodiment of the present application can design a special delay metric for determining the application's memory application, that is, the delay duration, to accurately measure the delay problem when the application applies for memory, so as to achieve the purpose of effectively avoiding the jitter situation caused by memory allocation delay, and further realizing the technical effect of effectively monitoring the delay duration when the application applies for memory, and solving the technical problem of being unable to effectively monitor the delay duration when the application applies for memory.
[0269] Embodiment 4
[0270] According to an embodiment of the present application, there is also provided an apparatus for monitoring data of an application for implementing the method for monitoring data of an application as described above Figure 3 shown.
[0271] Figure 10 is a schematic diagram of an apparatus for monitoring data of an application according to an embodiment of the present application. As Figure 10 shown, the apparatus 1000 for monitoring data of an application may include: a first monitoring unit 1002, a first control unit 1004, a first obtaining unit 1006, and a first determining unit 1008.
[0272] The first monitoring unit 1002 is configured to monitor, during the running of the application, a memory space in the free state in the operating system platform in response to a memory application instruction generated by the application on the operating system platform.
[0273] The first control unit 1004 is configured to control the operating system platform to perform at least one memory recovery operation if the attribute value of the memory space in the idle state is lower than the attribute threshold, where the attribute value is used to characterize the storage capacity of the memory space in the idle state that allows storage operations.
[0274] The first acquisition unit 1006 is configured to acquire the duration consumed by the operating system platform to perform the memory recovery operation.
[0275] The first determination unit 1008 is configured to determine the delay duration of the application program for applying for the required memory from the operating system platform based on the duration.
[0276] Here, the above-mentioned first monitoring unit 1002, first control unit 1004, first acquisition unit 1006, and first determination unit 1008 correspond to steps S302 to S308 in Embodiment 1. The functions of the four units are the same as those of the corresponding steps in terms of implementation examples and application scenarios, but are not limited to the content disclosed in the above-mentioned Embodiment 1. It should be noted that the above units may be hardware components or software components stored in a memory (for example, memory 1504) and processed by one or more processors (for example, processors 1502a, 1502b..., 1502n). The above units may also be part of a device and can run in the computer terminal 150 provided in Embodiment 7.
[0277] According to an embodiment of the present application, there is also provided an apparatus for monitoring the delay duration of an application program applying for memory for implementing the above Figure 4 shown method for monitoring the delay duration of an application program applying for memory.
[0278] Figure 11 is a schematic diagram of an apparatus for monitoring the delay duration of an application program applying for memory according to an embodiment of the present application. As Figure 11 shown, the apparatus 1100 for monitoring the delay duration of an application program applying for memory may include: a second determination unit 1102, a second control unit 1104, a first display unit 1106, a third control unit 1108, and a second display unit 1110.
[0279] The second acquisition unit 1102 is configured to determine the application program to be monitored in response to a data monitoring instruction on the operation interface.
[0280] The third acquisition unit 1104 is configured to control the application program to run in response to a program running instruction on the operation interface.
[0281] The first display unit 1106 is configured to display the memory space in the idle state in the operating system platform on the operation interface in response to a memory application instruction generated by the application program on the operating system platform.
[0282] A third control unit 1108, configured to control an operating system platform to perform at least one memory recovery operation if an attribute value of a memory space in an idle state is lower than an attribute threshold, where the attribute value is used to represent an amount of storage that the memory space in the idle state allows for storage operations.
[0283] A second display unit 1110, configured to display, on an operation interface, a delay duration for which an application delays in applying to the operating system platform for required memory, where the delay duration is determined based on a duration consumed by the operating system platform to perform a memory recovery operation.
[0284] It should be noted here that the above-mentioned second determination unit 1102, second control unit 1104, first display unit 1106, third control unit 1108, and second display unit 1110 correspond to steps S402 to S410 in Embodiment 1. The functions of the five units are the same as those of the corresponding steps in terms of implementation examples and application scenarios, but are not limited to the content disclosed in the above-mentioned Embodiment 1. It should be noted that the above-mentioned units may be hardware components or software components stored in a memory (for example, memory 1504) and processed by one or more processors (for example, processors 1502a, 1502b..., 1502n), and the above-mentioned units may also be part of a device and can run in the computer terminal 150 provided in Embodiment 7.
[0285] According to an embodiment of the present application, there is also provided an apparatus for monitoring data of an application for applying for memory, which is used to implement the above-mentioned Figure 5 data monitoring method for an application to apply for memory as shown.
[0286] Figure 12 FIG. is a schematic diagram of an apparatus for monitoring data of an application for applying for memory according to an embodiment of the present application. As Figure 12 shown, the apparatus 1200 for monitoring data of an application for applying for memory may include: a first calling unit 1202, a second monitoring unit 1204, a third control unit 1206, a second obtaining unit 1208, a second determination unit 1210, and a second calling unit 1212.
[0287] The first calling unit 1202 is configured to determine identification information of an application to be monitored by calling a first interface, where the first interface includes a first parameter, and a parameter value of the first parameter is the application.
[0288] The second monitoring unit 1204 is configured to, during the running of the application, based on the identification information, in response to a memory application instruction generated by the application on the operating system platform, monitor a memory space in an idle state in the operating system platform.
[0289] A third control unit 1206, configured to control an operating system platform to perform at least one memory recovery operation if an attribute value of a memory space in an idle state is lower than an attribute threshold, where the attribute value is used to characterize an amount of storage that the memory space in the idle state allows for storage operations.
[0290] A second obtaining unit 1208, configured to obtain a duration consumed by the operating system platform to perform a memory recovery operation.
[0291] A second determining unit 1210, configured to determine a delay duration for an application to apply to the operating system platform for required memory based on the duration.
[0292] A second calling unit 1212, configured to output the delay duration by calling a second interface, where the second interface includes a second parameter, and a parameter value of the second parameter is the delay duration.
[0293] It should be noted here that the above first calling unit 1202, second monitoring unit 1204, third control unit 1206, second obtaining unit 1208, second determining unit 1210, and second calling unit 1212 correspond to steps S502 to S512 in Embodiment 1. The instances and application scenarios implemented by the six units and the corresponding steps are the same, but are not limited to the content disclosed in the above Embodiment 1. It should be noted that the above units may be hardware components or software components stored in a memory (for example, memory 1504) and processed by one or more processors (for example, processors 1502a, 1502b..., 1502n), and the above units may also be part of a device and may run in the computer terminal 150 provided in Embodiment 7.
[0294] In the data monitoring device of the application program, the running process of the application program can be monitored in real time to monitor whether a memory application instruction is generated on the operating system platform associated with the application program. If there is no memory application instruction, it can be indicated that the current application program has no need to apply for memory, and at this time, the monitoring of the application program can continue. If there is, it can be indicated that the current application program has a need to apply for memory. At this time, based on the memory application instruction, the state of the memory space in the operating system platform can be monitored to determine whether there is a memory space in the idle state in the included memory space. If there is a memory space in the idle state, the storage capacity size allowed for storage operations by this memory space can be determined, that is, the comparison of the attribute value and the attribute threshold. If the attribute value is lower than the attribute threshold, at this time, the time consumed for the operating system platform to perform the memory recovery operation needs to be determined. And according to this time, the delay time that the application program needs to delay when applying for memory from the operating system platform based on the memory application instruction can be determined. Considering that the related technology only measures the health of the application program from the perspective of the overall machine resources, there will be situations such as misjudgment and low accuracy. However, the embodiment of the present application can design a special delay metric for determining the application of memory by the application program, that is, determining the delay time, to accurately measure the delay problem when the application program applies for memory, so as to achieve the purpose of effectively avoiding the jitter situation caused by memory allocation delay, and further realizing the technical effect of effectively monitoring the delay time when the application program applies for memory, and solving the technical problem of being unable to effectively monitor the delay time when the application program applies for memory.
[0295] Embodiment 5
[0296] The embodiment of the present application can provide a computer terminal, and this computer terminal can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the above computer terminal can also be replaced with a terminal device such as a mobile terminal.
[0297] Optionally, in this embodiment, the above computer terminal can be located in at least one network device among multiple network devices of a computer network.
[0298] In this embodiment, the above computer terminal may execute the program code of the following steps in the data monitoring method of the application program: during the running of the application program, in response to the memory application instruction generated by the application program on the operating system platform, monitor the memory space in the idle state in the operating system platform; if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity allowed for storage operations of the memory space in the idle state; obtain the duration consumed by the operating system platform to perform the memory recovery operation; based on the duration, determine the delay duration of the application program to apply for the required memory from the operating system platform.
[0299] Optionally, Figure 13 is a structural block diagram of a computer terminal according to an embodiment of the present application. As Figure 13 shown, the computer terminal A may include: one or more (only one is shown in the figure) processors 1302, a memory 1304, and a transmission device 1306.
[0300] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the data monitoring method and device of the application program in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implements the above-mentioned data monitoring method of the application program. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory may further include a memory remotely set relative to the processor, and these remote memories may be connected to the terminal A through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.
[0301] The processor may call the information and application program stored in the memory through the transmission device to execute the following steps: if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to call a memory recovery function to perform a memory recovery operation.
[0302] Optionally, the above processor may also execute the program code of the following steps: trace the calling process of the memory recovery function to obtain a first tracing result; based on the first tracing result, determine the duration consumed by the operating system platform to perform the memory recovery operation.
[0303] Optionally, the above-mentioned processor may also execute the program code of the following steps: obtain the process running state of the application program; if the running state is the process blocked state, during the calling process of the memory recycling function, track the first moment when the memory recycling operation starts to be executed and the second moment when the memory recycling operation ends. Among them, the first tracking result includes the first moment when the memory recycling operation starts to be executed and the second moment when the memory recycling operation ends.
[0304] Optionally, the above-mentioned processor may also execute the program code of the following steps: obtain the interval duration between the second moment and the first moment; determine the interval duration as the duration consumed by the operating system platform to execute the memory recycling operation.
[0305] Optionally, the above-mentioned processor may also execute the program code of the following steps: obtain the overlapping duration among the multiple durations corresponding to multiple memory recycling operations; filter out the overlapping duration from the multiple durations; determine the delay duration based on the filtered multiple durations. Optionally, the above-mentioned processor may also execute the program code of the following steps: accumulate the filtered multiple durations to obtain the accumulated duration; determine the delay duration based on the accumulated duration.
[0306] Optionally, the above-mentioned processor may also execute the program code of the following steps: determine the abnormal duration when the application program is in the major page fault exception state in the accumulated duration; filter out the abnormal duration from the accumulated duration to obtain the delay duration.
[0307] Optionally, the above-mentioned processor may also execute the program code of the following steps: determine the storage area where the memory space is located in the operating system platform; determine the attribute threshold matching the storage area, where the attribute threshold is used to represent the minimum storage amount allowed for storage operations in the storage area.
[0308] Optionally, the above-mentioned processor may also execute the program code of the following steps: call the memory application function to apply for the memory required by the application program from the operating system platform; track the calling process of the memory application function to obtain the second tracking result; in response to the failure to obtain the duration consumed by the operating system platform to execute the memory recycling operation, determine the delay duration based on the second tracking result.
[0309] Optionally, the above-mentioned processor may also execute the program code of the following steps: display the delay duration on the operation interface; and / or output the prompt information corresponding to the delay duration.
[0310] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: respond to the data monitoring instruction acting on the operation interface to determine the application program to be monitored; respond to the program running instruction acting on the operation interface to control the running of the application program; respond to the memory application instruction generated by the application program on the operating system platform and display the memory space in the idle state in the operating system platform on the operation interface; if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity of the memory space in the idle state that allows storage operations; display on the operation interface the delay duration for which the application program delays in applying for the required memory from the operating system platform, where the delay duration is determined based on the duration consumed by the operating system platform to perform the memory recovery operation.
[0311] The processor can call the information and application programs stored in the memory through the transmission device to perform the following steps: determine the identification information of the application program to be monitored by calling the first interface, where the first interface includes a first parameter and the parameter value of the first parameter is the identification information; during the running of the application program, based on the identification information, respond to the memory application instruction generated by the application program on the operating system platform and monitor the memory space in the idle state in the operating system platform; if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity of the memory space in the idle state that allows storage operations; obtain the duration consumed by the operating system platform to perform the memory recovery operation; determine the delay duration for which the application program delays in applying for the required memory from the operating system platform based on the duration; output the delay duration by calling the second interface, where the second interface includes a second parameter and the parameter value of the second parameter is the delay duration.
[0312] Using the embodiments of the present application, a method for monitoring data of an application program is provided. In the embodiments of the present application, the running process of the application program can be monitored in real time to monitor whether a memory application instruction is generated on the operating system platform associated with the application program. If there is no memory application instruction, it can be indicated that the current application program has no need to apply for memory. At this time, the application program can continue to be monitored. If there is, it can be indicated that the current application program has a need to apply for memory. At this time, based on the memory application instruction, the status of the memory space in the operating system platform can be monitored to determine whether there is a memory space in the idle state in the included memory space. If there is a memory space in the idle state, the size of the storage amount allowed for storage operations of the memory space can be determined, that is, the comparison between the attribute value and the attribute threshold. If the attribute value is lower than the attribute threshold, at this time, the duration required for the operating system platform to perform the memory recovery operation needs to be determined. And based on this duration, the delay duration that the application program needs to delay when applying for the memory from the operating system platform based on the memory application instruction can be determined. Since it is considered that the related technology only measures the health of the application program from the perspective of the overall machine resources, there will be situations such as misjudgment and low accuracy. However, the embodiments of the present application can design a special delay metric for determining the application program when applying for memory, that is, determining the delay duration, to accurately measure the delay problem when the application program applies for memory, so as to achieve the purpose of effectively avoiding the jitter situation caused by memory allocation delay, and further realizing the technical effect of being able to effectively monitor the delay duration when the application program applies for memory, and solving the technical problem of being unable to effectively monitor the delay duration when the application program applies for memory.
[0313] Those of ordinary skill in the art can understand that Figure 13 the structure shown is only for illustration, and the computer terminal A can also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, and a mobile Internet device (abbreviated as MID), a PAD and other terminal devices. Figure 13 It does not limit the structure of the above computer terminal A. For example, the computer terminal A may further include more or fewer components (such as a network interface, a display device, etc.) than those shown in Figure 13 or have a different configuration from that shown in Figure 13 the figure.
[0314] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program. This program can be stored in a computer-readable storage medium, which can include: a flash drive, a read-only memory (ROM for short), a random access memory (RAM for short), a magnetic disk, an optical disk, etc.
[0315] Embodiment 6
[0316] An embodiment of the present application further provides a computer-readable storage medium. Optionally, in this embodiment, the above computer-readable storage medium can be used to store the program code executed by the data monitoring method of the application program provided in the first embodiment above.
[0317] Optionally, in this embodiment, the above computer-readable storage medium can be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group.
[0318] Optionally, in this embodiment, the computer-readable storage medium is set to store program code for performing the following steps: during the running of the application program, in response to a memory application instruction generated by the application program on the operating system platform, monitor the memory space in the idle state on the operating system platform; if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to perform at least one memory recovery operation, where the attribute value is used to characterize the storage amount that the memory space in the idle state allows for storage operations; obtain the duration consumed by the operating system platform to perform the memory recovery operation; based on the duration, determine the delay duration of the application program's application for the required memory from the operating system platform.
[0319] Optionally, the above computer-readable storage medium can also execute the program code of the following steps: if the attribute value of the memory space in the idle state is lower than the attribute threshold, control the operating system platform to call a memory recovery function to perform the memory recovery operation.
[0320] Optionally, the above computer-readable storage medium can also execute the program code of the following steps: trace the calling process of the memory recovery function to obtain a first tracing result; based on the first tracing result, determine the duration consumed by the operating system platform to perform the memory recovery operation.
[0321] Optionally, the above computer-readable storage medium may also execute program code for the following steps: obtaining the process running status of an application; if the running status is a process blocked status, during the call of the memory recycling function, tracking the first moment when the memory recycling operation starts to be executed and the second moment when the memory recycling operation ends. Among them, the first tracking result includes the first moment when the memory recycling operation starts to be executed and the second moment when the memory recycling operation ends.
[0322] Optionally, the above computer-readable storage medium may also execute program code for the following steps: obtaining the interval duration between the second moment and the first moment; determining the duration consumed by the operating system platform to execute the memory recycling operation as the interval duration. Optionally, the above computer-readable storage medium may also execute program code for the following steps: obtaining the overlapping duration among multiple durations corresponding to multiple memory recycling operations; filtering out the overlapping duration from the multiple durations; and determining the delay duration based on the filtered multiple durations.
[0323] Optionally, the above computer-readable storage medium may also execute program code for the following steps: accumulating the filtered multiple durations to obtain an accumulated duration; and determining the delay duration based on the accumulated duration.
[0324] Optionally, the above computer-readable storage medium may also execute program code for the following steps: determining the abnormal duration when the application is in the major page fault exception state in the accumulated duration; and filtering out the abnormal duration from the accumulated duration to obtain the delay duration.
[0325] Optionally, the above computer-readable storage medium may also execute program code for the following steps: determining the storage area where the memory space is located in the operating system platform; and determining the attribute threshold matching the storage area, where the attribute threshold is used to represent the minimum storage amount allowed for storage operations in the storage area.
[0326] Optionally, the above computer-readable storage medium may also execute program code for the following steps: calling a memory application function to apply for the memory required by the application from the operating system platform; tracking the call process of the memory application function to obtain a second tracking result; and in response to the failure to obtain the duration consumed by the operating system platform to execute the memory recycling operation, determining the delay duration based on the second tracking result.
[0327] Optionally, the above computer-readable storage medium may also execute program code for the following steps: displaying the delay duration on the operation interface; and / or outputting a prompt message corresponding to the delay duration.
[0328] As an alternative example, a computer-readable storage medium is configured to store program code for performing the following steps: determining an application to be monitored in response to a data monitoring instruction acting on an operation interface; controlling the application to run in response to a program running instruction acting on the operation interface; displaying, on the operation interface, the memory space in the operating system platform that is in an idle state in response to a memory application instruction generated by the application on the operating system platform; if the attribute value of the memory space in the idle state is lower than an attribute threshold, controlling the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity of the memory space in the idle state that allows storage operations; displaying, on the operation interface, the delay duration for which the application delays in applying for the required memory from the operating system platform, where the delay duration is determined based on the duration consumed by the operating system platform to perform the memory recovery operation.
[0329] As an alternative example, a computer-readable storage medium is configured to store program code for performing the following steps: determining the identification information of the application to be monitored by calling a first interface, where the first interface includes a first parameter and the parameter value of the first parameter is the identification information; during the running of the application, monitoring, based on the identification information, the memory space in the operating system platform that is in an idle state in response to a memory application instruction generated by the application on the operating system platform; if the attribute value of the memory space in the idle state is lower than an attribute threshold, controlling the operating system platform to perform at least one memory recovery operation, where the attribute value is used to represent the storage capacity of the memory space in the idle state that allows storage operations; obtaining the duration consumed by the operating system platform to perform the memory recovery operation; determining, based on the duration, the delay duration for which the application delays in applying for the required memory from the operating system platform; and outputting the delay duration by calling a second interface, where the second interface includes a second parameter and the parameter value of the second parameter is the delay duration.
[0330] Embodiment 7
[0331] An embodiment of the present application may provide an electronic device, and the electronic device may include a memory and a processor.
[0332] Figure 14The block diagram of an electronic device for a data monitoring method of an application program according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described herein and / or claimed.
[0333] As Figure 14 shown, the device 1400 includes a computing unit 1401, which can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 1402 or the computer program loaded from the storage unit 1408 into the random access memory (RAM) 1403. In the RAM 1403, various programs and data required for the operation of the device 1400 can also be stored. The computing unit 1401, the ROM 1402, and the RAM 1403 are connected to each other through a bus 1404. The input / output (I / O) interface 1405 is also connected to the bus 1404.
[0334] A plurality of components in the device 1400 are connected to the I / O interface 1405, including: an input unit 1406, such as a keyboard, a mouse, etc.; an output unit 1404, such as various types of displays, speakers, etc.; a storage unit 1408, such as a magnetic disk, an optical disc, etc.; and a communication unit 1409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1409 allows the device 1400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0335] The computing unit 1401 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 1401 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processing (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1401 executes the various methods and processes described above, such as the data monitoring method of the application program. For example, in some embodiments, the data monitoring method of the application program can be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as the storage unit 1408. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 1400 via the ROM 1402 and / or the communication unit 1409. When the computer program is loaded into the RAM 1403 and executed by the computing unit 1401, one or more steps of the data monitoring method of the application program described above can be executed. Alternatively, in other embodiments, the computing unit 1401 can be configured to execute the data monitoring method of the application program in any other suitable manner (e.g., by means of firmware).
[0336] The method embodiment provided in Embodiment 1 of this application can be executed in a mobile terminal, a computer terminal, or a similar computing device. Figure 15 is a hardware structural block diagram of a computer terminal (or mobile device) for implementing the data monitoring method of an application program according to an embodiment of this application, as Figure 15 shown, the computer terminal 150 (or mobile device) can include one or more (shown as 1502a, 1502b,..., 1502n in the figure) processors 1502 (the processors 1502 can include, but are not limited to, processing devices such as a Microcontroller Unit (MCU) or a Field Programmable Gate Array (FPGA)), a memory 1504 for storing data, and a transmission device 1506 for communication functions. In addition to this, it can also include: a display, an input / output interface (I / O interface), a Universal Serial Bus (USB) port (which can be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand thatFigure 15 The structure shown is only schematic and does not limit the structure of the above-mentioned electronic device. For example, the computer terminal 150 may also include more or fewer components than those shown in Figure 15 or have a different configuration from that shown in Figure 15 .
[0337] Figure 15 The hardware structure block diagram shown can be used not only as an exemplary block diagram of the above-mentioned computer terminal 150 (or mobile device), but also as an exemplary block diagram of the above-mentioned server. In an alternative embodiment, Figure 2 An embodiment is illustrated in block diagram form using the above-mentioned Figure 15 computer terminal 150 (or mobile device) as a computing node in the computing environment 201.
[0338] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard parts (ASSPs), system-on-a-chip (SOC) systems, complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a dedicated or general-purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0339] The program code for implementing the methods of the present application can be written in any combination of one or more programming languages. These program codes can be provided to the processor or controller of a general-purpose computer, a dedicated computer, or other programmable data processing devices, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program codes can be executed entirely on the machine, partially on the machine, executed partially on the machine as an independent software package and partially on a remote machine, or executed entirely on a remote machine or server.
[0340] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0341] The program code for implementing the methods of this application can be written in any combination of one or more programming languages. These program codes can be provided to the processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowchart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0342] In the context of this application, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0343] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a cathode ray tube (CRT) or a liquid crystal display (LCD), a monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0344] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0345] A computer system can include a client and a server. The client and the server are generally far from each other and usually interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
[0346] It should be noted that the serial numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments.
[0347] In the above embodiments of the present application, the descriptions of the respective embodiments have their own emphases. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0348] In several embodiments provided by this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the couplings or direct couplings or communication connections shown or discussed with each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.
[0349] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0350] In addition, in each embodiment of this application, the functional units can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0351] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this 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 for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in each embodiment of this application. The foregoing storage medium includes: USB flash drives, read-only memories, random access memories, mobile hard disks, magnetic disks, or optical disks and other various media that can store program codes.
[0352] The above is only the preferred embodiment of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and refinements can still be made, and these improvements and refinements should also be regarded as the protection scope of this application.
Claims
1. A method for monitoring data of an application program, characterized in that, Including: During the running of the application, in response to a memory application instruction generated by the application on the operating system platform, monitoring the memory space in the operating system platform that is in an idle state; If the attribute value of the memory space in the idle state is lower than an attribute threshold, controlling the operating system platform to perform at least one memory recycling operation, where the attribute value is used to characterize the storage capacity of the memory space in the idle state that allows storage operations; Obtaining the duration consumed by the operating system platform to perform the memory recycling operation; Based on the duration, determining the delay duration for which the application delays in applying for the required memory from the operating system platform.
2. The method according to claim 1, wherein If the attribute value of the memory space in the idle state is lower than the attribute threshold, controlling the operating system platform to perform at least one memory recycling operation, including: If the attribute value of the memory space in the idle state is lower than the attribute threshold, controlling the operating system platform to call a memory recycling function to perform the memory recycling operation.
3. The method according to claim 2, characterized in that, Obtaining the duration consumed by the operating system platform to perform the memory recycling operation, including: Tracking the calling process of the memory recycling function to obtain a first tracking result; Based on the first tracking result, determining the duration consumed by the operating system platform to perform the memory recycling operation.
4. The method according to claim 3, wherein The first tracking result includes a first moment when the memory recycling operation starts to be executed and a second moment when the memory recycling operation ends. Among them, tracking the calling process of the memory recycling function to obtain a first tracking result includes: Obtaining the process running state of the application; If the running state is a process blocked state, during the calling process of the memory recycling function, tracking the first moment when the memory recycling operation starts to be executed and the second moment when the memory recycling operation ends.
5. The method according to claim 4, wherein Based on the first tracking result, determining the duration consumed by the operating system platform to perform the memory recycling operation, including: Obtaining the interval duration between the second moment and the first moment; Determining the interval duration as the duration consumed by the operating system platform to perform the memory recycling operation.
6. The method according to claim 1, characterized in that Based on the duration, determining the delay duration for which the application delays in applying for the required memory from the operating system platform, including: Obtaining the overlapping duration among the multiple durations corresponding to the multiple memory recycling operations; Filtering out the overlapping duration from the multiple durations; Based on the filtered multiple durations, determining the delay duration.
7. The method according to claim 6, characterized in that, Based on the filtered multiple durations, determining the delay duration, including: Accumulating the filtered multiple durations to obtain an accumulated duration; Determining the delay duration based on the accumulated duration.
8. The method according to claim 7, characterized in that Based on the accumulated duration, determining the delay duration, including: Determining the abnormal duration when the application is in the major page fault exception state in the accumulated duration; Filtering out the abnormal duration from the accumulated duration to obtain the delay duration.
9. The method according to claim 1, wherein The method further includes: Determining the storage area where the memory space is located in the operating system platform; Determine the attribute threshold that matches the storage area, where the attribute threshold is used to characterize the minimum storage amount allowed for storage operations in the storage area.
10. The method according to claim 1, wherein The method further includes: Calling a memory application function to apply for the memory required by the application program from the operating system platform; Tracking the calling process of the memory application function to obtain a second tracking result; In response to the failure to obtain the duration consumed by the operating system platform to perform the memory recovery operation, determining the delay duration based on the second tracking result.
11. The method according to any one of claims 1 to 10, characterized in that, The method further includes: Displaying the delay duration on the operation interface; and / or Outputting a prompt message corresponding to the delay duration.
12. The method according to any one of claims 1 to 10, characterized in that, The at least one memory recovery operation includes at least one of the following: Asynchronous memory recovery operation; Memory compaction operation; Direct memory recovery operation.
13. A method for monitoring the latency of an application's memory application, characterized in that, Includes: Responding to a data monitoring instruction on the operation interface to determine the application program to be monitored; Responding to a program running instruction on the operation interface to control the running of the application program; In response to a memory application instruction generated by the application program on the operating system platform, displaying the memory space in the idle state in the operating system platform on the operation interface; If the attribute value of the memory space in the idle state is lower than the attribute threshold, controlling the operating system platform to perform at least one memory recovery operation, where the attribute value is used to characterize the storage amount allowed for storage operations in the memory space in the idle state; Displaying on the operation interface the delay duration of the application program's application for the required memory from the operating system platform, where the delay duration is determined based on the duration consumed by the operating system platform to perform the memory recovery operation.
14. A method for monitoring data of an application program, characterized in that, Includes: Determining the identification information of the application program to be monitored by calling a first interface, where the first interface includes a first parameter, and the parameter value of the first parameter is the identification information; During the running of the application program, based on the identification information, in response to a memory application instruction generated by the application program on the operating system platform, monitoring the memory space in the idle state in the operating system platform; If the attribute value of the memory space in the idle state is lower than the attribute threshold, controlling the operating system platform to perform at least one memory recovery operation, where the attribute value is used to characterize the storage amount allowed for storage operations in the memory space in the idle state; Obtaining the duration consumed by the operating system platform to perform the memory recovery operation; Determining the delay duration of the application program's application for the required memory from the operating system platform based on the duration; Outputting the delay duration by calling a second interface, where the second interface includes a second parameter, and the parameter value of the second parameter is the delay duration.
15. A data monitoring system for an application program, characterized in that, Includes: A terminal device for uploading the identification information of the application program to be monitored; A server, during the running of an application, in response to a memory application instruction generated by the application on an operating system platform, monitors the memory space in the idle state in the operating system platform; if the attribute value of the memory space in the idle state is lower than an attribute threshold, controls the operating system platform to perform at least one memory recovery operation, wherein the attribute value is used to represent the storage capacity that the memory space in the idle state allows for storage operations; obtains the duration consumed by the operating system platform in performing the memory recovery operation; and determines, based on the duration, the delay duration of the application's application to the operating system platform for the required memory.
16. An electronic device, characterized in that, Comprising: A memory storing an executable program; A processor for running the program, wherein when the program runs, it executes the method according to any one of claims 1 to 14.