Flame pattern generation method, performance analysis method, related device and storage medium

By collecting and analyzing the full amount of program execution information in real time, performance data covering all function call relationships and time consumption distribution is generated, which solves the problems of data integrity and time dimension distortion in flame graph analysis and achieves high-precision performance analysis and optimization.

CN120707683APending Publication Date: 2025-09-26HANGZHOU XINMANG TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510863694.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-25
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Existing flame graph analysis methods are unable to meet the high-precision CPU performance analysis requirements in fields such as AI, high-performance computing, and real-time control systems, resulting in loss of data integrity, destruction of call stack continuity, and distortion of the time dimension.

Method used

Through performance collection tools, full program execution information is collected in real time, the complete instruction stream and program symbol table are parsed, performance data covering all function call relationships and time consumption distribution is generated, the precise start and end timestamps of function calls are recorded, time dimension distortion is eliminated, and the continuity of the call stack is ensured.

Benefits of technology

Improved flame graph data integrity and call stack continuity, capable of reconstructing complex control flows, providing more reliable performance analysis basis, and supporting real-time performance optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120707683A_ABST
    Figure CN120707683A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a flame pattern generation method, a performance analysis method, a related device and a storage medium. The flame map generation method comprises the steps that full-amount program execution information generated in the process that at least one processor executes a target program is collected in real time through a performance collection tool; analyzing complete instruction stream information in the process of executing the target program by the at least one processor from the full-amount program execution information; analyzing the program symbol table of the target program and the complete instruction stream information to obtain performance data of the at least one processor for executing the target program; according to the method, the performance data is provided for the flame map generation tool, the flame map is generated by the flame map generation tool, the data integrity and call stack continuity of the generated flame map are improved, the time dimension distortion is eliminated, and the performance bottleneck is quickly and accurately positioned.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of computer technology, and particularly relates to a flame graph generation method, a performance analysis method, related devices, and a storage medium. Background Art

[0002] With the continuous advancement of computer technology, a large number of computer programs have been produced to implement various functions. To continuously improve the user experience, computer programs require repeated code tuning after development. During this tuning process, performance acquisition tools (such as Perf) can be used to periodically sample program execution information generated by the central processing unit (CPU) during the execution of the target program. This information is then used to calculate the percentage of total CPU execution time occupied by function execution and the call relationships during the target program's execution. Flame graph generation tools can then be used to graphically display this program execution information. Flame graph analysis can then be used to identify performance bottlenecks in the target program, allowing targeted tuning of the target program's code segments. However, sampling-based flame graph analysis methods struggle to meet the high-precision requirements of CPU performance analysis in fields such as AI, high-performance computing, and real-time control systems. For example, when the typical sampling period for program execution information is 1 ms, function calls that take less than this threshold (e.g., real-time interrupt handlers that take less than 100 μs) are completely lost, resulting in a lack of data integrity in the generated flame graph. Program execution information obtained through periodic sampling cannot record the precise start and end timestamps of function call execution, making it impossible to capture and perform causal analysis of key QoS metrics (such as tail latency). This distorts the temporal dimension of the generated flame graphs. Discrete sampling points disrupt the continuity of the call stack, making it difficult to reconstruct complex control flows (such as recursive / coroutine call paths) from the generated flame graphs. Summary of the Invention

[0003] In view of the above problems, the embodiments of the present disclosure provide a flame graph generation method, a performance analysis method, related devices and storage media, aiming to improve the data integrity and call stack continuity of the generated flame graph and eliminate time dimension distortion.

[0004] According to a first aspect of an embodiment of the present disclosure, a flame graph generation method is provided, including:

[0005] Using a performance acquisition tool, respectively, to collect in real time all program execution information generated by at least one processor during execution of a target program;

[0006] Parsing complete instruction flow information during the execution of the target program by the at least one processor from the full program execution information;

[0007] Parsing the program symbol table and the complete instruction stream information of the target program to obtain performance data of the at least one processor executing the target program;

