Program delay measurement method and device, program configuration method and device

By constructing the point -point configuration strategy and calling the external latency module, the non -invasive delay data collection of the target program is realized, the problem of complex and time -consuming operation in the existing technology has been solved, and the flexibility of program optimization is improved. And efficiency.

CN118860836BActive Publication Date: 2025-01-24HUNDSUN TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411351745.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-24
Estimated Expiration
2044-09-26

AI Technical Summary

Technical Problem

In the prior art, program delay measurement methods usually adopt an invasive method, requiring pre-planning of measurement points, and adjusting measurement points requires changing code, resulting in complex and time-consuming operation.

Method used

By obtaining the measurement configuration information and program execution information of the target program, construct a measurement point configuration strategy, configure the delay measurement points according to the policy, and call the delay measurement module associated with the measurement configuration information to execute the measurement point code when the target program is running, to achieve Non-intrusive latency measurement data collection.

Benefits of technology

A non -invasive delay data collection is realized, supports custom measurement particle size, does not change the source code of the program, simplified the operation process, adapted to different types of programs, and improved the flexibility and efficiency of program optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118860836B_ABST
    Figure CN118860836B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification provide a program delay measurement method and device, and a program configuration method and device, wherein the program delay measurement method includes: obtaining measurement configuration information of a target program, and extracting program execution information of the target program in a target process of the target program; constructing a measurement point configuration strategy according to the measurement configuration information and the program execution information, and configuring a delay measurement point for the target program according to the measurement point configuration strategy; when the target program is in a running state and the delay measurement point is triggered, calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the delay measurement point; and determining the delay measurement data corresponding to the target program based on the code execution result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present specification relate to the field of computer technology, and in particular to a method and device for measuring program delay, and a method and device for configuring a program. Background Art

[0002] With the development of computer technology, taking up less resources and providing more stable services is an important criterion for program operation. As an important dynamic performance indicator of computer programs, running time refers to the time required to run all or part of the program logic under specific computer hardware resource conditions. Generally, under the same hardware resource conditions, it is expected that the program can achieve a lower running time, and before that, it is necessary to obtain the running time data of the program. In the prior art, the method for measuring the running time of the program is usually implemented in an intrusive manner. Intrusive means that the time measurement points are planned in advance, and the measurement logic is added to these points from the source code level of the program; generally, the measurement logic and data are independent of the program logic and data. After that, the time data can be collected during the program operation, and the data can be analyzed and processed afterwards. These data can also be used to locate the performance bottleneck of the program and optimize the performance of the program. However, the problem with the intrusive method is that the measurement points need to be planned in advance, and if the measurement points are adjusted, the entire process of code modification, release, and online is required. The entire operation process is relatively complex and time-consuming, so an effective solution is urgently needed to solve the above problems. Summary of the invention

[0003] In view of this, the embodiments of this specification provide a program delay measurement method. One or more embodiments of this specification also relate to a program delay measurement device, a program configuration method, a program configuration device, a computing device, a computer-readable storage medium, and a computer program product to solve the technical defects existing in the prior art.

[0004] According to a first aspect of an embodiment of this specification, a program delay measurement method is provided, including:

[0005] Acquiring measurement configuration information of a target program, and extracting program execution information of the target program in a target process of the target program;

[0006] Constructing a measurement point configuration strategy according to the measurement configuration information and the program execution information, and configuring a delay measurement point for the target program according to the measurement point configuration strategy;

[0007] When the target program is in a running state and the delay measurement point is triggered, calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the delay measurement point;

[0008] Determine the latency measurement data corresponding to the target program based on the code execution result.

[0009] According to a second aspect of the embodiments of this specification, a program configuration method is provided, including:

[0010] Get the target program's measurement configuration information;

[0011] Extracting program execution information of the target program in the target process of the target program;

[0012] Constructing a measurement point configuration strategy according to the measurement configuration information and the program execution information;

[0013] A delay measurement point is configured for the target program according to the measurement point configuration strategy, wherein the delay measurement point is used to collect delay measurement data when the target program is running.

[0014] According to a third aspect of an embodiment of this specification, another program delay measurement method is provided, including:

[0015] Determine a target program, and perform a delay measurement task for the target program, wherein the target program performs delay measurement point configuration by the above method;

[0016] In a case where the delay measurement point is triggered during the execution of the delay measurement task, calling a delay measurement module to execute a measurement point code corresponding to the delay measurement point;

[0017] Delay measurement data corresponding to the target program is determined based on the code execution result, and the target program is optimized according to the delay measurement data.

[0018] According to a fourth aspect of an embodiment of this specification, a program delay measurement device is provided, including:

[0019] an acquisition module configured to acquire measurement configuration information of a target program and extract program execution information of the target program in a target process of the target program;

[0020] A construction module is configured to construct a measurement point configuration strategy according to the measurement configuration information and the program execution information, and configure a delay measurement point for the target program according to the measurement point configuration strategy;

[0021] an execution module, configured to, when the target program is in a running state and the delay measurement point is triggered, call the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the delay measurement point;

[0022] The determination module is configured to determine the latency measurement data corresponding to the target program based on the code execution result.

[0023] According to a fifth aspect of the embodiments of this specification, a program configuration device is provided, including:

[0024] An information acquisition module configured to acquire measurement configuration information of a target program;

[0025] An information extraction module is configured to extract program execution information of the target program in the target process of the target program;

[0026] A strategy building module, configured to build a measurement point configuration strategy according to the measurement configuration information and the program execution information;

[0027] The configuration measurement point module is configured to configure a delay measurement point for the target program according to the measurement point configuration strategy, wherein the delay measurement point is used to collect delay measurement data when the target program is running.

[0028] According to a sixth aspect of an embodiment of this specification, another program delay measurement device is provided, including:

[0029] A determination task module is configured to determine a target program and perform a delay measurement task for the target program, wherein the target program is configured with delay measurement points by the above method;

[0030] an execution code module, configured to call a delay measurement module to execute a measurement point code corresponding to the delay measurement point when the delay measurement point is triggered in the execution state of the delay measurement task;

[0031] The program optimization module is configured to determine the delay measurement data corresponding to the target program based on the code execution result, and optimize the target program according to the delay measurement data.

[0032] According to a seventh aspect of an embodiment of this specification, there is provided a computing device, including:

[0033] Memory and processor;

[0034] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the above-mentioned program delay measurement method or program configuration method are implemented.

[0035] According to an eighth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned program delay measurement method or program configuration method.

[0036] According to a ninth aspect of the embodiments of this specification, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implement the steps of the above-mentioned program delay measurement method or program configuration method.

[0037] The program delay measurement method provided in this embodiment can first obtain the measurement configuration information set for the target program in order to realize non-intrusive delay measurement data collection and support customized measurement granularity. At the same time, in order to complete the delay data collection without changing the program source code, the program execution information of the target program can be extracted in the target process of the target program; on this basis, the measurement point configuration strategy can be constructed for the target program in combination with the measurement configuration information and the program execution information, so that the delay measurement point can be configured for the target program according to the measurement point configuration strategy. At this time, the added delay measurement point is only in the form of a pile point, and the source code of the target program will not be updated, thereby realizing non-intrusive delay measurement configuration operations. After that, if the target program is in a running state and the delay measurement point is triggered, the delay measurement module associated with the measurement configuration information outside the target program can be called to execute the measurement point code corresponding to the delay measurement point; the corresponding code of the measurement point is executed outside the target program to complete the corresponding delay measurement operation, so that the delay measurement data corresponding to the target program can be determined based on the code execution result. The delay measurement data collection of the target program is completed in a non-invasive manner, so that the downstream can optimize the program according to the data. The delay measurement data collection of this method is more flexible and can be adapted to different types of programs, thus making it easier to use for program optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a schematic diagram of a program delay measurement method provided by an embodiment of this specification;

