Code execution path determination method and related apparatus

By using the MD5 algorithm and Java probe technology, the path value of the code execution path is calculated to determine whether the code execution paths of the trace ID requests are the same, which solves the problem of low efficiency in the existing technology and realizes fast and accurate code execution path comparison and analysis.

WO2025241557A1PCT designated stage Publication Date: 2025-11-27HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/071961
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-05-20
Filing Date
2025-01-13
Publication Date
2025-11-27

AI Technical Summary

Technical Problem

In existing technologies, comparing code execution paths by querying the executable code of user requests from the source code is inefficient and computationally intensive, making it difficult to quickly determine whether the code execution paths of different trace ID requests are the same, resulting in low analysis efficiency.

Method used

Using a pre-defined algorithm, especially the MD5 algorithm, the path value of the code execution path requested by the user is calculated. By comparing the path values, it is determined whether the code execution paths of multiple user requests are the same. Combined with Java probe technology to obtain code coverage information and distributed link tracing technology, the correspondence between trace ID and code execution path is recorded, avoiding direct query and comparison analysis from the source code.

Benefits of technology

It improves the efficiency of code execution path comparison, replaces source code query with numerical comparison, enhances analysis speed and accuracy, and can intuitively show the differences in code execution paths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025071961_27112025_PF_FP_ABST
    Figure CN2025071961_27112025_PF_FP_ABST
Patent Text Reader

Abstract

The embodiments of the present application disclose a code execution path determination method and a related apparatus, which are configured to obtain path values of code execution paths based on a predefined algorithm, and then compare the path values corresponding to user requests with different trace IDs to determine whether or not the code execution paths of user requests with different trace IDs are the same, so as to improve comparison efficiency with respect to code execution paths. The method comprises: acquiring code execution paths of a plurality of user requests according to a plurality of trace IDs, wherein the plurality of trace IDs and the plurality of user requests are in one-to-one correspondence, and each trace ID uniquely identifies a corresponding user request; according to the code execution paths of the plurality of user requests, determining a plurality of path values by means of a predefined algorithm, wherein the path values are used for representing information of the code execution paths; and, according to the plurality of path values, determining whether the code execution paths of the plurality of user requests are the same.
Need to check novelty before this filing date? Find Prior Art

Description

A code execution path determination method and related apparatus

[0001] The present application claims priority from the Chinese patent application No. 202410631058.X filed on May 20, 2024, and entitled "A code execution path determination method and related apparatus", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] The present application relates to the field of computers, and in particular to a code execution path determination method and related apparatus. BACKGROUND

[0003] In traditional software development, there are often requests for the same content at different times, and the program returns different return values. In order to find out the reason why the program produces different return values, it is usually necessary to analyze the code execution path of the request.

[0004] At present, the code execution path of different trace ID requests is usually obtained by combining the distributed link tracking technology and the code coverage information statistical framework, wherein the trace ID corresponds to a request. Then, whether the code execution paths of different trace ID requests are the same is compared and analyzed, and the reason why the program produces different return values is further analyzed according to the comparison result. Specifically, the comparison of the code execution paths of different trace ID requests usually needs to query the execution code corresponding to the user request from the source code according to the code execution path for comparison and analysis.

[0005] However, in actual application, due to the huge amount of code, searching the execution code of the user request from the source code is low in efficiency and large in calculation, and therefore, it is urgent to find a method for quickly comparing the code execution paths to improve the comparison efficiency of the code execution paths. SUMMARY

[0006] The present application provides a code execution path determination method and related apparatus, which is used to obtain the path value of the code execution path based on a preset algorithm, and to determine whether the code execution paths of the user requests of different trace IDs are the same by comparing the path values corresponding to the user requests of different trace IDs, so as to improve the comparison efficiency of the code execution paths.

[0007] Therefore, in a first aspect, the present application provides a method for determining code execution paths of user requests. Each user request is associated with a trace ID, and each trace ID uniquely identifies the corresponding user request. First, code execution paths of multiple user requests are obtained based on the multiple trace IDs. Then, path values of the code execution paths of the multiple user requests are determined using a preset algorithm. The path values represent information of the code execution paths of the user requests. Finally, whether the code execution paths of the multiple user requests are the same is determined based on the path values.