[0008] The performance data is provided to a flame graph generation tool, and the flame graph generation tool generates a flame graph.

[0009] Optionally, the full program execution information includes execution logs and / or execution traces generated during the execution of the target program by at least one core of the same processor and / or different processors;

[0010] The step of parsing the complete instruction flow information of the at least one processor during execution of the target program from the full program execution information includes:

[0011] Taking cores as units, complete instruction stream information of at least one core executing the target program is parsed from the full program execution information, wherein the data structure of the complete instruction stream information includes an instruction memory address and a corresponding instruction execution timestamp.

[0012] Optionally, the data structure of the program symbol table includes a function call instruction memory address and a corresponding function name;

[0013] The parsing of the program symbol table and the complete instruction stream information of the target program to obtain performance data of the at least one processor executing the target program includes:

[0014] The program symbol table and the complete instruction stream information of the target program are parsed on a core-by-core basis to obtain performance data of the target program executed by at least one core. The performance data includes the start time, end time and duration of each function call execution of each function in the target program recorded in a time dimension, as well as the function call relationship of each function.

[0015] Optionally, providing the performance data to a flame graph generation tool, and having the flame graph generation tool generate a flame graph, includes:

[0016] The performance data of the at least one core executing the target program is provided to the flame graph generation tool, and the flame graph generation tool generates a flame graph corresponding to the at least one core.

[0017] Optionally, after providing the performance data to a flame graph generation tool and having the flame graph generation tool generate a flame graph, the flame graph generation method further includes at least one of the following:

[0018] The flame graph generation tool displays the flame graph corresponding to the at least one core on the same interface;

[0019] The flame graph generation tool displays statistical information, including the average execution time, the longest execution time, and the shortest execution time of all function calls of each function in the target program, the ratio of the total execution time of all function calls of each function in the target program to the program running time of the target program, and the number of function calls of each function in the target program.

[0020] According to a second aspect of an embodiment of the present disclosure, a performance optimization method is provided, including:

[0021] Generate a flame graph corresponding to the target program according to the flame graph generation method described above;

[0022] Performing performance bottleneck analysis on the target program using the flame graph;

[0023] Optimizing the target program in a targeted manner according to the analysis results;

[0024] According to the flame graph generation method described above, a flame graph corresponding to the optimized target program is generated to facilitate step-by-step optimization of the target program.

[0025] According to a third aspect of an embodiment of the present disclosure, a flame graph generating device is provided, including:

[0026] A full program execution information collection unit, configured to collect, in real time, full program execution information generated by at least one processor during execution of a target program using a performance collection tool;

[0027] a complete instruction stream information parsing unit, configured to parse the complete instruction stream information of the at least one processor in the process of executing the target program from the full program execution information;

[0028] a performance data parsing unit, configured to parse the program symbol table and the complete instruction stream information of the target program to obtain performance data of the at least one processor executing the target program;

[0029] The flame graph generation unit is configured to provide the performance data to a flame graph generation tool, so that the flame graph generation tool generates a flame graph.

[0030] According to a fourth aspect of an embodiment of the present disclosure, a performance optimization device is provided, including:

[0031] A flame graph generating unit, configured to generate a flame graph corresponding to a target program according to the flame graph generating apparatus described above;

[0032] a performance bottleneck analysis unit, configured to perform performance bottleneck analysis on the target program using the flame graph;

[0033] A program optimization unit, configured to optimize the target program in a targeted manner according to the analysis results;

[0034] The flame graph generating unit is further configured to generate a flame graph corresponding to the optimized target program according to the flame graph generating device described above, so as to gradually optimize the target program.

[0035] According to a fifth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program implements the steps of the method described above when executed by the processor.

[0036] According to a sixth aspect of an embodiment of the present disclosure, a storage medium is provided, on which a computer program or instructions are stored. When the computer program or instructions are executed by a processor, the steps of the method described above are implemented.

[0037] The embodiments of the present disclosure bring the following beneficial effects:

