Temporal decomposition method, apparatus, device, and storage medium

CN115185838BActive Publication Date: 2026-09-22XIAMEN UNISOC TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210798073.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-06
Publication Date
2026-09-22
Estimated Expiration
2042-07-06

AI Technical Summary

Technical Problem

[0002]程序运行于体系结构设计为多层且不同层编程语言不一致的操作系统会导致问题:无法准确获取特定软件层执行部分程序的执行时间

Benefits of technology

[0063]应当理解的是,本发明实施例的第二~四方面与本发明实施例的第一方面的技术方案一致,各方面及对应的可行实施方式所取得的有益效果相似,不再赘述。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115185838B_ABST
    Figure CN115185838B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a time decomposition method, device, equipment and storage medium, and relate to the technical field of computer; the time consumption of the programs in different software running environments is simply and quickly decomposed to obtain the execution time of different code blocks in the programs running in respective corresponding software running environments. The record data of a current code block in a corresponding running node is obtained, the record data including system time consumption of the current code block in the corresponding running node and a parent running node; each running node of multiple running nodes executing different code blocks belonging to the same program is taken as a child running node to establish a parent-child node relationship with the parent running node in the record data; and the execution time of each running node executing a corresponding code block is obtained according to the parent-child node relationship of each running node executing different code blocks belonging to the same program.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to the field of computer technology, and in particular to a time decomposition method, apparatus, device, and storage medium. [Background Technology]

[0002] Running a program on an operating system with a multi-layered architecture and inconsistent programming languages ​​across different layers can lead to problems: it's impossible to accurately obtain the execution time of specific software layer components. For example, in the Android system, different programming languages ​​(JAVA, C++, C) run between the upper-layer applications and the lowest-level hardware drivers, resulting in different runtime environments for each software layer. Furthermore, even within the same programming language, different runtime environments exist (e.g., even within a C-language software layer, the user-mode and kernel-mode environments differ). Because different code blocks within a program have different runtime environments, there is currently no standard method for decomposing the execution time of calls to programs operating in different runtime environments. [Summary of the Invention]

[0003] This invention provides a time decomposition method, apparatus, device, and storage medium that can quickly and easily decompose the time consumption of programs running in different software environments to obtain the execution time of different code blocks in the program running in their respective corresponding software environments.

[0004] In a first aspect, embodiments of the present invention provide a time decomposition method applied to an electronic device. The method includes: obtaining recorded data of a currently running code block at a corresponding running node, the recorded data including the system time consumed by the current code block from the start to the end of its execution at the corresponding running node and the parent running node of the running node corresponding to the current code block; the parent running node being the running node corresponding to the previous code block that executed the current code block; each running node among multiple running nodes that execute different code blocks of the same program is designated as a child running node, and a parent-child node relationship is established with the parent running node in the recorded data; based on the parent-child node relationship of each running node that executes different code blocks of the same program, the execution time of each running node executing the corresponding code block is obtained; the execution time is the difference between the system time consumed by a single running node and the total system time consumed by all child running nodes of the single running node.

[0005] In this embodiment of the invention, for the current code block in a specific program that is currently running, the system time spent by the current code block at the corresponding running node (e.g., the software layer or software runtime environment), the running node corresponding to the current code block, and the parent running node of the running node corresponding to the current code block are recorded and stored as record data in the application running node of the current code block. After all code blocks of the specific program have finished running, the record data stored in each relevant running node is read, and the parent-child node relationship of each running node is established according to the parent running node recorded in the record data corresponding to each running node. According to the parent-child node relationship, the system time spent by each running node running the code block is decomposed into all its child running nodes, and the remaining undecomposed system time is the actual execution time of the running node running the code block.

[0006] In one possible implementation, each of the multiple execution nodes belonging to different code blocks of the same program is treated as a child execution node, and a parent-child node relationship is established with the parent execution node in the recorded data, including:

[0007] Create a list of corresponding child execution nodes for each execution node that executes different code blocks belonging to the same program;

[0008] Based on the parent running node obtained from the recorded data of the current running node, the target running node that has a parent-child relationship with the current running node is found among multiple running nodes;

[0009] The currently running node is read and added to the list of child running nodes of the target running node.

[0010] In one possible implementation, the execution time of the corresponding code block for each running node is obtained based on the parent-child node relationship of each running node within the same program, including:

[0011] For each running node that executes different code blocks of the same program, a time decomposition list is created to decompose the local system time consumption into the sub-running nodes corresponding to the newly added time.

[0012] When a new running node is added to the list of sub-running nodes of any running node, the system time of the new running node is added to the time decomposition list, and the difference between the system time corresponding to the arbitrary running node and the system time corresponding to the new running node is obtained.

[0013] One possible implementation involves obtaining the record data of the currently running code block at the corresponding execution node, including:

[0014] The system time is retrieved through the system time interface of the running node corresponding to the current code block;

[0015] The identifier of the running node corresponding to the current code block, the system time consumption, and the identifier of the parent running node are recorded in the log system of the running node corresponding to the current code block through the log interface of the running node corresponding to the current code block.