[0008] In the embodiments of the present application, the path values of the code execution paths of the user requests are determined using the preset algorithm, and the path values represent information of the code execution paths of the user requests. Therefore, whether the code execution paths of the multiple user requests are the same can be determined based on the path values of the multiple user requests. When the call chains of the user requests at different times are the same but the return values are different, whether the execution paths of the multiple user requests are the same can be determined based on the path values of the multiple user requests, so as to avoid querying the corresponding codes from a large amount of source codes for comparison and analysis, thereby converting the comparison between the codes into comparison between values and improving the efficiency of the comparison between the code execution paths.

[0009] In a possible implementation, the determination of whether the code execution paths of the multiple user requests are the same based on the path values can include: comparing whether the path values of the multiple user requests are the same; and if the path values of the multiple user requests are the same, the code execution paths of the multiple user requests are the same.

[0010] In a possible implementation, the determination of the path values of the code execution paths of the multiple user requests based on the code execution paths of the multiple user requests can include: calculating the path values of the multiple user requests based on the code execution path information of the multiple user requests using a Message-Digest Algorithm 5 (MD5).

[0011] In the embodiments of the present application, the MD5 algorithm can convert input information of any length into a hash value based on bit operations and complex operations of nonlinear functions. Therefore, the hash value of each user request can be calculated based on the code execution path information using the MD5 algorithm, and the hash value can be used as the path value of the code execution path, so that whether the code execution paths of the user requests of different trace IDs are the same can be determined based on the paths of the user requests of different trace IDs.

[0012] In a possible implementation, before the foregoing obtaining the code execution paths of the multiple user requests according to the multiple trace IDs, the method can further include: obtaining code coverage information of the multiple user requests based on a Java probe technology, the code coverage information being used to indicate code execution of the user requests; and recording a correspondence between the trace IDs and the code coverage information according to the multiple trace IDs of the multiple user requests.

[0013] In the embodiments of the present application, the probe can be inserted into the bytecode based on the Java probe technology to obtain the code execution paths of the user requests, and the trace ID and the code execution paths of the user requests can be associated according to the trace ID and the unique identification of the user requests, so that the corresponding code execution paths can be directly obtained according to the trace ID subsequently.

[0014] In a possible implementation, the foregoing obtaining the code execution paths of the multiple user requests according to the multiple trace IDs can include: obtaining the code execution paths of the multiple user requests according to the correspondence between the trace IDs and the code coverage information.

[0015] In a possible implementation, the method can further include: marking the code executed by the user requests in the source code according to the code execution paths.

[0016] In a second aspect, the present application provides a code execution path determination apparatus, including:

[0017] An obtaining module is configured to obtain code execution paths of multiple user requests according to multiple trace IDs, the multiple trace IDs corresponding to the multiple user requests one by one, and each trace ID uniquely identifying a corresponding user request.

[0018] A determining module is configured to determine multiple path values by using a preset algorithm according to the code execution paths of the multiple user requests, the path values being used to represent information of the code execution paths.

[0019] A determining module is configured to determine whether the code execution paths of the multiple user requests are the same according to the multiple path values.

[0020] In a possible implementation, the foregoing determining module is specifically configured to: compare whether the path values corresponding to the multiple user requests are the same; and if the path values corresponding to the multiple user requests are the same, the code execution paths of the multiple user requests are the same.

[0021] In a possible implementation, the determining module is specifically configured to: calculate a plurality of path values of the plurality of user requests by using a Message-Digest Algorithm 5 according to the code execution paths of the plurality of user requests.

[0022] In a possible implementation, the obtaining module is further configured to obtain the code coverage information of the plurality of user requests based on a Java probe technology, and the code coverage information is used to indicate the code execution of the user requests.

[0023] In a possible implementation, the obtaining module is specifically configured to: obtain the code execution paths of the plurality of user requests according to the correspondence between the trace ID and the code coverage information.

[0024] In a possible implementation, the apparatus further includes a marking module configured to mark the code executed by the user requests in the source code according to the code execution paths.

[0025] In a third aspect, an embodiment of the present application provides a computing device, including a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device performs the method in the first aspect or any possible implementation manner of the first aspect.

[0026] In a fourth aspect, an embodiment of the present application provides a computing device cluster, including at least one computing device, and each computing device includes a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs the method in the first aspect or any possible implementation manner of the first aspect.

[0027] In a fifth aspect, an embodiment of the present application provides a computer readable storage medium, including computer program instructions, when the computer program instructions are executed by a computing device cluster, the computing device cluster performs the method in the first aspect or any possible implementation manner of the first aspect.

[0028] In a sixth aspect, an embodiment of the present application provides a computer program product including instructions, when the instructions are run by a computing device cluster, the computing device cluster performs the method in the first aspect or any possible implementation manner of the first aspect.