[0038] The flame graph generation method provided by the embodiments of the present disclosure uses a performance collection tool to collect, in real time, full program execution information generated by at least one processor during the execution of a target program. The method then parses the full program execution information to obtain complete instruction stream information from the at least one processor during the execution of the target program. The target program's program symbol table and complete instruction stream information are then parsed to obtain performance data for the at least one processor executing the target program. This performance data covers all function call relationships and time consumption distribution during the at least one processor's execution of the target program, improving the data integrity of the generated flame graph. The performance data also records the precise start and end timestamps of function call execution, eliminating time dimension distortion in the generated flame graph. The performance data also maintains call stack continuity, enabling the generated flame graph to reconstruct complex control flows. Consequently, the flame graph generated based on the performance data provides a more reliable basis for performance analysis of the target program.

[0039] Other features and advantages of the embodiments of the present disclosure will be described in the following description, and in part will become apparent from the description, or be understood by practicing the embodiments of the present disclosure. The purposes and other advantages of the embodiments of the present disclosure are achieved and obtained by the structures particularly pointed out in the description and the drawings.

[0040] In order to make the above-mentioned objectives, features and advantages of the embodiments of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and other objects, features and advantages of the embodiments of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0042] Figure 1 A schematic diagram of the structure of a performance analysis system provided according to an embodiment of the present disclosure;

[0043] Figure 2 A schematic diagram of a flame graph generation method according to an embodiment of the present disclosure;

[0044] Figure 3A A schematic diagram of the data structure of complete instruction stream information and program symbol table provided according to one embodiment of the present disclosure;

[0045] Figure 3B A flame graph corresponding to core 0 provided according to an embodiment of the present disclosure;

[0046] Figure 3C The flame graph corresponding to core 0 and core 1 is provided according to an embodiment of the present disclosure;

[0047] Figure 3D A schematic diagram showing statistical information of a flame graph generation tool provided according to an embodiment of the present disclosure;

[0048] Figure 4 A schematic diagram of a flow chart of a performance optimization method provided according to an embodiment of the present disclosure;

[0049] Figure 5 This is a schematic diagram of the structure of a flame graph generating device provided according to one embodiment of the present disclosure;

[0050] Figure 6 A schematic structural diagram of a performance optimization device provided according to an embodiment of the present disclosure;

[0051] Figure 7 The figure is a schematic structural diagram of an electronic device provided according to one embodiment of the present disclosure. DETAILED DESCRIPTION

[0052] Various embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. In each of the drawings, identical elements are represented by identical or similar reference numerals. For clarity, the various parts in the drawings are not drawn to scale.

[0053] The following terms are used in this article:

[0054] CPU, which covers processors of various architectures such as ARM, RISC-V, and X86, is the core computing component of the computer system, responsible for instruction execution and data processing tasks.

[0055] Computer programs are programs that run on processors such as embedded systems or system-on-chips (SoC chips). They include bare metal programs, operating systems (OSs), and applications that run on operating systems.

[0056] The function call stack is a data structure used to manage function calls and related data during computer program execution. The depth of the function call stack refers to the number of function call levels traversed from the currently executing function to the program entry point (such as the main function) during program execution. It reflects the complexity of nested function calls during program execution. The function call stack information can help developers quickly locate the function call hierarchy where problems occur, facilitating error detection and resolution.

[0057] A program symbol table (PST) is a structured metadata collection generated by a compiler / interpreter during code compilation or execution. It is used to systematically manage key information of all symbols (such as variables, functions, classes, etc.) in a program.

[0058] The Flame Graph is a visualization-based performance analysis tool that graphically displays the execution time share and call relationships of various functions during program execution. It gets its name from its flame-like shape. A flame graph typically uses rectangles of different colors to represent different functions. The width of the rectangles represents the processor's execution time (or percentage of the time spent executing the function call), while the height of the rectangles represents the depth of the function call stack, with each layer representing a function call. From bottom to top, the function call stack increases in layers, with the bottom layer representing the program's entry point and the top layer representing the currently executing function call.