[0039] Figure 2 is a flowchart of a program delay measurement method provided by an embodiment of this specification;

[0040] Figure 3 is a schematic diagram of delay measurement in a program delay measurement method provided by an embodiment of this specification;

[0041] Figure 4 is a process flow chart of a method for measuring program delay provided by an embodiment of this specification;

[0042] Figure 5 is a flowchart of a program configuration method provided by an embodiment of this specification;

[0043] Figure 6 is a flowchart of another program delay measurement method provided by an embodiment of this specification;

[0044] Figure 7 It is a structural diagram of a program delay measurement device provided by an embodiment of this specification;

[0045] Figure 8 It is a structural diagram of a program configuration provided by an embodiment of this specification;

[0046] Fig. 9 It is a structural schematic diagram of another program delay measurement device provided by an embodiment of this specification;

[0047] Fig.10 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION

[0048] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.

[0049] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0050] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0051] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0052] First, the terms involved in one or more embodiments of this specification are explained.

[0053] GCC (GNU Compiler Collection) tool chain: is an open source compiler tool chain that supports multiple programming languages, including C, C++, Objective-C, Fortran, Java, and Ada. The GCC tool chain includes not only the compiler itself, but also a series of tools related to the compilation process, such as linkers, preprocessors, debuggers, etc., as well as standard libraries and header files.

[0054] -g compilation option: used to embed debugging information in the generated target file to facilitate debugging the program using debugging tools (such as GDB).

[0055] In this specification, a program delay measurement method is provided. One or more embodiments of this specification also involve a program delay measurement device, a program configuration method, a program configuration device, a computing device, a computer readable storage medium, and a computer program product, which are described in detail one by one in the following embodiments.

[0056] See also Figure 1As shown in the schematic diagram, the program delay measurement method provided by this embodiment can first obtain the measurement configuration information set for the target program in order to realize non-intrusive delay measurement data collection and support custom measurement granularity. At the same time, in order to complete the delay data collection without changing the program source code, the program execution information of the target program can be extracted in the target process of the target program; on this basis, the measurement point configuration strategy can be constructed for the target program in combination with the measurement configuration information and the program execution information, so that the delay measurement point can be configured for the target program according to the measurement point configuration strategy. At this time, the added delay measurement point is only in the form of a pile point, and the source code of the target program will not be updated, thereby realizing non-intrusive delay measurement configuration operation. After that, if the target program is in a running state and the delay measurement point is triggered, the delay measurement module associated with the measurement configuration information outside the target program can be called to execute the measurement point code corresponding to the delay measurement point; the corresponding code corresponding to the measurement point is executed outside the target program to complete the corresponding delay measurement operation, so that the delay measurement data corresponding to the target program can be determined based on the code execution result. The delay measurement data collection of the target program is completed in a non-invasive manner, so that the downstream can optimize the program according to the data. The delay measurement data collection of this method is more flexible and can be adapted to different types of programs, thus making it easier to use for program optimization.

[0057] See also Figure 2 , Figure 2 A flowchart of a program delay measurement method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0058] Step S202, obtaining measurement configuration information of a target program, and extracting program execution information of the target program in a target process of the target program.

[0059] The program latency measurement method provided in this embodiment can be applied to latency data collection of programs running under any operating system, and the operating system and tool chain to which the program belongs can implement the same functions as the Linux operating system and the GCC tool chain. This embodiment does not make any limitations here; wherein, the target program for which latency data collection is required can be any type of program, such as a script program, a service application, a plug-in program, etc.

[0060] It should be noted that the program delay measurement method provided in this embodiment is used to realize non-intrusive delay data collection for the target program. In order to support the completion of measurement point configuration and delay data collection during runtime under non-intrusive operations, a -g compilation option can be added to the target program during the compilation phase to add debugging information to the program or module, so as to match the interval measurement based on the source code line with the actually executed instructions, thereby supporting non-intrusive program delay measurement.

[0061] Specifically, the measurement configuration information specifically refers to the description configuration of the delay measurement operation pre-set for the target program, which can define the measurement point insertion position, measurement level, etc. When performing delay measurement for the target program, the level of the collected delay data can be set according to the measurement configuration information, such as delay data collection for the entire program, or delay data collection for a module in the program, so as to achieve more flexible completion of the program delay measurement operation. Correspondingly, the target process specifically refers to the process running the target program in the operating system; correspondingly, the program execution information specifically refers to the information such as the memory address, debugging information, etc. of the program and each module loaded by the target program collected in the target process during the running of the target program, which can be used to combine the program execution information and the measurement configuration information in the future to determine the position where the measurement point needs to be inserted in the program, so as to complete the pre-operation of the delay measurement operation, so that the delay measurement can be performed when the program is running.

[0062] Based on this, in order to realize non-intrusive delay measurement data collection and support custom measurement granularity, the measurement configuration information set for the target program can be obtained first. At the same time, in order to complete the delay data collection without changing the program source code, the program execution information of the target program can be extracted in the target process of the target program; on this basis, the measurement configuration information and program execution information can be combined to build a measurement point configuration strategy for the target program, so that the delay measurement point can be configured for the target program according to the measurement point configuration strategy. At this time, the added delay measurement point is only in the form of a pile point, and the source code of the target program will not be updated, thereby realizing non-intrusive delay measurement configuration operations. After that, if the target program is in a running state and the delay measurement point is triggered, the delay measurement module associated with the measurement configuration information outside the target program can be called to execute the measurement point code corresponding to the delay measurement point; the corresponding code of the measurement point is executed outside the target program to complete the corresponding delay measurement operation, so that the delay measurement data corresponding to the target program can be determined based on the code execution result.

[0063] Furthermore, when obtaining the measurement configuration information of the target program, in order to realize the subsequent combination of the measurement configuration information to complete a more fine-grained measurement point configuration, the configuration information can be constructed by combining the measurement points and related hierarchical information. In this embodiment, the specific implementation method is as follows:

[0064] Receive measurement point information configured for a target program, and assign measurement point identification information and measurement point level information to the measurement point information; construct initial measurement configuration information based on the measurement point information, the measurement point identification information and the measurement point level information; and update the initial measurement configuration information to measurement configuration information in response to measurement description information submitted for the initial measurement configuration information.

[0065] Specifically, the measurement point information specifically refers to the insertion position information corresponding to the delay measurement point that needs to be inserted into the target program, such as the target program source code file name or code line number. Correspondingly, the measurement point identification information specifically refers to the unique identifier assigned to the measurement point that needs to be inserted, and the measurement point identification information corresponding to different measurement points is different. Correspondingly, the measurement point hierarchy information specifically refers to the information of the hierarchy of the measurement point to be inserted, and different hierarchy settings reflect the delay level of the measurement point used to measure the program at different program granularities. For example, the first-level measurement level can be used to measure the entire delay of the program, and the second-level measurement level can be used to measure the delay of a certain module in the program. In actual applications, the delay level of the measurement program required for different levels can be set according to actual needs, and this embodiment does not make any restrictions here. Correspondingly, the initial measurement configuration information specifically refers to the configuration information used for delay measurement of the target program constructed by combining the measurement point information, the measurement point identification information and the measurement point hierarchy information. Correspondingly, the measurement description information specifically refers to the custom description information added by the user to the initial measurement configuration information, which is used to clarify which part of the measurement program is required for each configuration content in the configuration information, so as to facilitate analysis according to the measurement description information after data collection.

[0066] Based on this, when it is necessary to measure the latency of the target program, the demand side can customize the measurement configuration, so that after receiving the measurement point information configured for the target program, the measurement point identification information and the measurement point level information can be allocated to the measurement point information first; the uniqueness of the measurement point can be reflected through the identification information, and the program measurement granularity can be reflected through the measurement point level information. Then, the initial measurement configuration information can be constructed based on the measurement point information, the measurement point identification information and the measurement point level information; on this basis, in order to facilitate the demand side to better identify and analyze the latency measurement data, the demand side is also supported to customize the measurement description information, that is, in response to the measurement description information submitted for the initial measurement configuration information, the initial measurement configuration information can be updated to the measurement configuration information, thereby generating measurement configuration information that matches the measurement requirements of the demand side, which can be used for subsequent measurement point instrumentation processing operations.