[0029] The technical effects brought by the second aspect to the sixth aspect or any possible implementation manner thereof can be referred to the technical effects brought by the first aspect or the related possible implementation manner of the first aspect, which will not be described here again. BRIEF DESCRIPTION OF DRAWINGS

[0030] FIG. 1 is a schematic diagram of a system framework provided by an embodiment of the present application;

[0031] FIG. 2 is a schematic diagram of a flow of analyzing code execution paths corresponding to different trace IDs;

[0032] FIG. 3 is a schematic diagram of a flow of a code execution path determination method provided by an embodiment of the present application;

[0033] FIG. 4 is a schematic diagram of tracking coverage of code based on Java agent technology;

[0034] FIG. 5 is a schematic diagram of visualizing code execution paths corresponding to different trace IDs;

[0035] FIG. 6 is a schematic diagram of a structure of a code execution path determination apparatus provided by an embodiment of the present application;

[0036] FIG. 7 is a schematic diagram of a structure of a computing device provided by an embodiment of the present application;

[0037] FIG. 8 is a schematic diagram of a structure of a computing device cluster provided by an embodiment of the present application. DETAILED DESCRIPTION

[0038] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0039] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of singular or plural items. The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or apparatus that comprises a series of units is not necessarily limited to those units, but may include other units not expressly listed or inherent to those processes, methods, products, or apparatus.

[0040] First, some concepts involved in the embodiments of this application will be introduced.

[0041] 1. Trace ID

[0042] A Trace ID is a unique identifier used to trace requests throughout a distributed system. It tracks all services and operations a request passes through throughout the system and can be used to quickly locate problems.

[0043] 2. Java Agent

[0044] Java Agent, also known as a Java probe, is a technology introduced in JDK 1.5 that allows dynamic modification of Java bytecode. It enables developers to dynamically modify or enhance the behavior of Java applications at runtime or startup. After a Java class is compiled, it forms bytecode which is executed by the Java Virtual Machine (JVM). Before executing the bytecode, the JVM obtains bytecode information and modifies it using a bytecode converter to perform additional functionalities.

[0045] 3. JaCOCO framework

[0046] Jacoco (Java code coverage) is a Java-oriented open source and free code coverage tool. It calculates the covered code blocks through ASM bytecode instrumentation technology and finally generates a code coverage report. Jacoco has two instrumentation methods, namely on the fly and offline modes.

[0047] On the fly instrumentation: the jvm starts the Instrumentation agent program specified by the -javaagent parameter, and the agent program loads a class through the ClassLoader to determine whether to convert and modify the class file. The code statistics are inserted into the class test coverage, which can be completed during the execution of the test code by the JVM.

[0048] Offline instrumentation: the file is instrumented before testing, and then the instrumented class or jar package is generated. After testing the instrumented class and jar package, the dynamic coverage information is generated to the file, and finally the coverage information is processed and the report is generated.

[0049] 4. Bytecode enhancement

[0050] The basic principle of bytecode enhancement technology is to read and modify bytecode files to enhance classes, methods, fields and other elements. The main steps include bytecode reading, parsing, modification and rewriting back to the file. There are two common ways: bytecode enhancement based on source code compilation and dynamic proxy. Java probe technology belongs to a kind of bytecode enhancement technology.

[0051] The system architecture provided by the embodiment of the present application is introduced below.

[0052] Referring to FIG. 1, a system architecture 100 provided by the present application is shown. As shown in FIG. 1, the system architecture can include a client 110 and a computing device cluster 120 including at least one computing device. Any computing device can be a terminal device, such as a desktop computer, a notebook computer or other terminal device, or a server, a server cluster, etc. When the computing device cluster includes multiple computing devices, the types of different computing devices can be the same or different.

[0053] Specifically, the plug-in for judging the code execution path can be deployed in any computing device in the computing device cluster 120, and when the computing device receives the user request sent by the client 110, the computing device can load the plug-in through a predefined interface or API while running the source code, so as to judge the code path executed by the user request. The plug-in includes program code for implementing the code execution path judgment method, which can obtain the corresponding code execution path information according to the trace ID of the user request, calculate the path value of the code execution path by using an algorithm, and judge whether the code paths are the same according to the path value. In addition, the code executed by the user request and the code not executed can be colored, so that the execution of the code can be visually displayed on the front end in the future.

[0054] For example, when the source code is a Java program, the plug-in can be a jar package, and the computing device loads the jar package while running the Java program to implement the judgment of the program code path.