[0016] Each of the multiple execution nodes belonging to different code blocks of the same program is treated as a child execution node, and a parent-child node relationship is established with the parent execution node in the recorded data, including:

[0017] The identifier of the parent running node is obtained by reading each running node in sequence, and a parent-child node relationship is established between the running node corresponding to the log reading system and the running node corresponding to the identifier of the parent running node.

[0018] One possible implementation involves obtaining the record data of the currently running code block at the corresponding execution node, including:

[0019] Obtain the target program information to which the current code block belongs;

[0020] Add the target program information to the record data;

[0021] Each of the multiple execution nodes belonging to different code blocks of the same program is treated as a child execution node, and a parent-child node relationship is established with the parent execution node in the recorded data, including:

[0022] Each running node in the running nodes corresponding to multiple records with the same target program information is taken as a child running node, and a parent-child node relationship is established with the parent running node in the corresponding record data.

[0023] One possible implementation involves obtaining the record data of the currently running code block at the corresponding execution node, including:

[0024] Obtain the name of the functional module implemented by the current code block when it is executed on the corresponding runtime node;

[0025] Add the name of the functional module to the record data;

[0026] After obtaining the execution time of the corresponding code block for each running node, the method further includes:

[0027] Based on the parent-child relationship of different running nodes, the execution time of the corresponding code block for each running node is displayed, as well as the name of the functional module that executes the corresponding code block.

[0028] One possible implementation displays the execution time of the corresponding code block for each running node, along with the name of the functional module executing the corresponding code block, according to the parent-child relationship between different running nodes.

[0029] If there is no parent running node in the record data being read, create a node list using the currently running node in the record data being read as the root directory;

[0030] If a parent running node exists in the record data being read, the current running node in the record data being read is added to the subdirectory of the corresponding parent running node in the node list;

[0031] Generate a tree structure based on the node list supplemented by the subdirectories;

[0032] Based on the position of each running node in the tree structure, the execution time of the corresponding code block executed by each running node is displayed, as well as the name of the functional module that executed the corresponding code block.

[0033] Secondly, embodiments of the present invention provide a time decomposition device, disposed in an electronic device, the device comprising:

[0034] The data acquisition module is used to obtain the recorded data of the current code block in the corresponding running node. The recorded data includes the system time spent by the current code block from the start to the end of its execution in the corresponding running node, as well as the parent running node of the current code block. The parent running node is the running node of the previous code block that executed and called the current code block.

[0035] The relationship establishment module is used to establish a parent-child node relationship between each of the multiple running nodes that execute different code blocks of the same program as a child running node and the parent running node in the recorded data.

[0036] The time acquisition module is used to obtain the execution time of each running node executing the corresponding code block based on the parent-child node relationship of each running node that executes different code blocks of the same program; the execution time is the difference between the system time corresponding to a single running node and the total system time corresponding to all child running nodes of the single running node.

[0037] In one possible implementation, the relationship establishment module includes:

[0038] The first creation submodule is used to sequentially create a list of corresponding sub-running nodes for each running node that executes different code blocks belonging to the same program.

[0039] The search submodule is used to find the target running node that has a parent-child relationship with the current running node among multiple running nodes, based on the parent running node obtained by reading the record data of the current running node;

[0040] The first value addition submodule is used to add the currently running node to the sub-running node list of the target running node.

[0041] In one possible implementation, the time acquisition module includes:

[0042] The second creation submodule is used to sequentially create a time decomposition list for each running node that executes different code blocks of the same program, which is used to decompose the local system time consumption into the sub-running node corresponding to the newly added time.

[0043] The second value addition submodule is used to add the system time of the newly added running node to the time decomposition list when a new running node is added to the list of sub-running nodes of any running node, and to obtain the difference between the system time corresponding to the arbitrary running node and the system time corresponding to the newly added running node.

[0044] In one possible implementation, the data acquisition module includes:

[0045] The retrieval submodule is used to retrieve the system time consumption through the system time interface of the running node corresponding to the current code block;

[0046] The recording submodule is used to record the identifier of the running node corresponding to the current code block, the system time consumption, and the identifier of the parent running node in the log system of the running node corresponding to the current code block through the log interface of the running node corresponding to the current code block;

[0047] The relationship establishment module is specifically used to sequentially read each running node to obtain the identifier of the parent running node, and establish a parent-child node relationship between the running node corresponding to the log reading system and the running node corresponding to the identifier of the parent running node.

[0048] In one possible implementation, the data acquisition module further includes:

[0049] The information acquisition submodule is used to acquire the target program information to which the current code block belongs;

[0050] The third addition submodule is used to add the target program information to the record data;

[0051] The relationship establishment module is specifically used to take each running node in the running nodes corresponding to multiple record data with the same target program information as a child running node, and establish a parent-child node relationship with the parent running node in the corresponding record data.

[0052] In one possible implementation, the data acquisition module further includes:

[0053] The name acquisition submodule is used to obtain the name of the functional module implemented by the current code block when the current code block is executed in the corresponding runtime node;

[0054] The fourth submodule is used to add the name of the functional module to the record data;

