Performance bottleneck positioning method, positioning device, electronic equipment and storage medium

By obtaining and analyzing the register information of the target process and the call stack of the virtual machine, the problem of the existing technology being unable to locate the code-level performance bottleneck of scripting languages ​​is solved, and the performance bottleneck positioning of multiple languages ​​is achieved, which simplifies the process and improves efficiency. .

CN111382044BActive Publication Date: 2024-11-08SHENZHEN TENCENT INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010131858.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-02-29
Publication Date
2024-11-08
Estimated Expiration
2040-02-29

AI Technical Summary

Technical Problem

Existing tools cannot effectively locate performance bottlenecks at the script language code level, resulting in only being able to locate the C/C++ function level in mixed use scenarios of multiple languages, which is costly, time-consuming and error-prone.

Method used

By obtaining the register information of the target process, converting it to the source code name, and combining the virtual machine's call stack analysis, the state machine information of the virtual machine is obtained to locate the source code information of the main function and subfunction of the virtual machine, thereby realizing the Performance bottleneck positioning.

Benefits of technology

It realizes the performance bottleneck that simultaneously locates the C/C++ function level and the script language code level in a mixed use scenario of multiple languages, simplifies the process, reduces costs, and improves accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111382044B_ABST
    Figure CN111382044B_ABST
Patent Text Reader

Abstract

The present application provides a performance bottleneck positioning method, positioning device, electronic device and storage medium. By acquiring register information of a target process to be tested, the source code name of a process within the target process is obtained, and the name is displayed together with the time consumption ratio of the process, so as to obtain a performance bottleneck analysis and positioning at the C / C++ function level; by further analyzing the call stack of the virtual machine, the state machine information of the virtual machine is obtained, and then the source code information of the sub-function corresponding to the main function of the virtual machine is obtained, so as to obtain a performance bottleneck positioning analysis at the script language code level; a performance bottleneck solution is implemented for simultaneously locating the C / C++ function level and the script language code level in a scenario where multiple languages ​​are mixed, and the solution is run by a computer, which is simple, fast, highly accurate and low-cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a method for locating a performance bottleneck, a positioning device, an electronic device and a storage medium. Background Art

[0002] In game development, a combination of multiple languages ​​is usually used for comprehensive consideration of operating performance and development efficiency. For example, some game engines use C++ to implement the underlying framework, while the upper-level business logic uses various flexible scripting languages. By combining various languages, a perfect balance between software operating performance and development efficiency can be achieved.

[0003] In actual development, it is easy to cause performance bottlenecks in the code due to some special business requirements or code defects. However, existing tools can only locate performance bottlenecks at the C / C++ function level, and there is no way to locate performance bottlenecks at the script language code level. To locate performance bottlenecks at the code level, the general approach is to continuously narrow the code scope and eventually locate the bottleneck. This solution is costly and requires technicians to spend a lot of time to check one by one, which is labor-intensive and prone to errors. Summary of the invention

[0004] The present application provides a performance bottleneck positioning method, positioning device, electronic device and storage medium to achieve the positioning of performance bottlenecks in a scenario where multiple languages ​​are mixed.

[0005] To achieve the above objectives, the technical solutions provided by this application are as follows:

[0006] The present application provides a method for locating a performance bottleneck, which includes:

[0007] Acquire register information of a target process to be tested, and obtain a source code name of a process in the target process, wherein the target process includes multiple processes, at least two of which have different function languages, and the register information includes parameters for determining the source code name corresponding to the process;

[0008] Display the source code name and time consumption ratio of the process, determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name;

[0009] When the analysis instruction is detected, matching the target source code name with the main function name of the virtual machine is performed;

[0010] When the source code name matches the main function name of the virtual machine, analyzing the call stack of the virtual machine to obtain state machine information of the virtual machine;

[0011] According to the state machine information of the virtual machine, obtaining source code information of the sub-function corresponding to the main function of the virtual machine;

[0012] Display the source code information and time consumption ratio of the sub-function, and determine the sub-function information corresponding to the performance bottleneck.

[0013] A device for locating a performance bottleneck, comprising:

[0014] A first acquisition module is used to acquire register information of a target process to be tested, and obtain a source code name of a process in the target process, wherein the target process includes multiple processes, and at least two of the processes have different function languages, and the register information includes a parameter for determining the source code name corresponding to the process;

[0015] A first display module is used to display the source code name and time consumption ratio of the process, and is also used to determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name;

[0016] A detection module, used for detecting and analyzing instructions;

[0017] A matching module, used for matching the target source code name with the main function name of the virtual machine;

[0018] A second acquisition module is used to analyze the call stack of the virtual machine and obtain the state machine information of the virtual machine;

[0019] A third acquisition module is used to obtain source code information of a sub-function corresponding to the main function of the virtual machine;

[0020] The second display module is used to display the source code information of the sub-function and the time consumption ratio of the sub-function, and is also used to determine the sub-function information corresponding to the performance bottleneck.

[0021] An electronic device comprising:

[0022] Memory, used to store programs;

[0023] The processor is used to execute the program to implement each step of the method for locating the performance bottleneck.

[0024] A storage medium stores a computer program, wherein the computer program enables a computer to execute each step of the above-mentioned method for locating a performance bottleneck.

[0025] The embodiments of the present application provide a method for locating a performance bottleneck, a positioning device, an electronic device, and a computer-readable storage medium. The method obtains register information of a target process to be tested, obtains the source code name of a process within the target process, and displays it together with the time consumption ratio of the process to obtain a performance bottleneck analysis and positioning at the C / C++ function level. The method further analyzes the call stack of the virtual machine to obtain the state machine information of the virtual machine, and then obtains the source code information of the sub-function corresponding to the main function of the virtual machine to obtain a performance bottleneck positioning analysis at the script language code level. The method implements a performance bottleneck solution that simultaneously locates the C / C++ function level and the script language code level in a scenario where multiple languages ​​are mixed, and the solution is run by a computer, which is simple, fast, highly accurate, and low-cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The technical solution and other beneficial effects of the present application will be made apparent by describing in detail the specific implementation methods of the present application in conjunction with the accompanying drawings.

[0027] Figure 1 A schematic diagram of a scenario of a system for locating a performance bottleneck provided in an embodiment of the present application.

[0028] Figure 2 A first flow chart of a method for locating a performance bottleneck provided in an embodiment of the present application.

[0029] Figure 3 A second flow chart of the method for locating a performance bottleneck provided in an embodiment of the present application.

[0030] Figure 4 A third flow chart of the method for locating a performance bottleneck provided in an embodiment of the present application.

[0031] Figure 5 A fourth flow chart of the method for locating a performance bottleneck provided in an embodiment of the present application.

[0032] Figure 6 This is the first page of the method for locating a performance bottleneck provided in an embodiment of the present application.

[0033] Figure 7 A memory layout diagram of a stack frame under the x86-64 architecture provided in an embodiment of the present application.