[0067] That is to say, the multi-dimensional information corresponding to the metric point to be inserted into the target program can be determined through the metric configuration information, including but not limited to the metric point insertion position, metric point level, metric point identification, etc. As shown in the following table (1), the structure of any metric point in the metric configuration information consists of 6 fields for use when inserting the metric point: (1)

[0069]

[0070] The above measurement point related information can be used to accurately complete the configuration operation when configuring the measurement point, so that the delay measurement data can be accurately collected during the program running phase.

[0071] In summary, by constructing measurement configuration information for the target program as needed and setting the measurement point level in the measurement configuration information, more flexible settings can be achieved for the target program delay measurement, so as to facilitate use in program optimization.

[0072] Furthermore, when extracting the program execution information corresponding to the target program, considering that the program execution information is the basis for accurate instrumentation measurement points, the program execution information can be constructed by combining the memory address information and the program debugging information. In this embodiment, the specific implementation method is as follows:

[0073] Obtain the process identifier corresponding to the target program in the running state, and determine the target process of the target program according to the process identifier; extract the memory address information and program debugging information of the target program in the target process; and construct the program execution information of the target program according to the memory address information and the program debugging information.

[0074] Specifically, the process identifier refers to the identification information corresponding to the process to which the target program belongs when it is running; correspondingly, the memory address information refers to the memory address where each module in the target program is loaded; correspondingly, the program debugging information refers to various information generated and used to diagnose program errors, understand program behavior, or optimize program performance. This information includes but is not limited to the value of variables, the path of program execution, function call relationships, memory usage, etc.; and the program debugging information needs to include .debug_line information to implement subsequent support for measurement point instrumentation operations. Among them, .debug_line information is an important part of the DWARF (Debugging With Attributed Record Formats) debugging format, which is mainly used to describe the line number mapping relationship between source code and compiled machine code.

[0075] Based on this, after determining the target program that needs to be measured and obtaining its corresponding measurement configuration information, in order to accurately collect delay measurement data when the program is measured, the program execution information corresponding to the program can be collected before measurement, which is used as the basic element of the instrumentation measurement point. Specifically, the process ID corresponding to the target program in the running state can be obtained first. At this time, the target process of the target program can be determined according to the process ID; then the memory address information and program debugging information of the target program can be extracted from the target process; thereby, the program execution information of the target program can be constructed according to the memory address information and program debugging information, so as to facilitate the subsequent coordination with the measurement configuration information to complete the delay measurement operation of the target program.

[0076] In actual applications, when performing latency measurement operations on programs, the program being measured can be required to obtain its corresponding process number, that is, pid, while it is running, and then the information in / proc / pid / maps of the measured process can be read; the memory addresses where the program and each module are loaded, as well as the debugging information including .debug_line information can be extracted from the reading results, so that the measurement point configuration operation can be completed in combination with the above information later.

[0077] For example, during the optimization phase of the target program H in the Linux operating system, it is necessary to first obtain the running time (delay) of the target program H in order to facilitate the subsequent program performance optimization. Before obtaining the delay data corresponding to the target program H, the target program H can be subjected to measurement configuration processing to complete the delay data collection in a non-intrusive source code manner. Specifically, n measurement points can be set for the target program H, and the measurement number, measurement level and other information can be configured for each of the n measurement points. For example, the measurement point 1 corresponding to the above table (1) is set for the target program H, and the measurement point is used to perform global delay measurement on the target program H. On this basis, the measurement configuration information shown below can be constructed according to the measurement point information in the above table (1) corresponding to measurement point 1, as well as the measurement point information corresponding to other measurement points, and the measurement configuration information is a json file:

[0078] {

[0079] "perf_points": [{

[0080] "file": "transaction.cc",

[0081] "line": 516,

[0082] "id": 1,

[0083] "level": 1,

[0084] "desc": "Start preparing undo cache"

[0085] }, {

[0086] "file": "transaction.cc",

[0087] "line": 533,

[0088] "id": 2,

[0089] "level": 2,

[0090] "desc": "Start allocating memory"

[0091] }, {

[0092] "file": "transaction.cc",

[0093] "line": 639,

[0094] "id": 1,

[0095] "level": 1,

[0096] "end": true,

[0097] "desc": "Prepare undo cache end"

[0098] }]

[0099] }

[0100] On this basis, the process number pid_1 corresponding to the target program H can be determined, so as to extract the memory addresses where the target program H and each module are loaded, as well as the debugging information of the target program H and each module in the corresponding process according to the process number pid_1, and include the .debug_line information; thereby, the target program H can be subsequently instrumented according to the above-mentioned measurement configuration information, memory address and debugging information, so as to obtain the latency measurement data of the target program H, which is convenient for developers to optimize the program.

[0101] In summary, by collecting the memory address and debugging information corresponding to the program in the process to form the program execution information, it is convenient to accurately complete the measurement point configuration in combination with the measurement configuration information, so as to accurately collect the delay measurement data of the target program, so as to optimize the use of the program.

[0102] Step S204: construct a measurement point configuration strategy according to the measurement configuration information and the program execution information, and configure a delay measurement point for the target program according to the measurement point configuration strategy.

[0103] Specifically, after obtaining the measurement configuration information and program execution information of the target program as mentioned above, in order to achieve accurate configuration of the measurement points, a measurement point configuration strategy can be first constructed according to the measurement configuration information and program execution information. The measurement point configuration strategy can be used to clarify the configuration position and measurement level of the delay measurement point, and then the delay measurement point can be configured for the target program according to the measurement point configuration strategy, so as to complete the stub insertion for the target program in a non-invasive manner, and the stub point (delay measurement point) can realize the delay measurement data collection of the target program when it is triggered.

[0104] Among them, the measurement point configuration strategy specifically refers to the strategy executed when configuring the delay measurement point for the target program, which is used to record the insertion position of the delay measurement point, the type of delay data collection, etc. Correspondingly, the delay measurement point specifically refers to the stub point for collecting delay data added in the target program according to the measurement point configuration strategy, and the configuration of the measurement point does not involve the modification of the source code of the target program. It only triggers the measurement point when the program is running, and then calls the external module to complete the corresponding delay data calculation, so that the delay data collection can be completed without intruding the source code.

[0105] Furthermore, when constructing the measurement point configuration strategy, the measurement configuration information can be combined to determine that when configuring the delay measurement point for the target program, different measurement points correspond to different levels. Therefore, the insertion position can be located according to the measurement configuration information and program execution information, thereby completing the configuration operation of the delay measurement point. In this embodiment, the specific implementation method is as follows:

[0106] Determine a measurement point position according to the measurement configuration information and the program execution information, and determine target measurement point information corresponding to the measurement point position according to the measurement configuration information; construct a measurement point configuration strategy for the target program based on the target measurement point information and the measurement point position; and configure a delay measurement point corresponding to the target measurement point information for the measurement point position in the target process of the target program according to the measurement point configuration strategy.

[0107] Specifically, the measurement point location specifically refers to the location where the delay measurement point is added for the target program, and the location information can be defined by the program code line number and source code file name. Correspondingly, the target measurement point information specifically refers to the information corresponding to the measurement point that needs to be added at the measurement point location.