[0055] The device also includes a display module, which is used to display the execution time of each running node executing the corresponding code block, as well as the name of the functional module that executes the corresponding code block, according to the parent-child node relationship of different running nodes.

[0056] In one possible implementation, the display module includes:

[0057] The first list creation submodule is used to create a node list with the current running node in the read record data as the root directory when there is no parent running node in the read record data.

[0058] The second list creation submodule is used to add the current running node in the record data being read to the subdirectory of the corresponding parent running node in the node list when there is a parent running node in the record data being read.

[0059] The generation submodule is used to generate a tree structure based on the node list supplemented by the subdirectory;

[0060] The display submodule is used to display the execution time of each running node executing the corresponding code block, as well as the name of the functional module that executes the corresponding code block, according to the position of each running node in the tree structure.

[0061] Thirdly, embodiments of the present invention provide an electronic device, including: at least one processor; and at least one memory communicatively connected to the processor, wherein: the memory stores program instructions executable by the processor, and the processor can execute the method provided in the first aspect by calling the program instructions.

[0062] Fourthly, embodiments of the present invention provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the method provided in the first aspect.

[0063] It should be understood that the second to fourth aspects of the embodiments of the present invention are consistent with the technical solutions of the first aspect of the embodiments of the present invention, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be described again. [Attached Image Description]

[0064] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0065] Figure 1 This is a flowchart of the time decomposition method proposed in the embodiments of the present invention.

[0066] Figure 2 This is a flowchart of the time decomposition method proposed in another embodiment of the present invention;

[0067] Figure 3 This is a schematic diagram illustrating the recording data format written to an arbitrary running node log system using another time decomposition method of the present invention;

[0068] Figure 4 This is a schematic diagram of a tree structure generated by an example of the present invention;

[0069] Figure 5 This is a functional block diagram of the time decomposition device proposed in the embodiments of the present invention;

[0070] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.

Detailed Implementation Methods

[0071] To better understand the technical solutions in this specification, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0072] It should be understood that the described embodiments are merely some, not all, of the embodiments in this specification. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without inventive effort are within the scope of protection of this specification.

[0073] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.

[0074] Taking the AI-Benchmark program running on an Android system as an example, the upper application layer runs the AI-Benchmark program, calling a C++-language software layer to run some code blocks and handle related resource allocation issues. It also calls the user-mode driver layer of the AI ​​computing device to run some code blocks for related calculations. Since the operating environments of different software layers are different, the duration of the upper application layer running the AI-Benchmark program from start to finish is T1. In the above process, the upper application layer calls the C++-language software layer, which in turn calls the user-mode driver layer of the AI ​​computing device. The user-mode driver layer of the AI ​​computing device runs relevant code blocks and then calls the kernel layer of the AI ​​computing device. Because the operating environments of each software layer are different, the time spent executing relevant code blocks locally within the total duration T of the upper application layer running the AI-Benchmark program cannot be accurately obtained.

[0075] In view of the above problems, embodiments of the present invention propose a time decomposition method, which decomposes the system time of a specific software layer into the software layers that execute related code block calls, thereby obtaining the execution time of the specific software layer running the related code blocks locally.

[0076] Figure 1 This is a flowchart of the time decomposition method proposed in the embodiments of the present invention, as follows: Figure 1 As shown, the time decomposition method is applied to electronic devices, which can be terminals, servers, computer clusters, etc. The time decomposition method includes the following steps:

[0077] S101: Obtain the record data of the current code block in the corresponding running node. The record data includes the system time spent by the current code block from the start to the end of its execution in the corresponding running node, and the parent running node of the current code block's corresponding running node. The parent running node is the running node corresponding to the previous code block that executed the call to the current code block.

[0078] A runtime node can be a specific software layer or a specific software runtime environment. The parent runtime node of the runtime node corresponding to the current code block is the runtime node of the specific software layer that calls and runs the current code block.

[0079] Node A runs code block A. Code block A needs to call node B to run code block B in order to execute the computation task. Node A is the parent running node of node B.

[0080] In one example of the present invention, when the upper application layer runs the startup program code block in the AI-Benchmark program, the current code block is the startup program code block, the running node corresponding to the current code block is the upper application layer, the upper application layer calls the running part code block of the software layer programmed in C++ language to handle related resource allocation issues, when the software layer programmed in C++ language runs the code block that handles related resource allocation issues, the current code block is the code block that handles related resource allocation issues, the running node corresponding to the current code block is the software layer programmed in C++ language, and the parent running node of the running node corresponding to the current code block is the upper application layer.

[0081] Recorded data obtained at a specific running node can be stored locally on that specific running node. After the program finishes running, the stored recorded data can be read from each running node, and the system time and parent running node can be extracted from the recorded data. This establishes the parent-child relationship for each running node, and the system time of each running node is decomposed based on the parent-child relationship.

[0082] S102: Each of the multiple running nodes that execute different code blocks of the same program is taken as a child running node, and a parent-child node relationship is established with the parent running node in the recorded data;

[0083] The recorded data of each running node can be read sequentially, and the running nodes that have a parent-child relationship with each running node can be extracted, thereby establishing the parent-child node relationship.

