Performance analysis programming framework, method and apparatus
By constructing a program abstraction graph and a user-defined performance analysis data flow graph, the problem of existing tools being unable to provide customized analysis is solved, enabling low-overhead performance analysis for specific scenarios and improving analysis efficiency.
Patent Information
- Application Number
- CN202210105952.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2042-01-28
AI Technical Summary
Existing general-purpose performance analysis tools cannot perform customized analysis for specific scenarios, have high overhead, and require a lot of manual coding, resulting in low efficiency in program performance analysis.
This paper provides a performance analysis programming framework that constructs a program abstract graph by combining static and dynamic techniques, performs performance analysis using user-defined performance analysis data flow graphs, and generates performance analysis reports.
It enables automatic performance analysis in specific scenarios, reducing overhead, improving analysis efficiency, and reducing the need for manual coding.
Smart Images

Figure CN114510419B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a performance analysis programming framework, method and device. BACKGROUND
[0002] At present, for the performance problems such as load imbalance, communication latency and resource contention existing in large-scale parallel applications, a large amount of manual coding is required to perform effective performance analysis by programmers with rich background knowledge. In the related art, a general performance analysis tool is developed to realize automatic performance analysis of the application, but the existing general performance tool has various problems, for example, it cannot be customized for specific scenarios, and has large overhead. SUMMARY
[0003] An object of the present application is to provide a performance analysis method, which can automatically analyze the application performance in a specific scenario, realize user-defined performance analysis tasks and ensure low overhead. Another object of the present application is to provide a performance analysis programming framework. Still another object of the present application is to provide a performance analysis device. Yet another object of the present application is to provide a computer readable medium. Still another object of the present application is to provide a computer device.
[0004] In order to achieve the above objects, in one aspect, the present application discloses a performance analysis method, comprising:
[0005] constructing a program abstract graph according to the application data extracted from the to-be-tested program;
[0006] performing performance analysis according to the program abstract graph through a user-defined performance analysis data flow graph to obtain a performance analysis report, the performance analysis data flow graph being generated according to a user-defined subtask function.
[0007] Preferably, before constructing the program abstract graph according to the application data extracted from the to-be-tested program, the method further comprises:
[0008] extracting the application data of the to-be-tested program through a static-dynamic combination technology.
[0009] Preferably, the application data comprises a control flow graph, a function call graph and performance data.
[0010] extracting the application data of the to-be-tested program through a static-dynamic combination technology, comprising:
[0011] extracting the control flow graph and the function call graph of the to-be-tested program from the to-be-tested program through a first analysis tool;
[0012] extracting the performance data of the to-be-tested program from the to-be-tested program in running through a second analysis tool.
[0013] Preferably, based on the application data extracted from the program under test, a program abstraction diagram is constructed, including:
[0014] Based on the control flow graph, generate a function structure subgraph for each function;
[0015] Based on the function call graph, the function structure subgraphs are merged to obtain the program structure graph;
[0016] Based on the call context corresponding to the performance data, the performance data is associated with the program structure diagram to obtain the program abstract diagram.
[0017] Preferably, before performing performance analysis based on the program abstraction diagram using a user-defined performance analysis data flow diagram to obtain a performance analysis report, the following steps are also included:
[0018] Receive subtask operations on the program abstract graph input by the user through a preset interface;
[0019] Based on the subtask operations, generate multiple analysis subtask functions;
[0020] Multiple analysis subtask functions are combined to generate a performance analysis data flow graph.
[0021] Preferably, before performing performance analysis based on the program abstraction diagram using a user-defined performance analysis data flow diagram to obtain a performance analysis report, the following steps are also included:
[0022] Call multiple target subtask functions selected by the user from the preset analysis subtask function library;
[0023] Multiple target subtask functions are combined to generate a performance analysis data flow graph.
[0024] Preferably, the performance analysis data flow graph includes multiple analysis subtask functions;
[0025] Performance analysis is performed based on the program abstraction diagram using a user-defined performance analysis data flow diagram, resulting in a performance analysis report, including:
[0026] Input the program abstract graph into the performance analysis data flow graph, execute multiple analysis subtask functions, and output a performance analysis report.
[0027] This invention also discloses a performance analysis programming framework, the device programming framework comprising:
[0028] The program performance programming abstraction layer is used to construct a program abstraction graph based on the application data extracted from the program under test.
[0029] The performance analysis process programming abstraction layer is used to generate performance analysis data flow graphs based on user-defined subtask functions.
[0030] The application further discloses a performance analysis device, comprising:
[0031] A construction unit is configured to construct a program abstract graph according to application data extracted from a program to be tested.
[0032] A performance analysis unit is configured to perform performance analysis on the program abstract graph according to a user-defined performance analysis data flow graph to obtain a performance analysis report, wherein the performance analysis data flow graph is generated according to a user-defined subtask function.
[0033] The application further discloses a computer readable medium, which stores a computer program, and the program is executed by a processor to implement the method.
[0034] The application further discloses a computer device, which comprises a memory and a processor, wherein the memory is configured to store information comprising program instructions, and the processor is configured to control execution of the program instructions, and the processor implements the method when executing the program.
[0035] The application constructs a program abstract graph according to application data extracted from a program to be tested, and performs performance analysis on the program abstract graph according to a user-defined performance analysis data flow graph to obtain a performance analysis report, wherein the performance analysis data flow graph is generated according to a user-defined subtask function, and the application can automatically analyze application performance in a specific scenario, implement a user-defined performance analysis task and ensure low overhead. BRIEF DESCRIPTION OF DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.
[0037] Figure 1 A structural schematic diagram of a performance analysis programming framework provided by the embodiment of the present application;
[0038] Figure 2 A flowchart of a performance analysis method provided by the embodiment of the present application;
[0039] Figure 3 A flowchart of another performance analysis method provided by the embodiment of the present application;
[0040] Figure 4 A structural schematic diagram of a program abstract graph provided by the embodiment of the present application;
[0041] Figure 5A logic diagram for analyzing subtask function running provided by the embodiment of the present application is shown in the figure;
[0042] Figure 6a A schematic diagram of the process internal structure extraction of the program to be tested provided by the embodiment of the present application is shown in the figure;
[0043] Figure 6b A schematic diagram of the program structure diagram obtained by the inter-process analysis provided by the embodiment of the present application is shown in the figure;
[0044] Figure 6c A schematic diagram of the program abstract diagram obtained by the data association provided by the embodiment of the present application is shown in the figure;
[0045] Figure 7a A schematic diagram of the thread flow of each thread provided by the embodiment of the present application is shown in the figure;
[0046] Figure 7b A schematic diagram of the parallel view of the program abstract diagram provided by the embodiment of the present application is shown in the figure;
[0047] Figure 8 A performance analysis data flow diagram taking the communication analysis as an example provided by the embodiment of the present application is shown in the figure;
[0048] Figure 9 A structural schematic diagram of the performance analysis device provided by the embodiment of the present application is shown in the figure;
[0049] Figure 10 A structural schematic diagram of the computer device provided by the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0050] The technical solutions in the embodiments of the present application will be described clearly and completely 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 of the present application. Based on the embodiments in the present application, all the other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0051] For the convenience of understanding the technical solutions provided in the present application, the related content of the technical solutions of the present application will be described first. Performance analysis is essential for understanding and optimizing application programs, and is widely used in different fields such as scientific computing, machine learning and big data processing. Specifically, it refers to an analysis method that studies program behavior by collecting program runtime information. Automatically analyzing the performance of parallel application programs can effectively improve the efficiency of programmers in understanding and optimizing application programs. At present, general performance analysis tools mainly include two categories: program profile-based and event trace-based performance analysis tools. Among them, the program profile-based performance analysis tool records program snapshots regularly and analyzes the overall statistical performance data of the program, and its overhead is very low. For example: a typical program profile-based performance analysis tool is HPCToolkit, which is a general performance analysis tool for measuring and analyzing the performance of programs on computers. This tool uses the program profile-based method for runtime performance data collection. Specifically, HPCToolkit collects program runtime, statistical values of performance monitoring units (such as the number of executed instructions, cache miss rate, etc.) by using timers and sampling functions of performance monitoring units, and associates them to the corresponding complete call context. Since HPCToolkit uses the above-mentioned program profile-based method (also known as sampling technology), the measurement overhead is low (about 1-5%) and can be extended to large parallel systems. HPCToolkit supports measurement and analysis of serial code, multi-threaded code (such as pthreads, OpenMP), MPI and multi-threaded hybrid parallel code. On the other hand, since HPCToolkit uses the program profile-based method, it only records program snapshots at certain time points, and the program behavior between time points is not completely recorded, so the tool loses critical information for in-depth analysis, such as data dependence, communication mode, etc. The lack of these information leads to that the tool only supports general performance analysis, such as hot spot analysis, balance analysis, etc., and cannot support in-depth analysis in complex scenarios. In addition, HPCToolkit is an end-to-end performance analysis tool that does not support users to use the performance data collected by the tool for further analysis. This means that if the user has analysis needs beyond the functions of HPCToolkit, a large amount of manual coding combined with special skills of performance analysis is needed, which wastes labor, has low automation degree, and leads to low efficiency of program performance analysis.
[0052] Event-trace-based tools track and record all events during program execution, and their logs contain rich information, including computation, memory access, and communication characteristics. However, the runtime overhead and log storage overhead of event-trace-based tools are large. Typical event-trace-based tools include Scalasca, Vampir, and TAU, etc. Taking Scalasca as an example, Scalasca is a software that supports performance data collection and analysis. The event-trace-based technique collects performance data at runtime. Specifically, when a specified function is called or ends, Scalasca records the current performance monitoring unit and the call parameters of the specified function. The tool can record all event traces of the specified function on the time axis and analyze the related lock and communication patterns. According to the information in the log, Scalasca analyzes the dependencies of inter-process performance problems and deeply analyzes performance problems. However, because Scalasca frequently interrupts the program and records events and corresponding parameters at runtime, it introduces a large runtime overhead, which is usually one to several hundred times. In addition, the log that records all event traces during the running process occupies a large storage space, which is usually in the order of GB to TB. Especially for large-scale parallel programs, the storage overhead introduced by recording logs is even larger. In addition, the tool does not support user customization of its recorded logs for performance analysis, and users still need to manually code a large amount of customization for in-depth analysis, resulting in low program performance analysis efficiency and large overhead, wasting resources.
[0053] In addition, large-scale parallel applications contain complex data and control dependencies, as well as complex inter-thread locks and inter-process communication patterns, which make performance problems more complex. Locating the root cause of performance problems in these complex scenarios requires further in-depth analysis by users, and general performance analysis tools cannot perform in-depth performance analysis and root cause positioning for specific scenarios. However, many current in-depth performance analysis methods for specific scenarios can automatically locate different types of performance problems in different scenarios, such as critical path analysis and root cause analysis. However, these performance analysis methods only focus on a specific scenario of parallel program performance problems, but performance problems of parallel programs can involve multiple factors that are intertwined in a complex way and give rise to various scenarios, such as complex communication, lock patterns, and data dependencies that hide performance problems in an unpredictable way, and different types of performance problems affecting each other. For the above complex scenarios, users need to design specific performance analysis tasks to locate performance problems. However, implementing specific performance analysis tasks requires a large amount of professional knowledge and manual coding, resulting in low user development efficiency.
[0054] To sum up, to solve the above technical problems, the embodiment of the present application provides a programming framework for performance analysis, which can help users to efficiently realize the deep performance analysis method for specific scenarios. Figure 1 The structure diagram of the performance analysis programming framework provided by the embodiment of the present application is shown in Figure 1 The performance analysis programming framework includes a program performance programming abstraction layer and a performance analysis process programming abstraction layer. The program performance programming abstraction layer includes static and dynamic analysis and construction of a program abstraction graph, which is used to construct a program abstraction graph according to application data extracted from a program to be tested. Specifically, the program to be tested is subjected to static and dynamic analysis, and program performance related data is extracted and collected, and the program performance behavior is converted into a program abstraction graph in combination with all the data. The performance analysis process programming abstraction layer includes an analysis subtask function library and a performance analysis data flow graph, which is used to generate a performance analysis data flow graph according to a user defined subtask function. Specifically, a bottom programming interface is provided to access program performance data and realize self-defined analysis subtasks, and a high-level programming interface is provided to assist in constructing a performance analysis data flow graph to represent the flow of a specific analysis task. Through the above interfaces, users can efficiently realize performance analysis tasks.
[0055] It is worth noting that, Figure 1 The performance analysis programming framework shown in Figure 2 or Figure 3 The performance analysis programming framework method, for specific processes, please refer to Figure 2 or Figure 3 The performance analysis programming framework method, which will not be described here.
[0056] The following takes a performance analysis device as an example to illustrate the implementation process of the performance analysis method provided by the embodiment of the present application. It can be understood that the execution subject of the performance analysis method provided by the embodiment of the present application includes but is not limited to the performance analysis device.
[0057] Figure 2 The flowchart of the performance analysis method provided by the embodiment of the present application is shown in Figure 2 The method includes:
[0058] Step 101, constructing a program abstraction graph according to application data extracted from a program to be tested.
[0059] Step 102, performing performance analysis according to the program abstraction graph through a user defined performance analysis data flow graph to obtain a performance analysis report, wherein the performance analysis data flow graph is generated according to a user defined subtask function.
[0060] The technical scheme provided by the embodiment of the present application comprises the following steps: constructing a program abstract graph according to application data extracted from a program to be tested; performing performance analysis according to the program abstract graph through a user-defined performance analysis data flow graph to obtain a performance analysis report, wherein the performance analysis data flow graph is generated according to a user-defined subtask function, and can automatically analyze application performance in a specific scenario, and can realize a user-defined performance analysis task and ensure low overhead.
[0061] Figure 3 The flowchart of another performance analysis method provided by the embodiment of the present application is shown in FIG. 2, and the method comprises the following steps: Figure 3
[0062] In step 201, application data of the program to be tested is extracted through a static-dynamic combination technique.
[0063] In the embodiment of the present application, each step is executed by a performance analysis device.
[0064] In the embodiment of the present application, the application data comprises but is not limited to a control flow graph, a function call graph and performance data.
[0065] In the embodiment of the present application, step 201 specifically comprises the following steps:
[0066] In step 2011, a control flow graph and a function call graph of the program to be tested are extracted from the program to be tested through a first analysis tool.
[0067] In the embodiment of the present application, the first analysis tool can be selected according to actual requirements, and the embodiment of the present application does not limit this. As an optional solution, the first analysis tool is a Dyninst tool. Specifically, when the program to be tested is static, the control flow graph and the function call graph are extracted from a binary executable file of the program to be tested through the Dyninst tool.
[0068] In step 2012, performance data of the program to be tested is extracted from the running program to be tested through a second analysis tool.
[0069] In the embodiment of the present application, the second analysis tool can be selected according to actual requirements, and the embodiment of the present application does not limit this. As an optional solution, the second analysis tool is a PAPI tool and a PMPI tool. Specifically, when the program to be tested is dynamic, the running program to be tested is sampled and dynamically plugged through the PAPI tool and the PMPI tool to collect performance data and dynamic structure information. The dynamic structure information is structure information that cannot be obtained when the program to be tested is static, for example, indirect call, lock, communication, etc.
[0070] In the embodiment of the present application, the application data of the program to be tested is extracted through the static-dynamic combination technique, and compared with pure dynamic analysis, the running overhead can be significantly reduced.
[0071] Step 202, constructing a program abstract graph according to the application data extracted from the program to be tested.
[0072] In the embodiment of the present application, the process of constructing the program abstract graph includes intra-process analysis, inter-process analysis and data correlation. Specifically, the intra-process analysis is to generate a function structure subgraph of each function according to a control flow graph; the inter-process analysis is to merge the function structure subgraphs to obtain a program structure graph according to a function call graph; and the process of data correlation is to associate the performance data with the program structure graph according to the call context corresponding to the performance data, so as to obtain the program abstract graph, wherein each piece of performance data corresponds to a call context, the performance data is associated with the matched vertex in the program structure graph through the vertex matching of the call context, and the program abstract graph is obtained. Figure 4 A structural schematic diagram of the program abstract graph provided by the embodiment of the present application is shown in FIG. 1. Figure 4 As shown in FIG. 1, the call contexts are _start, main, foo and pthread_create, which indicate that the call context starts from the main function and ends at the pthread_create function; the call context is searched from the root node of the program structure graph, that is, the main function is searched from the root node, and the search is performed until the pthread_create function is searched, the vertex corresponding to the matched function is associated with the performance data, and the program abstract graph is constructed. As shown in FIG. 2, the vertex corresponding to the matched call context function is represented by a thick line in the graph. Figure 4
[0073] In the embodiment of the present application, the program abstract graph is a weighted directed graph G=(V, E), which represents the performance of the program. The program abstract graph includes vertices and edges, each vertex v∈V represents a code segment or a control structure vertex of a program, the label of the vertex indicates the type of the vertex, including but not limited to functions, calls, loops and instructions, the call types include but are not limited to custom function calls, communication function calls, external function calls, recursive calls, indirect calls and the like; and the attribute represents the performance data recorded on the vertex, including but not limited to execution time, performance monitoring unit data, communication data, function call times, iteration times and the like, which specifically depends on the specific requirements of the analysis task, and the embodiment of the present application does not limit the same.
[0074] Each edge e=(vsrc, vdest) E in the program abstraction graph connects a source vertex (vsrc) and a destination vertex (vdest), and the label of the edge represents the type of the edge, including four types of intra-procedure, inter-procedure, inter-thread and inter-process. The intra-procedure edge represents the control flow of a function; the inter-procedure edge represents the function call relationship; the inter-thread edge represents the data dependency between different threads, such as a waiting event caused by a lock; and the inter-process edge represents the communication between different processes, including synchronous point-to-point communication, asynchronous point-to-point communication and collective communication. The attribute of the edge represents the data recorded on the edge, which can be performance data, execution time of communication, communication data volume, and waiting event time, etc., depending on the type of the edge and runtime data, which is not limited in the present application.
[0075] It is worth noting that the program abstraction graph includes two views, namely a top-down view and a parallel view, the top-down view only contains intra-procedure and inter-procedure edges; and the parallel view contains all types of edges, including intra-procedure, inter-procedure, inter-thread and inter-process edges.
[0076] Step 203, generating a performance analysis data flow graph.
[0077] In the embodiment of the present application, step 203 specifically includes:
[0078] Step 2031, receiving a sub-task operation on the program abstraction graph input by a user through a preset interface.
[0079] In the embodiment of the present application, different application programming interfaces (API) interfaces are provided, so that the user can conveniently and quickly realize an analysis sub-task function through the API interface. The API interface includes but is not limited to a graph operation interface, a graph algorithm interface and a set operation interface. The graph operation interface provides a channel for the user to access the vertices and edges on the program abstraction graph, and the user can access the name, type, performance data and debugging information of the vertices and edges on the program abstraction graph through the graph operation interface. The user can also modify the program abstraction graph through the graph operation interface. The graph algorithm interface provides a channel for the user to execute various graph algorithms on the program abstraction graph, and the graph algorithms include but are not limited to breadth-first search, subgraph matching and community discovery. The user can use these algorithms and combine with custom constraints to realize a specific analysis sub-task function. The set operation interface provides a channel for the user to operate the point and edge set of the program abstraction graph, and the user operations include but are not limited to element sorting, filtering, classification, and calculation of intersection, union, complement and difference of sets.
[0080] Step 2032, generating a plurality of analysis sub-task functions according to the sub-task operation.
[0081] Specifically, the user inputs a subtask operation through an API interface, the subtask operation including but not limited to a calculation operation on a set in a program abstract graph, a graph algorithm operation on the program abstract graph, and the like, and an analysis subtask function corresponding to the subtask operation is generated. Taking hotspot detection as an example, hotspot detection refers to finding a code segment with the highest value of a specific index, such as total execution cycle, cache miss, and instruction number. The most common hotspot detection is to identify the most time-consuming code segment, and the specific index is total execution time. The hotspot detection function hotspot is used to detect the hotspot vertex according to the index m used for hotspot sorting, and the index m and the first n hotspot vertices detected are returned, that is, the most serious n hotspots are returned. Different types of hotspots can be detected through the index m, and the specific setting of the index m can be set according to actual needs, which is not limited in the embodiment of the application.
[0082] Step 2033, combining the plurality of analysis subtask functions to generate a performance analysis data flow graph.
[0083] In the embodiment of the application, the plurality of analysis subtask functions are connected and combined according to the sequence of the subtask operations to generate a performance analysis data flow graph.
[0084] As another optional solution, step 203 specifically includes:
[0085] Step 3031, calling a plurality of target subtask functions selected by the user from a preset analysis subtask function library.
[0086] In the embodiment of the application, the analysis subtask function library is constructed according to common performance analysis scenarios, and the analysis subtask function library includes a plurality of built-in analysis subtask functions. The user can select target subtask functions from the analysis subtask function library according to scenario requirements.
[0087] Step 3032, combining the plurality of target subtask functions to generate a performance analysis data flow graph.
[0088] In the embodiment of the application, the user can combine the plurality of target subtask functions according to scenario requirements to generate a performance analysis data flow graph.
[0089] It is worth noting that if the built-in analysis subtask functions in the analysis subtask function library are insufficient to support the user's requirements, the user can implement a custom analysis subtask function using the method provided in steps 2031 to 2033, and then combine the custom analysis subtask function and the built-in analysis subtask function to construct a performance analysis data flow graph.
[0090] Furthermore, for performance analysis tasks in some common scenarios, this embodiment of the invention also provides multiple built-in performance analysis models, represented as performance analysis data flow graphs, such as: Messaging Interface (MPI) communication analysis model, critical path analysis model, and scalability analysis model. When facing performance analysis tasks in common scenarios, users can directly call the corresponding built-in performance analysis model to perform performance analysis, thereby improving performance analysis efficiency.
[0091] In this embodiment of the invention, the performance analysis process is abstracted as a performance analysis data flow graph. Each vertex in the performance analysis data flow graph represents an analysis subtask function, such as a running phase, analysis subtask, and result reporting phase. Each edge represents the input or output of a vertex. Specifically, the analysis result of each analysis subtask function is input to the next analysis subtask function through an edge. The performance abstract graph includes a vertex set and an edge set. The elements in the set are updated as the set flows through the vertices of the performance analysis data flow graph. The vertices and edges contained in the set represent the results of an analysis subtask, corresponding to code segments or the relationships between code segments. The specific input and output sets of each analysis subtask function are defined by the function itself, but each set is either a vertex set or an edge set.
[0092] Figure 5 A logical diagram illustrating the execution of an analysis subtask function is provided as an embodiment of the present invention, such as... Figure 5 As shown, taking an analysis subtask function as an example, the input set (V1, E1) is input into the analysis subtask function, the analysis subtask function is executed, and the output set (V2, E2) is generated. The format of the input set and the format of the output set are determined by the design of the analysis subtask function. Users can flexibly use and combine analysis subtask functions to construct the structure of performance analysis data flow graphs.
[0093] Step 204: Perform performance analysis based on the program abstract diagram using the user-defined performance analysis data flow diagram to obtain a performance analysis report. The performance analysis data flow diagram is generated based on the user-defined subtask functions.
[0094] In this embodiment of the invention, the performance analysis data flow diagram is designed for general analysis tasks or common scenarios. The performance analysis data flow diagram includes multiple analysis sub-task functions to complete specific performance analysis tasks. Users can directly use the performance analysis data flow diagram to obtain relevant performance analysis reports. Furthermore, users can also add analysis sub-task functions to existing performance analysis data flow diagrams to meet specific analysis needs.
[0095] Specifically, the program abstract graph is input into the performance analysis data flow graph, multiple analysis subtask functions are executed, and a performance analysis report is output. The performance analysis report includes key attributes of the communication functions with performance issues, including but not limited to function name, communication mode, debugging information, and execution time.
[0096] The performance analysis method is explained in detail below with a specific example:
[0097] The program under test is a parallel program using MPI and Pthreads, which includes three functions: main, foo, and add. Figure 6a This is a schematic diagram of the structure extraction within a program under test provided in an embodiment of the present invention, as shown below. Figure 6a As shown, the function structure subgraph of the `main` function has `main` as the root node, with `Loop_1` and `printf` as child nodes. `foo`, `pthread_mute_lock`, `pthread_mute_unlock`, and `pthread_join` are child nodes of `Loop_1`. The function structure subgraph of the `foo` function has `foo` as the root node, with `pthread_create`, `Loop_1`, and `MPI_Sendrecv` as child nodes. The function structure subgraph of the `add` function has `add` as the root node, with `pthread_mute_lock`, `Loop_1`, and `pthread_mute_unlock` as child nodes. Merging the function structure subgraphs of each function yields the program structure graph. Figure 6b A schematic diagram of a program structure obtained from inter-process analysis is provided in an embodiment of the present invention, such as... Figure 6b As shown, the call relationship used is that the pthread_create function calls the add function. The program structure diagram includes the main node, foo node, pthread_create node, and add node. Based on the call context corresponding to the performance data, the performance data is associated with the program structure diagram to obtain the program abstract diagram. Figure 6c This is a schematic diagram of a data association program abstraction diagram provided in an embodiment of the present invention, such as... Figure 6c As shown, the call context includes pthread_mute_lock, Loop_1.2, MPI_Sendrecv, and Loop_1.1. Following the call context, the program structure graph is searched downwards from the root node, and the vertices corresponding to the matched functions are associated with performance data to form the program abstract graph. For example... Figure 6cAs shown, the matched call context function corresponding vertex is represented by line thickening in the graph. As another alternative, if hotspot detection is performed, the vertex can also be shown in different colors to represent the severity of the hotspot, which is normalized according to the proportion of the vertex in the total time, so as to facilitate the user to intuitively obtain the conclusion. Figure 6c The program abstraction graph shown is a top-down view, and only contains intra-process and inter-process edges.
[0098] Figure 7a A thread stream diagram of each thread is provided for the embodiment of the present application, as shown in Figure 7a A stream is generated for each thread, and the stream is a vertex access sequence recorded by performing pre-order traversal on a specific part of the top-down view of the program abstraction graph. The traversal is thread-granularity, and specifically, when a pthread_create node or an OMP_parallel function (both of which create a new thread) is encountered during the traversal, a pre-order traversal stream is newly created, and after the new traversal stream ends, the previous traversal stream is continued, so as to ensure that each traversal stream represents a single thread. Inter-thread and inter-process edges are added to the thread stream to obtain a program stream graph. The inter-thread and inter-process edges represent locks, communications, and the like across the process and thread streams; performance data is associated with the program stream graph to generate a parallel view of the program stream graph. Figure 7b A parallel view of a program abstraction graph is provided for the embodiment of the present application, as shown in Figure 7b Two parallel program streams are associated through an MPI_Sendrecv node. The parallel view contains all types of edges, including intra-process, inter-process, inter-thread, and inter-process edges.
[0099] Taking a communication analysis task as an example, when analyzing the communication performance of a program, the balance of communication is one of the key points. If unbalanced behavior of communication is detected, the user needs to further decompose the performance to determine the reason for the imbalance, which has many reasons, including different message sizes, unbalanced computing load before communication, and the like. In the face of a communication analysis task, Figure 8 A performance analysis data flow graph taking a communication analysis task as an example is provided for the embodiment of the present application, and the performance analysis data flow graph for communication analysis is referred to as an MPI communication analysis model, as shown in Figure 8 The MPI communication analysis model runs, and the program abstraction graph is input into the MPI communication analysis model, and after passing through the filter, the hotspot detection, the balance analysis, and the decomposition analysis sub-task functions, a performance analysis report is output. The performance analysis report includes but is not limited to function name, communication mode, debugging information, and execution time.
[0100] The performance analysis method provided by the application introduces about 1.56% runtime overhead and about 2.4MB storage overhead through actual tests, and can realize user-defined performance analysis tasks and ensure low overhead through a small amount of code and different levels of abstract interfaces. The user-defined performance analysis tasks include, but are not limited to, scalability analysis tasks, root cause analysis tasks and critical path analysis tasks.
[0101] In the technical scheme of the performance analysis method provided by the embodiment of the application, the program abstract graph is constructed according to the application data extracted from the program to be measured; the performance analysis is performed according to the program abstract graph through the user-defined performance analysis data flow graph, and the performance analysis report is obtained. The performance analysis data flow graph is generated according to the user-defined subtask function, can automatically analyze the application performance in a specific scenario, realize the user-defined performance analysis tasks and ensure low overhead. The user-defined performance analysis tasks include, but are not limited to, scalability analysis tasks, root cause analysis tasks and critical path analysis tasks.
[0102] Figure 9 A structural schematic diagram of a performance analysis device provided by the embodiment of the application is shown in the figure. Figure 9 The device comprises a construction unit 11 and a performance analysis unit 12.
[0103] The construction unit 11 is configured to construct a program abstract graph according to the application data extracted from the program to be measured.
[0104] The performance analysis unit 12 is configured to perform performance analysis according to the program abstract graph through the user-defined performance analysis data flow graph, and obtain a performance analysis report. The performance analysis data flow graph is generated according to the user-defined subtask function.
[0105] In the embodiment of the application, the device further comprises an extraction unit 13.
[0106] The extraction unit 13 is configured to extract the application data of the program to be measured through a static-dynamic combination technology.
[0107] In the embodiment of the application, the extraction unit 13 is specifically configured to extract the control flow graph and the function call graph of the program to be measured from the program to be measured through a first analysis tool; and extract the performance data of the program to be measured from the running program to be measured through a second analysis tool.
[0108] In the embodiment of the application, the extraction unit 13 is specifically configured to generate a function structure subgraph of each function according to the control flow graph; merge the function structure subgraphs to obtain a program structure graph according to the function call graph; and associate the performance data with the program structure graph according to the calling context corresponding to the performance data, to obtain the program abstract graph. In the embodiment of the application, the extraction unit 13 is specifically configured to generate a function structure subgraph of each function according to the control flow graph; merge the function structure subgraphs to obtain a program structure graph according to the function call graph; and associate the performance data with the program structure graph according to the calling context corresponding to the performance data, to obtain the program abstract graph.
[0109] In the embodiment of the present application, the device further comprises a receiving unit 14, a first generating unit 15 and a second generating unit 16.
[0110] The receiving unit 14 is configured to receive a subtask operation on the program abstract graph input by a user through a preset interface.
[0111] The first generating unit 15 is configured to generate a plurality of analysis subtask functions according to the subtask operation.
[0112] The second generating unit 16 is configured to combine the plurality of analysis subtask functions to generate a performance analysis data flow graph.
[0113] In the embodiment of the present application, the device further comprises a selecting unit 17 and a combining unit 18.
[0114] The selecting unit 17 is configured to call a plurality of target subtask functions selected by the user from a preset analysis subtask function library.
[0115] The combining unit 18 is configured to combine the plurality of target subtask functions to generate a performance analysis data flow graph.
[0116] In the embodiment of the present application, the performance analysis unit 12 is specifically configured to input the program abstract graph into the performance analysis data flow graph, execute the plurality of analysis subtask functions, and output a performance analysis report.
[0117] In the scheme of the embodiment of the present application, a program abstract graph is constructed according to application data extracted from a program to be tested; a performance analysis report is obtained by performing performance analysis on the program abstract graph according to a performance analysis data flow graph defined by a user, the performance analysis data flow graph is generated according to a subtask function defined by the user, and the application performance in a specific scenario can be automatically analyzed, the performance analysis task defined by the user is implemented, and a low overhead is ensured.
[0118] The system, device, module or unit illustrated in the above embodiments can be specifically implemented by a computer chip or entity, or by a product having certain functions. A typical implementation device is a computer device, and specifically, the computer device may, for example, be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an electronic mail device, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0119] The embodiment of the present application provides a computer device, which comprises a memory and a processor, the memory is used to store information including program instructions, the processor is used to control the execution of the program instructions, and each step of the above-mentioned performance analysis method is implemented when the program instructions are loaded and executed by the processor. For specific description, refer to the above-mentioned performance analysis method.
[0120] Reference will now be made to the following description Figure 10 which shows a schematic diagram of a computer device 600 suitable for use in implementing embodiments of the application.
[0121] As shown in Figure 10 , the computer device 600 includes a central processing unit (CPU) 601 which can perform various appropriate works and processes according to programs stored in a read only memory (ROM) 602 or loaded into a random access memory (RAM) 603 from a storage section 608. In the RAM 603, various programs and data required for the operation of the computer device 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0122] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 606 as necessary. A removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 610 as necessary, so that a computer program read out therefrom is installed in the storage section 608 as necessary.
[0123] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program in accordance with embodiments of the application. For example, embodiments of the application include a computer program product comprising a computer program tangibly embodied on a machine readable medium, the computer program comprising program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication section 609 and / or installed from the removable media 611.
[0124] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.
[0125] For the convenience of description, the above device is described as various units respectively described in function. Of course, in the implementation of the present application, the functions of each unit can be implemented in the same or more software and / or hardware.
[0126] The present application is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device that implements the functions specified in the flowchart and / or block diagram. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in one or more blocks or flows.
[0127] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including instruction devices that implement the functions specified in the flowchart and / or block diagram. Figure 1 one or more flows and / or blocks Figure 1 an apparatus that performs the functions specified in one or more blocks or flows.
[0128] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operational steps are performed on the computer or other programmable data processing devices to generate a computer-implemented process, thus the instructions executed on the computer or other programmable data processing devices provide the function of implementing the processes specified in the flowchart Figure 1 one or more flows and / or blocks Figure 1 one or more blocks or several blocks.
[0129] It should also be noted that the terms "comprising", "comprises" or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.
[0130] The acquisition, storage, use, processing and the like of data in the technical solutions of the present application comply with the relevant provisions of national laws and regulations.
[0131] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, system or computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage and the like) containing computer-usable program code.
[0132] The present application can be described in the general context of computer-executable instructions, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform particular tasks or implement particular abstract data types. The present application can also be practiced in a distributed computing environment, where tasks are performed by remote processing devices that are connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media, including storage devices.
[0133] Each of the embodiments in the specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the difference from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.
[0134] The above merely provides an example of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application should be included in the scope of claims of the present application.
Claims
1. A performance analysis method, characterized in that, The method includes: Construct an abstract diagram of the program based on the application data extracted from the program under test; Receive subtask operations on the program abstract graph input by the user through a preset interface; Based on the subtask operations, multiple analysis subtask functions are generated; Multiple analysis subtask functions are combined to generate a performance analysis data flow graph; or... Call multiple target subtask functions selected by the user from the preset analysis subtask function library; The multiple target subtask functions are combined to generate a performance analysis data flow graph; A performance analysis report is obtained by performing performance analysis based on the program abstraction diagram using a user-defined performance analysis data flow diagram, which is generated from user-defined subtask functions.
2. The performance analysis method according to claim 1, characterized in that, Before constructing the program abstraction graph based on the application data extracted from the program under test, the following steps are also included: Application data of the program under test is extracted using a combination of static and dynamic techniques.
3. The performance analysis method according to claim 2, characterized in that, The application data includes control flow graphs, function call graphs, and performance data; The extraction of application data from the program under test using a combination of static and dynamic techniques includes: Using the first analysis tool, the control flow graph and function call graph of the program under test are extracted from the program under test. The second analysis tool is used to extract the performance data of the program under test from the program under test during operation.
4. The performance analysis method according to claim 3, characterized in that, The step of constructing a program abstraction diagram based on application data extracted from the program under test includes: Based on the control flow graph, generate a function structure subgraph for each function; Based on the function call graph, the function structure subgraphs are merged to obtain the program structure graph; Based on the call context corresponding to the performance data, the performance data is associated with the program structure diagram to obtain a program abstract diagram.
5. The performance analysis method according to claim 1, characterized in that, The performance analysis data flow graph includes multiple analysis subtask functions; The performance analysis report, obtained by performing performance analysis based on the program abstraction diagram using a user-defined performance analysis data flow diagram, includes: The program abstract graph is input into the performance analysis data flow graph, multiple analysis subtask functions are executed, and the performance analysis report is output.
6. A performance analysis programming framework, characterized in that, The programming framework includes: The program performance programming abstraction layer is used to construct a program abstraction graph based on the application data extracted from the program under test. The performance analysis process programming abstraction layer is used to generate performance analysis data flow graphs based on user-defined subtask functions; The performance analysis process programming abstraction layer is specifically used to receive subtask operations on the program abstraction graph input by the user through a preset interface; generate multiple analysis subtask functions based on the subtask operations; combine the multiple analysis subtask functions to generate a performance analysis data flow graph; or, call multiple target subtask functions selected by the user from a preset analysis subtask function library; combine the multiple target subtask functions to generate a performance analysis data flow graph.
7. A performance analysis device, characterized in that, The device includes: The building unit is used to construct an abstract diagram of the program based on the application data extracted from the program under test. The performance analysis unit is used to perform performance analysis based on the program abstraction diagram using a user-defined performance analysis data flow diagram, and to obtain a performance analysis report. The performance analysis data flow diagram is generated based on user-defined subtask functions. The device further includes: The receiving unit is used to receive subtask operations on the program abstract graph input by the user through a preset interface; The first generation unit is used to generate multiple analysis subtask functions based on the subtask operations; The second generation unit is used to combine multiple analysis subtask functions to generate a performance analysis data flow graph. The device further includes: The selection unit is used to call multiple target subtask functions selected by the user from a preset analysis subtask function library; The combination unit is used to combine multiple target subtask functions to generate a performance analysis data flow graph.
8. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the performance analysis method as described in any one of claims 1 to 5.
9. A computer device comprising a memory and a processor, the memory for storing information including program instructions, and the processor for controlling the execution of the program instructions, characterized in that, When the program instructions are loaded and executed by the processor, they implement the performance analysis method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Online performance change detection method and system in parallel program running period
CN106294136A
Data-driven big data analysis method, system and device, storage medium and terminal
CN111581932A