[0108] Based on this, after determining the measurement configuration information and program execution information, in order to achieve non-invasive instrumentation in the program, the measurement point location can be determined according to the measurement configuration information and program execution information. At this time, the target measurement point information corresponding to the measurement point location can be determined according to the measurement configuration information; on this basis, the measurement point configuration strategy can be constructed for the target program based on the target measurement point information and the measurement point location; the location and type of the delay measurement point can be defined through the strategy. Then, according to the measurement point configuration strategy, the delay measurement point corresponding to the target measurement point information can be configured for the measurement point location in the target process of the target program, so as to trigger the delay measurement point in the program execution phase and realize the determination of the delay measurement data.

[0109] In actual applications, after obtaining the measurement configuration information and program execution information corresponding to the target program, in order to implement instrumentation in the program, the two can be combined to generate a measurement point configuration strategy (insertion information). For example, a strategy as shown in the following table (2) can be generated: (2)

[0111]

[0112] Among them, the above table can record the plug-in address, the measurement number corresponding to the measurement point, and the start and end identifiers, so that the corresponding measurement point can be configured for the target program according to the information later, so that when the measurement point is triggered during the program running phase, the code corresponding to the delay measurement point can be executed, thereby completing the recording of the delay measurement data of the corresponding level.

[0113] Using the above example, after determining the measurement configuration information and program execution information corresponding to the target program H, the instrumentation information for adding measurement points to the target program H can be constructed based on the measurement configuration information, memory address, and debugging information, as shown in the above table (2). Thereafter, the instrumentation information can be used to instrument the target program H, so that when the program is subsequently run, the stub code can be executed at the corresponding measurement point, thereby recording the latency measurement data for program optimization.

[0114] In summary, by constructing a measurement point configuration strategy to configure the delay measurement points for the target program, the measurement point adding location can be realized to meet the delay measurement requirements, and the configuration of the measurement point will not change the source code of the program, so that the program delay measurement can be completed non-invasively.

[0115] Step S206: When the target program is in a running state and the delay measurement point is triggered, the delay measurement module of the measurement configuration information is called to execute the measurement point code corresponding to the delay measurement point.

[0116] Specifically, after the delay measurement point is configured for the target program, if the target program starts to measure the delay, when the target program is in the running state and the delay measurement point is triggered, it will indicate that the current target program triggers the pre-embedded delay measurement mechanism, and the delay measurement operation of the corresponding level will be performed for the measurement point. Considering that the non-intrusive setting is adopted when the delay measurement point is configured for the target program first, when the delay measurement point is triggered, the delay measurement module of the measurement configuration information can be called to execute the measurement point code corresponding to the delay measurement point through the delay measurement module outside the program, so as to complete the delay measurement data recording of the delay measurement point according to the code execution result.

[0117] Among them, the delay measurement module specifically refers to a component pre-built for the associated delay measurement point, which is used to run in the operating system to which the target program belongs, and is not associated with the program part of the target program, so as to complete the corresponding delay measurement data collection outside the program. Correspondingly, the measurement point code specifically refers to the stub code corresponding to the delay measurement point, different delay measurement points correspond to different measurement point codes, and the measurement point code is configured in the delay measurement module to realize that when the delay measurement module executes the measurement point code, the delay measurement data corresponding to the delay measurement point can be determined.

[0118] Furthermore, in order to achieve non-intrusive latency measurement for the target program, the latency measurement module can be started to complete the code execution outside the program, so as to complete the latency measurement data determination according to the execution result. In this embodiment, the specific implementation method is as follows:

[0119] The delay measurement module corresponding to the measurement configuration information is started according to the delay measurement point configuration result; wherein, when the target program is in a running state and the delay measurement point is triggered, the delay measurement module of the measurement configuration information is called to execute the measurement point code corresponding to the delay measurement point, including: when the target program is in a running state and the currently executed target instruction triggers the delay measurement point, the measurement point code corresponding to the delay measurement point is determined in the delay measurement module, and the measurement point code is executed through the delay measurement module.

[0120] Specifically, the target instruction specifically refers to the instruction triggered at the current stage when the target program is running. Based on this, in order to realize the non-intrusive completion of delay measurement data collection during the target program running stage, after completing the delay measurement point configuration, the delay measurement module corresponding to the measurement configuration information can be started according to the delay measurement point configuration result. The delay measurement module will run in the operating system to which the target program belongs. When the target program is in the running state and the currently executed target instruction triggers the delay measurement point, it can jump to the measurement point code corresponding to the delay measurement point of the delay measurement module. By executing the measurement point code, the delay measurement data corresponding to the delay measurement point can be determined.

[0121] In summary, by starting the delay measurement module outside the target program to execute the measurement point code corresponding to the delay measurement point, the delay measurement operation of the target program can be completed by executing the code outside the program, thereby avoiding program modification and saving development costs.

[0122] Furthermore, considering that in actual applications, when performing latency measurement on a target program, it may be necessary to collect latency measurement data at different levels, thereby making it easier to analyze the overall running time of the target program, when there are multiple latency measurement points, a loop execution method can be used to complete the latency measurement data determination. In this embodiment, the specific implementation method is as follows:

[0123] When the target program is in a running state and the i-th delay measurement point among the multiple delay measurement points is triggered, the delay measurement module of the measurement configuration information is called to execute the measurement point code corresponding to the i-th delay measurement point; according to the execution result of the measurement point code corresponding to the i-th delay measurement point, the sub-delay measurement data corresponding to the i-th delay measurement point is determined, and the target program is continued to run; when the i+1-th delay measurement point among the multiple delay measurement points is triggered, the step of calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the i+1-th delay measurement point is performed; i is incremented sequentially until i is equal to n, and the delay measurement data corresponding to the target program is constructed based on the sub-delay measurement data corresponding to each delay measurement point, wherein i starts from 1, i is a positive integer, and n is the number of delay measurement points.

[0124] Specifically, the sub-delay measurement data specifically refers to the delay measurement data determined after the measurement point code corresponding to any one of the multiple delay measurement points is executed.

[0125] Based on this, when multiple delay measurement points are configured for the target program, different delay measurement points will be triggered at different running stages of the program; in this process, if the target program is in a running state and the i-th delay measurement point among the multiple delay measurement points is triggered, the delay measurement module of the measurement configuration information can be called to execute the measurement point code corresponding to the i-th delay measurement point; so as to determine the sub-delay measurement data corresponding to the i-th delay measurement point according to the execution result of the measurement point code corresponding to the i-th delay measurement point.

[0126] After the determination of the sub-delay measurement data corresponding to the i-th delay measurement point is completed, the program will continue to run. If the i+1th delay measurement point among multiple delay measurement points is triggered at this time, the delay measurement module can be called for the i+1th delay measurement point to execute the measurement point code corresponding to the i+1th delay measurement point; and so on, i increases in sequence until i equals n, which means that all the delay measurement points configured in the target program are triggered, and the sub-delay measurement data of the corresponding measurement points are collected, and then the delay measurement data corresponding to the target program can be constructed based on the sub-delay measurement data corresponding to each delay measurement point, so that the delay measurement data can be used to optimize the target program later; wherein, i starts from 1, and i is a positive integer, and n is the number of delay measurement points.

[0127] Continuing with the above example, after the stub operation on the target program H is completed, the delay measurement module will be started. Then, when the target program H is running, if it is detected that the currently executed instruction corresponds to measurement point 1, it can jump to the delay measurement module, and the delay measurement module will execute the stub code corresponding to measurement point 1, thereby completing the collection of delay measurement data corresponding to measurement point 1. After that, the program will continue to run, and during the execution process, n measurement points will be triggered in sequence. Similar to the collection of delay measurement data corresponding to the measurement point, the stub code corresponding to each measurement point will be executed in sequence through the delay measurement module to obtain the delay measurement data corresponding to all measurement points, which can be used for the optimization operation of the target program H.

[0128] In summary, by setting different stub codes for different delay measurement points, the corresponding measurement point code can be executed when the measurement point is triggered, thereby completing the determination of the delay measurement data of the corresponding level of the measurement point, so that developers can perform optimization operations of different granularities on the program according to different levels of delay measurement data.