[0084] Continuing with the example above, this involves executing each of the multiple execution nodes belonging to different code blocks of the same program. The execution nodes of the AI-Benchmark program include: the upper application layer, the C++ software layer, the AI ​​computing device user-mode driver layer, and the AI ​​computing device kernel layer. The recorded data of the upper application layer, the C++ software layer, the AI ​​computing device user-mode driver layer, and the AI ​​computing device kernel layer are read sequentially. The recorded data of the C++ software layer is then read, and it is determined that the parent execution node of the C++ software layer is the upper application layer. A parent-child node relationship is then established between the upper application layer and the C++ software layer.

[0085] It can be understood that among multiple execution nodes belonging to different code blocks of the same program, there exists a specific execution node, which can have multiple sub-execution nodes; among multiple execution nodes belonging to different code blocks of the same program, there also exists a specific execution node, which has only one sub-execution node.

[0086] One embodiment of the present invention proposes a method for establishing parent-child node relationships:

[0087] Create a list of corresponding child execution nodes for each execution node that executes different code blocks belonging to the same program;

[0088] Based on the parent running node obtained from the recorded data of the current running node, the target running node that has a parent-child relationship with the current running node is found among multiple running nodes;

[0089] Record the parent running node in advance to quickly locate the target running node that can establish a parent-child relationship during the process of reading the recorded data.

[0090] The currently running node is read and added to the list of child running nodes of the target running node.

[0091] In this embodiment of the invention, by establishing a list of child running nodes, whenever a specific running node is read to appear in the record data of any other running node, any other running node that appears in the specific running node is added to the list of child running nodes of the specific running node. By adding to the list, the parent-child node relationship between multiple running nodes can be quickly established.

[0092] This invention proposes a method to obtain the recorded data of the current code block in the corresponding running node: by printing logs during the execution of the code block.

[0093] The system time is retrieved through the system time interface of the running node corresponding to the current code block;

[0094] It can read the system time difference between before the execution of the current code block to be monitored on the running node and after the execution of the current code block to be monitored on the running node, and obtain the system time.

[0095] In response to user commands, obtain the identifier of the currently running node and the identifier of the parent running node of the currently running node.

[0096] The identifier of the currently running node and the identifier of its parent running node can be in string format.

[0097] The identifier of the running node corresponding to the current code block, the system time consumption, and the identifier of the parent running node are recorded in the log system of the running node corresponding to the current code block through the log interface of the running node corresponding to the current code block.

[0098] Continuing with the example above, the user-mode driver layer of the AI ​​computing device runs a certain code block and performs related calculations. Through the log interface of the user-mode driver layer of the AI ​​computing device, the identifier of the user-mode driver layer of the computing device, the identifier of the upper layer of the parent running node, and the system time consumed from the start of the running of the certain code block of the AI ​​computing device user-mode driver layer to the end of the running are written to the log system.

[0099] This invention, through a simple logging method, writes the system time difference before and after the execution of code blocks that require execution time monitoring to their respective log systems during the execution of code blocks that require execution time monitoring at the software layer. It also writes the parent-child node relationship of the running node that calls the code block that requires execution time monitoring to its respective log system. Thus, the parent-child node relationship of each running node can be established by reading the log system.

[0100] One example of the present invention illustrates that, by reading the log system, each of the multiple running nodes that execute different code blocks of the same program can be treated as a child running node, and a parent-child node relationship can be established with the parent running node in the recorded data. Specifically, each running node is read sequentially to obtain the identifier of the parent running node, and a parent-child node relationship is established between the running node corresponding to the log system and the running node corresponding to the identifier of the parent running node.

[0101] Continuing with the example above, the user-mode driver layer of the AI ​​computing device executes a code block that calls the `log` interface to write its parent running node's C++-language software layer to the log system, and also writes the system execution time T2 to the log system. After the AI-Benchmark program finishes running, it reads the log systems of each running node to obtain recorded data. Taking the reading of the C++-language software layer and the AI ​​computing device's user-mode driver layer log systems as an example, a dictionary is created using the C++-language software layer as the key. The dictionary data includes a field: a list of child running nodes. When the log system of the AI ​​computing device's user-mode driver layer is read, the record showing that the parent running node of the AI ​​computing device's user-mode driver layer is a C++-language software layer is extracted, and the AI ​​computing device's user-mode driver layer is added to the list of child running nodes in the dictionary data created using the C++-language software layer as the key. When reading the log system of other running nodes whose parent running node is a C++-language software layer, the other nodes are similarly added to the list of child running nodes in the dictionary data created using the C++-language software layer as the key. This establishes the parent-child relationship between the C++-language software layer and all its child running nodes.

[0102] S103: Based on the parent-child node relationship of each running node that executes different code blocks of the same program, obtain the execution time of each running node executing the corresponding code block; the execution time is the difference between the system time corresponding to a single running node and the total system time corresponding to all child running nodes of the single running node.