[0034] Figure 8 A relationship diagram between registers and parameters provided for an embodiment of the present application.

[0035] Fig. 9 A mapping relationship diagram of a method for locating a performance bottleneck provided in an embodiment of the present application.

[0036] Fig.10 This is the second page of the method for locating a performance bottleneck provided in an embodiment of the present application.

[0037] Fig.11 A structural block diagram of a device for locating a performance bottleneck provided in an embodiment of the present application.

[0038] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0039] The following will be combined with the specific implementation scheme of the present application to clearly and completely describe the technical solutions in the implementation scheme and / or examples of the present application. Obviously, the implementation scheme and / or examples described below are only part of the implementation scheme and / or examples of the present application, rather than all the implementation schemes and / or examples. Based on the implementation scheme and / or examples in the present application, all other implementation schemes and / or examples obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0040] The terms "first", "second", etc. mentioned in this application are used for descriptive purposes only and should not be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features.

[0041] In order to solve the problem that performance bottlenecks can only be located at the C / C++ function level but not at the script language code level in scenarios where multiple languages ​​are used together, the present application provides a performance bottleneck location method that can locate both the C / C++ function level and the script language code level, thereby providing a feasible solution for performance bottleneck location in scenarios where multiple languages ​​are used together.

[0042] In order to facilitate the understanding of this application, some concepts involved in this application are first explained:

[0043] Performance bottleneck: the block of code that takes the most time to execute, the performance defect of the software.

[0044] Process: A program with certain independent functions that runs an activity on a certain data set, that is, a running application. It is the basic unit for resource allocation and scheduling in the system and the basis of the operating system structure. Each independent process has an entry point for program execution, a sequential execution sequence, and an exit point for the program, which is the main function in the program. Each process has its own address space, which generally includes a text region, a data region, and a stack region. The text region stores the code executed by the processor; the data region stores variables and dynamically allocated memory used during process execution; the stack region stores instructions and local variables called by the active process.

[0045] C / C++: A statically compiled programming language with high performance and the ability to operate at the bottom layer. It integrates the functions of high-level and low-level languages ​​and realizes programming operations on hardware. It can be used for system software development and is also suitable for application software development.

[0046] Scripting language: also known as extended language or dynamic language, is a computer programming language created to shorten the traditional writing-compiling-linking-running process. It is used to control software applications. Scripts are usually saved in text and are only interpreted or compiled when called.

[0047] LUA: A dynamic interpreted programming language with advantages such as flexible use and small code size. The language is designed to be embedded in applications, providing flexible expansion and customization capabilities for applications. Lua scripts can be easily called by C / C++ code, and can also call C / C++ functions in turn, which makes Lua widely used in applications. Not only as an extension script, but also as a common configuration file, and it is easier to understand and maintain.

[0048] Virtual Machine: An interpreter that interprets and executes scripting languages.

[0049] Source code: refers to a series of human-readable computer language instructions. Source code is relative to target code and executable code. Source code refers to the code written in assembly language and high-level language. Target code refers to the binary code that can be directly recognized by the CPU after the source code is compiled. Executable code is the binary executable file formed by connecting the target code.

[0050] ptrace: A system call on Linux / Unix that can be used to debug and inspect processes and read and write the memory of a specified process. Ptrace provides a way for a parent process to observe and control other processes. It can also change registers and kernel images in child processes, thus enabling breakpoint debugging and system call inspection.

[0051] libunwind: A third-party library that can expand the current stack frame of the mounted process and obtain the register information of the current process. The libunwind library provides basic stack unwinding functions for programs based on 64-bit CPUs and operating systems, including interfaces for outputting stack inspections, interfaces for unwinding the stack programmatically, and interfaces that support C++ exception handling mechanisms. The libunwind library is not suitable for 32-bit operating systems.

[0052] unwind: A third-party library used to obtain the call stack of the program.

[0053] Register: A device that stores data in the CPU (central processing unit). It is a high-speed storage component with limited storage capacity. It can be used to temporarily store instructions, data and addresses. In the X86 system assembly, registers can be divided into general registers, index registers, instruction pointer registers, flag registers and segment registers.

[0054] General registers are used to transfer and temporarily store data. They can also participate in arithmetic and logical operations and save the results of operations. They include: rdi (destination index Register), which is used in conjunction with the res segment register to access any storage unit in the additional segment and is the first parameter when calling a function; rsi (source index Register), which is used in conjunction with the rds segment register to access any storage unit in the data segment and is the second parameter when calling a function; rdx (I / O pointer), which provides the port address of the external device interface during I / O operations and is the third parameter when calling a function; rcx (count Register), which is the count control for loop operations and string processing and is the fourth parameter when calling a function; r8, which is the fifth parameter when calling a function; r9, which is the sixth parameter when calling a function.

[0055] The index register is mainly used to store the offset of the storage unit within the segment, realize the addressing mode of various memory operands, and provide convenience for accessing storage units in different address forms, including: rsi (Source Index Register), which is used to store the source index pointer relative to the rds segment; rdi (Destination Index Register), which is used to store the destination index pointer for the res segment.

[0056] The instruction pointer register is mainly used to store the offset of the storage unit in the stack, including: rsp (Stack Pointer Register), which provides the offset address of the top unit of the stack, and is used in conjunction with the rss segment register to control the data in and out of the stack; rbp (Base Pointer Register), which is used to provide the offset address of a unit in the stack, and is used in conjunction with the rss segment register to access any storage unit in the stack and is saved by the caller; rip (Instruction Pointer Register), which points to the offset within the segment of the instruction address, is used to control the execution order of instructions in the program. Under normal circumstances, rip is automatically increased by 1 each time an instruction code is accessed from the memory, thereby ensuring the sequential execution of instructions. Rip is actually the address pointer of the memory unit where the instruction machine code is stored.

[0057] The flag register is used to store control flags and condition code flags that reflect the status of the processor and process execution results.

[0058] The segment register is set according to the memory segmentation management mode, and is combined with an offset to form the physical address of the memory unit, including: rcs (Code Segment Register), which stores the starting address of the code segment; rds (Data Segment Register), which stores the starting address of the data segment; res (ExtraSegment Register), which stores the starting address of the additional segment; rss (Stack Segment Register), which stores the starting address of the stack segment.

[0059] Stack frame: also called procedure activity record, is a data structure used by the compiler to implement procedure / function calls, which describes the information of the function being executed: function parameters, function local variables, return address after function execution, etc.

[0060] Call Stack: A stack that stores information about a running process.

[0061] Pointer: Generally points to a function or a variable. It is a variable in a computer language or a register in a central processing unit that is used to indicate a memory address.

[0062] CallInfo: The call array in the state machine structure of the Lua virtual machine.

[0063] func; a functional function used to call a function with its own local variables and return to the calling process.

[0064] Closure: A closure is an expression (usually a function) that has many variables and an environment that binds these variables, so these variables are also part of the expression. In layman's terms, it refers to a collection of information in operation.