[0055] Specifically, the flowchart of the embodiment of the present application for analyzing the code execution paths corresponding to different trace IDs is shown in FIG. 2. As shown in FIG. 2, first, the code execution paths of the user requests with different trace IDs can be recorded based on the bytecode enhancement and the distributed link tracking technology according to the user request and the program code; then, the path hash value is generated according to the obtained code execution path information, and the correspondence between the trace ID and the code execution path is stored in the database. The corresponding code execution path can be obtained according to the trace ID, and the code paths of different trace IDs can be quickly compared according to the path value of the code execution path; finally, the code execution path corresponding to each TraceID in the database can be queried, and the source code can be visually displayed on the front end, so that the user can more intuitively compare the code execution paths corresponding to different trace IDs.

[0056] Next, the method flow provided by the present application will be introduced in combination with the foregoing system architecture.

[0057] Referring to FIG. 3, the flowchart of the code execution path judgment method provided by the present application is shown as follows.

[0058] 301. According to a plurality of trace IDs, the computing device obtains a plurality of code execution paths of user requests;

[0059] At present, the JaCOCO coverage statistics framework is usually used to record the code coverage information of the user request, which is used to indicate the code execution of the user request, i.e., the code coverage information can be used to obtain the executed code and the unexecuted code information in the source code.

[0060] Specifically, the JaCOCO framework collects the code coverage by dynamically or statically inserting a probe at the code runtime by using the Java Agent technology, wherein the probe is not inserted for each line of code, and the implementation of the probe requires multiple bytecode instructions, which will increase the size of the class file by several times and reduce the execution speed of the detected class, so only a few probes need to be inserted in the appropriate place of each method. Specifically, the probe can be inserted at the exit of each method, or the probe can be inserted on multiple edges of the target indicator with multiple edges.

[0061] In addition, the traditional JaCOCO coverage statistics framework cannot know the user request corresponding to the executed code, so the distributed link tracking technology can be combined to first generate a trace ID for each user request by the computing device, the trace ID is used to identify the user request, and the trace ID and the user request are one-to-one corresponding. In addition, since the trace ID can be passed in the call chain of the user request, when the JaCOCO framework is used to record the code coverage information of the user request, the trace ID corresponding to the code coverage information can be recorded at the same time, and the corresponding relationship between the trace ID and the code coverage information can be stored in the database.

[0062] The database can be an elasticsearch (ES) or other non-relational database, which is not limited here.

[0063] For example, as shown in FIG. 4, first, the computing device can generate a trace ID for each user request, including trace 1 and trace 2, then according to the insertion strategy of the probe, the probe P1 can be inserted between the statement 2 and the goto statement, and the probe 2 can be inserted after the statement 4, when the computing device runs the code according to the user request, the probe will be triggered, and the partial code coverage information recorded by the probe P1 and the probe P2 will be combined, and according to the trace ID of the user request, the code coverage information corresponding to each trace ID is recorded respectively, so as to record the code information executed by each trace ID.

[0064] Optionally, the trace ID corresponding to the code execution path of the user request can be obtained according to the correspondence between the trace ID and the code coverage information in the database. In the database, the code execution path is usually stored in the form of a binary string, where 0 represents that a code line in the source code is not executed, and 1 represents that a code line in the source code is executed.

[0065] For example, the trace ID and the corresponding code execution path can be recorded in the ES, where the trace ID-code execution path information recording table can be as shown in Table 1.

[0066] Table 1

[0067] where the commit ID represents the source code version number, the class ID represents the identification of the class, the method ID represents the identification of the method, the pathMd5 represents the path value of the code path corresponding to the trace ID, the classMd5 represents the value of the class corresponding to the class ID, the class name represents the class name, and 1, 2, 3,..., respectively, represent the number of code lines in the source code, i.e., the first code line, the second code line, the third code line, and the like in the source code.

[0068] As can be seen from Table 1, the ES not only stores the correspondence between the trace ID and the code execution path, but also stores the source code version number. When the code execution paths corresponding to different trace IDs are different, the version number corresponding to the trace ID can be queried first, and when the code versions are different, the code execution paths are usually different, so as to assist in investigating the reason for the different code execution paths.

[0069] Specifically, as can be seen from Table 1, the code execution path of the trace ID 345670124 can be [0, 1, 1], which means that the second line and the third line in the source code are executed; and the code execution path of the trace ID 896403212 can be [1, 1, 0], which means that the first line and the second line in the source code are executed.