[0059] A software emulator (e.g., simulator) is a tool that simulates the behavior of hardware devices (such as the CPU, memory, and I / O devices) through software. It is primarily used to verify the functionality, timing, and performance of hardware designs. By simulating hardware behavior within a software environment, software emulators allow developers to test and verify designs before actual hardware is available. Software emulators typically provide detailed execution path and status information, including logs and waveforms, enabling developers to deeply analyze program execution. Common software emulators include GEM5 and Verilator.

[0060] A hardware emulator (e.g., an emulator) simulates chip behavior through hardware or software, providing signal capture capabilities to help developers verify and debug hardware designs. Common commercial hardware emulators include Zebu and Palladium.

[0061] The Trace tool is a tool used to record and analyze the program execution process. It can provide trace data in the form of waveforms, etc., that records the detailed path and status of program execution, accurate to every clock beat, helping developers understand the program's operating status, performance bottlenecks, and potential problems.

[0062] Figure 1 FIG. 1 is a schematic diagram of a performance analysis system according to an embodiment of the present disclosure. Figure 1 As shown, the performance analysis system includes a terminal device 100 and a terminal device 200. The terminal device 100 and the terminal device 200 can communicate and exchange data. Specifically, at least one processor of the terminal device 100 is used to run a target program (a computer program to be tuned), and the terminal device 200 is used to perform performance analysis on the target program. In one example, the terminal device 100 and the terminal device 200 are personal computers (PCs). It is understood that the terminal device 100 and the terminal device 200 can also be different types of electronic devices or their simulation systems, such as mobile phones, tablet computers, personal computers (PCs), servers, personal digital assistants (PDAs), smart watches, netbooks, wearable electronic devices, augmented reality (AR) devices, virtual reality (VR) devices, in-vehicle devices, smart cars, smart speakers, robots, smart glasses, etc.

[0063] In some embodiments, when a developer performs performance analysis on a target program on a terminal device 100, the terminal device 100 can simulate the execution of the target program by at least one processor using a software emulator or a hardware emulator. Alternatively, the target program can be run on a real hardware system and performance collection tools (e.g., logging tools and / or tracing tools) can be used to collect, in real time, full program execution information generated by at least one processor executing the target program in the simulated environment or on the real hardware system. Then, given the large amount of data processing required for performance analysis, the collected full program execution information is sent to the terminal device 200, which parses and processes the data to obtain performance data of the target program executed by at least one processor. In some embodiments, the terminal device 200 can also provide the performance data to a flame graph generation tool, which generates a flame graph to graphically display the performance data. The flame graph can then be used to analyze performance bottlenecks of the target program, enabling targeted optimization of the target program based on the analysis results. The terminal device 200 can also generate a flame graph corresponding to the optimized target program to facilitate progressive optimization of the target program. It should be noted that the flame graph generation method of the disclosed embodiments can also be implemented on a single terminal device. For example, if a developer needs to perform performance analysis on an application running on at least one processor of the terminal device 200, the entire process of real-time data collection, data analysis and processing, and flame graph generation can be completed on the terminal device 200. This disclosure does not impose any restrictions on this.

[0064] Figure 2 FIG. 1 is a flow chart of a flame graph generation method according to an embodiment of the present disclosure. Figure 2 As shown, the flame graph generation method of the embodiment of the present disclosure includes:

[0065] In step S210, full program execution information generated by at least one processor during execution of a target program is collected in real time using a performance collection tool.

[0066] In some embodiments, the terminal device includes at least one processor, and each processor may include at least one core. At least one core from the same processor and / or different processors can collaboratively execute the target program. The terminal device can simulate the process of the at least one core executing the target program through a software emulator or a hardware emulator, and can also actually run the target program on the at least one core. In some embodiments, the terminal device also includes a performance collection tool (for example, a log tool and / or a trace tool), which can use the performance collection tool to collect in real time the full program execution information generated by the at least one core collaboratively executing the target program in the simulation environment or the real hardware system. The full program execution information includes the execution log and / or execution trace generated by the at least one core in the process of executing the target program. It can be understood that the execution log and / or execution trace is a complete record of the process of the multiple cores executing the target program.