[0065] Proto: Implicit prototype, which refers to the constructor that creates an object.

[0066] Function: A group of computer instructions.

[0067] ncurses: A third-party programming library that provides character terminal user interaction. It provides a series of functions that users can call to generate text-based user interfaces. In short, it is a UI (User Interface) library under a pure character interface, which is used to respond to key input and display content.

[0068] See also Figure 1 , Figure 1 A schematic diagram of a scenario of a positioning system for a performance bottleneck provided in an embodiment of the present application, the system may include a user-side device and a service-side device, the user-side device and the service-side device are connected via the Internet composed of various gateways, etc., which will not be repeated here, wherein the user-side device includes a terminal 11, and the service-side device includes a server 12; wherein:

[0069] The terminal 11 includes but is not limited to portable terminals such as mobile phones and tablets, as well as fixed terminals such as computers, query machines, and advertising machines. It is a service port that users can use and operate. In this application, the terminal provides users with functions such as page display of performance bottleneck location analysis, and can also provide performance bottleneck location analysis functions;

[0070] The server 12 includes a processor and a memory. The memory stores various instructions for program execution. The instructions are suitable for loading by the processor to execute various steps of the performance bottleneck location method described in the embodiment of the present application.

[0071] It should be noted that Figure 1The system scenario diagram shown is only an example. The server and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. Ordinary technicians in this field can know that with the evolution of the system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.

[0072] Please refer to Figure 2 , Figure 2 A first flow chart of a method for locating a performance bottleneck provided in an embodiment of the present application is shown. The positioning method provided in an embodiment of the present application can be applied to the above-mentioned electronic device, the electronic device includes a server and a terminal, and the electronic device is installed with an application program that needs to locate the performance bottleneck. The positioning method includes:

[0073] Step S201, obtaining register information of a target process to be tested, and obtaining source code names of processes within the target process. The target process includes multiple processes, and at least two processes have different function languages. The register information includes parameters for determining source code names corresponding to the processes.

[0074] The target process to be tested is a process whose performance bottleneck needs to be located, and the target process includes multiple different subprocesses, each of which includes its own function language, code information, and stack, and the subprocesses share the context of the target process. Since the language environment targeted by the embodiment of the present application is a language environment in which at least two different languages ​​are mixed, in the target process, there are at least two processes whose function languages ​​are different types of function languages.

[0075] In one embodiment, the step of obtaining register information of a target process to be tested and obtaining a source code name of a process within the target process includes:

[0076] The target process to be tested is determined, and the inspection and debugging tool is attached to the target process in a timed sampling manner; the inspection and debugging tool is used to debug and inspect the target process and read and write the memory of the target process.

[0077] Through the stack frame expansion library, the current stack frame of the mounted target process is expanded to obtain the current register information of the target process; these register information include the CPU's instruction pointer register, destination address register, stack pointer register and other registers related to the target process, where the pointer instruction register points to the address of each process, which is the binary function identifier of the corresponding process.

[0078] Convert the binary function identifier of each process into a source code name; the binary function identifier is an address information, which is a binary code that can be directly recognized by the CPU after the source code is compiled. However, the binary function identifier belongs to computer-recognizable information, not user-recognizable information, so it needs to be converted into user-recognizable source code information, that is, convert the binary function identifier of the process into a user-recognizable source code name. The conversion process can be performed through the above-mentioned stack frame expansion library.

[0079] In this embodiment, the inspection debugging tool is attached to the target process in a timed sampling manner, and the running information of the target process is sampled at fixed intervals. When the number of samples is large enough and the interval is small enough, the accuracy of the performance bottleneck can be guaranteed. The register information of the target process is obtained through the stack frame expansion library, and the binary function identification name of each process is converted into a source code name, which is ready for the C++ function-level performance bottleneck location analysis.

[0080] Step S202: display the source code name and time consumption ratio of the process, determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name.

[0081] In one embodiment, the steps of displaying the source code name and time consumption ratio of a process, determining the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and placing a cursor on the target source code name include:

[0082] Display the first page, which displays the source code name of each process and the time consumption ratio of the process; match the source code name and time consumption ratio of each process and then display them. On the first page, the source code name of the process can be arranged from top to bottom in descending order of the time consumption ratio of the process;.

[0083] Determine the source code name with the largest time consumption as the target source code name of the target process corresponding to the performance bottleneck; when the source code names of the processes on the first page are arranged from top to bottom in descending order of the process time consumption, the source code name in the first place is the target source code name of the target process corresponding to the performance bottleneck.

[0084] Position the cursor on the target source code name.

[0085] In this embodiment, the first page showing the C++ function level performance bottleneck location analysis is obtained, and the performance bottleneck location of the C / C++ function level of the target process is completed.

[0086] Step S203: When an analysis instruction is detected, the target source code name is matched with the main function name of the virtual machine.

[0087] The analysis instruction is issued by the user to trigger the matching operation between the target source code name and the main function name of the virtual machine. The analysis instruction may be issued by the user clicking the right button of the keyboard when the cursor is located on the target source code name.

[0088] The target source code name is matched with the main function name of the virtual machine in detail as follows: the characters of the target source code name are matched with the characters of the main function name of the virtual machine one by one; if all the characters of the target source code name match the characters of the main function name of the virtual machine, then the target source code name matches the main function name of the virtual machine; if at least one of the characters of the target source code name does not match the characters of the main function name of the virtual machine, then the target source code name does not match the main function name of the virtual machine.

[0089] Step S204: When the source code name matches the main function name of the virtual machine, the call stack of the virtual machine is analyzed to obtain the state machine information of the virtual machine.

[0090] When the source code name matches the main function name of the virtual machine, based on the main function of the virtual machine, the call stack of the virtual machine is expanded for analysis, the parameters of the destination address register are obtained, the pointer information of the state machine of the virtual machine is obtained, and then the next step of analysis is carried out.

[0091] Step S205: Obtain source code information of the sub-function corresponding to the main function of the virtual machine according to the state machine information of the virtual machine.

[0092] In one embodiment, the step of obtaining source code information of a sub-function corresponding to a main function of the virtual machine according to state machine information of the virtual machine includes:

[0093] Based on the state machine function of the virtual machine, obtain the calling information of the state machine of the virtual machine;

[0094] According to the calling information of the state machine of the virtual machine, the complete source code information is located through the mapping relationship. The source code information includes the file name, start line and end line information of the sub-function.

[0095] In this embodiment, based on the pointer information of the state machine of the virtual machine obtained in the previous step, the source code information of the sub-function corresponding to the main function of the virtual machine is obtained through the mapping relationship, and the target process corresponding to the performance bottleneck is further analyzed to the script code level.

[0096] Step S206: Display the source code information and time consumption ratio of the sub-function, and determine the sub-function information corresponding to the performance bottleneck.