[0070] In the embodiment of the application, according to the distributed link tracking technology, a trace ID can be allocated to each user request, so that the corresponding code execution path can be queried according to the trace ID subsequently, and the Java agent technology and the bytecode enhancement technology can be combined to insert a Java probe into the bytecode to record the trace ID and the corresponding code execution path. Since the Java agent technology is non-intrusive, the code execution path can be recorded without changing the original code logic.

[0071] 302、the computing device determines a plurality of path values according to the plurality of user-requested code execution paths by using a preset algorithm;

[0072] The preset algorithm can be a message-digest algorithm 5 (MD5). After obtaining the plurality of user-requested code execution paths, the computing device can use the MD5 algorithm to obtain a plurality of hash values according to the plurality of user-requested code execution paths, and the hash value is the path value of the user-requested code execution path. The path value is used to represent the user-requested code execution path, so that subsequent comparison of the path value can be used to determine whether the code execution paths are the same, and comparison of the code is converted into comparison of numerical values, thereby improving the efficiency of the code execution path.

[0073] 303、the computing device determines whether the plurality of user-requested code execution paths are the same according to the plurality of path values.

[0074] After obtaining the path values of the user-requested code execution paths, the computing device can compare the path values corresponding to the user requests of different trace IDs in the plurality of path values to determine whether the code execution paths of the user requests of different trace IDs in the plurality of user requests are the same.

[0075] For example, as shown in Table 1, the path value pathMd5 of the code execution path corresponding to the trace ID 345670124 is e4332sd5, and the path value pathMd5 of the code execution path corresponding to the trace ID 896403212 is dv56yhj8. Therefore, by comparing the path value e4332sd5 with the path value dv56yhj8, it can be determined whether the code execution paths corresponding to the two trace IDs are the same.

[0076] Alternatively, the computing device can compare whether the path values corresponding to the user requests of different trace IDs are the same, and then determine the code execution paths of the user requests of different trace IDs according to the comparison result. Specifically, when the path values corresponding to the user requests of different trace IDs are the same, it indicates that the code execution paths of the user requests of different trace IDs are the same. When the first path value of a first user request and the second path value of a second user request of different trace IDs are different, it indicates that the code execution paths of the first user request and the second user request are different.

[0077] In the embodiments of the present application, after obtaining the code execution paths corresponding to the trace IDs, whether the code execution paths are the same can be quickly compared by calculating the path values of the code execution paths. When it is judged that the code execution paths corresponding to different trace IDs are different, the code version corresponding to the trace ID can be queried to obtain the source code information, and the reasons for the inconsistency of the code paths can be further analyzed by combining the code execution paths and the source code information. In order to make the comparison and analysis of the code more intuitive, the executed code in the source code can also be subjected to dyeing processing. For example, the executed code can be marked as green, and the unexecuted code can be marked as red, so that the user can more intuitively judge the difference between the code execution paths. In the present application, the execution paths of the code are analyzed by the front-end visualization method, thereby improving the efficiency of code problem troubleshooting.

[0078] Specifically, the user issues a request "output order price method of different order discounts according to user type" at different times, and the user requests at different times correspond to two trace IDs (trace ID1 and trace ID2, respectively). Then, the code execution path corresponding to trace ID1 and the code execution path corresponding to trace ID2 can be queried according to trace ID1 and trace ID2, and the code execution paths corresponding to trace ID1 and trace ID2 can be dyed to realize visual comparison. As shown in FIG. 5, (a) of FIG. 5 shows the code execution path of trace ID1, and (b) of FIG. 5 shows the code execution path of trace ID2. In (a) of FIG. 5, the solid line box represents the executed code marked as green, and the dashed line box represents the unexecuted code marked as red. Therefore, it can be quickly analyzed from FIG. 5 that trace ID1 hits the discount of userType=1, and trace ID2 hits the discount of userType=2, thereby obtaining the reason for the inconsistency of the code paths. Through the visual comparison, the user can more intuitively understand the reason for the difference in the returned values of the same request call.

[0079] In the embodiments of the present application, a preset algorithm can be used to determine the path value of the code execution path requested by the user, and the path value is used to represent the information of the code execution path corresponding to the trace ID, so that whether the code execution paths requested by different trace IDs are the same can be directly determined according to the path values corresponding to the different trace IDs. When the call chains of different trace IDs are the same but the return values are different, the execution paths of different trace IDs can be first determined according to the path values corresponding to the different trace IDs, so as to avoid querying the corresponding code from a large amount of source code for comparison, thereby converting the comparison between codes into comparison between numerical values, and improving the efficiency of the comparison of the code execution paths.