[0103] The execution time of a running node executing a corresponding code block can be considered as the time during which the running node performs related calculations locally while executing the code block. It can be understood that the system time spent by code block A from the start to the end of its execution on node A includes the execution time of related calculations performed on node A using local computing resources, as well as the waiting time of node A when it calls other nodes to perform calculations on those nodes.

[0104] A single running node may have multiple child running nodes, or it may have only one child running node.

[0105] For any running node, calculate the local system time and subtract the system time of all its child running nodes to obtain the execution time of that running node.

[0106] In this embodiment of the invention, during the sequential execution of code blocks in a program, for each currently running code block, the system time consumed by the current code block from the start to the end of its execution on the running node is recorded through log entries. The execution node of the previous code block that called the current execution node is also recorded, along with the time decomposition relationship between the system time of the current execution node and the system time of its parent execution node. After all code blocks in the program have finished executing, the parent-child node relationships representing the time decomposition relationship are extracted by reading the logs, completing the system time decomposition and obtaining the actual execution time of the code block running locally on the running node.

[0107] This invention proposes a method for obtaining execution time based on parent-child node relationships:

[0108] For each running node that executes different code blocks of the same program, a time decomposition list is created to decompose the local system time consumption into the sub-running nodes corresponding to the newly added time.

[0109] When a new running node is added to the list of sub-running nodes of any running node, the system time of the new running node is added to the time decomposition list, and the difference between the system time corresponding to the arbitrary running node and the system time corresponding to the new running node is obtained.

[0110] During the process of reading the recorded data of each running node, a time breakdown list and a child running node list are established. When the recorded data of node A is read, a time breakdown list and a child running node list for node A are established, and node A is added to the child running node list of its parent node. When the recorded data of node B is read, a time breakdown list and a child running node list for node B are established. Since node A is the parent running node of node B, node B is added to the child running node list of node A, and the system time of node B is automatically subtracted from the time breakdown list of node A.

[0111] Another embodiment of the present invention proposes another time decomposition method, which records the current running node of the running code block, the parent running node of the current running node, the system time spent running the code block of the current running node, the target program information of the program to which the running code block belongs, and the display name of the code block executed by the current running node during program execution.

[0112] Figure 2 This is a flowchart of the time decomposition method proposed in another embodiment of the present invention, as follows: Figure 2 As shown, the steps include:

[0113] S201: Obtain the record data of the current code block in the corresponding running node. The record data includes the system time consumed from the start to the end of the current code block in the corresponding running node and the parent running node of the current code block; the parent running node is the running node corresponding to the previous code block that executed the call to the current code block.

[0114] S202: Obtain the target program information to which the current code block belongs.

[0115] The target program can be a single task of an application (software).

[0116] S203: Add the target program information to the record data.

[0117] S204: Obtain the name of the functional module implemented by the current code block when it is executed on the corresponding runtime node.

[0118] For example, if the kernel layer of an AI computing device executes a corresponding code block to classify a target object, then the name of the functional module implemented by the corresponding code block could be the classification task. After obtaining the execution time of the AI ​​computing device's kernel layer, the execution time of the classification task can be displayed.

[0119] S205: Add the name of the functional module to the record data.

[0120] Figure 3This is a schematic diagram illustrating the data format for writing records into an arbitrary running node log system using another time decomposition method of the present invention, as shown below. Figure 3 As shown, the recorded data includes: target program information, the string corresponding to the current running node, the string corresponding to the parent running node, the name of the functional module, and the system time.

[0121] S206: Take each of the running nodes corresponding to the running nodes of multiple record data with the same target program information as a child running node, and establish a parent-child node relationship with the parent running node in the corresponding record data.

[0122] Multiple records with the same target program information have code block calling relationships between their respective running nodes.

[0123] Continuing with the example above, the upper application layer runs the AI-Benchmark program, which calls a C++-language software layer to execute a code block. This C++ software layer then calls the AI ​​computing device's user-mode driver layer, which in turn executes a relevant code block and subsequently calls the AI ​​computing device's kernel layer. The upper application layer, the C++ software layer, the AI ​​computing device's user-mode driver layer, and the AI ​​computing device's kernel layer are each of multiple execution nodes belonging to different code blocks of the same program. The code blocks executed by each of these layers are multiple code blocks with the same target program information. The log systems of each of these layers store multiple records with the same target program information.

[0124] S207: Based on the parent-child node relationship of each running node that executes different code blocks of the same program, obtain the execution time of the corresponding code block executed by each running node.

[0125] S208: Display the execution time of the corresponding code block for each running node, as well as the name of the functional module that executes the corresponding code block, according to the parent-child node relationship of different running nodes.

[0126] This invention also proposes one implementation method for step S208:

[0127] S2081: When there is no parent running node in the record data being read, create a node list using the currently running node in the record data being read as the root directory.

[0128] The target program information can be used as a key to create the first dictionary data, with the value being each running node. When the record data being read does not have a parent running node, the current running node in the read record data is node 1, and a node list is created with node 1 as the root directory, which is used as the first value of the first dictionary data.

[0129] Create a second dictionary with node1 as the root directory and node1 as the key. The second dictionary includes the corresponding string of node1, the name of the functional module displayed when node1 executes the corresponding code block, the list of child running nodes of node1, the time decomposition list of node1, and the system time spent by node1 in running the corresponding code block.

