This disclosure relates generally to the technical field of software performance evaluation and, more specifically, to a method and system for evaluating performance of a software application by using trace markers inserted into the code that identify when functions are executed to create a visual mapping of the execution path in order to identify areas where performance can be improved.
Code tracing is a method to visualize the execution of a program or code segment to aid software engineers in the analysis of the performance of their application by capturing and displaying the execution times of their applications' processes. In the past, sifting through all the possible scenarios to optimize an application was extremely time-consuming and was often hit-or-miss to determine the source of the performance issues. Early on code tracing was primarily textual, until visual representations of the trace in cool colors (icicle) or warm colors (fire) charts became popular. In either icicle or fire charts, a “slice” represents the time between the beginning and the end of the execution of a code segment. The trace helps software engineers to analyze the code segments from historical data compiled from use of the application.
Software applications may execute several operations at the same time using multiple threads. Code can produce multiple results simultaneously, in parallel, and in different threads. Multi-threaded applications may include a large number of execution paths and may perform operations in an unexpected manner that affects performance.
For independent threads that are run in parallel, the beginning and the end of the thread can be seen during tracing. However, a function may be run in multiple threads, which requires asynchronous traces, resulting in a chart with more complexity for visualization. If multiple asynchronous threads are present, they can be grouped as being related to a single process. This is distributed tracing, which is a method used to track requests or transmissions throughout a transaction. While distributed tracing allows for top-down visibility of the infrastructure stack, it fails to show the real path of how the functions execute relative to each other. Although useful, distributed tracing does not show the direct connection in terms of how one function schedules another function, only that they are related to one transaction. This type of tracing simply tells you what is happening regarding the transaction that occurred, but not why it is happening, because the inter-relationship of the functions is not shown. Thus, the more complex the software the harder it is to sift through the various threads.
Determining the “why” of what is occurring during operation of the software application is challenging for software engineers because once “what” is happening is known there are a multitude of reasons “why” it might be happening. Conventional tracing shows only the record of the execution program with the sequence of operation but lacks the information about the link between the function and the place (in which function and at which time) it was scheduled. This inhibits software engineers from fully analyzing the cause of performance-related issues of their applications.
The present disclosure is directed to a method and system for evaluating performance of a software application by visually mapping the execution path of functions during use of the application to identify areas for improved performance. The system and method disclosed herein can be utilized with any of a variety of computer programs by inserting trace markers into the code at various points in the code, for example when a given function begins and where the function ends, or where a code segment may be executed in a parallel thread, to map the functions when they are executed by the program.
In an exemplary embodiment, trace markers can be added to a function or a code snippet to indicate that a given section of code has begun and ended. If within the trace markers the code defines a lambda function, then a trace marker can be added within the lambda function with an identifier which represents the initial trace marker.
In an exemplary embodiment, if a Runnable (or a Callable) is created from a function and added to a thread queue, a trace marker with an identifier of the Runnable (or Callable) can be added to the place in the code where it was added to the queue (e.g. where execution of the function “post” of the standard Handler class of Android SDK). Alternatively, if a Message was added to the thread queue, a trace marker with an identifier of the Message to the function responsible to handle the message may be added.
In an exemplary embodiment, a set of pairs of method name identifiers can be defined to link the closest slices on the timeline in the trace, which represent methods in a pair. In addition, a class instance identifier may be added to trace markers to link the closest slices which represent methods in a pair, and which also have the same instance identifier.
To add trace markers as described herein, the computer network that access the code may include an automated system, for example artificial intelligence, that can be utilized to analyze the code and add corresponding lines to the code including trace markers. Alternately, the system to analyze the code and insert trace markers may utilize methods such as bytecode injections or methods swizzling, as would be known to those of skill in the art. Alternatively, other methods of marking the code can be utilized in accordance with the present disclosure to achieve dynamic mapping and visualization, as would also be known to those of skill in the art.
In an exemplary embodiment, which function calls which threads are identified and may be drawn as the user is interacting with the application. Because the disclosed mapping utilizes dynamic tracing it does not require compiling data from multiple uses of the application for analysis, but only a single interaction, and provides an easily identifiable cause for performance-related issues. As will be appreciated, the presently disclosed method and/or system allows for visualization of all the links of its parent functions, and recursively the links of all functions that are linked to the parent functions, to visualize the full execution path which led to the execution of a particular function of the application. As used herein, parent functions include not only those functions which execute the runnable, but also the function which scheduled the runnable.
These aspects of the disclosure are not meant to be exclusive and other features, aspects, and advantages of the present disclosure will be readily apparent to those of ordinary skill in the art when read in conjunction with the following description, appended claims, and accompanying drawings.
The foregoing and other objects, features, and advantages of the disclosure will be apparent from the following description of exemplary embodiments of the disclosure, as illustrated in the accompanying drawings in which like reference characters refer to the same parts throughout the different views. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating the principles of the disclosure.
This disclosure includes examples and references to specific characteristics of marking code to create one or more paths, which together make a visual map, to improve the ease of identification of areas of code where performance can be improved, i.e., optimized. The paths are represented in yellow in the exemplary embodiment but may be represented in any color. The examples and references are provided as exemplary embodiments for the purposes of disclosure and are not intended to limit the scope of the system and methods disclosed herein.
Various embodiments are described below with reference to block diagrams and flowchart illustrations of methods, apparatuses (e.g., systems) and computer program products. Each block of the block diagrams and flowchart illustrations, and combinations of blocks in the block diagrams and flowchart illustrations, respectively, can be implemented by a computer executing computer program instructions. These computer program instructions may be loaded onto a general-purpose computer, special purpose computer, or other programmable data processing apparatus, such that the instructions execute on the computer or other programmable data processing apparatus to implement the functions specified in the flowchart block or blocks.
Accordingly, blocks of the block diagrams and flowchart illustrations support combinations of mechanisms for performing the specified functions, combinations of steps for performing the specified functions, and program instructions for performing the specified functions. It should also be understood that each block of the block diagrams and flowchart illustrations, and combinations of blocks in the block diagrams and flowchart illustrations, are not limited to the order in which they are presented.
Referring now to
Referring now to
The computer network that accesses the code can include an automated system, for example artificial intelligence, that can be utilized to analyze the code and add corresponding lines to the code including trace markers. Alternatively, the system to analyze the code and insert trace markers may utilize methods such as bytecode injections or methods swizzling, i.e., adding custom code before the original code, as would be known to those of skill in the art. Other methods of marking the code can be utilized in accordance with the present disclosure to achieve dynamic mapping and visualization.
As illustrated in
In an exemplary embodiment of
Referring now to
In one exemplary embodiment, the creation of the trace and drawing of the paths may be done concurrently as the user operates the program and recorded during operation 142 while the mobile application is being run. For example, if when a user selects a button on the screen to move to a next step the application slows down, the present mapping technique is able to draw the sequence that the application is running to execute the function as the button is selected. The mapping of the paths is then reviewed to determine which functions are not operating optimally 144, e.g., when the button is pressed by the user, to determine why the application is slowing down in order to correct the problem thereby improving performance of the application.
The placement and execution of the trace markers as disclosed herein results in a path being drawn when the code is run, the combination of paths forming a mapping, as discussed hereinabove. As a result, the link between a particular function and the function it was scheduled from can be readily seen, e.g., by adding a line that represents this connection, as well as any other functions in the thread, and understood by following the path that has been drawn. Compared to running the same code without the trace markers being placed in the code, as shown in
In the exemplary embodiment, the paths are drawn to show visualization of all the links of a function, its parent functions, and recursively the links of all functions that are linked to the parent functions, to visualize the full execution path which led to the execution of a particular function of the application. For example, if a function schedules a task to perform a network request in a dedicated thread and then to perform a closure function when the corresponding response will be received, a path from the closure function to the function which performed the network request and to the initial function where the network request was scheduled is drawn to visualize the full execution path.
The mapping created according to the present disclosure aids in understanding complicated scenarios, for example where a function is run in multiple threads leading to asynchronous traces. The resulting traces have more complexity for visualization when drawn without trace marking, an example of which is shown in
Conventional traces lack the information about the link between the function and the place (in which function and at which time) it was scheduled. The present disclosure improves optimization for computer programs by providing dynamic mapping and visualization that links the function to the place and the time the function was scheduled. Through dynamic tracing the system and method disclosed herein allows for real-time evaluation without the need for collecting historical data that enhances the evaluation of software programs by readily and easily identify areas where performance can be improved. The enhanced visualization of the paths show not only where optimization may be needed, but why it is happening because the inter-relationship of the functions is mapped, along with when and where the functions were scheduled and executed.
It will be appreciated from the above that the invention may be implemented by marking software applications, which may take the form of a mobile application or as an application on a computer, through a transmission medium such as a local-area network or a wide-area network, such as the Internet. It is to be further understood that, because some of the constituent system components and method steps depicted in the accompanying Figures can be implemented in software, the actual connections between the systems components (or the process steps) may differ depending upon the manner in which the present invention is implemented. Given the teachings of the present disclosure provided herein, one of ordinary skill in the related art will be able to contemplate these and similar implementations or configurations of the present disclosure.
While the principles of the invention have been described herein, it is to be understood by those skilled in the art that this description is made only by way of example and not as a limitation as to the scope of the disclosure. Other embodiments are contemplated within the scope of the present disclosure in addition to the exemplary embodiments shown and described herein. Modifications and substitutions by one of ordinary skill in the art are considered to be within the scope of the present disclosure. In addition, it is to be understood that the phraseology and terminology used herein is for the purpose of description and should not be regarded as limiting. The use of “including,” “comprising,” “containing,” “involving,” or “having,” and variations thereof herein, is meant to encompass the items listed thereafter and equivalents thereof as well as additional items while only the terms “consisting only of” or “consisting essentially of” are to be construed in a limitative sense. References to “or” may be construed as inclusive so that any terms described using “or” may indicate any of a single, more than one, and all of the described terms.
Priority is claimed on Provisional Patent Application No. 63/373,353, filed Aug. 4, 2022, the contents of which are incorporated herein by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
63373353 | Aug 2022 | US |