[0080] The foregoing describes the method flow provided by the present application, and the following describes the device provided by the present application based on the foregoing method flow.

[0081] Referring to FIG. 6, the structure of a code execution path determination device provided by the present application is shown in the following.

[0082] The acquisition module 601 acquires the code execution paths of multiple user requests according to multiple trace IDs, the multiple trace IDs correspond to the multiple user requests one by one, and each trace ID uniquely identifies the corresponding user request.

[0083] The determination module 602 determines multiple path values according to the code execution paths of the multiple user requests by using a preset algorithm, and the path value is used to represent the information of the code execution path.

[0084] The determination module 602 determines multiple path values according to the code execution paths of the multiple user requests by using a preset algorithm, and the path value is used to represent the information of the code execution path.

[0085] In a possible implementation, the determination module 602 is specifically configured to: compare the path values corresponding to the multiple user requests; and if the path values corresponding to the multiple user requests are the same, the code execution paths of the multiple user requests are the same.

[0086] In a possible implementation, the determination module 602 is specifically configured to: calculate the path values of the multiple user requests by using a message digest algorithm (Message-Digest Algorithm 5) according to the code execution paths of the multiple user requests.

[0087] In a possible implementation, the obtaining module 601 is further configured to obtain the code coverage information of the user requests based on a Java probe technology, the code coverage information being used to indicate code execution of the user requests; and before the obtaining of the code execution path of the user requests according to the trace ID, the apparatus can further include a recording module 604 configured to record a correspondence between the trace ID and the code coverage information according to the trace IDs of the user requests.

[0088] In a possible implementation, the obtaining module 601 is specifically configured to obtain the code execution path of the user requests according to the correspondence between the trace ID and the code coverage information.

[0089] In a possible implementation, the apparatus can further include a marking module 605 configured to mark the code executed by the user requests in the source code according to the code execution path.

[0090] The obtaining module, the determining module, the judging module, the recording module, and the marking module can be implemented by software or by hardware. For example, the implementation of the obtaining module is described below. The implementation of the determining module, the judging module, the recording module, and the marking module can be similar to the implementation of the obtaining module.

[0091] As an example of a software functional unit, the obtaining module can include code running on a computing instance. The computing instance can include at least one of a physical host (computing device), a virtual machine, and a container. Further, the computing instance can be one or more. For example, the obtaining module can include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers running the code can be distributed in the same region, or can be distributed in different regions. Further, the multiple hosts / virtual machines / containers running the code can be distributed in the same availability zone (AZ), or can be distributed in different AZs, each AZ including one data center or multiple data centers in a similar geographical location. Generally, one region can include multiple AZs.

[0092] Likewise, the multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Among them, usually one VPC is set in one region, and communication between two VPCs in the same region or between VPCs in different regions needs to set a communication gateway in each VPC to realize the interconnection between VPCs through the communication gateway.

[0093] As an example of a hardware functional unit, the obtaining module can include at least one computing device, such as a server, etc. Alternatively, the obtaining module can also be a device implemented by a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or a programmable logic device (PLD), etc. Among them, the above-mentioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), a data processing unit (DPU), a neural network processing unit (NPU), a system on chip (SoC), an offload card, an acceleration card, or any combination thereof.

[0094] The multiple computing devices included in the obtaining module can be distributed in the same region or in different regions. The multiple computing devices included in the obtaining module can be distributed in the same AZ or in different AZs. Likewise, the multiple computing devices included in the obtaining module can be distributed in the same VPC or in multiple VPCs. Among them, the multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, DPUs, NPUs, SoCs, offload cards, acceleration cards, etc.

[0095] It should be noted that in other embodiments, the obtaining module can be configured to perform any of the steps of the code execution path determination method, the determining module can be configured to perform any of the steps of the code execution path determination method, the judging module can be configured to perform any of the steps of the code execution path determination method, the recording module can be configured to perform any of the steps of the code execution path determination method, and the marking module can be configured to perform any of the steps of the code execution path determination method. The steps performed by the obtaining module, the determining module, the judging module, the recording module, and the marking module can be specified as needed, and the functions of the code execution path determination apparatus can be implemented by the obtaining module, the determining module, the judging module, the recording module, and the marking module performing different steps of the code execution path determination method.