[0129] Step S208: Determine the latency measurement data corresponding to the target program based on the code execution result.

[0130] Specifically, after calling the delay measurement module to execute the measurement point code corresponding to the delay measurement point, the delay measurement data corresponding to the target program can be determined according to the code execution result, so that developers can optimize the target program based on the delay measurement data. The delay measurement data specifically refers to the running time data that characterizes the execution logic of the delay measurement point corresponding to the target program.

[0131] For example, if the delay measurement data is used to determine that the program has an algorithmic bottleneck problem, the optimization can be completed by reducing unnecessary calculations, improving data structures, and using more efficient algorithms. Alternatively, for data that is frequently queried but not often modified, you can consider using a hash table or index structure to speed up the search operation. Alternatively, for parallel processing tasks, you can use parallel or multi-threaded methods to execute tasks. In actual applications, the optimization operation of the program based on the delay measurement data can be set according to actual needs, and this embodiment does not make any restrictions here.

[0132] Furthermore, after executing the code corresponding to the delay measurement point, the delay measurement data can be determined by comparing the current time with the historical time. In this embodiment, the specific implementation is as follows:

[0133] Determine the current time information according to the code execution result, and read the historical time information corresponding to the delay measurement point; calculate the delay information according to the current time information and the historical time information, and read the delay measurement identifier in the measurement configuration information according to the instruction address of the delay measurement point; based on the delay information and the delay measurement identifier, generate the delay measurement data corresponding to the target program.

[0134] Specifically, the current time information specifically refers to the time information collected by executing the measurement point program corresponding to the delay measurement point. Correspondingly, the historical time information specifically refers to the time information collected by the delay measurement point in the previous trigger cycle. By calculating the difference between the current time information and the historical time information, the delay information of the corresponding delay measurement point can be determined. Correspondingly, the instruction address specifically refers to the address of the delay measurement point information recorded in the measurement point configuration strategy. Correspondingly, the delay measurement identifier is the measurement number corresponding to the delay measurement point.

[0135] Based on this, after executing the measurement point code corresponding to the delay measurement point, the current time information can be determined according to the code execution result, and the historical time information corresponding to the delay measurement point can be read at the same time; then the delay information corresponding to the delay measurement point can be calculated according to the current time information and the historical time information. In order to facilitate subsequent storage and use, the delay measurement identifier can also be read in the measurement configuration information according to the instruction address of the delay measurement point; thus, the delay measurement data corresponding to the target program can be generated based on the delay information and the delay measurement identifier, so that it can be directly used in the program optimization stage.

[0136] In actual applications, when executing the stub code corresponding to the corresponding delay measurement point, the time difference between the current time and the last execution to the delay measurement point can be calculated, which can be recorded as delta; at the same time, according to the instruction address of the delay measurement point, the corresponding delay measurement identifier can be read from the measurement configuration information, and then the time difference and the delay measurement identifier can be combined to construct the delay measurement data corresponding to the delay measurement point for subsequent use.

[0137] Continuing with the above example, after executing the stub code corresponding to measurement point 1, the current time corresponding to measurement point 1 will be obtained, and the historical time corresponding to the last execution of measurement point 1 can be read. By calculating the current time and the historical time, the time difference T1 corresponding to measurement point 1 can be determined. At the same time, according to the instruction address of measurement point 1, the measurement number 1 corresponding to measurement point 1 can be read, and then the relationship between time difference T1 and measurement number 1 is established, and stored as the delay measurement data corresponding to measurement point 1. This can be repeated until the delay measurement data corresponding to n measurement points are recorded and can be used for the optimization operation of the target program H.

[0138] In summary, by calculating the time difference corresponding to the delay measurement point and combining it with the corresponding delay measurement identifier, the delay measurement data corresponding to the delay measurement point is constructed, which can be more convenient for subsequent use and accurately complete the optimization operation of the target program.

[0139] Furthermore, considering that the latency measurement data of the target program may exist at multiple levels, the latency measurement data collected at this time will be more, and in order to facilitate subsequent program optimization, it can be cached to a specified location. In this embodiment, the specific implementation method is as follows:

[0140] The delay metric data is stored in the target cache of the delay metric module; when the cache space of the target cache is greater than or equal to a preset space threshold, the target cache of the delay metric module is switched to the candidate cache, and the global delay metric data in the target cache is stored in the target disk of the delay metric module.

[0141] Specifically, the target cache refers to the cache in the latency measurement module used to store latency measurement data. Correspondingly, the candidate cache refers to the backup cache set by the latency measurement module, which can be switched to the candidate cache for storing latency measurement data when the target cache reaches the storage limit. Correspondingly, the target disk refers to the disk for persistent storage of latency measurement data.

[0142] Based on this, after the delay measurement data of the target program is determined, in order to facilitate the subsequent program optimization, the delay measurement data can be stored in the target cache of the delay measurement module; when the cache space of the target cache is greater than or equal to the preset space threshold, in order to avoid the loss of delay measurement data, the target cache of the delay measurement module can be switched to the candidate cache, and the global delay measurement data in the target cache can also be stored in the target disk of the delay measurement module to achieve persistence of the delay measurement data.

[0143] In actual applications, when storing latency measurement data, a double cache structure can be set in advance for the latency measurement module to achieve that when the current cache is full, it can switch to another cache to write latency measurement data, and at the same time trigger the background asynchronous thread to input the global latency measurement data in the cache that is already full into the disk. In specific implementation, in order to save storage space, the latency measurement data can be stored in a file in a stream format with an unfixed length, such as Figure 3 As shown in the figure, the flag, metric ID and metric value constitute a set of delay metric data, where the metric ID is the metric point identification information and the metric value is the delay information. The flag is fixed to 1 byte, and the metric ID and metric value are dynamic, so their length can change according to the actual storage length requirements, and the actual byte length of the metric ID can be reflected by the 0th and 1st bits in the flag, and the actual byte length of the metric value can be reflected by the 2nd and 3rd bits in the flag, and the 4th bit in the flag indicates the start and end information corresponding to the metric point, 0 indicates the start of the metric point, and 1 indicates the end of the metric point.

[0144] In addition, when caching latency measurement data, other storage methods may be used, such as generating a Linux perf data storage format, and subsequent analysis may be completed using existing tools. During specific implementation, the selection may be based on actual needs, and this embodiment does not impose any limitation thereto.

[0145] Continuing with the above example, after completing the collection of delay measurement data corresponding to n measurement points of the target program H, the delay measurement data can be stored in the cache of the delay measurement module, and when the cache reaches the storage limit, it can be switched to the backup cache. At the same time, all delay measurement data in the cache can be stored to the disk for subsequent program optimization.

[0146] In summary, by adopting double caching and persisting the latency measurement data to complete the storage, it can be ensured that the latency measurement data is stored for a long time, so that the corresponding data can be read at any subsequent time node to complete the program optimization operation.

[0147] In addition, in the program optimization stage, in order to facilitate developers to have clearer instructions on the optimization direction of the program, the latency analysis graph can be constructed in combination with the collected latency measurement data, and used to construct an optimization strategy to optimize the target program. In this embodiment, the specific implementation method is as follows:

[0148] In response to a latency analysis request submitted to the target program, the latency measurement data and the measurement configuration information are read; a program latency analysis graph is generated according to the latency measurement data and the measurement configuration information, and a program optimization strategy is constructed for the target program based on the program latency analysis graph; the target program is optimized based on the program optimization strategy until a release program that meets the optimization conditions is obtained.

[0149] Specifically, the latency analysis request specifically refers to the optimization request submitted by the developer for the target program, which is used to optimize the target program. Correspondingly, the latency analysis graph specifically refers to the analysis graph that characterizes the running time of the target program. The graph can be drawn according to actual needs, and this embodiment does not make any restrictions here. Correspondingly, the program optimization strategy specifically refers to the strategy constructed according to the latency analysis graph for the target program, which is used to optimize the program, such as over-optimization to reduce unnecessary calculations, improve data structures, and use more efficient algorithms to complete optimization; for data that is frequently queried but not often modified, you can consider using hash tables or index structures to speed up search operations. Alternatively, for parallel processing tasks, you can use parallel or multi-threaded methods to execute tasks, etc.