[0130] When creating the list of child running nodes, the list of child running nodes is empty.

[0131] When creating a time breakdown list, the time breakdown list is equal to the system time consumed.

[0132] S2081: When there is a parent running node in the record data being read, add the current running node in the record data being read to the subdirectory of the corresponding parent running node in the node list.

[0133] After reading the record data of node 1 and completing the dictionary data creation of node 1, continue to read the dictionary data of node 2; using node 2 as the root directory as the key, create a third dictionary data, which includes the corresponding string of node 2, the corresponding string of node 1 as the parent running node of node 2, the name of the functional module displayed when node 2 executes the corresponding code block, the list of child running nodes of node 2, the time decomposition list of node 2, and the system time spent by node 1 in running the corresponding code block.

[0134] Add the corresponding string for node 2 to the child node list of node 1. The time breakdown list of node 1 will automatically decompose the system time of node 2 to node 2. The time in the time breakdown list of node 1 at this time is the system time of node 1 minus the system time of node 2. Complete the supplementation of the subdirectories of node 1.

[0135] Complete the above operation steps for node 2 after reading the record data of each running node. Add subdirectories for each node.

[0136] S2083: Generate a tree structure based on the node list supplemented by the subdirectories.

[0137] After reading the record data of all running nodes, the subdirectories corresponding to each node are supplemented. Assuming that node n executes the corresponding code block without any other nodes, then node n's list of child running nodes is empty, and the time decomposition list of the child running nodes is the same as node n's system time.

[0138] The data recorded by each running node can be read and a structure tree can be created using a script, such as a Python script.

[0139] Figure 4 This is a schematic diagram of a tree structure generated by an example of the present invention. Figure 4 This invention provides an example of an execution time tree structure generated after completing time decomposition and obtaining the execution time of the corresponding code block for each running node and the name of the functional module that executes the corresponding code block, according to the parent-child relationship of different running nodes.

[0140] like Figure 4 The target program shown is a target tracing program. The overall execution time of the target program is decomposed into the execution time of each code block in the execution node, and the execution time of each execution node is obtained for the local execution of related calculations.

[0141] S2084: Based on the position of each running node in the tree structure, display the execution time of the corresponding code block executed by each running node, as well as the name of the functional module that executed the corresponding code block.

[0142] This invention employs a simple log printing method, where each running node adds its own log to print the local system time consumption. Then, by parsing the logs of each running node and adding them to a list of values, the system time consumption of a specific running node is automatically decomposed into its child running nodes to obtain the execution time of that specific running node. Based on the data structure used to decompose the system time consumption, an execution time tree structure is generated and displayed to visually demonstrate the execution time of the relevant code executed by each running node and the functions implemented by the relevant code.

[0143] Figure 5 This is a functional block diagram of the time decomposition device proposed in an embodiment of the present invention. The time decomposition device is installed in an electronic device, such as... Figure 5 As shown, the device includes:

[0144] The data acquisition module 51 is used to obtain the recorded data of the current code block in the corresponding running node. The recorded data includes the system time spent by the current code block from the start to the end of its execution in the corresponding running node and the parent running node of the current code block; the parent running node is the running node corresponding to the previous code block that executed and called the current code block.

[0145] The relationship establishment module 52 is used to establish a parent-child node relationship between each of the multiple running nodes that execute different code blocks of the same program as a child running node and the parent running node in the recorded data.

[0146] The time acquisition module 53 is used to obtain the execution time of each running node executing the corresponding code block according to the parent-child node relationship of each running node that executes different code blocks of the same program; the execution time is the difference between the system time corresponding to a single running node and the total system time corresponding to all child running nodes of the single running node.

[0147] Figure 5 The time decomposition apparatus provided in the illustrated embodiment can be used to execute this specification. Figures 1 to 4 The implementation principle and technical effects of the method embodiment shown can be further referred to the relevant description in the method embodiment.

[0148] Optionally, the relationship establishment module includes:

[0149] The first creation submodule is used to sequentially create a list of corresponding sub-running nodes for each running node that executes different code blocks belonging to the same program.

[0150] The search submodule is used to find the target running node that has a parent-child relationship with the current running node among multiple running nodes, based on the parent running node obtained by reading the record data of the current running node;

[0151] The first value addition submodule is used to add the currently running node to the sub-running node list of the target running node.

[0152] Optionally, the time acquisition module includes:

[0153] The second creation submodule is used to sequentially create a time decomposition list for each running node that executes different code blocks of the same program, which is used to decompose the local system time consumption into the sub-running node corresponding to the newly added time.

[0154] The second value addition submodule is used to add the system time of the newly added running node to the time decomposition list when a new running node is added to the list of sub-running nodes of any running node, and to obtain the difference between the system time corresponding to the arbitrary running node and the system time corresponding to the newly added running node.

[0155] Optionally, the data acquisition module includes:

[0156] The retrieval submodule is used to retrieve the system time consumption through the system time interface of the running node corresponding to the current code block;