[0097] In one embodiment, the steps of displaying the source code information and the time consumption ratio of the sub-functions and determining the sub-function information corresponding to the performance bottleneck include:

[0098] The second page is displayed. The second page displays the file name, start line and end line information of the sub-function, and the time consumption ratio of the sub-function. The file name, start line and end line information of the sub-function are arranged from top to bottom in descending order of the time consumption ratio, which is similar to the source code name and time consumption ratio of the process displayed in step S202.

[0099] It is determined that the sub-function ranked first is the sub-function corresponding to the performance bottleneck, and the function information displayed by the sub-function is the sub-function information corresponding to the performance bottleneck.

[0100] In this implementation, through further analysis and display, the performance bottleneck is located at the sub-function of the script code level. Through the displayed sub-function information, the performance bottleneck of the process can be accurately known, so as to perform optimization.

[0101] At this point, the performance bottleneck location of the entire target process is completed. The performance bottleneck location method provided in the embodiment of the present application can not only locate the performance bottleneck at the C / C++ function level, but also can further locate the performance bottleneck at the script language code level, providing a feasible solution for performance bottleneck location in scenarios where multiple languages ​​are used together.

[0102] Please refer to Figure 3 , Figure 3 A second flow chart of the method for locating a performance bottleneck provided in an embodiment of the present application is shown. The positioning method provided in an embodiment of the present application can be applied to the above-mentioned electronic device, the electronic device includes a server and a terminal, and the electronic device is installed with an application program that needs to locate the performance bottleneck. The positioning method includes:

[0103] Step S301, obtaining register information of a target process to be tested, and obtaining source code names of processes within the target process. The target process includes multiple processes, and at least two processes have different function languages. The register information includes parameters for determining source code names corresponding to the processes.

[0104] Step S302: display the source code name and time consumption ratio of the process, determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name.

[0105] Step S303: When an analysis instruction is detected, the target source code name is matched with the main function name of the virtual machine.

[0106] Step S304: When the source code name matches the main function name of the virtual machine, the call stack of the virtual machine is analyzed to obtain the state machine information of the virtual machine.

[0107] Step S305: According to the state machine information of the virtual machine, the source code information of the sub-function corresponding to the main function of the virtual machine is obtained.

[0108] Step S306: Display the source code information and time consumption ratio of the sub-function, and determine the sub-function information corresponding to the performance bottleneck.

[0109] Step S307: When a return instruction is received, the source code name and time consumption ratio of the process are displayed again, and the target source code name of the target process corresponding to the performance bottleneck is re-determined.

[0110] The return instruction is issued by the user to trigger the C++ function-level performance bottleneck location analysis. The return instruction can be issued by the user clicking the left key on the keyboard.

[0111] In one embodiment, when a return instruction is received, the steps of re-displaying the source code name and time consumption ratio of the process and re-determining the target source code name of the target process corresponding to the performance bottleneck include:

[0112] When a return instruction is received, the register information of the target process is retrieved, and the binary function identifier of the process is converted into a source code name; the specific implementation method is similar to that in step S201, and may refer to step S201, which will not be repeated here.

[0113] The source code name and time consumption ratio of the process are displayed again, the target source code name of the target process corresponding to the performance bottleneck is determined, and the cursor is placed on the target source code name; the specific implementation method is similar to that in step S202, and can refer to step S202, which will not be repeated here.

[0114] In this implementation, by performing the first step of performance bottleneck location analysis on the target process, the performance bottleneck of the target process is located at the C / C++ function level. By further performing performance bottleneck location on the process corresponding to the performance bottleneck, the performance bottleneck is located at the sub-function at the script code level. The performance bottleneck can be located at the C / C++ function level again through the return operation, thus completing the performance bottleneck location in the case of mixed use of C / C++ functions and script languages, and satisfying the switching display of the performance bottleneck location analysis page at the C / C++ function level and the performance bottleneck location analysis page at the script code level sub-function, so that the user can grasp the performance bottleneck location of the target process at any time.

[0115] For ease of understanding, the following uses a scenario where C++ and LUA scripting languages ​​are mixed and the operating environment is a terminal as an example to schematically illustrate the method for locating performance bottlenecks provided in the embodiment of the present application. Figure 4 , Figure 4 A third flow chart of a method for locating a performance bottleneck provided in an embodiment of the present application is shown. The method for locating a performance bottleneck includes:

[0116] Step S401: Display the process list and determine the target process.

[0117] The terminal displays all processes in a list and determines the target process to be tested based on the user's selection.

[0118] Step S402: attach ptrace to the target process in a timed sampling manner.

[0119] The target process includes multiple procedures, wherein the function language of at least one procedure is C++ language, and the function language of at least one procedure is LUA scripting language.

[0120] Ptrace itself is a very complex system call, used to debug and check the target process, read and write the target process's memory. Its function prototype is long ptrace(enum_ptrace_request request,pid_t pid,void*addr,void*data). When attached to the target process, PTRACE_ATTACH is passed as the first parameter, and the target process ID is passed as the second parameter. For Windows environment, ptrace can be replaced by ETW (Event Trace For for Windows), which can be implemented across platforms.

[0121] Step S403: Expand the current stack frame of the mounted target process through libunwind, obtain the current register information of the target process, and convert the binary function identification name of the process into a source code name.

[0122] These register information include the target process related information in registers such as the instruction pointer register, the destination index register, and the stack pointer register. The pointer instruction register points to the address of each process, which is the binary function identifier of the corresponding process. libunwind obtains the current register information of the target process and converts the binary function identifier of the process into a source code name. This can be achieved through the following functions, and the steps include:

[0123] Through the function

[0124] unw_addr_space_t unw_create_addr_space(unw_accessors_t*ap,intbyteorder), creates and initializes the unwind address space;

[0125] Through the function

[0126] int unw_init_remote(unw_cursor_t*c,unw_addr_space_t as,void*arg), initialize the unwind pointer

[0127] Through the function

[0128] int unw_get_reg(unw_cursor_t*cp,unw_regnum_t reg,unw_word_t*valp), read the register information pointed to by the unwind pointer;

[0129] Through the function

[0130] int unw_get_proc_name(unw_cursor_t*cp,char*bufp,size_t len,unw_word_t*offp), converts the address information of the instruction pointer register pointed to by the unwind pointer into the compiled C++ code and returns it, that is, returns the binary function identifier of the procedure pointed to by the unwind pointer;

[0131] The compiled binary function name is converted to the function name before compilation, that is, the source code name, through the function abi::_cxa_demangle.

[0132] Step S404: display the source code name and time consumption ratio of the process, determine the target source code name of the target process corresponding to the performance bottleneck, and place the cursor on the target source code name.