[0150] Based on this, after completing the collection of delay measurement data for the target program, if the developer has optimization requirements for the target program, an optimization request can be submitted. At this time, the delay measurement data and the measurement configuration information can be read in response to the delay analysis request submitted to the target program; on this basis, a program delay analysis graph can be generated according to the delay measurement data and the measurement configuration information. Through the delay analysis graph, the program running time corresponding to different delay measurement points can be reflected, and then it can be determined whether the program part associated with each measurement point needs to be optimized. After that, a program optimization strategy can be constructed for the target program based on the program delay analysis graph; thus, the target program can be optimized based on the program optimization strategy until a release program that meets the optimization conditions is obtained.

[0151] In actual applications, when analyzing latency measurement data to optimize a program, latency measurement data analysis can be completed from both overall and local dimensions to discover the performance bottleneck of the program. Therefore, by reading latency measurement data and measurement configuration information, measurement data as shown in the following table (3) can be constructed: (3)

[0153]

[0154] After that, data processing can be performed according to the id, level, and end in the above table, and then a program delay analysis graph can be generated. The delay analysis graph reflects the level, identification, and delay information of different delay measurement points, so that developers can intuitively understand the program delay information and decide on the corresponding optimization strategy.

[0155] The program delay measurement method provided in this embodiment can first obtain the measurement configuration information set for the target program in order to realize non-intrusive delay measurement data collection and support customized measurement granularity. At the same time, in order to complete the delay data collection without changing the program source code, the program execution information of the target program can be extracted in the target process of the target program; on this basis, the measurement point configuration strategy can be constructed for the target program in combination with the measurement configuration information and the program execution information, so that the delay measurement point can be configured for the target program according to the measurement point configuration strategy. At this time, the added delay measurement point is only in the form of a pile point, and the source code of the target program will not be updated, thereby realizing non-intrusive delay measurement configuration operations. After that, if the target program is in a running state and the delay measurement point is triggered, the delay measurement module associated with the measurement configuration information outside the target program can be called to execute the measurement point code corresponding to the delay measurement point; the corresponding code of the measurement point is executed outside the target program to complete the corresponding delay measurement operation, so that the delay measurement data corresponding to the target program can be determined based on the code execution result. The delay measurement data collection of the target program is completed in a non-invasive manner, so that the downstream can optimize the program according to the data. The delay measurement data collection of this method is more flexible and can be adapted to different types of programs, thus making it easier to use for program optimization.

[0156] The following combination Figure 4 Taking the application of the program delay measurement method provided in this specification to measure the delay of a shopping program as an example, the program delay measurement method is further described. Figure 4 A processing flow chart of a program delay measurement method provided by an embodiment of the present specification is shown, which specifically includes the following steps.

[0157] Step S402: receiving measurement point information configured for the target program, and allocating measurement point identification information and measurement point level information for the measurement point information.

[0158] Step S404: construct initial measurement configuration information according to the measurement point information, the measurement point identification information and the measurement point level information.

[0159] Step S406: in response to the metric description information submitted for the initial metric configuration information, the initial metric configuration information is updated to the metric configuration information.

[0160] Step S408, obtaining a process identifier corresponding to the target program in the running state, and determining a target process of the target program according to the process identifier.

[0161] Step S410, extracting the memory address information and program debugging information of the target program in the target process, and constructing the program execution information of the target program according to the memory address information and the program debugging information.

[0162] Step S412, determining the measurement point position according to the measurement configuration information and the program execution information, and determining the target measurement point information corresponding to the measurement point position according to the measurement configuration information.

[0163] Step S414: construct a measurement point configuration strategy for the target program based on the target measurement point information and the measurement point location.

[0164] Step S416: According to the measurement point configuration strategy, in the target process of the target program, a delay measurement point corresponding to the target measurement point information is configured for the measurement point position.

[0165] Step S418, when the target program is in the running state and the currently executed target instruction triggers the delay measurement point, the measurement point code corresponding to the delay measurement point is determined in the delay measurement module, and the measurement point code is executed by the delay measurement module.

[0166] Step S420, determining the current time information according to the code execution result, and reading the historical time information corresponding to the delay measurement point.

[0167] Step S422: Calculate the delay information according to the current time information and the historical time information, and read the delay measurement identifier in the measurement configuration information according to the instruction address of the delay measurement point.

[0168] Step S424: generating delay measurement data corresponding to the target program based on the delay information and the delay measurement identifier.

[0169] Step S426: Reading the delay measurement data and the measurement configuration information in response to the delay analysis request submitted to the target program.

[0170] Step S428, generating a program delay analysis graph according to the delay measurement data and the measurement configuration information, and constructing a program optimization strategy for the target program based on the program delay analysis graph.

[0171] Step S430, optimizing the target program based on the program optimization strategy until a release program that meets the optimization conditions is obtained.

[0172] In summary, in order to achieve non-intrusive delay measurement data collection and support custom measurement granularity, the measurement configuration information set for the target program can be obtained first. At the same time, in order to complete the delay data collection without changing the program source code, the program execution information of the target program can be extracted in the target process of the target program; on this basis, the measurement configuration information and program execution information can be combined to build a measurement point configuration strategy for the target program, so that the delay measurement point can be configured for the target program according to the measurement point configuration strategy. At this time, the added delay measurement point is only in the form of a pile point, and the source code of the target program will not be updated, thereby realizing non-intrusive delay measurement configuration operations. After that, if the target program is in a running state and the delay measurement point is triggered, the delay measurement module associated with the measurement configuration information outside the target program can be called to execute the measurement point code corresponding to the delay measurement point; the corresponding code of the measurement point is executed outside the target program to complete the corresponding delay measurement operation, so that the delay measurement data corresponding to the target program can be determined based on the code execution result. The delay measurement data collection of the target program is completed in a non-invasive manner, so that the downstream can optimize the program according to the data. The delay measurement data collection of this method is more flexible and can be adapted to different types of programs, thus making it easier to use for program optimization.

[0173] See also Figure 5 , Figure 5 A flowchart of a program configuration method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0174] Step S502, obtaining the measurement configuration information of the target program;

[0175] Step S504, extracting program execution information of the target program in the target process of the target program;

[0176] Step S506, constructing a measurement point configuration strategy according to the measurement configuration information and the program execution information;

[0177] Step S508: configuring a delay measurement point for the target program according to the measurement point configuration strategy, wherein the delay measurement point is used to collect delay measurement data when the target program is running.

[0178] The above is a schematic scheme of a program configuration method of this embodiment. It should be noted that the technical scheme of the program configuration method and the technical scheme of the program delay measurement method described above belong to the same concept, and the details not described in detail in the technical scheme of the program configuration method can be referred to the description of the technical scheme of the program delay measurement method described above.

[0179] See also Figure 6 , Figure 6A flowchart of another program delay measurement method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.

[0180] Step S602, determining a target program, and executing a delay measurement task for the target program, wherein the target program is configured with delay measurement points by the above method;

[0181] Step S604: when the delay measurement point is triggered during the execution of the delay measurement task, calling the delay measurement module to execute the measurement point code corresponding to the delay measurement point;

[0182] Step S606: Determine the latency measurement data corresponding to the target program based on the code execution result, and optimize the target program according to the latency measurement data.

[0183] The above is an illustrative scheme of another program delay measurement method of this embodiment. It should be noted that the technical scheme of the program delay measurement method and the technical scheme of the above program delay measurement method belong to the same concept, and the details not described in detail in the technical scheme of the program delay measurement method can be referred to the description of the technical scheme of the above program delay measurement method.