[0157] The recording submodule is used to record the identifier of the running node corresponding to the current code block, the system time consumption, and the identifier of the parent running node in the log system of the running node corresponding to the current code block through the log interface of the running node corresponding to the current code block;

[0158] The relationship establishment module is specifically used to sequentially read each running node to obtain the identifier of the parent running node, and establish a parent-child node relationship between the running node corresponding to the log reading system and the running node corresponding to the identifier of the parent running node.

[0159] Optionally, the data acquisition module includes:

[0160] The information acquisition submodule is used to acquire the target program information to which the current code block belongs;

[0161] The third addition submodule is used to add the target program information to the record data. The relationship establishment module is specifically used to take each running node in the running nodes corresponding to multiple record data with the same target program information as a child running node and establish a parent-child node relationship with the parent running node in the corresponding record data.

[0162] Optionally, the data acquisition module includes:

[0163] The name acquisition submodule is used to obtain the name of the functional module implemented by the current code block when the current code block is executed in the corresponding runtime node;

[0164] The fourth submodule is used to add the name of the functional module to the record data;

[0165] The device also includes a display module, which is used to display the execution time of each running node executing the corresponding code block, as well as the name of the functional module that executes the corresponding code block, according to the parent-child node relationship of different running nodes.

[0166] Optionally, the display module includes:

[0167] The first list creation submodule is used to create a node list with the current running node in the read record data as the root directory when there is no parent running node in the read record data.

[0168] The second list creation submodule is used to add the current running node in the record data being read to the subdirectory of the corresponding parent running node in the node list when there is a parent running node in the record data being read.

[0169] The generation submodule is used to generate a tree structure based on the node list supplemented by the subdirectory;

[0170] The display submodule is used to display the execution time of each running node executing the corresponding code block, as well as the name of the functional module that executes the corresponding code block, according to the position of each running node in the tree structure.

[0171] The apparatus provided in the above embodiments is used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effects can be further referred to the relevant descriptions in the method embodiments, and will not be repeated here.

[0172] The apparatus provided in the above embodiments may be, for example, a chip or a chip module. The apparatus provided in the above embodiments is used to execute the technical solutions of the above-described method embodiments. Its implementation principles and technical effects can be further referred to the relevant descriptions in the method embodiments, and will not be repeated here.

[0173] Regarding the modules / units included in the various devices described in the above embodiments, they can be software modules / units, hardware modules / units, or a combination of both. For example, for devices applied to or integrated into a chip, all modules / units can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs running on a processor integrated within the chip, while the remaining modules / units can be implemented using hardware methods such as circuits. For devices applied to or integrated into a chip module, all modules / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented using software programs. The software program runs on the processor integrated inside the chip module, and the remaining modules / units can be implemented using hardware methods such as circuits. For each device applied to or integrated into an electronic terminal device, each of its modules / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components within the electronic terminal device. Alternatively, at least some modules / units can be implemented using software programs that run on the processor integrated inside the electronic terminal device, and the remaining (if any) modules / units can be implemented using hardware methods such as circuits.

[0174] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 600 includes a processor 610, a memory 611, and a computer program stored in the memory 611 and executable on the processor 610. When the processor 610 executes the program, it implements the steps in the aforementioned method embodiment. The electronic device provided in this embodiment can be used to execute the technical solution of the method embodiment shown above. Its implementation principle and technical effect can be further referred to the relevant description in the method embodiment, which will not be repeated here.

[0175] This invention provides a non-transitory computer-readable storage medium that stores computer instructions that cause the computer to execute the contents of this specification. Figures 1-4 The illustrated embodiment provides a time decomposition method. A non-transitory computer-readable storage medium can refer to a non-volatile computer storage medium.

[0176] The aforementioned non-transitory computer-readable storage medium may be any combination of one or more computer-readable media. A computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium that contains or stores a program that may be used by or in connection with an instruction execution system, apparatus, or device.

[0177] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0178] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, radio frequency (RF), etc., or any suitable combination thereof.

[0179] Computer program code for performing the operations described herein can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as "C" or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0180] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0181] In the description of the embodiments of the present invention, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0182] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this specification, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0183] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this specification includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which the embodiments of this specification pertain.

[0184] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0185] In the several embodiments provided in this specification, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0186] Furthermore, the functional units in the various embodiments of this specification can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.

[0187] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this specification. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0188] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.

Claims

1. A time decomposition method, characterized in that, The method includes: Obtain the recording data of the current code block in the corresponding running node. The recording data is obtained through the log system of the running node corresponding to the current code block. The recording data includes the system time spent by the current code block from the start to the end of its execution in the corresponding running node, as well as the parent running node of the running node corresponding to the current code block. The parent running node is the running node corresponding to the previous code block that executed and called the current code block. Each of the multiple running nodes that execute different code blocks of the same program is treated as a child running node, and a parent-child node relationship is established with the parent running node in the recorded data, wherein the multiple running nodes correspond to different software layers; Based on the parent-child node relationship of each running node that executes different code blocks of the same program, the execution time of each running node executing the corresponding code block is obtained; the execution time is the difference between the system time corresponding to a single running node and the total system time corresponding to all child running nodes of the single running node; Obtain the record data of the currently running code block at the corresponding execution node, including: The system time is retrieved through the system time interface of the running node corresponding to the current code block; The identifier of the running node corresponding to the current code block, the system time consumption, and the identifier of the parent running node are recorded in the log system of the running node corresponding to the current code block through the log interface of the running node corresponding to the current code block. Each of the multiple execution nodes belonging to different code blocks of the same program is treated as a child execution node, and a parent-child node relationship is established with the parent execution node in the recorded data, including: The identifier of the parent running node is obtained by reading each running node in sequence, and a parent-child node relationship is established between the running node corresponding to the log reading system and the running node corresponding to the identifier of the parent running node.