[0067] In step S220, complete instruction flow information during the execution of the target program by the at least one processor is parsed from the full program execution information.

[0068] In some embodiments, complete instruction flow information during the process of executing the target program by at least one core is parsed from the full program execution information on a core-by-core basis. Figure 3A Schematic diagram of the data structure of the complete instruction flow information and program symbol table provided according to one embodiment of the present disclosure. For the convenience of description, Figure 3A Only part of the complete instruction flow information is shown. Figure 3A As shown, the data structure of the complete instruction stream information includes the instruction memory address and the corresponding instruction execution timestamp. It should be noted that the complete instruction stream information can completely cover the entire life cycle from code loading to final execution.

[0069] In step S230, the program symbol table of the target program and the complete instruction stream information are parsed to obtain performance data of the at least one processor executing the target program.

[0070] Reference again Figure 3A , for the convenience of description, Figure 3A Only part of the program symbol table is shown. Figure 3A As shown, the data structure of the program symbol table includes the memory address of the function call instruction and the corresponding function name. It can be understood that according to the memory address of the instruction in the data structure of the complete instruction stream information and the memory address of the function call instruction in the data structure of the program symbol table, a correspondence between the instruction execution timestamp and the corresponding function name can be established. For example, Figure 3AAs shown, the instruction execution timestamp for the start of the "main" function is 62226000 ps, ​​the instruction execution timestamp for the start of the "iprintf" function is 62436000 ps, ​​and the instruction execution timestamp for the end of the "iprintf" function is 78526000 ps. In some embodiments, the program symbol table and complete instruction stream information of the target program are parsed on a per-core basis (i.e., the correspondence between instruction execution timestamps and corresponding function names is parsed) to obtain performance data for the target program executed by at least one core. This performance data includes the start, end, and duration of each function call in the target program, as well as the function call relationships for each function, recorded in time. It will be appreciated that this performance data covers all function call relationships and duration distribution during the execution of the target program by at least one processor in the terminal device 100, improving the data integrity of the generated flame graph, avoiding sampling errors, and providing a more reliable basis for performance analysis. The performance data also records the precise start and end timestamps of function call execution, eliminating time-dimensional distortion in the generated flame graph. Performance data also has call stack continuity, allowing the generated flame graphs to reconstruct complex control flows.

[0071] In step S240, the performance data is provided to a flame graph generation tool, and the flame graph generation tool generates a flame graph.

[0072] In some embodiments, the performance data of the at least one core executing the target program is provided to a flame graph generation tool (eg, ECharts, d3-flame-graphs), and the flame graph generation tool generates a flame graph corresponding to the at least one core. Figure 3B This is a flame graph corresponding to core 0 provided according to an embodiment of the present disclosure. Figure 3B As shown, taking core 0 as an example, the flame graph in the embodiment of the present disclosure shows the function call execution status of all functions in the process of the core executing the target program, the precise start and end timestamps of each call execution of each function, and the continuous function call relationship, so that complex control flow can be reconstructed by analyzing the generated flame graph. In some embodiments, the flame graph corresponding to the at least one core generated by the flame graph generation tool also has an interactive function, which supports hovering the mouse to display function detailed information (such as function name, function call execution start and end time, function call execution time, the total time of all function call executions of the function as a percentage of the program running time of the target program, the number of function calls, etc.), and also supports clicking to enlarge the flame graph of a certain time period for detailed analysis. It also supports (for example, regular / wildcard) search highlighting function to highlight the selected function, so that it is convenient to observe the execution time of the selected function in each function call execution in the flame graph. Through this intuitive visualization method, the performance of key functions can be quickly located.