[0184] Corresponding to the above method embodiment, this specification also provides a program delay measurement device embodiment, Figure 7 FIG. 1 shows a schematic diagram of the structure of a program delay measurement device provided by an embodiment of the present specification. Figure 7 As shown, the device comprises:

[0185] An acquisition module 702 is configured to acquire measurement configuration information of a target program and extract program execution information of the target program in a target process of the target program;

[0186] A construction module 704 is configured to construct a measurement point configuration strategy according to the measurement configuration information and the program execution information, and configure a delay measurement point for the target program according to the measurement point configuration strategy;

[0187] An execution module 706 is configured to call the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the delay measurement point when the target program is in a running state and the delay measurement point is triggered;

[0188] The determination module 708 is configured to determine the latency measurement data corresponding to the target program based on the code execution result.

[0189] In an optional embodiment, the acquisition module 702 is further configured to:

[0190] Receive measurement point information configured for a target program, and assign measurement point identification information and measurement point level information to the measurement point information; construct initial measurement configuration information based on the measurement point information, the measurement point identification information and the measurement point level information; and update the initial measurement configuration information to measurement configuration information in response to measurement description information submitted for the initial measurement configuration information.

[0191] In an optional embodiment, the acquisition module 702 is further configured to:

[0192] Obtain the process identifier corresponding to the target program in the running state, and determine the target process of the target program according to the process identifier; extract the memory address information and program debugging information of the target program in the target process; and construct the program execution information of the target program according to the memory address information and the program debugging information.

[0193] In an optional embodiment, the construction module 704 is further configured to:

[0194] Determine a measurement point position according to the measurement configuration information and the program execution information, and determine target measurement point information corresponding to the measurement point position according to the measurement configuration information; construct a measurement point configuration strategy for the target program based on the target measurement point information and the measurement point position; and configure a delay measurement point corresponding to the target measurement point information for the measurement point position in the target process of the target program according to the measurement point configuration strategy.

[0195] In an optional embodiment, the device further comprises:

[0196] A startup module, configured to start a delay measurement module corresponding to the measurement configuration information according to the delay measurement point configuration result;

[0197] Wherein, the execution module 706 is further configured to:

[0198] When the target program is in a running state and the currently executed target instruction triggers the delay measurement point, a measurement point code corresponding to the delay measurement point is determined in the delay measurement module, and the measurement point code is executed by the delay measurement module.

[0199] In an optional embodiment, the determining module 708 is further configured to:

[0200] Determine the current time information according to the code execution result, and read the historical time information corresponding to the delay measurement point; calculate the delay information according to the current time information and the historical time information, and read the delay measurement identifier in the measurement configuration information according to the instruction address of the delay measurement point; based on the delay information and the delay measurement identifier, generate the delay measurement data corresponding to the target program.

[0201] In an optional embodiment, the device further comprises:

[0202] A cache module is configured to store the delay measurement data in a target cache of the delay measurement module; when the cache space of the target cache is greater than or equal to a preset space threshold, switch the target cache of the delay measurement module to a candidate cache, and store the global delay measurement data in the target cache to a target disk of the delay measurement module.

[0203] In an optional embodiment, when there are multiple delay measurement points, the execution module 706 is further configured to:

[0204] When the target program is in a running state and the i-th delay measurement point among the multiple delay measurement points is triggered, the delay measurement module of the measurement configuration information is called to execute the measurement point code corresponding to the i-th delay measurement point; according to the execution result of the measurement point code corresponding to the i-th delay measurement point, the sub-delay measurement data corresponding to the i-th delay measurement point is determined, and the target program is continued to run; when the i+1-th delay measurement point among the multiple delay measurement points is triggered, the step of calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the i+1-th delay measurement point is performed; i is incremented sequentially until i is equal to n, and the delay measurement data corresponding to the target program is constructed based on the sub-delay measurement data corresponding to each delay measurement point, wherein i starts from 1, i is a positive integer, and n is the number of delay measurement points.

[0205] In an optional embodiment, the device further comprises:

[0206] an optimization module, configured to read the latency measurement data and the measurement configuration information in response to a latency analysis request submitted to the target program;

[0207] Generating a program delay analysis graph according to the delay measurement data and the measurement configuration information, and constructing a program optimization strategy for the target program based on the program delay analysis graph;

[0208] The target program is optimized based on the program optimization strategy until a release program that meets the optimization conditions is obtained.

[0209] The program delay measurement device provided in this embodiment can first obtain the measurement configuration information set for the target program in order to realize non-intrusive delay measurement data collection and support customized measurement granularity. At the same time, in order to complete the delay data collection without changing the program source code, the program execution information of the target program can be extracted in the target process of the target program; on this basis, the measurement point configuration strategy can be constructed for the target program in combination with the measurement configuration information and the program execution information, so that the delay measurement point can be configured for the target program according to the measurement point configuration strategy. At this time, the added delay measurement point is only in the form of a pile point, and the source code of the target program will not be updated, thereby realizing non-intrusive delay measurement configuration operation. After that, if the target program is in a running state and the delay measurement point is triggered, the delay measurement module associated with the measurement configuration information outside the target program can be called to execute the measurement point code corresponding to the delay measurement point; the corresponding code of the measurement point is executed outside the target program to complete the corresponding delay measurement operation, so that the delay measurement data corresponding to the target program can be determined based on the code execution result. The delay measurement data collection of the target program is completed in a non-invasive manner, so that the downstream can optimize the program according to the data. The delay measurement data collection of this method is more flexible and can be adapted to different types of programs, thus making it easier to use for program optimization.

[0210] The above is a schematic scheme of a program delay measurement device of this embodiment. It should be noted that the technical scheme of the program delay measurement device and the technical scheme of the program delay measurement method described above belong to the same concept, and the details not described in detail in the technical scheme of the program delay measurement device can be referred to the description of the technical scheme of the program delay measurement method described above.

[0211] Corresponding to the above method embodiment, this specification also provides a program configuration device embodiment, Figure 8 FIG. 1 shows a schematic diagram of a program configuration device provided by an embodiment of the present specification. Figure 8 As shown, the device comprises:

[0212] An information acquisition module 802 is configured to acquire measurement configuration information of a target program;

[0213] An information extraction module 804 is configured to extract program execution information of the target program in the target process of the target program;

[0214] A strategy building module 806 is configured to build a measurement point configuration strategy according to the measurement configuration information and the program execution information;

[0215] The configuration measurement point module 808 is configured to configure a delay measurement point for the target program according to the measurement point configuration strategy, wherein the delay measurement point is used to collect delay measurement data when the target program is running.

[0216] The above is a schematic scheme of a program configuration device of this embodiment. It should be noted that the technical scheme of the program configuration device and the technical scheme of the program configuration method described above are of the same concept, and the details not described in detail in the technical scheme of the program configuration device can be referred to the description of the technical scheme of the program configuration method described above.

[0217] Corresponding to the above method embodiment, this specification also provides another program delay measurement device embodiment, Fig. 9 FIG. 2 shows a schematic diagram of the structure of another program delay measurement device provided by an embodiment of the present specification. Fig. 9 As shown, the device comprises:

[0218] The determination task module 902 is configured to determine a target program and perform a delay measurement task for the target program, wherein the target program performs delay measurement point configuration by the above method;

[0219] An execution code module 904 is configured to call a delay measurement module to execute a measurement point code corresponding to the delay measurement point when the delay measurement point is triggered in the execution state of the delay measurement task;

[0220] The program optimization module 906 is configured to determine the latency measurement data corresponding to the target program based on the code execution result, and optimize the target program according to the latency measurement data.

[0221] The above is a schematic scheme of another program delay measurement device of this embodiment. It should be noted that the technical scheme of the program delay measurement device and the technical scheme of the program delay measurement method described above belong to the same concept, and the details not described in detail in the technical scheme of the program delay measurement device can be referred to the description of the technical scheme of the program delay measurement method described above.