2. The method according to claim 1, characterized in that, Each of the multiple execution nodes belonging to different code blocks of the same program is treated as a child execution node, and a parent-child node relationship is established with the parent execution node in the recorded data, including: Create a list of corresponding child execution nodes for each execution node that executes different code blocks belonging to the same program; Based on the parent running node obtained from the recorded data of the current running node, the target running node that has a parent-child relationship with the current running node is found among multiple running nodes; The currently running node is read and added to the list of child running nodes of the target running node.

3. The method according to claim 2, characterized in that, Based on the parent-child node relationship of each running node in the same program, the execution time of the corresponding code block for each running node is obtained, including: For each running node that executes different code blocks of the same program, a time decomposition list is created to decompose the local system time into the sub-running nodes corresponding to the newly added time. When a new running node is added to the list of sub-running nodes of any running node, the system time of the new running node is added to the time decomposition list, and the difference between the system time corresponding to the arbitrary running node and the system time corresponding to the new running node is obtained.

4. The method according to claim 1, characterized in that, Obtain the record data of the currently running code block at the corresponding execution node, including: Obtain the target program information to which the current code block belongs; Add the target program information to the record data; Each of the multiple execution nodes belonging to different code blocks of the same program is treated as a child execution node, and a parent-child node relationship is established with the parent execution node in the recorded data, including: Each running node in the running nodes corresponding to multiple records with the same target program information is taken as a child running node, and a parent-child node relationship is established with the parent running node in the corresponding record data.

5. The method according to claim 1, characterized in that, Obtain the record data of the currently running code block at the corresponding execution node, including: Obtain the name of the functional module implemented by the current code block when it is executed on the corresponding runtime node; Add the name of the functional module to the record data; After obtaining the execution time of the corresponding code block for each running node, the method further includes: Based on the parent-child relationship of different running nodes, the execution time of the corresponding code block for each running node is displayed, as well as the name of the functional module that executes the corresponding code block.

6. The method according to claim 5, characterized in that, Based on the parent-child relationship of different running nodes, the execution time of the corresponding code block for each running node is displayed, along with the name of the functional module that executed the corresponding code block, including: If there is no parent running node in the record data being read, create a node list using the currently running node in the record data being read as the root directory; If a parent running node exists in the record data being read, the current running node in the record data being read is added to the subdirectory of the corresponding parent running node in the node list; Generate a tree structure based on the node list supplemented by the subdirectories; Based on the position of each running node in the tree structure, the execution time of the corresponding code block executed by each running node is displayed, as well as the name of the functional module that executed the corresponding code block.

7. A time-decomposition device, characterized in that, The device includes: The data acquisition module is used to obtain the recorded data of the current code block in the corresponding running node. The recorded data is obtained by the log system of the running node corresponding to the current code block. The recorded data includes the system time spent by the current code block from the start to the end of its execution in the corresponding running node and the parent running node of the running node corresponding to the current code block. The parent running node is the running node corresponding to the previous code block that executed and called the current code block. The relationship establishment module is used to establish a parent-child node relationship between each of the multiple running nodes that execute different code blocks of the same program as a child running node and the parent running node in the recorded data, wherein the multiple running nodes correspond to different software layers; The time acquisition module is used to obtain the execution time of each running node executing the corresponding code block based on the parent-child node relationship of each running node that executes different code blocks of the same program; the execution time is the difference between the system time corresponding to a single running node and the total system time corresponding to all child running nodes of the single running node; The data acquisition module is specifically used for: The system time is retrieved through the system time interface of the running node corresponding to the current code block; The identifier of the running node corresponding to the current code block, the system time consumption, and the identifier of the parent running node are recorded in the log system of the running node corresponding to the current code block through the log interface of the running node corresponding to the current code block. The relationship establishment module is specifically used for: The identifier of the parent running node is obtained by reading each running node in sequence, and a parent-child node relationship is established between the running node corresponding to the log reading system and the running node corresponding to the identifier of the parent running node.

8. An electronic device, comprising: At least one processor; as well as At least one memory communicatively connected to the processor, characterized in that, The memory stores program instructions that can be executed by the processor, and the processor can execute the method as described in any one of claims 1 to 6 by calling the program instructions.

9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions cause the computer to perform the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dynamic calculation of sample profile reports

    CN102385552A

  • Data processing method and device and related product

    CN111767249A

  • Time consumption data determination method and device

    CN114637658A