[0073] In some embodiments, the concurrent execution status among multiple cores can be displayed in the same timeline dimension of the same interface of the flame graph generation tool, that is, the flame graph corresponding to the at least one core is displayed by the flame graph generation tool on the same interface. Figure 3C The flame graphs corresponding to core 0 and core 1 are provided according to an embodiment of the present disclosure. Figure 3C As shown, taking the concurrent execution of the target program by core 0 and core 1 as an example, the flame graph generation tool displays the flame graphs corresponding to core 0 and core 1 on the same interface. In some embodiments, if you want to analyze the concurrent execution between core 0 and core 1, you can temporarily hide the flame graphs corresponding to other cores. In some embodiments, the flame graph generation tool can display statistical information, which includes the average execution time, the longest execution time, and the shortest execution time of all function calls of each function in the target program, the total execution time of all function calls of each function in the target program as a percentage of the program running time of the target program, and the number of function calls of each function in the target program. Multi-dimensional performance statistical information can provide a full range of performance analysis perspectives. Figure 3D A schematic diagram showing statistical information of a flame graph generation tool provided according to an embodiment of the present disclosure. Figure 3D As shown, during the execution of the target program by core 0, the total execution time of all function calls of the "iprintf" function is 566660000 ps, ​​the average execution time is 10691698.11 ps, the longest execution time is 15390000 ps, ​​the shortest execution time is 6018000 ps, ​​and the number of function calls is 53.

[0074] In some embodiments, a flame graph is used to analyze the performance bottlenecks of the target program, and based on the analysis results, the target program is optimized in a targeted manner, so that a flame graph corresponding to the optimized target program can be further generated according to the flame graph generation method of the embodiment of the present disclosure, so as to gradually optimize the target program. In this way, after several iterations, the target program can be tuned to the optimal performance state. It should be noted that the performance optimization method of the embodiment of the present disclosure can be applied to fields with strict requirements on performance details, such as real-time performance optimization of automotive ECUs, iterative performance optimization before chip tape-out, and performance optimization verification of AI / high-performance computing systems.

[0075] In some embodiments, steps S210 to S240 can be executed in real time while at least one processor is executing the target program, thereby collecting and parsing complete instruction stream information in real time and generating performance data of at least one processor executing the target program in real time. This can reflect the system performance status of the target program in real time through a flame graph, meeting the need for real-time performance analysis and optimization of the target program and shortening the performance analysis and optimization cycle. Of course, steps S210 to S240 can also be executed to perform performance analysis after at least one processor has finished executing the target program.

[0076] Figure 4 FIG. 1 is a flow chart of a performance optimization method according to an embodiment of the present disclosure. Figure 4 As shown, the flame graph generation method of the embodiment of the present disclosure includes:

[0077] In step S410, a flame graph corresponding to the target program is generated according to the flame graph generation method described above.

[0078] In step S420, a performance bottleneck analysis is performed on the target program using the flame graph.

[0079] In step S430, the target program is optimized in a targeted manner according to the analysis result.

[0080] In step S440 , a flame graph corresponding to the optimized target program is generated according to the flame graph generation method described above, so as to gradually optimize the target program.

[0081] Since the specific process of generating flame graphs for performance optimization has been described in detail above, it will not be repeated here.

[0082] Figure 5 FIG. 1 shows a schematic diagram of a flame graph generating device according to an embodiment of the present disclosure. Figure 5 As shown, the flame graph generating device 500 of the embodiment of the present disclosure includes a full program execution information collecting unit 510 , a complete instruction flow information parsing unit 520 , a performance data parsing unit 530 and a flame graph generating unit 540 .

[0083] The full program execution information collection unit 510 is configured to collect, in real time, full program execution information generated by at least one processor during execution of a target program using a performance collection tool.

[0084] The complete instruction stream information parsing unit 520 is configured to parse the complete instruction stream information of the at least one processor in the process of executing the target program from the full program execution information.