[0222] Fig.10 The block diagram of a computing device 1000 according to an embodiment of the present specification is shown. The components of the computing device 1000 include but are not limited to a memory 1010 and a processor 1020. The processor 1020 is connected to the memory 1010 via a bus 1030, and the database 1050 is used to store data.

[0223] The computing device 1000 also includes an access device 1040 that enables the computing device 1000 to communicate via one or more networks 1060. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 1040 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).

[0224] In one embodiment of the present specification, the above components of the computing device 1000 and Fig.10 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig.10 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0225] The computing device 1000 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 1000 may also be a mobile or stationary server.

[0226] The processor 1020 is used to execute the following computer executable instructions, which, when executed by the processor, implement the steps of the above-mentioned program delay measurement method or program configuration method.

[0227] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the program delay measurement method or program configuration method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the program delay measurement method or program configuration method mentioned above.

[0228] An embodiment of the present specification further provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the above-mentioned program delay measurement method or program configuration method.

[0229] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the program delay measurement method or program configuration method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the program delay measurement method or program configuration method mentioned above.

[0230] An embodiment of the present specification further provides a computer program product, including a computer program or instructions, which implements the steps of the above-mentioned program delay measurement method or program configuration method when executed by a processor.

[0231] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the program delay measurement method or program configuration method described above belong to the same concept, and the details not described in detail in the technical scheme of the computer program product can be referred to the description of the technical scheme of the program delay measurement method or program configuration method described above.

[0232] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0233] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0234] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.

[0235] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0236] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can understand and use this specification well.

Claims

1. A program delay measurement method, characterized in that: include: Receiving measurement point information configured for a target program, and allocating measurement point identification information and measurement point level information for the measurement point information; Constructing initial measurement configuration information according to the measurement point information, the measurement point identification information and the measurement point level information; In response to the measurement description information submitted for the initial measurement configuration information, updating the initial measurement configuration information to measurement configuration information, and extracting program execution information of the target program in a target process of the target program; Determine the measurement point position according to the measurement configuration information and the program execution information, and determine the target measurement point information corresponding to the measurement point position according to the measurement configuration information; Constructing a measurement point configuration strategy for the target program based on the target measurement point information and the measurement point location; According to the measurement point configuration strategy, in the target process of the target program, configuring a delay measurement point corresponding to the target measurement point information for the measurement point position; When the target program is in a running state and the delay measurement point is triggered, calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the delay measurement point, wherein the delay measurement module runs in the operating system of the target program and is not associated with the program part of the target program, and the measurement point code is the stub code of the delay measurement point; Delay measurement data corresponding to the target program is determined based on the code execution result, wherein the delay measurement data is the running time consumption data of the target program corresponding to the execution logic of the delay measurement point.

2. The program delay measurement method according to claim 1, characterized in that: Extracting the program execution information of the target program in the target process of the target program includes: Obtaining a process identifier corresponding to the target program in a running state, and determining a target process of the target program according to the process identifier; Extracting the memory address information and program debugging information of the target program in the target process; The program execution information of the target program is constructed according to the memory address information and the program debugging information.

3. The program delay measurement method according to claim 1, characterized in that: Also includes: Start the delay measurement module corresponding to the measurement configuration information according to the delay measurement point configuration result; Wherein, when the target program is in a running state and the delay measurement point is triggered, calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the delay measurement point includes: When the target program is in a running state and the currently executed target instruction triggers the delay measurement point, a measurement point code corresponding to the delay measurement point is determined in the delay measurement module, and the measurement point code is executed by the delay measurement module.

4. The program delay measurement method according to claim 1, characterized in that: The determining the latency measurement data corresponding to the target program based on the code execution result includes: Determine the current time information according to the code execution result, and read the historical time information corresponding to the delay measurement point, wherein the historical time information is the time information collected by the delay measurement point in the previous trigger cycle; Calculating delay information according to the current time information and the historical time information, and reading a delay measurement identifier in the measurement configuration information according to an instruction address of the delay measurement point; Based on the delay information and the delay measurement identifier, delay measurement data corresponding to the target program is generated.

5. The program delay measurement method according to any one of claims 1 to 4, characterized in that: After the step of determining the latency measurement data corresponding to the target program based on the code execution result is executed, the method further includes: storing the delay metric data into a target cache of the delay metric module; When the cache space of the target cache is greater than or equal to a preset space threshold, the target cache of the delay metric module is switched to the candidate cache, and the global delay metric data in the target cache is stored in the target disk of the delay metric module.

6. The program delay measurement method according to claim 1, characterized in that: In the case where there are multiple delay measurement points, in the case where the target program is in a running state and the delay measurement point is triggered, calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the delay measurement point includes: When the target program is in a running state and an i-th delay measurement point among a plurality of delay measurement points is triggered, calling the delay measurement module of the measurement configuration information to execute a measurement point code corresponding to the i-th delay measurement point; Determine the sub-delay measurement data corresponding to the i-th delay measurement point according to the execution result of the measurement point code corresponding to the i-th delay measurement point, and continue to run the target program; In the case of triggering the i+1th delay measurement point among the multiple delay measurement points, executing the step of calling the delay measurement module of the measurement configuration information to execute the measurement point code corresponding to the i+1th delay measurement point; i is incremented sequentially until i is equal to n, and the delay measurement data corresponding to the target program is constructed based on the sub-delay measurement data corresponding to each delay measurement point, wherein i starts from 1, i is a positive integer, and n is the number of delay measurement points.

7. The program delay measurement method according to any one of claims 1 to 4, characterized in that: After the step of determining the latency measurement data corresponding to the target program based on the code execution result is executed, the method further includes: reading the latency measurement data and the measurement configuration information in response to a latency analysis request submitted to the target program; Generating a program delay analysis graph according to the delay measurement data and the measurement configuration information, and constructing a program optimization strategy for the target program based on the program delay analysis graph; The target program is optimized based on the program optimization strategy until a release program that meets the optimization conditions is obtained.

8. A program configuration method, characterized in that: include: Receiving measurement point information configured for a target program, and allocating measurement point identification information and measurement point level information for the measurement point information; Constructing initial measurement configuration information according to the measurement point information, the measurement point identification information and the measurement point level information; In response to the metric description information submitted for the initial metric configuration information, updating the initial metric configuration information to metric configuration information; Extracting program execution information of the target program in the target process of the target program; Determine the measurement point position according to the measurement configuration information and the program execution information, and determine the target measurement point information corresponding to the measurement point position according to the measurement configuration information; Constructing a measurement point configuration strategy for the target program based on the target measurement point information and the measurement point location; According to the measurement point configuration strategy, in the target process of the target program, a delay measurement point corresponding to the target measurement point information is configured for the measurement point position, wherein the delay measurement point is used to collect delay measurement data when the target program is running, and the delay measurement data is the running time consumption data of the target program corresponding to the execution logic of the delay measurement point.

9. A method for measuring program delay, characterized in that: include: Determine a target program, and perform a delay measurement task for the target program, wherein the target program performs delay measurement point configuration by the method of claim 8; In a case where the delay measurement point is triggered during the execution of the delay measurement task, calling a delay measurement module to execute a measurement point code corresponding to the delay measurement point; Delay measurement data corresponding to the target program is determined based on the code execution result, and the target program is optimized according to the delay measurement data.

10. A computing device, characterized in that include: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the method described in any one of claims 1 to 9 are implemented.

11. A computer-readable storage medium, characterized in that: It stores computer executable instructions, which, when executed by a processor, implement the steps of the method described in any one of claims 1 to 9.

12. A computer program product, characterized in that The method comprises a computer program or an instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Reliable core dynamic integrity measuring method

    CN103268440A

  • Memory leak detection method and device, electronic device and mobile equipment

    CN118069476A