Analyzing program based on combination of dynamic detection and sampling
By combining a dynamic, lightweight detection and memory allocation analyzer, and dynamically collecting program function call counts and execution times, the problems of inaccurate sampling analyzers and high overhead detection analyzers are solved, achieving efficient and accurate program performance analysis.
Patent Information
- Application Number
- CN202380028732.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-04-11
- Filing Date
- 2023-01-26
- Publication Date
- 2024-11-05
AI Technical Summary
Among existing program performance analysis methods, sampling analyzers have low overhead but inaccurate information, while detection analyzers are accurate but have high overhead and are highly interfering, making them difficult to use in large-scale applications.
By combining dynamic, lightweight detection with another analyzer, code instructions are dynamically inserted to initialize counters and timers by collecting function call counts and execution times during program execution, reducing detection overhead, and combining with a memory allocation analyzer to aggregate information to report anomalies.
It enables efficient and accurate analysis of program performance in large-scale applications, reduces detection overhead and interference, improves the statistical significance of data, and can detect performance anomalies in a timely manner.
Smart Images

Figure CN118901061A_ABST
Abstract
Description
Background Art
[0001] Traditionally, there are two common methods for using a profiler to find performance problems in a program. One is sampling, and the other is instrumentation. Sampling usually involves periodically asking a program to provide information associated with its execution. Instrumentation usually requires modifying the program so that the modified program records each step during its execution.
[0002] Sampling and instrumentation methods each have advantages and disadvantages. The benefits of sampling profilers are lower overhead and less intrusiveness, but the information is less accurate because only limited data is collected. The less data collected, the less statistically significant the results. This can lead to erroneous conclusions. For example, a sampling profiler may indicate that there is a performance problem when there is actually no such problem, or vice versa.
[0003] Instrumented profilers can provide more accurate information, but have the disadvantage of being more expensive and intrusive. Instrumented profilers require modifying the program so that the modified program records each step during its execution. In this way, instrumented profilers can record all events of interest. Although instrumented profilers can collect more accurate data, using instrumentation to analyze large applications is generally not practical.
[0004] The subject matter claimed herein is not limited to embodiments that solve any disadvantages nor to embodiments that operate only in the above-described environment.Rather, this background is merely provided to illustrate one exemplary technology area in which some embodiments described herein may be practiced. Summary of the invention
[0005] This Summary is provided to introduce some concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
[0006] The principles described herein relate to a computer system configured to analyze a program during execution of the program. Analyzing the program includes obtaining a first information set associated with the execution of the program by a first analyzer. In some embodiments, the first analyzer is based on sampling. In some embodiments, the first analyzer is based on detection. In some embodiments, the first analyzer is configured to obtain memory allocations of the program during execution of the program.
[0007] The analyzing program also includes obtaining, by a second analyzer, a second set of information associated with one or more executions of a function in the program, wherein the second analyzer is configured to dynamically detect the function in the program. The second set of information includes at least a call count or execution time of each of the one or more executions of the function. The computer system is also configured to identify a subset of the first set of information associated with the execution of the function, and create aggregate information based on (1) the subset of the first set of information and (2) the second set of information associated with the one or more executions of the function. The aggregate information is then reported.
[0008] In some embodiments, dynamically detecting a function includes inserting a code instruction into a program during runtime. The inserted code instruction is configured to initialize a counter for the function. Each time the function is called, the counter is increased by one. In response to completion of execution of the program, the number counted by the counter is recorded as a call count of the function. In some embodiments, the inserted code instruction is also configured to initialize a timer each time the function is called. In response to completion of execution of the function, the timer records the execution time of the function. In some embodiments, creating aggregate information also includes calculating an average execution time of the function based on each execution time of the function.
[0009] In some embodiments, creating the aggregate information further comprises correlating a subset of the first set of information associated with the function execution with the second set of information to detect anomalies.
[0010] The principles described herein also relate to a method for analyzing a program based on a combination of dynamic detection and sampling and / or another analyzer. The method includes analyzing the program during execution of the program. Analyzing the program includes obtaining a first information set associated with the execution of the program by a first analyzer. In some embodiments, the first analyzer is based on sampling. In some embodiments, the first analyzer is based on detection. In some embodiments, the first analyzer is configured to obtain memory allocation during execution of the program.
[0011] The method also includes dynamically instrumenting functions in the program to collect a second set of information associated with one or more executions of the function. The second set of information includes at least a call count or an execution time for each execution of the function. The method also includes identifying a subset of the first set of information associated with the one or more executions of the function, and creating aggregate information based on (1) the subset of the first set of information and (2) the second set of information associated with the one or more executions of the function. The aggregate information is then reported.
[0012] Additional features and advantages will be set forth in the following description, and some features and advantages will be apparent from the description, or may be learned by practicing the teachings herein. Features and advantages of the present invention may be realized and obtained by means of the tools and combinations particularly pointed out in the appended claims. Features of the present invention will become more apparent from the following description and the appended claims, or may be learned by practicing the present invention as described below. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to describe the manner in which the above and other advantages and features are obtained, a more particular description of the subject matter briefly described above will be rendered by reference to specific embodiments illustrated in the accompanying drawings. Understanding that these drawings depict only typical embodiments and are therefore not to be considered limiting in scope, the embodiments will be described and explained with additional specificity and detail through the use of the accompanying drawings, in which:
[0014] Figure 1 illustrates an example architecture of a computer system in which the principles described herein may be implemented;
[0015] Figure 2A An example process for instrumenting machine code or native code is illustrated;
[0016] Figure 2B illustrates an example process for instrumenting bytecode or managed code;
[0017] Figure 3 illustrates an example process of executing an example program;
[0018] Figure 4A An example process for analyzing a program based on a combination of dynamic instrumentation and sampling is illustrated;
[0019] Figure 4B An example process of aggregating a dataset collected based on dynamic detection and a dataset collected based on sampling is illustrated;
[0020] Figure 5 The relationship between the call counts corresponding to a plurality of functions and the amount of sampled data is illustrated;
[0021] Figure 6 illustrates an example user interface for reporting aggregate information generated based on a data set collected from dynamic instrumentation and a data set collected from sampling;
[0022] Figure 7 A flow chart illustrating an example method for analyzing a program based on a combination of dynamic instrumentation and sampling; and
[0023] Figure 8 A flow chart of an example method for lightweight instrumentation of functions of a program is illustrated. DETAILED DESCRIPTION
[0024] Traditionally, there are two common methods for using a profiler to find performance problems in a program. One is sampling, and the other is instrumentation. Sampling usually involves periodically asking a program to provide information associated with its execution. Instrumentation usually requires modifying the program so that the modified program records each step during its execution.
[0025] Sampling and instrumentation methods each have advantages and disadvantages. The benefits of sampling profilers are lower overhead and less intrusiveness, but the information is less accurate because only limited data is collected. The less data collected, the less statistically significant the results. This can lead to erroneous conclusions. For example, a sampling profiler may indicate that there is a performance problem when there is actually no such problem, or vice versa.
[0026] Instrumented profilers can provide more accurate information, but have the disadvantage of being more expensive and intrusive. Instrumented profilers require modifying the program so that the modified program records each step during its execution. In this way, instrumented profilers can record all events of interest. Although instrumented profilers can collect more accurate data, using instrumentation to analyze large applications is generally not practical.
[0027] The principles described herein solve the above problems by combining dynamic, lightweight detection with another analyzer. The principles described herein relate to a computer system configured to analyze a program during the execution of the program. The analysis program includes obtaining a first information set associated with the execution of the program by a first analyzer. In some embodiments, the first analyzer is based on sampling. In some embodiments, the first analyzer is based on detection. In some embodiments, the first analyzer is configured to obtain memory allocation during the execution of the program. The analysis program also includes dynamically detecting functions in the program to collect a second information set associated with one or more executions of the function. The second information set includes at least a call count or execution time for each execution of the function. In some embodiments, lightweight dynamic detection only collects call counts and / or execution times for each execution of the function.
[0028] The computer system is also configured to identify a subset of the first set of information related to the execution of the function and create aggregate information based on (1) the subset of the first set of information and (2) a second set of information associated with one or more executions of the function.
[0029] In some embodiments, the computer system is configured to combine dynamic, lightweight detection with a memory allocation analyzer. The memory allocation analyzer can be based on sampling, detection, some other mechanisms and / or their combination. For example, when the memory allocation analyzer is based on sampling, the analyzer can use memory allocation events as intervals and track memory allocations and objects generated by the processes that are started or attached to. When the memory allocation analyzer is based on detection, the analyzer can only track those memory allocations and objects generated by the detected modules. In some embodiments, call counts or execution times of calls are combined and / or related to the memory allocations collected by the memory allocation analyzer.
[0030] In some embodiments, dynamically detecting a function includes inserting a code instruction into a program during runtime. The inserted code instruction is configured to initialize a counter for the function in response to the first call to the function. Each time the function is called, the counter is increased by one. In response to the completion of the execution of the program, the number counted by the counter is recorded as the call count of the function. In some embodiments, the inserted code instruction is also configured to initialize a timer each time the function is called. In response to the completion of the execution of the function, the timer records the execution time of the function. In some embodiments, creating the aggregate information also includes calculating the average execution time of the function based on each execution time of the function.
[0031] In some embodiments, creating the aggregate information further comprises correlating a subset of the first set of information associated with the function execution with the second set of information to detect anomalies.Then, the aggregate information is reported.
[0032] Figure 1 An example computer system 100 is illustrated in which the principles described herein may be implemented. The computer system 100 includes hardware 140 and an operating system 130, which together make the computer system usable by users and programs 120. The operating system 130 is often the core software running on the computer system, although there may be other software layers above the operating system that provide other interfaces for users or programs of the system. The hardware 140 of the computer system 100 includes one or more processors 142 (e.g., central processing units (CPUs)), memory 144 (e.g., random access memory (RAM)), and storage 146 (e.g., hard disk). The ellipsis 148 indicates that there may be additional hardware components as part of the computer system 100, such as (but not limited to) input / output devices (e.g., keyboards, displays, touch screens, etc.). The processor 142 is configured to run instructions and calculate data and memory addresses. The memory 144 stores data and instructions for the programs being run.
[0033] Some source code is written in a compiled language (such as, but not limited to, C++). This source code is first converted into machine code (such as binary code). This conversion is performed by a program called a compiler. The compiled machine code can then be loaded into memory 144 and executed by (multiple) processors 142. This machine code that the operating system can load into memory and start is also called "native code."
[0034] Some source code is written in a high-level language and compiled into bytecode. The bytecode can then be run on a runtime (such as .NET). This bytecode is also called "managed code". The runtime is responsible for taking the managed code, compiling it into machine code, and then executing it. In addition to this, the runtime usually provides several additional services, such as automatic memory management, security boundaries, type safety, etc.
[0035] As briefly discussed above, the detection of code includes inserting code instructions into a program so that information associated with the program is recorded. In some embodiments, the detection of code includes detecting managed code or bytecode. In some embodiments, the detection of code includes detecting native code or machine code.
[0036] Figure 2A An example process 200A for detecting machine code or native code is illustrated. Figure 2A As shown in FIG. 2 , the source code 210A of the program is first compiled into a machine code 230A by a compiler 220A. The machine code 230A is then detected to generate a detected machine code 250A. In some embodiments, the detection 240A of the machine code 230A includes inserting machine code instructions of one or more counters 242A and / or one or more timers 244A into the machine code 230A. The counter is configured to collect call counts of the execution of the function in the program. The timer is configured to record the execution time of the function. Then, the detected machine code 250A is executed by the computer system. After the execution 260A of the detected machine code 250A, a data set 270A associated with the execution of the function is collected.
[0037] Figure 2B An example process 200B for detecting managed code or bytecode is illustrated. Figure 2BAs shown in FIG. 2 , the source code 210B of the program is compiled into bytecode 230B by a first compiler 220B. Then, the bytecode 230B is instrumented to generate instrumented bytecode 250B. In some embodiments, the instrumentation 240B includes inserting bytecode instructions of one or more counters 242B and / or one or more timers 244B into the bytecode 230B. The counters are configured to collect all counts of the execution of the function. The timers are configured to record the execution time of the function. The instrumented bytecode 250B is then compiled by a second compiler 260B to generate machine code 270B. The machine code 270B is then executed by the computer system. After the execution 280B of the machine code 270B, a data set 290B is collected. Figure 2A Similar to data set 270A, data set 290B includes at least a call count of the function in the program, and / or an execution time of each execution of the function.
[0038] In some embodiments, Figure 2A or Figure 2B The detection in 240A or 240B includes dynamically detecting the function in response to the first call to the function. In this way, if the function is not called, the computer system does not bear the burden of performing additional calculations related to the detection. In some embodiments, a counter is initialized for the function in response to the first call to the function. Each time the function is called, the counter is increased by one. In response to the completion of the execution of the program, the number counted by the counter is recorded as the call count of the function. In some embodiments, a timer is initialized each time the function is called. In response to the completion of the execution of the function, the timer is configured to record the execution time of the function.
[0039] In some embodiments, additional information associated with the function may also be dynamically detected based on the purpose of the detection. Alternatively, the dynamically detected function is lightweight so that only limited information is collected, such as call counts and / or execution times for each execution of the function. In some embodiments, all functions are dynamically detected. Alternatively, only a subset of functions is detected based on user selection or based on the purpose of the detection, such as (but not limited to) a specific type of function, a specific function, a predetermined set of functions.
[0040] It is worth noting that a program usually includes multiple functions. These functions can be called once or multiple times during the execution of the program. In some cases, a function is called by another function. In some cases, a function is called when a specific condition is true or false. In some cases, a function is called in response to a specific event. Figure 3 An example execution process 300 of an example program is illustrated. Figure 3As shown in FIG. 3 , once the program begins execution (act 310), function A is first executed (act 320). In response to executing function A, function B and / or function C may then be called and executed (acts 330, 340). In response to executing function B or function C, function A may then be called and executed again. Ellipsis 350 indicates that there may be any number of functions in the program, and these functions may be executed any number of times at any time or in any order.
[0041] During the execution of a program, the program can be analyzed based on a combination of sampling and dynamic instrumentation. Figure 4A An example process 400A for analyzing a program is shown, including function A, function B, and function C. The horizontal axis represents time. It is worth noting that each function can be executed any number of times during the execution of the program, and each execution can take any amount of time. Figure 4A As shown in FIG. 1 , function A is executed seven times, each time corresponding to a corresponding execution time ET A1 , E.T. A2 , E.T. A3 , E.T. A4 , E.T. A5 , E.T. A6 , or ET A7 ; Function B is executed twice, each time corresponding to the corresponding execution time ET B1 or ET B2 ; and function C is executed only once, which corresponds to the execution time ET C1 It is worth noting that function A has been executed the most times, and the time spent on each execution of function A is quite short, which is ET A1 , E.T. A2 , E.T. A3 , E.T. A4 , E.T. A5 , E.T. A6 , or ET A7 In contrast, function C is executed only once, and the time it takes to execute function C is much longer, ET C1 .
[0042] like Figure 4A As shown in , during the execution of the program, a first analyzer and a second analyzer are implemented. The first analyzer is based on sampling, while the second analyzer is based on an analyzer. Sampling can be performed at a predetermined frequency, at a predetermined time, or at a random time. Figure 4AAs illustrated in , sampling is performed at times t1-t12. At each time t1-t12, a first set of information associated with the execution of the program is collected. For example, at time t1, data set 402 is collected; at time t2, data set 404 is collected; at time t3, data set 406 is collected, and so on. At the same time, instrumentation is performed on each of function A, function B, and function C to collect a second set of information. For example, for function A, data set 432 is collected; for function B, data set 434 is collected, and for function C, data set 436 is collected.
[0043] In some embodiments, to reduce the overhead of detection, a lightweight detection is performed during which only limited data is collected, such as the call count and / or execution time of each execution of a function. For example, in some embodiments, data set 432 may include the call count (=7) and / or execution time ET of function A. A1 , E.T. A2 , E.T. A3 , E.T. A4 , E.T. A5 , E.T. A6 , or ET A7 ; Data set 434 may include the call count (=2) and / or execution time ET of function B B1 or ET B2 ; and data set 436 may include the call count and / or execution time ET of function C (=1) C1 .
[0044] In an embodiment, the detection described herein includes dynamically detecting a function. In some embodiments, dynamically detecting a function includes inserting code instructions into a program during execution of the program so that the behavior of the function is recorded only in response to calling the function.
[0045] In some embodiments, the code instructions are configured to initialize a counter for a function. Each time the function is called, the counter is increased by one. In response to completion of the execution of the program, the number counted by the counter is recorded as a call count of the function.
[0046] In some embodiments, the code instructions are configured to initialize a timer each time the function is called. In response to the completion of the execution of the function, the timer is configured to record the execution time of the function. In some embodiments, when the function is called each time, a first time is recorded; when the execution of the function is completed, a second time is recorded. The execution time is calculated based on the first time and the second time.
[0047] In some embodiments, the code instructions are configured to allocate a portion of the memory to record a second set of information associated with the execution of the function. In some embodiments, the code instructions are configured to allocate a portion of the memory having a specific address to store an integer value initially set to zero. Each time the function is called, the integer value stored at the specific address is increased by one. In some embodiments, a portion of the memory (e.g., an array) is allocated to store a time sequence of execution of the function.
[0048] In some embodiments, the computer system is further configured to identify a subset of multiple functions in the program, each of which is to be dynamically detected. In this way, only a subset of the target function is detected, thereby further reducing the detection overhead.
[0049] The first set of information and the second set of information collected based on the detection are then aggregated to create aggregate information. Specifically, a subset of the first set of information associated with one or more executions of the function is identified. The subset of the first set of information and the second set of information associated with the one or more executions of the function are then aggregated to create aggregate information.
[0050] Figure 4B An example process 400B for creating aggregate information is illustrated. Figure 4B As illustrated in , sampling-based data sets 402 and 412 include information associated with the execution of function A. Detection-based data set 432 also includes information associated with the execution of function A. Therefore, data sets 402 and 412 are aggregated with data set 432. Similarly, sampling-based data sets 408 and 418 include information associated with the execution of function B. Detection-based data set 434 also includes information associated with the execution of function B. Therefore, data sets 408, 418 are aggregated with data set 434. Similarly, sampling-based data sets 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, and 426 include information associated with the execution of function C. Detection-based data set 436 also includes information associated with the execution of function C. Thus, data sets 404 , 406 , 408 , 410 , 412 , 414 , 416 , 418 , 420 , 422 , 424 , and 426 are aggregated with data set 436 .
[0051] In some embodiments, the first set of information and the second set of information are correlated to identify an anomaly. Figure 4A and Figure 4B As illustrated in , the call count of function A is 7 (which is the highest among functions A, B, and C), but only two sets of sampling data are collected, which indicates the possibility of an abnormality. On the contrary, the call count of function C is 1 (which is the lowest among functions A, B, and C), but 11 sets of sampling data are collected, which also indicates the possibility of an abnormality.
[0052] In some embodiments, creating the aggregate information includes calculating an average execution time of the function based on the recorded execution time series. In some embodiments, creating the aggregate information includes identifying a relationship between the number of collected samples associated with the function, the total call count of the function, and / or the average execution time of the function.
[0053] In some embodiments, creating the aggregate information includes calculating a ratio between the number of samples collected during the execution of the function and the total call count of the function. When the ratio is greater than a threshold, it is determined that an anomaly exists. In some embodiments, when the number of samples collected during the execution of the function is greater than a first threshold and / or the total call count of the function is less than a second threshold, it is determined that an anomaly exists.
[0054] In some embodiments, the computer system is configured to combine dynamic, lightweight detection with a memory allocation analyzer. The memory allocation analyzer can be based on sampling, detection, some other mechanisms and / or their combination. For example, when the memory allocation analyzer is based on sampling, the analyzer can use memory allocation events as intervals and track memory allocations and objects generated by processes that are started or attached to. When the memory allocation analyzer is based on detection, the analyzer usually only tracks those memory allocations and objects generated by the detected modules. In some embodiments, creating aggregate information includes aggregating call counts or execution times of calls with memory allocations collected by the memory allocation analyzer.
[0055] Figure 5 The relationship between the call counts and the amount of sampled data collected for functions A, B, and C is illustrated 500. The horizontal axis represents the call counts, while the vertical axis represents the amount of sampled data collected. Figure 5 As shown in FIG. 5 , function A corresponds to a high call count, but a small amount of sampled data; function B corresponds to a low call count, but a high amount of sampled data. A first region 512 between the vertical axis and the dashed line 510 represents a first abnormal region, and a second region 522 between the horizontal axis and the dashed line 520 represents a second abnormal region. Any data point (corresponding to a function) falling into the first region 512 or the second region 522 can be considered an abnormality.
[0056] After the aggregate information is created, the aggregate information can then be reported.In some embodiments, in response to detecting an anomaly, an alert is generated and sent to a user.
[0057] Figure 6An example user interface 600 configured to report aggregate information is illustrated. The user interface 600 includes a table having multiple columns, including (but not limited to) function name 610, total CPU 620, own CPU 630, call count 640, and / or average execution time 650. The data associated with total CPU 620 and own CPU 630 is collected based on sampling. The data associated with call count 640 and average execution time 650 is collected based on detection. In some embodiments, in response to detecting an abnormal function, the function is marked to generate an alert. As shown in FIG. Figure 6 As shown in , functions A and C are marked as abnormal.
[0058] Now, the following discussion involves various methods and method actions that can be performed. Although method actions may be discussed in a specific order or illustrated in a flowchart as occurring in a specific order, no specific order is required unless otherwise specified or because one action is dependent on another action being completed before performing the action.
[0059] Figure 7 A flow chart of a method 700 for analyzing a program based on a combination of dynamic instrumentation and sampling is illustrated. The method 700 includes analyzing a program during execution of the program (act 710). Analyzing the program (act 710) includes obtaining, by a first analyzer, a first set of information associated with the execution of the program (act 712), and obtaining, by a second analyzer, a second set of information associated with one or more executions of a function (act 714).
[0060] In some embodiments, the first analyzer is based on sampling. In some embodiments, the first analyzer is based on detection. In some embodiments, the first analyzer is configured to obtain the memory allocation of the program during the execution of the program. In some embodiments, the second analyzer is configured to dynamically detect the function in the program at runtime. In some embodiments, dynamically detecting the function in the program includes inserting the code instruction into the bytecode of the program before compiling the bytecode into native code. In some embodiments, dynamically detecting the function in the program includes inserting the code instruction into the native code of the program.
[0061] The second information set includes at least a call count or execution time for each execution of the function. In some embodiments, dynamically detecting the function includes inserting a code instruction into the program during runtime. The code instruction is configured to initialize a counter for the function during runtime. Each time the function is called, the counter is increased by one. In response to the completion of the execution of the program, the number counted by the counter is recorded as the call count of the function.
[0062] In some embodiments, the code instructions are further configured to initialize a timer each time the function is called. In response to the completion of the execution of the function, the timer is configured to record the execution time of the function. In some embodiments, when the function is called, a first time is recorded; and when the execution of the function is completed, a second time is recorded. Based on the first time and the second time, the execution time of the function is calculated.
[0063] Method 700 also includes identifying a subset of the first information set associated with one or more executions of the function (act 720), and creating aggregate information based on (1) the subset of the first information set and (2) the second information set associated with the one or more executions of the function (act 730). In some embodiments, creating the aggregate information also includes calculating an average execution time of the function based on each execution time of the function. In some embodiments, creating the aggregate information also includes correlating the subset of the first information set with the second information set to identify an anomaly. In some embodiments, creating the aggregate information also includes calculating a ratio between the number of samples collected during one or more executions of the function and the total call count of the function. When the ratio is greater than a threshold, it is determined that an anomaly exists. In some embodiments, when the number of samples collected during one or more executions of the function is greater than a first threshold, and / or the total call count of the function is lower than a second threshold, it is determined that an anomaly exists.
[0064] Method 700 also includes reporting the aggregate information (act 740). In some embodiments, reporting the aggregate information includes flagging a function or generating an alert in response to detecting an anomaly.
[0065] Figure 8 A flowchart of an example method 800 for dynamically detecting a function is illustrated, corresponding to Figure 7 Act 714. Method 800 includes allocating a portion of memory to store data associated with one or more executions of a function (act 810). In some embodiments, the allocation of memory (act 810) is performed dynamically only during runtime. In some embodiments, the allocation of memory (act 810) includes allocating a first portion of memory to store an integer corresponding to a call count (act 812). In some embodiments, the allocation of memory (act 810) includes allocating a second portion of memory to store one or more execution times of the function (act 814). In some embodiments, the second portion of memory is an array configured to store a sequence of execution times of the function.
[0066] The method 800 also includes detecting that the function is called (action 820). In response to detecting that the function is called (action 820), data associated with the execution of the function is collected and stored in a portion of the allocated memory (action 830). In some embodiments, the storing of the data (action 830) includes increasing the integer value (corresponding to the call count) stored in the first portion of the memory by one (action 832). In some embodiments, the storing of the data (action 830) also includes obtaining the execution time of the function (action 834) and recording the execution time in the second portion of the memory (action 836).
[0067] In some embodiments, additional data associated with the function is also detected. In some embodiments, dynamic detection is a lightweight detection during which only limited data is collected. In some embodiments, only call counts and / or only execution times are recorded to reduce the overhead of detection.
[0068] Although the subject matter has been described in language specific to structural features and / or methodological acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the above-described features or acts, or the order of the above-described acts. Rather, the described features and acts are disclosed as example forms of implementing the claims.
[0069] Embodiments of the present invention may include or utilize a special or general-purpose computer system (e.g., computer system 100) that includes hardware 140, such as, for example, one or more processors (e.g., processor 142) and system memory (e.g., memory 144). Embodiments within the scope of the present invention also include physical and other computer-readable media for carrying or storing computer-executable instructions and / or data structures. Such computer-readable media can be any available media that can be accessed by a general or special-purpose computer system. Computer-readable media that store computer-executable instructions and / or data structures are computer storage media (e.g., memory 144, storage device 146). Computer-readable media that carry computer-executable instructions and / or data structures are transmission media. Therefore, by way of example and not limitation, embodiments of the present invention may include at least two distinct computer-readable media: computer storage media and transmission media.
[0070] Computer storage media are physical storage media that store computer executable instructions and / or data structures. Physical storage media include computer hardware, such as RAM, ROM, EEPROM, solid state drives ("SSD"), flash memory, phase change memory ("PCM"), optical disk storage, magnetic disk storage or other magnetic storage devices, or any other hardware storage device(s) that can be used to store program code in the form of computer executable instructions or data structures that can be accessed and executed by general or special purpose computer systems to implement the functionality disclosed in the present invention.
[0071] Transmission media can include networks and / or data links, which can be used to carry program code in the form of computer executable instructions or data structures, and can be accessed by general or special computer systems."Network" is defined as one or more data links, which enables electronic data to be transmitted between computer systems and / or modules and / or other electronic devices. When information is transmitted or provided to a computer system through a network or another communication connection (wired, wireless or wired or wireless combination), the computer system can regard the connection as a transmission medium. The above combination should also be included in the scope of computer-readable media.
[0072] In addition, upon reaching various computer system components, program code in the form of computer executable instructions or data structures can be automatically transferred from transmission media to computer storage media (or vice versa). For example, computer executable instructions or data structures received over a network or data link can be buffered in RAM within a network interface module (e.g., a network interface) and then ultimately transferred to computer system RAM and / or to less volatile computer storage media in the computer system. Therefore, it should be understood that computer storage media can be included in computer system components that also (or even primarily) use transmission media.
[0073] Computer executable instructions include, for example, instructions and data that, when executed on one or more processors, cause a general purpose computer system, a special purpose computer system, or a special purpose processing device to perform a certain function or a group of functions. Computer executable instructions may be, for example, binary files, intermediate format instructions (such as assembly language), or even source code.
[0074] Those skilled in the art will appreciate that the present invention can be put into practice in a network computing environment with various types of computer system configurations, including personal computers, desktop computers, notebook computers, message processors, handheld devices, multiprocessor systems, microprocessor-based or programmable consumer electronics, network PCs, minicomputers, mainframe computers, mobile phones, PDAs, tablet computers, pagers, routers, switches, etc. The present invention can also be implemented in a distributed system environment, wherein the local and remote computer systems that are linked (by a hard-wired data link, a wireless data link, or by a combination of a hard-wired and wireless data link) by a network all perform tasks. Thus, in a distributed system environment, a computer system can include a plurality of composed computer systems. In a distributed system environment, a program module can be located in a local and remote memory storage device.
[0075] Those skilled in the art will also appreciate that the present invention can be implemented in a cloud computing environment. A cloud computing environment can be distributed, but this is not required. When a cloud computing environment is distributed, it can be distributed internationally within an organization and / or have components across multiple organizations. In this specification and the following claims, "cloud computing" is defined as a model for enabling on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, and services). The definition of "cloud computing" is not limited to any of the other numerous advantages that can be obtained from such a model when properly deployed.
[0076] The cloud computing model can consist of various characteristics, such as on-demand self-service, broad network access, resource pooling, rapid elasticity, measured services, etc. The cloud computing model can also take the form of various service models, such as, for example, software as a service ("SaaS"), platform as a service ("PaaS"), and infrastructure as a service ("IaaS"). The cloud computing model can also be deployed using different deployment models, such as private cloud, community cloud, public cloud, hybrid cloud, etc.
[0077] Some embodiments, such as cloud computing environments, may include a system that includes one or more hosts, each of which is capable of running one or more virtual machines. During operation, the virtual machine simulates an operating computing system, thereby supporting an operating system and possibly one or more other applications. In some embodiments, each host includes a virtual machine hypervisor that simulates virtual resources for the virtual machine using physical resources abstracted from the virtual machine's view. The hypervisor also provides appropriate isolation between virtual machines. Therefore, from the perspective of any given virtual machine, the hypervisor provides the illusion that the virtual machine is interacting with physical resources, even though the virtual machine is only interacting with the appearance of physical resources (e.g., virtual resources). Examples of physical resources include processing power, memory, disk space, network bandwidth, media drives, etc.
[0078] Without departing from its basic characteristics, the present invention may be embodied in other specific forms. The described embodiments should be considered in all respects to be illustrative only and not restrictive. Therefore, the scope of the present invention is indicated by the appended claims rather than the foregoing description. All changes in the equivalent meanings and scopes of the claims should be included within their scope. When introducing elements in the appended claims, the articles "one", "an", "the" and "said" are intended to mean that there are one or more elements. The terms "include", "comprise" and "have" are intended to be inclusive and mean that there may be other elements in addition to the listed elements. Unless otherwise specified, the terms "set", "superset" and "subset" are intended to exclude empty sets, so "set" is defined as a non-empty set, "superset" is defined as a non-empty superset, and "subset" is defined as a non-empty subset. Unless otherwise specified, the term "subset" excludes all of its supersets (that is, the superset contains at least one item that is not included in the subset). Unless otherwise specified, "superset" may include at least one additional element, while "subset" may exclude at least one element.
Claims
1. A computer system comprising: one or more processors; as well as One or more computer-readable hardware storage devices having computer-executable instructions stored thereon, the computer-executable instructions being structured such that when the computer-executable instructions are executed by the one or more processors, the computer system is configured to: During the execution of a program, the program is analyzed by at least the following steps: obtaining, by a first analyzer, a first set of information associated with the execution of the program; and obtaining, by a second analyzer, a second set of information associated with one or more executions of a function in the program, the second set of information comprising at least a call count or an execution time for each of the one or more executions of the function; identifying a subset of the first set of information associated with the one or more executions of the function; creating aggregate information based on (1) the subset of the first set of information and (2) the second set of information associated with the one or more executions of the function; as well as The aggregate information is reported.
2. The computer system of claim 1 , wherein the second analyzer is configured to dynamically detect the function, the dynamically detecting the function comprising inserting a code instruction into the program, the code instruction: during runtime of the program, initializing a counter for the function; Each time the function is called, the counter is incremented by one; In response to completion of the execution of the program, a number counted by the counter is recorded as the call count of the function.
3. The computer system of claim 2, wherein dynamically detecting the function further comprises inserting code instructions into the program, the code instructions: Each time the function is called, a timer is initialized; In response to completion of execution of the function, an execution time of the function is recorded.
4. The computer system of claim 3, wherein creating aggregate information further comprises: Based on each execution time of the function, an average execution time of the function is calculated.
5. The computer system of claim 2, wherein dynamically detecting the function comprises inserting code instructions into the program, the code instructions: A portion of memory is allocated to record the second set of information associated with execution of the function.
6. The computer system of claim 2, wherein dynamically detecting the function comprises inserting code instructions into the program, the code instructions: allocating a portion of memory having a particular address to store an integer value that is initially set to zero; and Each time the function is called, the integer value stored at the specific address is increased by one.
7. The computer system of claim 1, wherein the computer system is further configured to identify a subset of a plurality of functions in the program, each of the plurality of functions being dynamically instrumented.
8. The computer system of claim 1, wherein creating aggregate information further comprises: The first set of information and the second set of information associated with execution of the function are correlated to detect anomalies.
9. The computer system of claim 8, wherein: The first analyzer is based on sampling, and Creating aggregate information also includes: calculating a ratio between the number of samples collected by the first profiler during the one or more executions of the function and a total call count of the function; and When the ratio is greater than a threshold value, it is determined that an abnormality exists.
10. The computer system of claim 8, wherein when the number of samples collected during the one or more executions of the function is greater than a first threshold and the total call count of the function is lower than a second threshold, the computer system is configured to determine that an anomaly exists.