[0133] Please refer to Figure 6 , Figure 6 The first page of the method for locating the performance bottleneck provided by the embodiment of the present application is shown, and the first page displays the source code name of each process and the time-consuming proportion of the process. On the first page, the first column displays the time-consuming proportion of each process, and the second column displays the source code name of each process. The source code name of the process can be arranged from top to bottom in the order of the time-consuming proportion of the process from large to small. The first page shows that the time-consuming proportion of the first process is 95.61% and its source code name luaV_exeucte, the time-consuming proportion of the second process is 4.28% and its source code name luaV_tonumber, the time-consuming proportion of the third process is 0.06% and its source code name HeroPart::OnTick(), and the time-consuming proportion of the fourth process is 0.05% and its source code name SkillPart::OnTick(). The display information on the first page can be refreshed in real time through ncurses.

[0134] Determine the source code name that takes up the largest proportion of time as the target source code name of the target process corresponding to the performance bottleneck. That is, determine the source code name of the first process ranked first, luaV_exeucte, as the target source code name of the target process corresponding to the performance bottleneck, and place the cursor on the target source code name luaV_exeucte.

[0135] At this point, the performance bottleneck positioning at the C / C++ function level has been completed.

[0136] Step S405: Analyze the call stack of the Lua virtual machine to obtain the state machine information of the Lua virtual machine.

[0137] When the cursor is on luaV_exeucte and the user clicks the right button on the keyboard, the target source code name luaV_exeucte analysis instruction will be triggered. When the target source code name luaV_exeucte analysis instruction is detected, the characters of the target source code name luaV_exeucte are matched one by one with the characters of the lua virtual machine main function name. If the lua virtual machine main function name is luaV_exeucte and its characters completely match the target source code name luaV_exeucte, it is determined that the target process corresponds to the lua virtual machine main function, and then the lua virtual machine analysis is carried out. The lua virtual machine information is stored in the lua_State structure of the lua virtual machine state machine, and the lua_State structure of the lua virtual machine state machine can be obtained through the destination address register rdi.

[0138] Please refer to Figure 7 and Figure 8 , Figure 7 The figure shows the memory layout of the stack frame under the x86-64 architecture, where parameter N-1, parameter N, and return address are the stack frame information of the caller, and rbp, local variable 1, local variable 2, and rsp are the stack frame information of the callee; Figure 8 The relationship between registers and parameters is shown, where the parameter L of the destination index register rdi is also the first parameter of the function call. In the main function of Lua, there is only one parameter - the parameter of the destination index register rdi. Based on the main function of the Lua virtual machine, the call stack of the Lua virtual machine is expanded to analyze the Lua virtual machine, and the parameter L of the destination index register rdi is obtained. The parameter L is the pointer information of the state machine lua_State of the Lua virtual machine, which points to the state machine lua_State structure of the Lua virtual machine, and then the next step of analysis is carried out.

[0139] Step S406: According to the lua_State information of the state machine of the lua virtual machine, further obtain the source code information of the sub-function corresponding to the main function of the lua virtual machine.

[0140] Please refer to Fig. 9 , shows the mapping relationship between the lua virtual machine state machine lua_State structure, the call information CallInfo structure and the source code information Proto structure. First, based on the function of the lua virtual machine state machine lua_State, obtain the lua virtual machine state machine lua_State structure, thereby obtaining the call information ci of the lua virtual machine state machine lua_State; ci points to a CallInfo stack, and determines the sub-function currently running in the CallInfo stack; expand the CallInfo structure of the current sub-function and obtain the func function information; according to the func function information, obtain the closure closure, the running information set; according to closure, finally locate the Proto structure, and obtain the file name, start line, and end line information of the sub-function in the Proto structure.

[0141] Step S407: Display the source code information and time consumption ratio of the sub-function, and determine the sub-function information corresponding to the performance bottleneck.

[0142] Please refer to Fig.10 , Fig.10 The second page of the method for locating the performance bottleneck provided by the embodiment of the present application is shown, and the second page displays the file name, starting line and ending line information of each sub-function, and the time-consuming proportion of each sub-function. On the second page, the first column displays the time-consuming proportion of each sub-function, and the second column displays the file name, starting line and ending line information of each sub-function. The file name, starting line and ending line information of the sub-function are arranged from top to bottom in the order of large to small time-consuming proportion. The first page shows that the time-consuming proportion of the first sub-function is 99.58%, the file name @task.lua of the first sub-function, the starting line 5, and the ending line 10, and the time-consuming proportion of the second sub-function is 0.42%, and the file name @active.lua of the second sub-function, the starting line 5, and the ending line 10. The display information on the second page can be refreshed in real time by ncurses.

[0143] Determine the sub-function that takes up the most time, which is the sub-function corresponding to the performance bottleneck. The file name of the sub-function corresponding to the performance bottleneck is @task.lua, the starting line is line 5, and the ending line is line 10.

[0144] At this point, the performance bottleneck of the LUA scripting language has been completely located, and the performance bottleneck has finally been located at the code level of the LUA scripting language. If the correct result is not obtained, it may be that you do not have the permission to debug the process. You can add permissions, or it may not be an x86_64 type CPU. You can find the corresponding stack frame layout according to the official manual of each CPU and make corresponding changes.

[0145] Step S408: When a return instruction is received, the source code name and time consumption ratio of the process are displayed again, and the target source code name of the target process corresponding to the performance bottleneck is determined.

[0146] The return instruction is issued by the user to trigger the page switching, switching from the second page to the first page, returning to the performance bottleneck location page at the C / C++ function level, re-displaying the source code name and time consumption ratio of the process, and determining the target source code name of the target process corresponding to the performance bottleneck. The return instruction can be issued by the user clicking the left button on the keyboard.

[0147] The performance bottleneck location method provided in this embodiment can locate the performance bottleneck at the C / C++ function level, and can further locate the performance bottleneck at the LUA scripting language code level, and quickly and accurately completes the performance bottleneck location in the mixed use scenario of C / C++ function language and LUA scripting language. In addition to the mixed use scenario of C / C++ function language and LUA scripting language, the performance bottleneck location method provided in this application is also applicable to the mixed use of C / C++ and python, the mixed use of C / C++ and javascript, etc.

[0148] For ease of understanding, the following uses a scenario where the C++ language and the LUA scripting language are mixed and the electronic device is a server as an example to schematically illustrate the method for locating the performance bottleneck provided by the embodiment of the present application. Figure 5 , Figure 5 A fourth flow chart of a method for locating a performance bottleneck provided in an embodiment of the present application is shown. The method for locating a performance bottleneck includes:

[0149] S501: Sending a performance bottleneck location instruction

[0150] The terminal sends a performance bottleneck location instruction to the server, requesting that the performance bottleneck of the program running on the server be located.

[0151] S502: Sending program list

[0152] The server sends to the terminal a list of all programs running on the server.

[0153] S503: Send a first performance bottleneck location analysis request.

[0154] The terminal determines the target process to be tested according to the user's selection, and sends a performance bottleneck location request for the target process to the server.

[0155] S504: Send the first performance bottleneck location analysis result.