[0096] The present application also provides a computing device 700. As shown in FIG. 7, the computing device 700 includes a bus 702, a processor 704, a memory 706, and a communication interface 708. The processor 704, the memory 706, and the communication interface 708 communicate with each other through the bus 702. The computing device 700 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 700.

[0097] The bus 702 can be a peripheral component interconnect Express (PCIe) bus or an extended industry standard architecture (EISA) bus, a unified bus (Ubus or UB), a compute express link (CXL), a cache coherent interconnect for accelerators (CCIX), etc. The unified bus is also referred to as a smart bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one line is used in FIG. 7, but it does not mean that there is only one bus or only one type of bus. The bus 704 can include a path for transmitting information between various components (e.g., the memory 706, the processor 704, and the communication interface 708) of the computing device 700. The unified bus can also be referred to as a smart bus.

[0098] The processor 704 can include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP), an ASIC, an FPGA, a CPLD, an NPU, a SoC, an offload card, an acceleration card, or other computing device.

[0099] The memory 706 can include volatile memory, such as random access memory (RAM). The processor 704 can further include non-volatile memory, such as read-only memory (ROM), Flash memory, a hard disk drive (HDD), or a solid-state drive (SSD). In addition, the memory 706 can also be implemented by storage class memory (SCM), phase change memory (PCM), or other types of storage media.

[0100] It is worth noting that the same type of storage medium can be configured to implement the function of the memory 706 in the same computing device, or two or more types of storage media can be configured to implement the function of the memory 706, which is not limited in the present application.

[0101] The memory 706 stores executable program code, and the processor 704 executes the executable program code to respectively implement the functions of the foregoing acquisition module, determination module, judgment module, recording module, and marking module, thereby implementing the code execution path judgment method. That is, the memory 706 stores instructions for executing the code execution path judgment method.

[0102] The communication interface 708 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 700 and other devices or communication networks.

[0103] The embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a notebook computer, or a smart phone.

[0104] As shown in FIG. 8, the computing device cluster includes at least one computing device 700. The memory 706 in one or more computing devices 700 in the computing device cluster can store the same instructions for performing the code execution path determination method.

[0105] In some possible implementation manners, the memory 706 in one or more computing devices 700 in the computing device cluster can also respectively store partial instructions for performing the code execution path determination method. In other words, the combination of one or more computing devices 700 can collectively perform the instructions for performing the code execution path determination method.

[0106] It should be noted that the memory 706 in different computing devices 700 in the computing device cluster can store different instructions, respectively used for performing partial functions of the code execution path determination apparatus. That is, the instructions stored in the memory 706 in different computing devices 700 can implement the functions of one or more of the obtaining module, the determining module, the determining module, the recording module, and the marking module.

[0107] In some possible implementation manners, one or more computing devices in the computing device cluster can be connected through a network. The network can be a wide area network, a local area network, or the like. For example, two computing devices 700A and 700B are connected through the network. Specifically, the computing devices are connected to the network through the communication interfaces in the computing devices. In this type of possible implementation manner, the memory 706 in the computing device 700A stores instructions for performing the functions of the obtaining module. Meanwhile, the memory 706 in the computing device 700B stores instructions for performing the functions of the determining module, the determining module, the recording module, and the marking module.

[0108] It should be understood that the functions of the computing device 700A can also be completed by multiple computing devices 700. Similarly, the functions of the computing device 700B can also be completed by multiple computing devices 700.

[0109] Embodiments of the present application also provide another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to the connection manner of the foregoing computing device cluster. The difference is that the memory 706 in one or more computing devices 700 in the computing device cluster can store the same instructions for performing the code execution path determination method.

[0110] In some possible implementation manners, the memory 706 in one or more computing devices 700 in the computing device cluster can also respectively store partial instructions for performing the code execution path determination method. In other words, the combination of one or more computing devices 700 can collectively perform the instructions for performing the code execution path determination method.

[0111] The embodiment of the present application further provides a computer program product containing instructions. The computer program product can be software or program product containing instructions, which can run on a computing device or be stored in any available medium. When the computer program product runs on at least one computing device, the at least one computing device is caused to execute the method provided by the present application.

[0112] The embodiment of the present application further provides a computer program product containing instructions. The computer program product can be software or program product containing instructions, which can run on a computing device or be stored in any available medium. When the computer program product runs on at least one computing device, the at least one computing device is caused to execute the method provided by the present application.

[0113] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the protection scope of the technical solutions of the embodiments of the present application.

Claims

