An Application Code-Level Performance Analysis Method, Device, Equipment and Medium
The kernel stack traces are collected and aggregated by the eBPF sampler, which solves the high overhead and difficult positioning problems of traditional performance analysis methods, and realizes efficient application performance diagnosis and root cause positioning.
Patent Information
- Application Number
- CN202310342075.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-29
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-03-29
AI Technical Summary
Traditional application performance analysis methods increase a lot of overhead, and are difficult to analyze and position problems, resulting in high labor maintenance and time costs for enterprises.
The eBPF sampler is used to trigger a soft interrupt when the application runs to the function to be detected and traps it into the kernel. The kernel stack trace and process symbol table are collected and stored in the eBPF Map. The analyzer is used for aggregation analysis to obtain the thread stack and number of calls corresponding to each kernel stack trace called.
Save labor and time costs, real-time performance diagnosis of deployed applications is achieved, allowing developers to quickly analyze and accurately locate the root causes of program time.
Smart Images

Figure CN116303078B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of code performance analysis, and in particular to an application program code-level performance analysis method, device, equipment and medium. Background Art
[0002] Container technology is a virtualization technology that is more computing resource-saving and more flexible than virtual machine technology. With the development of container technology, many container orchestration engines have emerged for managing containers. Kubernetes (an open-source system for automatically deploying, scaling, and managing containerized applications) technology has stood out and become the de facto standard in the field of container orchestration. In the cloud era, applications under the distributed microservices architecture are also becoming increasingly rich, and a large number of complex application exception problems follow one after another.
[0003] Currently, traditional application program code performance analysis is implemented using a profiler. The profiler adds measurement code to the binary file, and the profiler collects information each time a function is entered or exited. However, the profiler not only adds a large amount of overhead, but also makes it extremely difficult to analyze and locate problems, causing great human maintenance and time costs to enterprises. Summary of the Invention
[0004] In view of this, it is necessary to provide an application program code-level performance analysis method, device, equipment and medium for the above technical problems.
[0005] According to a first aspect of the present invention, there is provided an application program code-level performance analysis method, the method comprising:
[0006] Create a probe task to configure the application name of the application to be probed, the name of the function to be probed, and the monitoring duration;
[0007] Start the application to be probed based on the application name;
[0008] Use an eBPF sampler to obtain the probe task, and inject sampling code into the started application to be probed based on the name of the function to be probed and the monitoring duration. The sampling code is used to trigger a soft interrupt to enter the kernel to collect the kernel stack trace and the process symbol table and store them in the eBPF Map when the application runs to the function corresponding to the name of the function to be probed. The process symbol table is a table of the correspondence between the kernel stack trace and the thread stack;
[0009] Generate access traffic to run the application to be probed after injecting the sampling code;
[0010] Use a profiler to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each kernel stack trace that is called.
[0011] In some embodiments, the eBPF Map includes a first storage Map and a second storage Map. One entry of the first storage Map corresponds to a kernel stack trace collected once, and one entry of the second storage Map corresponds to a kernel stack trace and a thread stack corresponding to the kernel stack trace.
[0012] In some embodiments, obtaining the kernel stack trace and the process symbol table from the eBPF Map by an analyzer and performing aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace includes:
[0013] Performing the following operations for each entry in each first storage Map;
[0014] Obtaining the kernel stack trace stored in the entry as the called kernel stack trace;
[0015] And matching the called kernel stack trace with each entry of the second storage Map;
[0016] In response to matching the same kernel stack trace in an entry of the second storage Map, taking the thread stack corresponding to the kernel stack trace in the certain entry as the thread stack corresponding to the called kernel stack trace, and increasing the call count of the thread stack by one.
[0017] In some embodiments, the method further includes:
[0018] Using a UI interface to display the thread stack and the call count corresponding to each called kernel stack trace obtained by the aggregation analysis of the analyzer.
[0019] In some embodiments, using a UI interface to display the thread stack and the call count corresponding to each called kernel stack trace obtained by the aggregation analysis of the analyzer includes:
[0020] Performing the following operations for each thread stack:
[0021] Creating a grid with a preset height and a preset width;
[0022] In response to the call count of the thread stack being greater than 1, adjusting the width of the created grid to a ratio equal to the call count of the thread stack with the preset width.
[0023] In some embodiments, using a UI interface to display the thread stack and the call count corresponding to each called kernel stack trace obtained by the aggregation analysis of the analyzer includes:
[0024] Performing the following operations for each thread stack:
[0025] Create a grid with a preset height and a preset width;
[0026] In response to the number of calls of the thread stack being greater than one, adjust the height of the created grid so that the ratio to the preset height is equal to the number of calls of the thread stack.
[0027] In some embodiments, the method further includes:
[0028] Store the thread stack and the number of calls corresponding to each kernel stack trace obtained by the aggregation analysis of the analyzer into a database.
[0029] According to a second aspect of the present invention, there is provided an application code-level performance analysis device, the device includes:
[0030] A creation module configured to create a detection task to configure the application name of the application to be detected, the function name to be detected, and the monitoring duration;
[0031] A start module configured to start the application to be detected based on the application name;
[0032] An injection module configured to obtain the detection task by using an eBPF sampler and inject sampling code into the application to be detected after startup based on the function name to be detected and the monitoring duration, wherein the sampling code is used to trigger a soft interrupt to trap into the kernel to collect the kernel stack trace and the process symbol table and store them into an eBPF Map when the application runs to the function corresponding to the function name to be detected, and the process symbol table is a correspondence table between the kernel stack trace and the thread stack;
[0033] A running module configured to create access traffic to run the application to be detected after injecting the sampling code;
[0034] An analysis module configured to obtain the kernel stack trace and the process symbol table from the eBPF Map by using an analyzer and perform aggregation analysis to obtain the thread stack and the number of calls corresponding to each kernel stack trace that is called.
[0035] According to a third aspect of the present invention, there is also provided a computer device, the computer device includes:
[0036] At least one processor; and
[0037] A memory, the memory stores a computer program that can run on the processor, and when the processor executes the program, it executes the foregoing application code-level performance analysis method.
[0038] According to a fourth aspect of the present invention, there is also provided a computer-readable storage medium storing a computer program, which when executed by a processor, performs the foregoing application program code-level performance analysis method.
[0039] The above application program code-level performance analysis method uses an eBPF-based sampler to detect the calling functions of a program and inject sampling code into the calling functions. When the application program runs to the corresponding function, a soft interrupt is triggered to enter the kernel, and the injected sampling code is executed to collect stack traces, which are continuously stored in the eBPF Map. With the help of an analyzer, the stack traces are obtained and aggregated. This not only saves labor and time costs but also enables real-time performance diagnosis of the deployed application, facilitating developers to quickly analyze online and accurately locate the root cause of program time consumption, and has high application value.
[0040] In addition, the present invention also provides an application program code-level performance analysis device, a computer device, and a computer-readable storage medium, which can also achieve the above technical effects and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other embodiments based on these drawings without creative efforts.
[0042] Figure 1 It is a flowchart of an application program code-level performance analysis method provided by an embodiment of the present invention;
[0043] Figure 2 It is a schematic diagram of aggregative analysis by an analyzer provided by another embodiment of the present invention;
[0044] Figure 3 It is a schematic diagram of data flow of an application program code-level performance analysis method provided by an embodiment of the present invention;
[0045] Figure 4 It is a schematic structural diagram of an application program code-level performance analysis device provided by another embodiment of the present invention;
[0046] Figure 5 It is an internal structure diagram of a computer device in another embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0047] To make the objectives, technical solutions, and advantages of the present invention more clearly understood, the following further elaborates on the embodiments of the present invention in detail with reference to specific embodiments and the accompanying drawings.
[0048] It should be noted that all the expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two entities or parameters with the same name but different identities. It can be seen that "first" and "second" are only for the convenience of expression and should not be construed as a limitation on the embodiments of the present invention. This will not be elaborated in the subsequent embodiments one by one.
[0049] First, the following technical terms involved in the embodiments are explained as follows:
[0050] Application program: It is a collection of application components that can provide services externally and related supplementary information. In actual usage scenarios, it can be the specific application system of the user. It usually includes one or more application components, access addresses, security groups, etc.
[0051] Soft interrupt: It uses the concept of hardware interrupt and is simulated in software to achieve an asynchronous execution effect macroscopically. A soft interrupt is usually an interrupt from the hard interrupt service program to the kernel. It is an upgrade of the original "bottom half processing" in the Linux system and a new processing method developed on the original basis to adapt to the soft interrupt processing of multi-CPU and multi-thread.
[0052] Stack trace: It is a description of the active stack frame information at a certain time point during the program running process. Stack trace is also called stack backtrace.
[0053] Thread stack, a thread stack refers to a line of code.
[0054] eBPF, the full name is Extended Berkeley Packet Filter, which represents an extended Berkeley packet filter.
[0055] eBPF Map: It is a general data structure for storing different types of data, providing functions such as data interaction between user space and kernel space, data storage, and data sharing among multiple programs.
[0056] In one embodiment, please refer to Figure 1 As shown, the present invention provides an application program code-level performance analysis method 100. Specifically, the method includes the following steps:
[0057] Step 101, create a detection task to configure the application program name, the function name to be detected, and the monitoring duration of the application program to be detected;
[0058] Step 102, start the application program to be detected based on the application program name;
[0059] Step 103: Use the eBPF sampler to obtain the detection task, and inject sampling code into the application to be detected after startup based on the function name to be detected and the monitoring duration. The sampling code is used to trigger a soft interrupt to enter the kernel when the application runs to the function corresponding to the function name to be detected, collect the kernel stack trace and the process symbol table, and store them in the eBPF Map. The process symbol table is a table of the correspondence between the kernel stack trace and the thread stack;
[0060] Step 104: Create access traffic to run the application to be detected after injecting the sampling code;
[0061] Step 105: Use the analyzer to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace.
[0062] The above application code-level performance analysis method uses an eBPF-based sampler to detect the calling functions of the program, injects sampling code into the calling functions, triggers a soft interrupt to enter the kernel when the application runs to the corresponding function, executes the injected sampling code to collect the stack trace, continuously stores it in the eBPF Map, and uses the analyzer to obtain the stack trace and perform aggregation. This not only saves labor and time costs but also enables real-time performance diagnosis of the deployed application, facilitating developers to quickly analyze online and accurately locate the root cause of program time consumption, and has high application value.
[0063] In some embodiments, as shown in Figure 2 The eBPF Map includes a first storage Map and a second storage Map. One entry of the first storage Map corresponds to a kernel stack trace collected once, and one entry of the second storage Map corresponds to a kernel stack trace and the thread stack corresponding to the kernel stack trace.
[0064] In some embodiments, as shown in Figure 2 Step 105: Use the analyzer to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace, including:
[0065] Perform the following operations for each entry in each first storage Map;
[0066] Obtain the kernel stack trace stored in the entry as the called kernel stack trace;
[0067] And match the called kernel stack trace with each entry of the second storage Map;
[0068] In response to a match of a certain entry in the second storage Map with the same kernel stack trace, the thread stack corresponding to the kernel stack trace in the certain entry is used as the thread stack corresponding to the called kernel stack trace, and the call count of the thread stack is incremented by one.
[0069] In some embodiments, the method further includes:
[0070] Use the UI interface to display the thread stack and call count corresponding to each called kernel stack trace obtained from the aggregated analysis of the profiler.
[0071] In some embodiments, using the UI interface to display the thread stack and call count corresponding to each called kernel stack trace obtained from the aggregated analysis of the profiler includes:
[0072] Perform the following operations for each thread stack:
[0073] Create a grid with a preset height and width;
[0074] In response to the call count of the thread stack being greater than 1, adjust the width of the created grid so that the ratio to the preset width is equal to the call count of the thread stack.
[0075] In some embodiments, using the UI interface to display the thread stack and call count corresponding to each called kernel stack trace obtained from the aggregated analysis of the profiler includes:
[0076] Perform the following operations for each thread stack:
[0077] Create a grid with a preset height and width;
[0078] In response to the call count of the thread stack being greater than one, adjust the height of the created grid so that the ratio to the preset height is equal to the call count of the thread stack.
[0079] In some embodiments, the method further includes:
[0080] Store the thread stack and call count corresponding to each called kernel stack trace obtained from the aggregated analysis of the profiler into a database.
[0081] In yet another embodiment, for the convenience of understanding the solution of the present invention and for realizing online code performance analysis, this embodiment adopts Figure 3 an architecture to implement an application code-level performance analysis method, which specifically includes five parts: an application, an eBPF sampler, an eBPF Map memory, a platform backend (profiler), and a UI.
[0082] Application: Deploy application components in Kubernetes.
[0083] eBPF Sampler: The eBPF-based sampler probes the calling functions of the program and injects sampling code into the calling functions. When the current program runs to the corresponding function, a soft interrupt is triggered to enter the kernel, and the injected sampling code is executed to collect stack traces to record the program execution location, and continuously collect and store them in the eBPF Map. Obtain sampling tasks from the platform backend and collect data according to the duration.
[0084] eBPF Map Memory: It contains two storage Maps. One is used to save the sampled kernel stack traces, and each entry is a list of addresses representing the stack trace, and the stack trace is accessed through the allocated stack trace ID; the other is used to save the sampled process symbol table. In the kernel, the data content is still stored in the form of a stack, but each stack frame of the stack is actually a memory address. At this time, the process symbol table is needed to map the address to the real symbol. This symbol can be understood as each line of code in the code. By combining the two, the real stack situation can be known.
[0085] Platform Backend (Analyzer): Supports data aggregation, receives user-created probe tasks, and periodically obtains stack traces from the eBPF Map Memory according to the probe tasks for aggregation and storage, and finally uses them for display and analysis.
[0086] UI: Obtains data from the platform backend, integrates it, and displays the full-link tracing information of the application and the time-consuming code in real time.
[0087] Deploy the application to be monitored, the eBPF sampler for collecting data, the eBPF Map Memory for storing kernel stack traces, the platform backend for collecting and analyzing monitoring data, and the UI interface for displaying full-link tracing on Kubernetes. The specific implementation process is as follows:
[0088] Step 1, the user creates the application to be monitored in the platform application interface;
[0089] Step 2, create a probe task, add the name of the application to be collected, continuously monitor events, and monitoring duration;
[0090] Step 3, after the eBPF sampler obtains the probe task, it will probe the calling functions of the application according to the configuration parameters of the task details, and inject sampling code into the calling functions. When the current program runs to the corresponding function, a soft interrupt is triggered to enter the kernel, and the injected sampling code is executed to collect stack traces to record the program execution location;
[0091] Step 4: The eBPF Map memory stores the kernel stack trace data and process symbol table detected by eBPF. Each entry is a list of addresses representing the stack trace, and the stack trace is accessed through the allocated stack trace ID.
[0092] Step 5: The platform backend analyzer periodically retrieves the stack traces from the eBPF Map memory, aggregates them, and stores them.
[0093] Step 6: The user can view the link information of the entire application component in the UI interface. Each column represents a call stack, each grid represents a function, and the width of the grid represents the frequency of its occurrence in the sampling. Therefore, the wider the grid, the greater the possibility that it is the cause of the bottleneck, and these codes can be optimized accordingly.
[0094] An application code-level performance analysis method according to this embodiment has at least the following beneficial technical effects: The sampler based on eBPF detects the calling functions of the program, injects sampling code into the calling functions. When the current program runs to the corresponding function, a soft interrupt is triggered to enter the kernel, and the injected sampling code is executed to collect the stack trace, which is continuously stored in the eBPF Map. The analyzer on the user side periodically obtains the data, analyzes and summarizes the execution of the method, and combines the distributed link tracing context to estimate the code execution speed; this not only simplifies the user's operation steps, saves labor and time costs, but also can perform real-time performance diagnosis on the deployed application, facilitating developers to quickly analyze and accurately locate the root cause of program time consumption online, and has high application value.
[0095] In some embodiments, please refer to Figure 4 As shown, the present invention also provides an application code-level performance analysis device 200, and the device includes:
[0096] A creation module 201 configured to create a detection task to configure the application name of the application to be detected, the name of the function to be detected, and the monitoring duration;
[0097] A start module 202 configured to start the application to be detected based on the application name;
[0098] An injection module 203 configured to obtain the detection task by using an eBPF sampler and inject sampling code into the application to be detected after startup based on the name of the function to be detected and the monitoring duration, wherein the sampling code is used to trigger a soft interrupt to enter the kernel to collect the kernel stack trace and process symbol table and store them in the eBPF Map when the application runs to the function corresponding to the name of the function to be detected, and the process symbol table is a correspondence table between the kernel stack trace and the thread stack;
[0099] The running module 204 is configured to generate access traffic to run the application to be detected after injecting the sampling code;
[0100] The analysis module 205 is configured to use an analyzer to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace.
[0101] The above application code-level performance analysis device uses an eBPF-based sampler to detect the calling functions of a program, injects sampling code into the calling functions, triggers a soft interrupt to enter the kernel when the application runs to the corresponding function, executes the injected sampling code to collect stack traces, continuously stores them in the eBPF Map, and uses an analyzer to obtain and aggregate the stack traces. This not only saves labor and time costs but also enables real-time performance diagnosis of deployed applications, facilitating developers to quickly analyze online and accurately locate the root cause of program time consumption, and has high application value.
[0102] It should be noted that the specific limitations of the application code-level performance analysis device can refer to the limitations of the application code-level performance analysis method described above, which will not be elaborated here. Each module in the above application code-level performance analysis device can be implemented in whole or in part by software, hardware, and their combinations. The above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0103] According to another aspect of the present invention, a computer device is provided. The computer device can be a server, and its internal structure diagram is shown in Figure 5 as follows. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with external terminals through a network. When the computer program is executed by the processor, it implements the above-mentioned application code-level performance analysis method. Specifically, the method includes the following steps:
[0104] Create a detection task to configure the application name, the name of the function to be detected, and the monitoring duration of the application to be detected;
[0105] Start the application to be detected based on the application name;
[0106] Obtain the detection task by using an eBPF sampler, and inject sampling code into the application to be detected after startup based on the function name to be detected and the monitoring duration, where the sampling code is used to trigger a soft interrupt to enter the kernel when the application runs to the function corresponding to the function name to be detected, so as to collect the kernel stack trace and the process symbol table and store them in the eBPF Map, and the process symbol table is a correspondence table between the kernel stack trace and the thread stack;
[0107] Generate access traffic to run the application to be detected after injecting the sampling code;
[0108] Use an analyzer to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace.
[0109] According to another aspect of the present invention, there is provided a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned application code-level performance analysis method is implemented. Specifically, it includes performing the following steps:
[0110] Create a detection task to configure the application name, the function name to be detected, and the monitoring duration of the application to be detected;
[0111] Start the application to be detected based on the application name;
[0112] Obtain the detection task by using an eBPF sampler, and inject sampling code into the application to be detected after startup based on the function name to be detected and the monitoring duration, where the sampling code is used to trigger a soft interrupt to enter the kernel when the application runs to the function corresponding to the function name to be detected, so as to collect the kernel stack trace and the process symbol table and store them in the eBPF Map, and the process symbol table is a correspondence table between the kernel stack trace and the thread stack;
[0113] Generate access traffic to run the application to be detected after injecting the sampling code;
[0114] Use an analyzer to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace.
[0115] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0116] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0117] The above-described embodiments merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A method for analyzing the performance of application code at the code level, characterized in that, The method includes: Creating a detection task to configure the application name of the application to be detected, the function name to be detected, and the monitoring duration; Starting the application to be detected based on the application name; Using an eBPF sampler to obtain the detection task, and injecting sampling code into the started application to be detected based on the function name to be detected and the monitoring duration, where the sampling code is used to trigger a soft interrupt to trap into the kernel to collect the kernel stack trace and the process symbol table when the application runs to the function corresponding to the function name to be detected and store them in the eBPF Map, and the process symbol table is a table of the correspondence between the kernel stack trace and the thread stack; Generating access traffic to run the application to be detected after injecting the sampling code; Using an analyzer to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace.
2. The application program code-level performance analysis method according to claim 1, wherein The eBPF Map includes a first storage Map and a second storage Map. One entry of the first storage Map corresponds to one collected kernel stack trace, and one entry of the second storage Map corresponds to a kernel stack trace and the thread stack corresponding to the kernel stack trace.
3. The application program code-level performance analysis method according to claim 2, wherein Using an analyzer to obtain the kernel stack trace and the process symbol table from the eBPF Map and perform aggregation analysis to obtain the thread stack and the call count corresponding to each called kernel stack trace, including: Performing the following operations for each entry in each first storage Map; Obtaining the kernel stack trace stored in the entry as the called kernel stack trace; And matching the called kernel stack trace with each entry of the second storage Map; In response to matching the same kernel stack trace in an entry of the second storage Map, taking the thread stack corresponding to the kernel stack trace in the certain entry as the thread stack corresponding to the called kernel stack trace, and incrementing the call count of the thread stack by one.
4. The application program code-level performance analysis method according to claim 3, wherein The method further includes: Using a UI interface to display the thread stack and the call count corresponding to each called kernel stack trace obtained by the aggregation analysis of the analyzer.
5. The application program code-level performance analysis method according to claim 4, wherein Using a UI interface to display the thread stack and the call count corresponding to each called kernel stack trace obtained by the aggregation analysis of the analyzer, including: Performing the following operations for each thread stack: Creating a grid with a preset height and a preset width; In response to the call count of the thread stack being greater than 1, adjusting the width of the created grid to a ratio equal to the call count of the thread stack with the preset width.
6. The application program code-level performance analysis method according to claim 4, wherein Using a UI interface to display the thread stack and the call count corresponding to each called kernel stack trace obtained by the aggregation analysis of the analyzer, including: Performing the following operations for each thread stack: Creating a grid with a preset height and a preset width; In response to the call count of the thread stack being greater than one, adjusting the height of the created grid to a ratio equal to the call count of the thread stack with the preset height.
7. The application program code-level performance analysis method according to claim 3, wherein The method further includes: Store the thread stack and the number of calls corresponding to each kernel stack trace obtained from the aggregation analysis of the analyzer into the database.
8. An apparatus for analyzing the performance of application code at the code level, characterized in that, The device includes: A creation module configured to create a detection task to configure the application name of the application to be detected, the name of the function to be detected, and the monitoring duration; A start module configured to start the application to be detected based on the application name; An injection module configured to obtain the detection task by using an eBPF sampler and inject sampling code into the application to be detected after startup based on the name of the function to be detected and the monitoring duration, wherein the sampling code is used to trigger a soft interrupt to enter the kernel to collect the kernel stack trace and the process symbol table and store them in the eBPF Map when the application runs to the function corresponding to the name of the function to be detected, and the process symbol table is a correspondence table between the kernel stack trace and the thread stack; A running module configured to generate access traffic to run the application to be detected after injecting the sampling code; An analysis module configured to obtain the kernel stack trace and the process symbol table from the eBPF Map by using an analyzer and perform aggregation analysis to obtain the thread stack and the number of calls corresponding to each kernel stack trace that is called.
9. A computer device, characterized in that, It includes: At least one processor; And A memory storing a computer program that can run in the processor, and when the processor executes the program, it executes the method according to any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it executes the method according to any one of claims 1-7.
Citation Information
Patent Citations
Performance analysis method and device
CN111679984A
Performance analysis method and device for storage server and electronic equipment
CN111756575A