[0156] The server locates the performance bottleneck of the target process at the C / C++ function level.

[0157] First, ptrace is attached to the target process in a timed sampling manner. The target process includes multiple processes, wherein the function language of at least one process is C++ language, and the function language of at least one process is LUA script language.

[0158] Ptrace itself is a very complex system call, used to debug and check the target process, read and write the target process's memory. Its function prototype is long ptrace(enum_ptrace_request request,pid_t pid,void*addr,void*data). When attached to the target process, PTRACE_ATTACH is passed as the first parameter, and the target process ID is passed as the second parameter. For Windows environment, ptrace can be replaced by ETW (Event Trace For for Windows), which can be implemented across platforms.

[0159] Then, through libunwind, the current stack frame of the mounted target process is expanded, the current register information of the target process is obtained, and the binary function identification name of the process is converted into a source code name.

[0160] These register information include the target process related information in registers such as the instruction pointer register, the destination index register, and the stack pointer register. The pointer instruction register points to the address of each process, which is the binary function identifier of the corresponding process. libunwind obtains the current register information of the target process and converts the binary function identifier of the process into a source code name. This can be achieved through the following functions, including:

[0161] Through the function

[0162] unw_addr_space_t unw_create_addr_space(unw_accessors_t*ap,intbyteorder), creates and initializes the unwind address space;

[0163] Through the function

[0164] int unw_init_remote(unw_cursor_t*c,unw_addr_space_t as,void*arg), initialize the unwind pointer

[0165] Through the function

[0166] int unw_get_reg(unw_cursor_t*cp,unw_regnum_t reg,unw_word_t*valp), read the register information pointed to by the unwind pointer;

[0167] Through the function

[0168] int unw_get_proc_name(unw_cursor_t*cp,char*bufp,size_t len,unw_word_t*offp), converts the address information of the instruction pointer register pointed to by the unwind pointer into the compiled C++ code and returns it, that is, returns the binary function identifier of the procedure pointed to by the unwind pointer;

[0169] The compiled binary function name is converted to the function name before compilation, that is, the source code name, through the function abi::_cxa_demangle.

[0170] Finally, the source code name and time consumption ratio of the obtained process are sent to the terminal.

[0171] S505: Display the first performance bottleneck location analysis result.

[0172] Please refer to Figure 6 , Figure 6 The first page of the method for locating the performance bottleneck provided by the embodiment of the present application is shown, and the first page displays the source code name of each process and the time-consuming proportion of the process. On the first page, the first column displays the time-consuming proportion of each process, and the second column displays the source code name of each process. The source code name of the process can be arranged from top to bottom in the order of the time-consuming proportion of the process from large to small. The first page shows that the time-consuming proportion of the first process is 95.61% and its source code name luaV_exeucte, the time-consuming proportion of the second process is 4.28% and its source code name luaV_tonumber, the time-consuming proportion of the third process is 0.06% and its source code name HeroPart::OnTick(), and the time-consuming proportion of the fourth process is 0.05% and its source code name SkillPart::OnTick(). The display information on the first page can be refreshed in real time through ncurses.

[0173] Determine the source code name that takes up the largest proportion of time as the target source code name of the target process corresponding to the performance bottleneck. That is, determine the source code name of the first process ranked first, luaV_exeucte, as the target source code name of the target process corresponding to the performance bottleneck, and place the cursor on the target source code name luaV_exeucte.

[0174] At this point, the performance bottleneck positioning at the C / C++ function level has been completed.

[0175] S506: Send a second performance bottleneck location analysis request.

[0176] When the cursor is on luaV_exeucte and the user clicks the right button on the keyboard, the target source code name luaV_exeucte analysis instruction will be triggered. When the terminal detects the target source code name luaV_exeucte analysis instruction, it will send a further analysis request for luaV_exeucte to the server, that is, the second performance bottleneck location analysis request.

[0177] S507: Send the second performance bottleneck location analysis result.

[0178] When the server receives a request for further performance bottleneck location analysis of luaV_exeucte, it will trigger the matching of the target source code name luaV_exeucte with the name of the lua virtual machine main function, and match the characters of the target source code name luaV_exeucte with the characters of the lua virtual machine main function name one by one. The name of the lua virtual machine main function is luaV_exeucte, and its characters completely match the target source code name luaV_exeucte. It is determined that the target process corresponds to the lua virtual machine main function, and then the analysis of the lua virtual machine is carried out.

[0179] The lua virtual machine information is stored in the lua_State structure of the lua virtual machine state machine. The lua_State structure of the lua virtual machine state machine can be obtained through the destination address register rdi. Please refer to Figure 7 and Figure 8 , Figure 7 The figure shows the memory layout of the stack frame under the x86-64 architecture, where parameter N-1, parameter N, and return address are the stack frame information of the caller, and rbp, local variable 1, local variable 2, and rsp are the stack frame information of the callee; Figure 8 It shows the relationship between registers and parameters, where the parameter of the destination index register rdi is also the first parameter of the function call. In the main function of Lua, there is only one parameter - the parameter of the destination index register rdi.

[0180] Based on the main function of the Lua virtual machine, expand the call stack of the Lua virtual machine to analyze the Lua virtual machine, obtain the parameter L of the destination address register rdi, and the parameter L is the pointer information of the state machine lua_State of the Lua virtual machine. The pointer information points to the state machine lua_State structure of the Lua virtual machine, and then proceed to the next step of analysis.

[0181] Please refer to Fig. 9 ; Fig. 9 The mapping relationship between the lua_State structure of the state machine of the Lua virtual machine, the CallInfo structure of the call information and the Proto structure of the source code information is shown.

[0182] Based on the function of the state machine lua_State of the Lua virtual machine, obtain the state machine lua_State structure of the Lua virtual machine, thereby obtaining the call information ci of the state machine lua_State of the Lua virtual machine; ci points to a CallInfo stack, and determines to point to the sub-function currently running in the CallInfo stack; expand the CallInfo structure of the current sub-function to obtain the func function information; according to the func function information, obtain the closure closure, the running information collection; according to closure, finally locate the Proto structure, and obtain the file name, start line, and end line information of the sub-function in the Proto structure.

[0183] Finally, the obtained sub-function file name, start line, end line information, and the time consumption ratio of the sub-function are sent to the terminal.

[0184] S508: Display the second performance bottleneck location analysis result.

[0185] Please refer to Fig.10 , Fig.10 The second page of the method for locating the performance bottleneck provided by the embodiment of the present application is shown, and the second page displays the file name, starting line and ending line information of each sub-function, and the time-consuming proportion of each sub-function. On the second page, the first column displays the time-consuming proportion of each sub-function, and the second column displays the file name, starting line and ending line information of each sub-function. The file name, starting line and ending line information of the sub-function are arranged from top to bottom in the order of large to small time-consuming proportion. The first page shows that the time-consuming proportion of the first sub-function is 99.58%, the file name @task.lua of the first sub-function, the starting line 5, and the ending line 10, and the time-consuming proportion of the second sub-function is 0.42%, and the file name @active.lua of the second sub-function, the starting line 5, and the ending line 10. The display information on the second page can be refreshed in real time by ncurses.