1. A method of determining a code execution path, characterized by, The method comprises the following steps: According to a plurality of trace IDs, a plurality of code execution paths of user requests are obtained, the plurality of trace IDs correspond to the plurality of user requests one by one, and each trace ID uniquely identifies a corresponding user request; According to the plurality of code execution paths of user requests, a plurality of path values are determined by using a preset algorithm, and the path values are used to represent information of the code execution paths; According to the plurality of path values, it is judged whether the code execution paths of the plurality of user requests are the same.

2. The method of claim 1, wherein, The step of judging whether the code execution paths of the plurality of user requests are the same according to the plurality of path values comprises: The path values corresponding to the plurality of user requests are compared; If the path values corresponding to the plurality of user requests are the same, the code execution paths of the plurality of user requests are the same.

3. The method of claim 2, wherein, The step of determining a plurality of path values according to the plurality of code execution paths of user requests by using a preset algorithm comprises: According to the plurality of code execution paths of user requests, the plurality of path values of the plurality of user requests are calculated by using a message-digest algorithm 5.

4. The method according to any one of claims 1 to 3, characterized in that, Before the step of obtaining a plurality of code execution paths of user requests according to a plurality of trace IDs, the method further comprises: Based on Java probe technology, code coverage information of the plurality of user requests is obtained, and the code coverage information is used to indicate code execution conditions of the user requests; According to a plurality of trace IDs of the plurality of user requests, a corresponding relationship between the trace IDs and the code coverage information is recorded.

5. The method of claim 4, wherein, The step of obtaining a plurality of code execution paths of user requests according to a plurality of trace IDs comprises: According to the corresponding relationship between the trace IDs and the code coverage information, the plurality of code execution paths of user requests are obtained.

6. The method according to any one of claims 1 to 5, characterized in that, The method further comprises: According to the code execution paths, code executed by the user requests in source code is marked.

7. A code execution path determination apparatus characterized by comprising: The method comprises the following steps: An obtaining module is configured to obtain a plurality of code execution paths of user requests according to a plurality of trace IDs, the plurality of trace IDs correspond to the plurality of user requests one by one, and each trace ID uniquely identifies a corresponding user request; A determining module is configured to determine a plurality of path values according to the plurality of code execution paths of user requests by using a preset algorithm, and the path values are used to represent information of the code execution paths; A judging module is configured to judge whether the code execution paths of the plurality of user requests are the same according to the plurality of path values.

8. The apparatus of claim 7, wherein, The judging module is specifically configured to: The path values corresponding to the plurality of user requests are compared; If the path values corresponding to the plurality of user requests are the same, the code execution paths of the plurality of user requests are the same.

9. The apparatus of claim 8, wherein, The determining module is specifically configured to: According to the code execution path of the plurality of user requests, a plurality of path values of the plurality of user requests are calculated by using a Message-Digest Algorithm 5.

10. The apparatus of any one of claims 7 to 9, wherein, The obtaining module is further configured to obtain code coverage information of the plurality of user requests based on a Java probe technology, the code coverage information being used to indicate code execution of the user requests, and the code execution path determining device further comprises: A recording module is configured to record a correspondence between the trace IDs and the code coverage information according to the plurality of trace IDs of the plurality of user requests.

11. The apparatus of claim 10, wherein, The obtaining module is specifically configured to: Obtain the code execution path of the plurality of user requests according to the correspondence between the trace IDs and the code coverage information.

12. The apparatus of any one of claims 7-11, wherein, The device further comprises: A marking module is configured to mark code executed by the user requests in source code according to the code execution path.

13. A computing device, comprising: The computing device comprises a processor and a memory; The processor is configured to execute instructions stored in the memory, so that the computing device performs the method of any one of claims 1 to 6.

14. A cluster of computing devices, characterized in that, The computing device comprises a processor and a memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster performs the operation steps of the method of any one of claims 1 to 6.

15. A computer-readable storage medium, characterized in that, The computer program instructions, when executed by the computing device cluster, cause the computing device cluster to perform the operation steps of the method of any one of claims 1 to 6.

16. A computer program product comprising instructions, characterized in that, The instructions, when executed by the computing device cluster, cause the computing device cluster to perform the operation steps of the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Path alignment-based verification function positioning method

    CN107193732A

  • Test case generation method and device, server and storage medium

    CN111309635A

  • Unauthorized analysis method, device and system and computer readable storage medium

    CN117556419A

  • Request processing method and device and task execution method and device

    CN117632445A

  • Request processing method and apparatus, electronic device, and computer storage medium

    US20210274017A1