[0085] The performance data parsing unit 530 is configured to parse the program symbol table of the target program and the complete instruction stream information to obtain performance data of the target program executed by the at least one processor.

[0086] The flame graph generation unit 540 is configured to provide the performance data to a flame graph generation tool, so that the flame graph generation tool generates a flame graph.

[0087] Since the specific process of generating flame graphs for performance optimization has been described in detail above, it will not be repeated here.

[0088] Figure 6 FIG. 1 shows a schematic diagram of a performance optimization device according to an embodiment of the present disclosure. Figure 6 As shown, the performance optimization device 600 of the embodiment of the present disclosure includes a flame graph generation unit 610 , a performance bottleneck analysis unit 620 and a program optimization unit 630 .

[0089] The flame graph generating unit 610 is configured to generate a flame graph corresponding to the target program according to the flame graph generating apparatus described above.

[0090] The performance bottleneck analysis unit 620 is configured to perform performance bottleneck analysis on the target program using the flame graph.

[0091] The program optimization unit 630 is used to optimize the target program in a targeted manner according to the analysis result.

[0092] The flame graph generating unit 610 is further configured to generate a flame graph corresponding to the optimized target program according to the flame graph generating apparatus described above, so as to gradually optimize the target program.

[0093] Since the specific process of generating flame graphs for performance optimization has been described in detail above, it will not be repeated here.

[0094] The present disclosure also provides an electronic device, such as Figure 7 As shown, it includes a memory 720, a processor 710, and a program stored in the memory 720 and executable on the processor 710. When the program is executed by the processor 810, the various processes of the various embodiments of the above method can be implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0095] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments can be accomplished by instructions, or by instructions controlling related hardware. The instructions can be stored in a computer-readable storage medium and loaded and executed by a processor. To this end, the present disclosure also provides a storage medium having a computer program or instructions stored thereon. When the computer program or instructions are executed by the processor, the various processes of the various embodiments of the above methods can be implemented.

[0096] Since the instructions stored in the storage medium can execute the steps in the method provided in the embodiment of the present disclosure, the beneficial effects that can be achieved by the method provided in the embodiment of the present disclosure can be achieved. For details, please refer to the previous embodiment and will not be repeated here. The specific implementation of each of the above operations can be referred to the previous embodiment and will not be repeated here.

[0097] In summary, according to the embodiments of the present disclosure, the full program execution information generated by at least one processor during the execution of the target program is collected in real time through a performance collection tool, the complete instruction stream information of at least one processor during the execution of the target program is parsed from the full program execution information, the program symbol table and the complete instruction stream information of the target program are parsed, and the performance data of at least one processor executing the target program is obtained. The performance data covers all function call relationships and time consumption distributions during the execution of the target program by at least one processor, thereby improving the data integrity of the generated flame graph. The performance data also records the precise start and end timestamps of the function call execution, eliminating the time dimension distortion of the generated flame graph. The performance data also has call stack continuity, so that the generated flame graph can reconstruct complex control flows. The flame graph generated based on the performance data provides a more reliable performance analysis basis for the performance analysis of the target program.

[0098] Finally, it should be noted that the above embodiments are merely examples for the purpose of illustrating the present disclosure and are not intended to limit the embodiments. Those skilled in the art will readily appreciate that other variations or modifications based on the above descriptions are possible. It is not necessary and impossible to provide an exhaustive list of all embodiments. Obvious variations or modifications arising therefrom remain within the scope of protection of the present disclosure.

Claims

1. A flame graph generation method, comprising: Using a performance acquisition tool, respectively, to collect in real time all program execution information generated by at least one processor during execution of a target program; Parsing complete instruction flow information during the execution of the target program by the at least one processor from the full program execution information; Parsing the program symbol table and the complete instruction stream information of the target program to obtain performance data of the at least one processor executing the target program; The performance data is provided to a flame graph generation tool, and the flame graph generation tool generates a flame graph.