[0186] Determine the sub-function that takes up the most time, which is the sub-function corresponding to the performance bottleneck. The file name of the sub-function corresponding to the performance bottleneck is @task.lua, the starting line is line 5, and the ending line is line 10.

[0187] At this point, the performance bottleneck of the LUA scripting language has been completely located, and the performance bottleneck has finally been located at the code level of the LUA scripting language. If the correct result is not obtained, it may be that you do not have the permission to debug the process. You can add permissions, or it may not be an x86_64 type CPU. You can find the corresponding stack frame layout according to the official manual of each CPU and make corresponding changes.

[0188] The performance bottleneck location method provided in this embodiment can locate the performance bottleneck at the C / C++ function level, and can further locate the performance bottleneck at the LUA scripting language code level, and quickly and accurately completes the performance bottleneck location in the mixed use scenario of C / C++ function language and LUA scripting language. In addition to the mixed use scenario of C / C++ function language and LUA scripting language, the performance bottleneck location method provided in this application is also applicable to the mixed use of C / C++ and python, the mixed use of C / C++ and javascript, etc.

[0189] Rapidly locating performance bottlenecks is conducive to discovering design or implementation defects hidden in the software as early as possible, providing a smooth and superior experience for the final product. The performance bottleneck locating method provided in this application obtains the register information of the target process to be tested, converts the binary function identifier of the process into a source code name, and displays it together with the time consumption ratio of the process to obtain the performance bottleneck analysis and positioning at the C / C++ function level; by further analyzing the call stack of the virtual machine, the state machine information of the virtual machine is obtained, and then the source code information of the sub-function corresponding to the main function of the virtual machine is obtained to obtain the performance bottleneck positioning analysis at the script language code level; it realizes the performance bottleneck solution of locating the C / C++ function level and the script language code level at the same time in the mixed use scenario of multiple languages, and the solution is run by a computer, which is simple, fast, accurate and low cost.

[0190] At the same time, the embodiment of the present application also provides a performance bottleneck positioning device, which is set in an electronic device and is used to execute the performance bottleneck positioning method provided by the embodiment of the present application. Fig.11 , Fig.11 The structural block diagram of the performance bottleneck positioning device provided in the embodiment of the present application is shown, and the positioning device includes:

[0191] The first acquisition module 1101 is used to acquire register information of a target process to be tested, and obtain the source code name of a process in the target process. The target process includes multiple processes, and the function languages ​​of at least two processes are different. The register information includes parameters for determining the source code name corresponding to the process.

[0192] The first display module 1102 is used to display the source code name of the process and the time consumption ratio of the process, and is also used to determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name;

[0193] A detection module 1103, used for detecting and analyzing instructions;

[0194] A matching module 1104 is used to match the target source code name with the virtual machine main function name;

[0195] The second acquisition module 1105 is used to analyze the call stack of the virtual machine and obtain the state machine information of the virtual machine;

[0196] The third acquisition module 1106 is used to acquire source code information of a sub-function corresponding to the main function of the virtual machine;

[0197] The second display module 1107 is used to display the source code information of the sub-function and the time consumption ratio of the sub-function, and is also used to determine the sub-function information corresponding to the performance bottleneck.

[0198] The performance bottleneck locating device provided in the embodiment of the present application obtains the register information of the target process to be tested, obtains the source code name of the process in the target process, and displays it together with the time consumption ratio of the process, thereby obtaining the performance bottleneck analysis and positioning at the C / C++ function level; obtains the state machine information of the virtual machine by further analyzing the call stack of the virtual machine, and then obtains the source code information of the sub-function corresponding to the main function of the virtual machine, thereby obtaining the performance bottleneck positioning analysis at the script language code level; and realizes a performance bottleneck solution for simultaneously locating the C / C++ function level and the script language code level in a scenario where multiple languages ​​are mixed.

[0199] The present application also provides an electronic device. Fig.12 ,like Fig.12 The structure diagram of the electronic device involved in the embodiment of the present application is shown, specifically:

[0200] The electronic device may include components such as a processor 1201 with one or more processing cores, a memory 1202 with one or more computer-readable storage media, a power supply 1403, and an input submodule 1204. Those skilled in the art will appreciate that Fig.12 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0201] The processor 1201 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire server. By running or executing software programs and / or modules stored in the memory 1202, and calling data stored in the memory 1202, the processor 1201 performs various functions of the electronic device and processes data, thereby performing overall detection of the electronic device. Optionally, the processor 1201 may include one or more processing cores; preferably, the processor 1201 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1201.

[0202] The memory 1202 can be used to store software programs and modules. The processor 1401 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202. The memory 1202 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1202 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 1202 may also include a memory controller to provide the processor 1201 with access to the memory 1202.

[0203] The electronic device also includes a power supply 1203 for supplying power to each component. Preferably, the power supply 1203 can be logically connected to the processor 1201 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 1203 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0204] The electronic device may further include an input submodule 1204, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0205] Although not shown, the electronic device may further include a display submodule, etc., which will not be described in detail herein. Specifically, in the embodiment of the present application, the processor 1201 in the electronic device will load the executable file corresponding to the process of one or more application programs into the memory 1202 according to the following instructions, and the processor 1201 will run the application program stored in the memory 1202, thereby realizing various functions, as follows:

[0206] Acquire register information of a target process to be tested, and obtain a source code name of a process within the target process, wherein the target process includes multiple processes, at least two processes have different function languages, and the register information includes parameters for determining the process corresponding to the source code name;

[0207] Display the source code name and time consumption ratio of the process, determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name;

[0208] When an analysis instruction is detected, a target source code name is matched with a main function name of a virtual machine;

[0209] When the source code name matches the main function name of the virtual machine, the call stack of the virtual machine is analyzed to obtain the state machine information of the virtual machine;

[0210] According to the state machine information of the virtual machine, the source code information of the sub-function corresponding to the main function of the virtual machine is obtained;

[0211] Display the source code information and time consumption ratio of the sub-function, and determine the sub-function information corresponding to the performance bottleneck.

[0212] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0213] In the electronic device provided in the embodiment of the present application, a program for locating the performance bottleneck of the target process is stored in the memory, and the processor can execute this program to implement the steps of any one of the positioning methods provided in the embodiment of the present application, and obtain the beneficial effects that can be achieved by any one of the methods provided in the embodiment of the present application. The specific implementation method is detailed in the previous embodiment and will not be repeated here.

[0214] A person skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a storage medium and loaded and executed by a processor.

[0215] To this end, an embodiment of the present application further provides a storage medium, in which a computer program is stored, and the computer program enables a computer to execute the steps in any one of the positioning methods provided in the embodiments of the present application.