2. The flame graph generation method according to claim 1, wherein: The full program execution information includes execution logs and / or execution traces generated during the execution of the target program by at least one core of the same processor and / or different processors; The step of parsing the complete instruction flow information of the at least one processor during execution of the target program from the full program execution information includes: Taking cores as units, complete instruction stream information of at least one core executing the target program is parsed from the full program execution information, wherein the data structure of the complete instruction stream information includes an instruction memory address and a corresponding instruction execution timestamp.

3. The flame graph generation method according to claim 2, wherein: The data structure of the program symbol table includes a function call instruction memory address and a corresponding function name; The parsing of the program symbol table and the complete instruction stream information of the target program to obtain performance data of the at least one processor executing the target program includes: The program symbol table and the complete instruction stream information of the target program are parsed on a core-by-core basis to obtain performance data of the target program executed by at least one core. The performance data includes the start time, end time and duration of each function call execution of each function in the target program recorded in a time dimension, as well as the function call relationship of each function.

4. The flame graph generation method according to claim 3, wherein: Providing the performance data to a flame graph generation tool, and having the flame graph generation tool generate a flame graph, includes: The performance data of the at least one core executing the target program is provided to the flame graph generation tool, and the flame graph generation tool generates a flame graph corresponding to the at least one core.

5. The flame graph generation method according to claim 4, wherein: After providing the performance data to a flame graph generation tool and the flame graph generation tool generating a flame graph, the flame graph generation method further includes at least one of the following: The flame graph generation tool displays the flame graph corresponding to the at least one core on the same interface; The flame graph generation tool displays statistical information, including the average execution time, the longest execution time, and the shortest execution time of all function calls of each function in the target program, the ratio of the total execution time of all function calls of each function in the target program to the program running time of the target program, and the number of function calls of each function in the target program.

6. A performance optimization method comprising: Generate a flame graph corresponding to a target program according to the flame graph generation method according to any one of claims 1 to 5; Performing performance bottleneck analysis on the target program using the flame graph; Optimizing the target program in a targeted manner according to the analysis results; According to the flame graph generation method according to any one of claims 1 to 5, a flame graph corresponding to the optimized target program is generated to facilitate step-by-step optimization of the target program.

7. A flame graph generating device, comprising: A full program execution information collection unit, configured to collect, in real time, full program execution information generated by at least one processor during execution of a target program using a performance collection tool; a complete instruction stream information parsing unit, configured to parse the complete instruction stream information of the at least one processor in the process of executing the target program from the full program execution information; a performance data parsing unit, configured to parse the program symbol table and the complete instruction stream information of the target program to obtain performance data of the at least one processor executing the target program; The flame graph generation unit is configured to provide the performance data to a flame graph generation tool, so that the flame graph generation tool generates a flame graph.

8. A performance optimization device comprising: a flame graph generating unit, configured to generate a flame graph corresponding to a target program according to the flame graph generating apparatus according to claim 7; a performance bottleneck analysis unit, configured to perform performance bottleneck analysis on the target program using the flame graph; A program optimization unit, configured to optimize the target program in a targeted manner according to the analysis results; The flame graph generating unit is further configured to generate a flame graph corresponding to the optimized target program according to the flame graph generating device according to claim 7, so as to gradually optimize the target program.

9. An electronic device comprising: A processor, a memory, and a program stored in the memory and executable on the processor, wherein the program implements the steps of the method according to any one of claims 1 to 6 when executed by the processor.

10. A storage medium having a computer program or instructions stored thereon, wherein the computer program or instructions, when executed by a processor, implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Function calling time and statistical result visualization method and device, and readable medium

    CN111104104A

  • Software testing method and device, computer equipment and storage medium

    CN111897727A

  • Method for collecting and tracking trace call chain and electronic equipment

    CN113448815A

  • Method and device for automatically analyzing software performance

    CN115658468A

  • Method, system and equipment for analyzing CPU (Central Processing Unit) occupancy condition of program

    CN118113550A