[0216] For example, the instruction may execute the following steps:

[0217] Acquire register information of a target process to be tested, and obtain source code names of processes within the target process, wherein the target process includes multiple processes, and at least two processes have different function languages, and the register information includes parameters for determining source code names corresponding to the processes;

[0218] Display the source code name and time consumption ratio of the process, determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name;

[0219] When an analysis instruction is detected, a target source code name is matched with a main function name of a virtual machine;

[0220] When the source code name matches the main function name of the virtual machine, the call stack of the virtual machine is analyzed to obtain the state machine information of the virtual machine;

[0221] According to the state machine information of the virtual machine, the source code information of the sub-function corresponding to the main function of the virtual machine is obtained;

[0222] Display the source code information and time consumption ratio of the sub-function, and determine the sub-function information corresponding to the performance bottleneck.

[0223] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0224] The storage medium provided in the embodiment of the present application stores a computer program, which enables the computer to execute the steps in any one of the positioning methods provided in the embodiment of the present application to obtain the beneficial effects that can be achieved by any one of the methods provided in the embodiment of the present application. The specific implementation method is detailed in the previous embodiment and will not be repeated here.

[0225] The above is a detailed introduction to a performance bottleneck positioning method, positioning device, electronic device and storage medium provided in an embodiment of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for locating a performance bottleneck, characterized in that: include: Acquire register information of a target process to be tested, and obtain a source code name of a process in the target process, wherein the target process includes multiple processes, and at least two of the processes have different function languages, and the register information includes parameters for determining the source code name corresponding to the process, and the register information of the target process is obtained by expanding the current stack frame of the target process to which the stack frame expansion library is attached, and the target process attaches a check and debugging tool to the target process in a timed sampling manner; Display the source code name and time consumption ratio of the process, determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name, wherein after matching the source code name and the time consumption ratio of each process, they are arranged from top to bottom in the order of the time consumption ratio from large to small, and the target source code name of the target process corresponding to the performance bottleneck is the source code name with the largest time consumption ratio; When the analysis instruction is detected, matching the target source code name with the main function name of the virtual machine is performed; When the source code name matches the main function name of the virtual machine, analyzing the call stack of the virtual machine to obtain state machine information of the virtual machine; According to the state machine information of the virtual machine, the source code information of the sub-function corresponding to the main function of the virtual machine is obtained, including: based on the state machine function of the virtual machine, obtaining the calling information of the state machine of the virtual machine; according to the calling information of the state machine of the virtual machine, locating the source code information through a mapping relationship; The source code information and time consumption ratio of the sub-function are displayed, and the sub-function information corresponding to the performance bottleneck is determined. The source code information and time consumption ratio of the sub-function are arranged from top to bottom in the order of the time consumption ratio from large to small. The sub-function information corresponding to the performance bottleneck is the function information displayed for the sub-function ranked first.

2. The positioning method according to claim 1, characterized in that: The step of obtaining register information of the target process to be tested and obtaining the source code name of the process within the target process includes: The inspection and debugging tool is periodically attached to the target process; Obtaining register information of the target process; The acquired parameter of the process corresponding to the source code name is converted into a source code name.

3. The positioning method according to claim 1, characterized in that: The step of displaying the source code name and time consumption ratio of the process, determining the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and placing the cursor on the target source code name includes: Displaying a first page, wherein the first page displays the source code name of the process and the time consumption ratio of the process; Determine the source code name that takes up the largest proportion of time, and use it as the target source code name of the target process corresponding to the performance bottleneck; Position the cursor on the target source code name.

4. The positioning method according to claim 1, characterized in that: The step of matching the target source code name with the main function name of the virtual machine when the analysis instruction is detected includes: The characters of the target source code name are matched one by one with the characters of the virtual machine main function name.

5. The positioning method according to claim 1, characterized in that: When the source code name matches the main function name of the virtual machine, the step of analyzing the call stack of the virtual machine to obtain the state machine information of the virtual machine includes: The call stack of the virtual machine is analyzed, the parameters of the destination index register are obtained, and the pointer information of the state machine of the virtual machine is obtained.

6. The positioning method according to claim 5, characterized in that: The step of obtaining source code information of a sub-function corresponding to a main function of the virtual machine according to the state machine information of the virtual machine includes: According to the pointer information, obtaining the calling information of the state machine of the virtual machine; According to the calling information, the source code information of the sub-function is obtained, where the source code information includes the file name, start line and end line information of the sub-function.

7. The positioning method according to claim 6, characterized in that: The step of displaying the source code information and the time consumption ratio of the sub-function and determining the sub-function information corresponding to the performance bottleneck includes: Displaying a second page, wherein the second page displays the file name, start line and end line information of the sub-function, and the time consumption ratio of the sub-function, and the file name, start line and end line information of the sub-function are arranged from top to bottom in descending order of the time consumption ratio; Determine that the sub-function ranked first is the sub-function corresponding to the performance bottleneck.

8. A device for locating a performance bottleneck, characterized in that: include: A first acquisition module is used to acquire register information of a target process to be tested, and obtain a source code name of a process in the target process, wherein the target process includes multiple processes, and at least two of the processes have different function languages, and the register information includes parameters for determining the source code name corresponding to the process, and the register information of the target process is acquired by expanding the current stack frame of the target process to which the stack frame expansion library is mounted, and the target process mounts the inspection and debugging tool to the target process in a timed sampling manner; The first display module is used to display the source code name and time consumption ratio of the process, and is used to determine the target source code name of the target process corresponding to the performance bottleneck according to the time consumption ratio, and place the cursor on the target source code name, wherein after matching the source code name and the time consumption ratio of each process, they are arranged from top to bottom in the order of the time consumption ratio from large to small, and the target source code name of the target process corresponding to the performance bottleneck is the source code name with the largest time consumption ratio; A detection module, used for detecting and analyzing instructions; A matching module, used for matching the target source code name with the main function name of the virtual machine; A second acquisition module is used to analyze the call stack of the virtual machine and obtain the state machine information of the virtual machine; A third acquisition module is used to acquire source code information of a sub-function corresponding to the main function of the virtual machine, including: acquiring call information of the state machine of the virtual machine based on the state machine function of the virtual machine; locating the source code information through a mapping relationship according to the call information of the state machine of the virtual machine; The second display module is used to display the source code information of the sub-function and the time consumption ratio of the sub-function, and is also used to determine the sub-function information corresponding to the performance bottleneck. The source code information and time consumption ratio of the sub-function are arranged from top to bottom in the order of the time consumption ratio from large to small. The sub-function information corresponding to the performance bottleneck is the function information displayed for the sub-function ranked first.

9. An electronic device, characterized in that: include: Memory, used to store programs; The processor is used to execute the program to implement each step of the method for locating a performance bottleneck as described in any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores a computer program, which enables a computer to execute each step of the method for locating a performance bottleneck as described in any one of claims 1 to 7.