Application performance analysis method and device, computing equipment, system and storage medium
The coprocessor obtains the virtual address of the performance monitoring counter in the main processor and collects running information directly from the virtual address, which solves the problem of low processor information collection frequency and improves the efficiency and effect of application performance analysis.
Patent Information
- Application Number
- CN202310261102.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-10
- Publication Date
- 2024-09-10
AI Technical Summary
Computer processors collect application execution information less frequently, resulting in poor monitoring of application operation.
The coprocessor obtains the correspondence between the physical address and the virtual address of the performance monitoring counter in the main processor, and directly obtains the running information from the virtual address, avoiding the delay caused by the main processor switching operation permissions, and increasing the frequency of information collection.
It improves the efficiency and effect of application performance analysis, reduces the amount of data analysis on the main processor, avoids business interruptions or freezes, and improves application fluency.
Smart Images

Figure CN118626327A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an application performance analysis method, apparatus, computing device, system and storage medium. Background Art
[0002] Computers are used to implement functions such as numerical calculations, logical calculations, and storage memory. For example, computers include processors and memories. To implement various functions, different applications (APPs) are deployed in computers. In order to monitor the operation of applications, the processor will collect the operation events of the applications running in the processor, and store the number of times the different operation events have occurred in the physical address space provided by the memory; then, the processor analyzes the operation of the application based on the information stored in the physical address space. However, the processor switches the processor to the permission to operate higher-authority instructions through the interrupt mechanism and the exception mechanism, so as to read the information collected in the aforementioned physical address space; because the state switching process has a certain time overhead, the frequency of the processor's execution information collection on the application is low, which affects the monitoring effect of the processor on the operation of the application. Therefore, how to more effectively analyze application performance has become a problem that needs to be solved urgently. Summary of the invention
[0003] The present application provides an application performance analysis method, apparatus, computing device, system and storage medium to solve the problem that the processor has a low frequency of collecting application execution information, which affects the monitoring effect of the processor on the application operation status.
[0004] In the first aspect, the present application provides an application performance analysis method. The application performance analysis method can be applied to an application performance analysis system or to a computing device that supports the application performance analysis system to implement the application performance analysis method, for example, the computing device includes a main processor and a coprocessor. Here, the application performance analysis method provided by the present application is described by taking the coprocessor as an example. The application performance analysis method includes: the coprocessor responds to an analysis request, obtains a first relationship, and obtains operation information based on the first relationship. Thereby, the coprocessor determines the performance analysis result of the application based on the operation information. Among them, the analysis request is used to perform a performance analysis operation on the application running in the main processor of the computing device; and the first relationship is used to record the correspondence between the physical address of the performance monitoring counter in the main processor and the virtual address associated with the coprocessor; and the operation information is used to indicate the number of occurrences of the performance monitoring unit event when the main processor runs the application, and one performance monitoring counter corresponds to one performance monitoring unit event.
[0005] In the present application, the coprocessor obtains the operation information from the virtual address according to the first relationship between the physical address of the performance monitoring counter and the virtual address associated with the coprocessor, thereby avoiding the delay caused by the main processor directly obtaining the operation information from the physical address of the performance monitoring counter by switching the operation authority, and then the coprocessor can collect the operation information at a higher frequency, and the coprocessor analyzes the application performance based on the high-frequency operation information, thereby improving the analysis effect of the application performance. On the other hand, the present application uses the coprocessor to analyze the operation information of the main processor, which reduces the amount of data analysis of the main processor, and is conducive to improving the efficiency of application performance analysis. Since the main processor does not need to perform application performance analysis, it avoids the need to switch the state of the main processor from user state to kernel state when obtaining the operation information, which causes the service interruption or jamming of the application, thereby improving the fluency of the application.
[0006] Exemplarily, the main processor writes the analysis request into the second physical address space, and the coprocessor obtains the analysis request from the second physical address space.
[0007] In a possible implementation, before responding to the analysis request, the application performance analysis method further includes: the coprocessor obtains the physical address of the performance monitoring counter in the main process, and establishes a first relationship between the physical address and the virtual address associated with the coprocessor.
[0008] In order to avoid the problem that the coprocessor cannot directly access the physical address of the performance monitoring counter in the main processor, in the present application, the coprocessor establishes a first relationship between the physical address of the performance monitoring counter in the main processor and the virtual address of the coprocessor. The coprocessor can read data from the physical address based on the first relationship and the virtual address, and the coprocessor does not need to switch from user mode to kernel mode during the data acquisition process, which reduces time consumption and improves data acquisition efficiency.
[0009] Exemplarily, the main processor includes a plurality of performance monitoring counters, and the physical address of each performance monitoring counter has a unique corresponding relationship with the virtual address associated with the coprocessor.
[0010] In a possible implementation, the coprocessor obtains the operation information according to the first relationship, including: the coprocessor obtains the operation information from the virtual address according to the first relationship at a first frequency, where the first frequency is greater than or equal to a set threshold.
[0011] In the present application, since the coprocessor obtains the operation information from the virtual address according to the first relationship, it avoids the processor from switching the operation authority and directly obtains the operation information from the physical address of the performance monitoring counter, thereby being able to obtain the operation information at a higher frequency, such as the first frequency. The coprocessor performs performance analysis on the application based on the operation information, which can improve the coprocessor's analysis effect on the application performance.
[0012] Exemplarily, the first frequency may be obtained by parsing and analyzing a request by the coprocessor, or the first frequency may be preset on the coprocessor.
[0013] In a possible implementation, the coprocessor determines the performance analysis result of the application according to the running information, including: the coprocessor determines the type of the running information and obtains a set analysis rule matching the type of the running information. Thus, the coprocessor performs performance analysis on the running information according to the set analysis rule to obtain the performance analysis result.
[0014] In the present application, the coprocessor obtains the setting analysis rules matching the type of the operation information based on the type of the operation information, and realizes the adaptive acquisition of the setting analysis rules. And the coprocessor uses different setting analysis rules to perform performance analysis for different types of operation information, and realizes targeted analysis of the operation information.
[0015] In a possible implementation, the coprocessor collects operation information from the virtual address according to the first frequency and the first relationship, including: the coprocessor parses and analyzes the request to obtain at least one of the sampling time or the sampling frequency, and, if the sampling frequency obtained by the coprocessor is the first frequency, the coprocessor collects the operation information from the virtual address according to the first relationship according to the information collection frequency indicated by the first frequency. The sampling frequency is used to indicate the information collection frequency of the coprocessor in a unit time.
[0016] In the present application, the coprocessor collects operation information based on at least one of the sampling time or sampling frequency indicated by the analysis request, and can use different sampling frequencies or sampling times when different functions are executed, so that the coprocessor can adaptively analyze the function and improve the analysis effect on the application.
[0017] In a possible implementation, after the coprocessor obtains the running information, the application performance analysis method further includes: the coprocessor reads a stop request from the second physical address space, and the coprocessor stops collecting the running information according to the stop request. The stop request is used to instruct to stop the analysis process of the application performance.
[0018] In the present application, the coprocessor stops collecting running information from the physical address based on the stop request, and then stops performing performance analysis on the application, thereby performing performance analysis on the application on the main processor within a specified time, avoiding the problem of resource waste caused by long-term performance analysis of the application, improving resource utilization, and reducing the amount of data obtained during this time, thereby improving the efficiency of application performance analysis.
[0019] In a possible implementation, a third physical address space supported by the main processor for access stores multiple addresses of the second virtual address space, one address corresponds to one of the multiple instructions executed by the main processor, and the second virtual address space supports access by the main processor. The main processor writes the analysis request to the second physical address space, including: the main processor obtains the second relationship between the multiple virtual addresses and the multiple functions, and determines the multiple functions executed by the main processor based on the multiple addresses corresponding to the multiple instructions and the second relationship. Furthermore, the main processor obtains one or more monitoring functions that meet the preset conditions from the multiple functions, and if the one or more monitoring functions are executed, the main processor writes the analysis request to the second physical address space.
[0020] In order to avoid waste of resources caused by the coprocessor monitoring the main processor for a long time, in the present application, the main processor determines the multiple functions executed by the main processor and the corresponding number of times of each function based on the second relationship, and then determines one or more monitoring functions that meet the conditions according to the number of times corresponding to each function. The monitoring function is executed as a key condition to trigger the main processor to generate an analysis request and write the analysis request to the shared memory, so as to enable the coprocessor to perform targeted analysis of the main processor, reduce resource waste and improve analysis efficiency.
[0021] In one possible implementation, the above-mentioned operation information includes the occurrence counts of multiple types of operation events, and each time the main processor executes an instruction, the occurrence count of the operation event corresponding to the instruction increases once; the main processor obtains one or more monitoring functions that meet preset conditions from multiple functions, including: the main processor determines the occurrence counts of the operation events corresponding to multiple functions respectively based on the second relationship and the multiple virtual addresses stored in the third physical address space, and uses the function whose occurrence count reaches the threshold indicated by the preset condition as the monitoring function.
[0022] In order to avoid the waste of resources caused by the coprocessor monitoring the main processor for a long time, in the present application, the main processor determines one or more monitoring functions among multiple functions, and uses the monitoring function as an important factor to trigger the main processor to generate an analysis request, so as to enable the coprocessor to perform targeted analysis on the main processor, reduce resource waste and improve analysis efficiency.
[0023] In a possible implementation, the second relationship includes a kernel mapping file and a user mapping file, and the main processor obtains the second relationship between the multiple virtual addresses and the multiple functions, including: the main processor determines whether the multiple virtual addresses belong to the kernel space or the user space, and if the multiple addresses belong to the kernel space, the main processor obtains the kernel mapping file. If the multiple addresses belong to the user space, the processor obtains the user mapping file.
[0024] In the present application, if the main processor determines that the virtual address of the execution instruction belongs to the user space or the kernel space, it obtains the corresponding user mapping file or kernel mapping file under the second relationship, thereby avoiding the problem of the main processor searching for the function corresponding to the address from the entire second relationship based on the address of the execution instruction, and searching for a large amount of data, thereby narrowing the matching range, reducing the amount of data search, and thus speeding up the matching efficiency of determining the function corresponding to the address.
[0025] In a possible implementation, a third physical address space supported by the main processor for access stores multiple addresses of the second virtual address space, one address corresponds to one of the multiple instructions executed by the main processor, and the second virtual address space supports access by the main processor. The main processor writes the analysis request into the second physical address space, including: the main processor determines the subordinate relationship between the multiple addresses and the set address range based on the multiple addresses corresponding to the multiple instructions, and if at least one address included in the multiple addresses belongs to the set address range, the main processor writes the analysis request into the second physical address space.
[0026] In the present application, the main processor triggers the process of generating an analysis request and writing the analysis request to the shared memory as soon as possible by executing an instruction in the form where the address of the instruction belongs to the address range corresponding to the monitoring function, thereby enabling the coprocessor to perform targeted analysis on the main processor and improving analysis efficiency.
[0027] In a second aspect, the present application provides an application performance analysis device, which is applied to a computing device and is suitable for a computing device including a main processor and a coprocessor. The application performance analysis device includes various modules for executing the application performance analysis method in the first aspect or any optional implementation of the first aspect. Exemplarily, the application performance analysis device includes: a first acquisition module, a second acquisition module and a determination module applied to the coprocessor. Among them, the first acquisition module is used to respond to an analysis request and obtain a first relationship. The analysis request is used to perform a performance analysis operation on an application running in the main processor of the computing device. The first relationship is used to record the correspondence between the physical address of the performance monitoring counter in the main processor and the virtual address associated with the coprocessor. The second acquisition module is used to obtain operation information according to the first relationship. The operation information is used to indicate the number of occurrences of a performance monitoring unit event when the main processor runs an application. One performance monitoring counter corresponds to one performance monitoring unit event. The determination module is used to determine the performance analysis result of the application according to the operation information.
[0028] In a possible implementation, the application performance analysis device further includes: a relationship establishment module applied to the coprocessor. The relationship establishment module is used to obtain the physical address of the performance monitoring counter in the main processor and establish a first relationship between the physical address space and the virtual address associated with the coprocessor.
[0029] In a possible implementation, the main processor includes a plurality of performance counters, and a physical address of each performance monitoring counter has a unique corresponding relationship with a virtual address associated with the coprocessor.
[0030] In a possible implementation, the second acquisition module is further configured to acquire the operation information from the virtual address according to the first frequency and the first relationship, where the first frequency is greater than or equal to a set threshold.
[0031] In a possible implementation, the determination module is further used to determine the type of the operation information, obtain a set analysis rule matching the type of the operation information, and perform performance analysis on the operation information according to the set analysis rule to obtain a performance analysis result.
[0032] In a possible implementation, the application performance analysis device further includes: a write module applied to a main processor and a read module applied to a coprocessor. The write module is used to write an analysis request into a second physical address space, the analysis request is used to instruct the coprocessor to start an analysis process of the application, and the second physical address space supports access by the main processor and the coprocessor. The read module is used to read the analysis request from the second physical address space, and determine the first virtual address space corresponding to the first physical address space according to the first relationship and the analysis request.
[0033] In one possible implementation, a third physical address space supported by the main processor stores multiple addresses of a second virtual address space, one address corresponds to one of multiple instructions executed by the main processor, and the second virtual address space supports access by the main processor. The write module is further used to obtain a second relationship between multiple addresses and multiple functions, and to determine multiple functions executed by the main processor based on the multiple addresses corresponding to the multiple instructions and the second relationship. Furthermore, the write module is further used to obtain one or more monitoring functions that meet preset conditions from the multiple functions, and if the one or more monitoring functions are executed, the main processor writes an analysis request to the second physical address space.
[0034] In a possible implementation, the operation information includes the number of occurrences of multiple types of operation events, and each time the main processor executes an instruction, the number of occurrences of the operation event corresponding to the instruction will increase once. The writing module is specifically used to determine the number of occurrences of the operation events corresponding to the multiple functions respectively based on the second relationship and the multiple addresses stored in the third physical address space, and to use the function whose number of occurrences reaches the threshold indicated by the preset condition as the monitoring function.
[0035] In a possible implementation, the second relationship includes a kernel mapping file and a user mapping file. The write module is specifically used to determine whether the multiple addresses belong to the kernel space or the user space, and if the multiple addresses belong to the kernel space, the main processor obtains the kernel mapping file, or, if the multiple addresses belong to the user space, the main processor obtains the user mapping file.
[0036] In a possible implementation, a third physical address space supported by the main processor for access stores multiple addresses of the second virtual address space, one address corresponds to one of the multiple instructions executed by the main processor, and the second virtual address space supports access by the main processor. The writing module is further used to determine the subordinate relationship between the multiple addresses and the set address range based on the multiple addresses corresponding to the multiple instructions, and if at least one address included in the multiple addresses belongs to the set address range, the main processor writes an analysis request to the second physical address space.
[0037] For more detailed implementation content of the application performance analysis device, please refer to the description of any implementation method in the first aspect above, as well as the content of the following specific implementation methods, which will not be repeated here.
[0038] In a third aspect, the present application provides a chip comprising: an interface circuit and a power supply circuit; the interface circuit is used to obtain an analysis request, and the control circuit is used to execute the method in the above-mentioned first aspect and any possible implementation of the first aspect.
[0039] In a fourth aspect, the present application provides a computing device, comprising a processor and a memory, wherein the memory stores instructions, and the processor calls the instructions to implement the method in the above-mentioned first aspect and any possible implementation manner of the first aspect.
[0040] In a fifth aspect, the present application provides an application performance analysis system, which includes a main processor and a coprocessor. The main processor is used to run the application, and the first physical address space supported by the main processor to access stores the running information of the application, and the first physical address space does not support direct access by other processors. The main processor is used to send an analysis request, and the coprocessor is used to respond to the analysis request, and execute the method in the first aspect and any possible implementation of the first aspect according to the analysis request.
[0041] In a sixth aspect, the present application provides a computer-readable storage medium, which stores a computer program or instructions. When the computer program or instructions are executed by a computing device, the method in the above-mentioned first aspect and any one of the optional implementations of the first aspect is implemented.
[0042] In a seventh aspect, the present application provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a computing device, the method in the above-mentioned first aspect and any optional implementation manner of the first aspect is implemented.
[0043] The beneficial effects of the third to seventh aspects above can refer to the description of the first aspect or any implementation of the first aspect, and will not be repeated here. Based on the implementations provided by the above aspects, this application can also be further combined to provide more implementations. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A schematic diagram of an application performance analysis system provided for this application;
[0045] Figure 2 A flowchart of an application performance analysis method provided for this application;
[0046] Figure 3 Schematic diagram of the analysis request writing method provided in this application Figure 1 ;
[0047] Figure 4 A flowchart of the monitoring function determination method provided in this application;
[0048] Figure 5 Schematic diagram of the analysis request writing method provided in this application Figure 2 ;
[0049] Fig. 6A A schematic diagram of the structure of an application performance analysis device provided in this application Figure 1 ;
[0050] Figure 6B A schematic diagram of the structure of an application performance analysis device provided in this application Figure 2 ;
[0051] Figure 7 A schematic diagram of the structure of a computing device provided in this application. DETAILED DESCRIPTION
[0052] To facilitate understanding, the technical terms involved in this application are first introduced.
[0053] A performance monitor counter (PMC) is used to monitor and count processor (central processing unit, CPU) parameters. Different CPUs are configured with different types of PMCs, and one type of PMC monitors and counts one type of running event. The performance monitor counter is a register.
[0054] For example, by reading the value of the same PMC at the beginning or end of a specified time interval and then performing a difference operation, the number of occurrences of a specified running event within the time interval can be obtained.
[0055] The performance monitoring unit (PMU) includes multiple PMCs, which are used to measure CPU performance and understand the characteristics of CPU workload. Different types of PMCs can be monitored to obtain different types of PMU events (also called run events). For example, PMU events include cache-related events, run-related events, and instruction-related events.
[0056] The interrupt mechanism refers to the process in which the CPU terminates the executing program and switches to process randomly-asked requests. After the processing is completed, the CPU returns to the originally interrupted program and resumes execution.
[0057] In order to perform application performance analysis more effectively, the present application provides an application performance analysis method, which is applicable to a computing device including a main processor and a coprocessor. The main processor is used to run the application, and the first physical address space supported by the main processor stores the application's running information, and the first physical address space does not support direct access by other processors. The application performance analysis method includes: the coprocessor responds to the analysis request and obtains the first relationship between the physical address of the PMC in the main processor and the virtual address associated with the coprocessor; then, the coprocessor obtains the running information according to the first relationship. And, the coprocessor obtains the analysis result of the application according to the collected running information.
[0058] In the present application, the coprocessor obtains the operation information from the virtual address according to the first relationship between the physical address of the PMC and the virtual address associated with the coprocessor, thereby avoiding the delay caused by the main processor directly obtaining the operation information from the physical address of the PMC by switching the operation authority, and then the coprocessor can collect the operation information at a higher frequency, and the coprocessor analyzes the application performance based on the high-frequency operation information, thereby improving the analysis effect of the application performance. On the other hand, the present application uses the coprocessor to analyze the operation information of the main processor, which reduces the amount of data analysis of the main processor, and is conducive to improving the efficiency of application performance analysis. Since the main processor does not need to perform application performance analysis, it avoids the need to switch the state of the main processor from user state to kernel state when obtaining the operation information, which causes the service interruption or jamming of the application, thereby improving the fluency of the application.
[0059] Next, the application performance analysis method provided in this application is introduced in detail with reference to the accompanying drawings.
[0060] First, see Figure 1, Figure 1 A schematic diagram of an application performance analysis system provided in this application. Figure 1 As shown, the application performance analysis system includes a processor 110 , a processor 120 , and a processor 130 , and the processors are connected via a bus 140 .
[0061] As a possible implementation, the above-mentioned application performance analysis system may be a computing device, for example, a server, a storage array, an edge device, or other computer system for performing computing tasks.
[0062] Among them, the main processor, such as processor 110 and processor 120, is used to run the application program (or called application), and the coprocessor, such as processor 130, is used to collect and analyze the number of occurrences of multiple types of PMU events when the main processor runs the application (which can be called operation information), and the operation information is stored in the PMC of the main processor. For example, application 111 is running on processor 110, and this application does not limit the application 111, which can be video software, chat software or game software, etc.
[0063] Among them, the processor 110, the processor 120 or the processor 130 may respectively include one or more processing units, for example: the above-mentioned processing units may include a CPU, an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA), discrete gates, transistor logic devices, discrete hardware components, a baseband processor, and / or a neural network processor (neural-network processing unit, NPU), an artificial intelligence (artificial intelligence, AI) chip, etc., any one or a combination thereof.
[0064] The bus 140 is used to transmit information between the processors. In addition to the data bus, the bus 140 may also include a power bus, a control bus, a status signal bus, etc. However, for the sake of clarity, various buses are labeled as bus 140 in the figure.
[0065] The bus 140 may be a high-speed bus of a peripheral component interconnect express (PCIe), or an extended industry standard architecture (EISA) bus, a unified bus (Ubus or UB), a computer express link (CXL), a cache coherent interconnect for accelerators (CCIX) and other buses, a quick path interconnect (QPI) bus and other standards or protocols for implementing data interaction. For example, the processor 110 may access the processor 130 via the PCIe bus. The processor 110 may be connected to the processor 130 via a double data rate (DDR) bus. Here, different processors 130 may use different data buses to communicate with the processor 110, so the DDR bus may also be replaced by other types of data buses, and the bus type is not limited in the embodiment of the present application. It should be understood that multiple processors can be mounted on a host or server and communicate using hardware communication channels, and multiple processors transmit data through memory or temporary files, reducing the transmission delay of data or instructions.
[0066] In one possible scenario, the present application is applicable not only to the application performance analysis between different processors in a single computing device, but also to the application performance analysis process between different processors in multiple computing devices. Figure 1 The bus 140 shown may be a remote procedure call (RPC) channel, and multiple processors are connected through the RPC channel. Exemplarily, when the processor 110, the processor 120 or the processor 130 are located in different servers, the processor 110 may call the object (such as data, etc.) on the remote processor 120 or the processor 130 based on the RPC channel without knowing the specific call details. For example, the processor 110 instructs the processor 130 to collect the PMC that the processor 110 supports access according to the set frequency based on the RPC channel. Exemplarily, the processor 110 remotely calls the RPC interface of the processor 130 through a remote communication tool (such as a run-time library) to establish an RPC channel connection between the processor 110 and the processor 130.
[0067] It should be noted that Figure 1This is just an example provided in this application. The application performance analysis system may also include other processors, or memory, power supply, hard disk, optical drive, chassis, cooling system and other input and output controllers and interfaces that support the operation of the processor. Figure 1 This application does not limit the form and quantity of the other processors or the hardware supporting the operation of the above processors.
[0068] For the sake of convenience, the application performance analysis method is generally described by taking the main processor as processor 110, the coprocessor as processor 130, and the main processor and the coprocessor being located in the same computing device as an example. Figure 1 In the schematic diagram of the application performance analysis system shown, the processor 110 runs an application, and multiple PMCs in the processor 110 will record the operation information in real time. The processor 130 obtains the first relationship between the physical address of the PMC in the processor 110 and the virtual address associated with the processor 130, each PMC has a fixed physical address, and obtains all the aforementioned operation information according to the first relationship. And, the processor 130 obtains the analysis result of the application according to the operation information. Among them, the physical address of the above-mentioned PMC is only allowed to be directly accessed by the processor 110, and other processors are not supported to be directly accessed.
[0069] Exemplarily, the physical address of the PMC is represented by a base address and an operation code. The base address of each register is specified by the chip manufacturer; and the operation code is obtained by the rules defined by the chip architecture manufacturer and is also fixed. Therefore, the physical address of the PMC is fixed and can be obtained.
[0070] In order to avoid the problem that the processor 130 directly reads the first physical address space and needs to switch operation permissions, which results in a long time consumption, the present application provides a possible implementation method, in which the processor 130 obtains all physical addresses of the computing device kernel, such as the physical address of the PMC in the processor 110, and establishes a first relationship between the free virtual address in the virtual memory area of the collector process and the physical address of the PMC.
[0071] Since the physical address of the PMC in each processor is set to be fixed, when the processor 110 and the processor 130 belong to the same computing device, the processor 130 can obtain the physical address of the PMC through the virtual device and call the memory mapping function to establish a first relationship between the physical address and the virtual address. The virtual address can be a space in the virtual memory area corresponding to the collector process on the processor 130.
[0072] Among them, a virtual memory area will be allocated to the collector process on the processor 130 when it is started. When the processor 130 uses the memory mapping function to associate the virtual memory area of the process with the first physical address space, a free space on the virtual memory area, such as the first virtual address space, will be used as a mapping area with the first physical address space. The first physical address space includes multiple physical addresses of multiple PMCs, and each physical address has a unique corresponding relationship with the virtual address in the first virtual address space.
[0073] For example, the virtual device is called out by the processor 130 through / dev / mem, and the / dev / mem device is a virtual character device of the Linux system, and the / dev / mem device shows all physical addresses of the computing device kernel, and then the processor 130 can obtain multiple physical addresses including multiple PMCs through the dev / mem device. In addition, the processor 130 calls the memory mapping function (mmap function) to complete the mapping of the first physical address space and the first virtual address space, that is, to establish the first relationship between the physical address of the PMC and the virtual address of the collector process on the processor 130.
[0074] To avoid the problem that processor 130 cannot directly access the physical address of the PMC in processor 110, in this embodiment, processor 130 establishes a first relationship between the physical address of the PMC in processor 110 and the virtual address of the process in processor 130. Processor 130 can read data from the physical address based on the first relationship and the virtual address, and processor 130 does not need to switch from user mode to kernel mode during the data acquisition process, thereby reducing time consumption and improving data acquisition efficiency.
[0075] For example, Table 1 below shows a mapping table of the first relationship indication.
[0076] Table 1
[0077]
[0078] The above Table 1 shows the correspondence between the first physical address space including the physical address of PMC1 and the physical address of PMC2 in the processor 110 and the first virtual address space including multiple virtual addresses in the processor 130. For example, a correspondence is established between the physical address 0x4800000B-0x480000AB of PMC1 in the processor 110 and the virtual address 0xC000000B-0xC00000AB of the processor 130.
[0079] It is worth noting that one or more PMCs may be included in the same processor. The content included in Table 1 above is only an example provided by the present application and should not be understood as a limitation of the present application. The mapping table may also include more or less content, such as the first relationship between the physical address 0x40000C00-0x4000AC00 of the PMC in other processors and the virtual address 0xB000000B-0xB00000AB of processor 130.
[0080] After the processor 130 establishes the first relationship, Figure 1 As shown, during the process of processor 110 running application 111 , processor 110 generates an analysis request based on a preset condition trigger, and writes the analysis request into a second physical address space, which supports access by processor 110 and processor 130 .
[0081] For example, the second physical address space is a shared memory, and the processor 110 and the processor 130 establish an association relationship between an area in their respective virtual address spaces and an area in the physical address space, and the area is the shared memory. The association relationship is maintained in the memory management unit (MMU), and the processor 110 writes an analysis request to the specified virtual address space, and the analysis request is stored in the aforementioned shared memory through the memory management unit.
[0082] Optionally, the processor 110 may write the sending request directly into the second physical address space.
[0083] Regarding the expression form of the analysis request, the present application provides a possible example, where the analysis request is a data structure (or an object), and the object retains the necessary information required to describe the analysis request, such as the identification of the processor that issued the analysis request, and information such as start or pause.
[0084] Among them, for the above-mentioned preset conditions, any possible example provided below may be adopted:
[0085] Example 1: The preset condition is that if a set application is started, the processor 110 generates an analysis request.
[0086] Example 2: The preset condition is that if a function set in the application is executed, the processor 110 generates an analysis request.
[0087] Example 3: The preset condition is that if the virtual address corresponding to the instruction executed in the application belongs to the set address range, the processor 110 generates an analysis request.
[0088] The above preset conditions are merely examples provided in this embodiment. In a possible scenario, the preset conditions may also be a combination of the above multiple examples, which should not be understood as a limitation on the present application. For example, the preset condition is that if the set application is started and the function set in the application is executed, an analysis request is generated.
[0089] For the corresponding contents of Example 2 and Example 3 above, please refer to the following Figure 3 and Figure 5 The corresponding content will not be repeated here.
[0090] Combination of the above Figure 1 The application performance analysis system involved in this application is introduced in detail. Figure 2 Further explain the application performance analysis method.
[0091] After the processor 130 establishes the first relationship, the processor 130 receives the analysis request sent by the main processor, and performs analysis processing on the main processor based on the analysis request. Figure 1 Based on the application performance analysis system shown, the present application provides an application performance analysis method, such as Figure 2 As shown, Figure 2 A flow chart of an application performance analysis method provided in an embodiment of the present application is taken as an example in which the processor 110 in the main processor and the physical address A of the PMC on the processor 110 has a first relationship with the virtual address A managed by the processor. The method includes the following steps S210 to S240.
[0092] S210: The processor 130 obtains an analysis request.
[0093] In a possible example, the processor 110 writes the analysis request into the second physical address space, and the processor 130 reads the data in the second physical address space at a set frequency, thereby obtaining the analysis request.
[0094] In another possible example, the processor 130 provides an interface to the outside, and the processor 130 receives an analysis request through the interface, where the analysis request is generated according to the user's operation on the front-end display interface.
[0095] The analysis request is used to instruct the processor 130 to start an analysis process of the application on one or more processors in the processor 110 .
[0096] Taking the example of processor 130 obtaining an analysis request from the second physical address space, processor 130 reads the analysis request in the second physical address space from an area in the virtual address space based on the association between an area in the virtual address space and the second physical address space and the MMU. The analysis request instructs processor 130 to start the analysis process of application 111 on processor 110.
[0097] S220: The processor 130 responds to the analysis request and obtains the first relationship.
[0098] The processor 130 determines the virtual address A corresponding to the processor 110 based on the analysis request and the first relationship established above. The virtual address supports access by the processor 130 .
[0099] S230. The processor 130 obtains operation information based on the first relationship.
[0100] The processor 130 determines the physical address A corresponding to the virtual address by using the address conversion of the MMU based on the first relationship and the virtual address A, and collects the operation information in the physical address A. The processor 130 does not need to switch from the user state to the kernel state, which reduces the time overhead and can increase the frequency of collecting the operation information.
[0101] In a possible scenario, the analysis request further indicates at least one of a sampling time or a collection frequency, where the sampling frequency is used to indicate the frequency of information collection by the processor 130 within a unit time.
[0102] Example 1, the analysis request indicates the sampling frequency. The analysis request generated by the processor 110 carries the sampling frequency or analysis parameters. The processor 130 parses the analysis request to obtain only the acquisition frequency, and the sampling frequency is the first frequency, or the processor 130 parses the analysis request to obtain the analysis parameter, the analysis parameter indicates the sampling frequency, and the sampling frequency is the first frequency. Then the processor 130 collects the operation information located at the physical address A from the virtual address A according to the first frequency.
[0103] Among them, the first frequency is greater than or equal to a set threshold, such as the threshold is 100KHz or 200KHz, and the above-mentioned analysis parameter may be an identifier of an application running on the processor 110 or an identifier of an execution instruction. The processor 130 obtains the sampling frequency indicated by the analysis parameter based on the correspondence between the identifier of the maintained application or the identifier of the execution instruction and the sampling frequency.
[0104] Example 2, the analysis request indicates the sampling time. The analysis request generated by the processor 110 carries the sampling time. The processor 130 parses the analysis request and only obtains the sampling time. The processor 130 collects the operation information in the physical address A from the virtual address A at the second frequency set, and only samples the sampling time indicated in the analysis request. Among them, the second frequency is greater than or equal to the above-mentioned set threshold. The setting method of the second frequency may include but is not limited to: system default (manufacturer setting), user adjustment, or determination according to the type of application, etc.
[0105] Example 3: The analysis request indicates the sampling frequency and sampling time. The analysis request generated by the processor 110 carries the sampling frequency or sampling time, and the processor 130 parses the analysis request to obtain the acquisition frequency and sampling time, and the sampling frequency is the first frequency, then the processor 130 acquires the operation information located at the physical address A from the virtual address A according to the first frequency, and only samples the sampling time indicated in the analysis request.
[0106] In this embodiment, the processor 130 collects operation information based on at least one of the sampling time or sampling frequency indicated by the analysis request, and can use different sampling frequencies or sampling times when different functions are executed, so that the processor 130 performs adaptive analysis on the function, thereby improving the analysis effect on the application.
[0107] During the process of the processor 130 collecting and analyzing the operation information stored in the PMC in the processor 110 according to the analysis request, the processor 130 obtains a stop request, and stops the process of collecting and analyzing the operation information according to the stop request.
[0108] Exemplarily, the processor 130 reads the stop request in the second physical address space based on the aforementioned association relationship and the corresponding area of the virtual address space. Based on the stop request, the processor 130 stops collecting operation information from the physical address A and performing analysis based on the operation information.
[0109] In this embodiment, based on the stop request, the processor 130 stops collecting operation information from the physical address A, and then stops analyzing the application, thereby analyzing the application on the processor 110 within a specified time, avoiding the problem of resource waste caused by analyzing the application for a long time, improving resource utilization, and the amount of data obtained during this time is reduced, thereby improving the efficiency of application performance analysis.
[0110] S240: The processor 130 determines a performance analysis result of the application according to the operation information.
[0111] Taking the operation information provided by the aforementioned S230 as an example, the process of the processor obtaining the analysis results is explained: the processor 130 performs data statistics and calculations on the number of occurrences of each type of operation event or the recorded information (such as the address of the instruction) in the operation information to obtain the operation status of the application, that is, the performance analysis result.
[0112] For example, the coprocessor determines the type of the operation information according to the type of the PMC, and obtains a set analysis rule matching the type of the operation information. The coprocessor performs performance analysis on the operation information according to the set analysis rule to obtain a performance analysis result.
[0113] Regarding the processor 130 analyzing the operation information and obtaining the analysis result, four possible implementations are provided below.
[0114] In a first possible implementation, if the operation information includes an operation event that records the number of executed instructions, the processor 130 can determine the instructions executed in each clock cycle (instruction per clock, IPC) of the processor 110 during the acquisition cycle based on the acquisition frequency of the processor 130, the number of executed instructions and the frequency of the processor 110.
[0115] In a second possible implementation, if the execution information includes cache-related execution events, the processor 130 determines the address discreteness of instructions when running the application based on the cache-related events, and the address discreteness indicates the locality of data processed by the application.
[0116] In a third possible implementation, if the operation information includes instruction-related events, the processor 130 analyzes the instruction-related events to obtain utilization information of the processor vector unit and floating point unit by the application. For example, the processor 130 determines the utilization of the processor vector unit and floating point unit by comparing the IPC corresponding to the instruction-related events with the set value.
[0117] In a fourth possible implementation, if the operation information includes execution-related events, the processor 130 analyzes the execution-related events to obtain processor pipeline width information. For example, the processor 130 analyzes the cache miss rate and IPC of the execution-related events to obtain the processor pipeline width information.
[0118] In this embodiment, the coprocessor obtains the setting analysis rules matching the type of the operation information based on the type of the operation information, thereby realizing adaptive acquisition of the setting analysis rules. And the coprocessor uses different setting analysis rules to perform performance analysis for different types of operation information, thereby realizing targeted analysis of the operation information.
[0119] In one possible scenario, the processor 130 may perform application performance analysis, application similarity analysis, application periodicity analysis, etc. based on the collected operation information.
[0120] Compared with the problem of the processor taking a long time to switch operation permissions, the processor 130 in this embodiment can directly collect the operation information in the physical address based on the virtual address based on the first relationship, without performing the aforementioned switching process, that is, there will be no delay caused by switching operation permissions, and the operation information can be collected at a higher frequency, such as the first frequency. Since the processor 130 collects operation information at a high frequency, the instantaneous occurrence of the operation event can be determined, that is, the processor 130 can effectively capture the peak and valley, so the processor 130 can obtain an instantaneous analysis result based on the operation event, and the instantaneous analysis result accurately reflects the peak demand of the processor for resources during the operation of the application, thereby improving the analysis effect of the processor 110.
[0121] Furthermore, the present application uses the processor 130 to analyze the operation information of the processor 110, which reduces the amount of data analysis by the processor 110, and is conducive to improving the efficiency of application performance analysis. Since the processor 110 does not need to perform application performance analysis, it avoids the need to switch the state of the processor 110 from the user state to the kernel state when obtaining the operation information, which causes the service interruption or jamming of the application, thereby improving the fluency of the application.
[0122] In another possible embodiment, the processor 130 analyzes the performance of the processor 110 based on the collected operation information, wherein the performance may include processing performance, instruction fetch capability, or branch prediction capability, etc.
[0123] Regarding the analysis of the performance of the processor 110 by the processor 130 , three possible examples are provided below.
[0124] Example 1: The processor 130 can obtain the processing performance of the processor 110 according to the number of instructions that can be executed in each clock cycle indicated by the above IPC.
[0125] Example 2: The processor 130 determines the instruction fetch capability of the processor 110 according to the operation event recorded with the instruction fetch information of the processor 110 included in the operation information. For example, the operation event recorded with the instruction fetch information records 10k pieces of address information in one acquisition cycle (5kcycle), and it is determined that the processor 110 fetches 2 instructions in one clock cycle, and the 2 instructions reflect the instruction fetch capability of the processor 110.
[0126] Example 3: The processor 130 determines the branch prediction performance of the processor 110 according to the running events of the branch instructions or jump instructions (such as if instructions) executed by the processor 110 recorded in the running information. For example, when the processor 110 executes the if instruction, it does not directly make a judgment, but makes a prediction in advance to speed up the processing process. The processor 130 obtains the branch prediction performance of the processor 110 according to the number of branch instructions and the success or failure of each prediction by the processor 110.
[0127] With respect to the above-mentioned preset condition that an analysis request is generated if a set function is executed, a possible implementation method is provided below.
[0128] When the processor 110 is running the application, the processor 110 will also sample the data in the PMC and store the sampled data in the third physical address space, such as sampling the PMC storing the address of the instruction executed by the processor 110. The PMC is a register for storing the memory address of the instruction, and the memory address belongs to the second virtual address space supported by the processor 110, and one address corresponds to one of the multiple instructions executed by the processor 110.
[0129] Exemplarily, the processor 110 collects addresses of instructions executed by the processor 110 in the PMC through the perf_event_open system call, and stores the sampled addresses of multiple executed instructions in a third physical address space, which is a ring buffer.
[0130] For example, the processor 110 utilizes the sampling mode of the perf_event_open system call, and the sampling period is 1M clock cycles to sample the data in the PMC, such as the address of the instruction (program counter, PC).
[0131] In one possible scenario, a mapping relationship is established between the third physical address space and the virtual address space supported by processor 110 and processor 130, so that the states of processor 110 and processor 130 do not need to be switched from user mode to kernel mode, and processor 110 and processor 130 can access the third physical address space.
[0132] exist Figure 2 Before the processor 130 performs the analysis process, the present application also provides a possible implementation method in which the processor 110 generates an analysis request and writes it into the second physical address space, such as Figure 3 As shown, Figure 3 Schematic diagram of the analysis request writing method provided in this application Figure 1 . Figure 3The content shown is that the processor 110 determines one or more monitoring functions from the multiple functions being executed, and when the monitoring function is executed, generates an analysis request and writes it into the second address space. Figure 3 In this embodiment, the processor 110 in the main processor and the processor 130 as a coprocessor are used as an example for explanation. The method includes the following steps S310 to S340.
[0133] S310: The processor 110 obtains a second relationship between a plurality of virtual addresses and a plurality of functions and addresses of a plurality of instructions.
[0134] The processor 110 obtains the second relationship from a set physical address space, and the addresses of the multiple instructions are virtual addresses.
[0135] Exemplarily, the second relationship includes a kernel mapping file and a user mapping file. The processor 110 periodically reads the address of the instruction from the third physical address space based on the third physical address space and the virtual address space supported by the processor 110, and obtains the corresponding second relationship based on the address.
[0136] Taking address C among multiple addresses corresponding to multiple instructions as an example, the processor 110 determines whether the address C belongs to the user space or the kernel space.
[0137] If the address C belongs to the kernel space, the processor 110 obtains the kernel mapping file; if the address C belongs to the user space, the processor 110 obtains the user mapping file.
[0138] The kernel mapping file is a symbol table, which records the function's first address and function name. For example, the symbol table is / proc / kallsyms file. The user mapping file describes the executable and linkable format (ELF) files corresponding to different parts of the virtual address space of the adopted process. For example, the user mapping file is / proc / <pid> / maps files.
[0139] For example, taking a 32-bit operating system as an example, the addressing range of its virtual address space is 4G, of which the highest 1G bytes (virtual address 0xC0000000 to 0xFFFFFFFF) is used by the kernel, called the kernel space; the lower 3G bytes (virtual address 0xC0000000 to 0xBFFFFFFF) are used by the processes on the processor, called the user space. If an address is 0xC00000AB, it can be determined that the address belongs to the user space, and the processor 110 obtains the user mapping file.
[0140] In this embodiment, if the processor 110 determines that the address of the execution instruction belongs to the user space or the kernel space, it obtains the corresponding user mapping file or kernel mapping file under the second relationship, thereby avoiding the problem of the processor 110 searching for the function corresponding to the address from the entire second relationship based on the address of the execution instruction, and searching for a large amount of data, thereby narrowing the matching range, reducing the amount of data search, and thus speeding up the matching efficiency of determining the function corresponding to the address.
[0141] S320: The processor 110 determines multiple functions executed by the processor 110 based on multiple addresses corresponding to the multiple instructions and the second relationship.
[0142] Take address D among multiple addresses corresponding to multiple instructions as an example for explanation. If the address D belongs to the user space, the processor 110 determines the function corresponding to the address based on the address D and the user mapping file.
[0143] For example, the processor 110 may use the addr2line tool or the binary file descriptor library (BFD) to search for a specific function in the ELF file corresponding to the address D.
[0144] If the address D belongs to the kernel space, the processor 110 determines the function corresponding to the address D based on the address D and the kernel mapping file.
[0145] For example, the processor 110 determines the address range of the function according to the function head address and the function size, and then determines the address range to which the address D belongs. If the address range to which the address D belongs is determined, the function corresponding to the address D is determined.
[0146] Optionally, the processor 110 may use a binary search method to speed up the process of determining the address range to which the address belongs.
[0147] In this embodiment, the processor 110 determines the function corresponding to the address from the mapping file corresponding to the address of the execution instruction, thereby avoiding the processor 110 determining the function corresponding to the address from the entire second relationship, reducing the amount of data search, and improving the matching efficiency of determining the function corresponding to the address.
[0148] S330. The processor 110 obtains one or more monitoring functions that meet preset conditions from multiple functions.
[0149] Exemplarily, the preset condition is that the number of occurrences (or execution times) of the function within a set time is greater than or equal to a threshold.
[0150] For example, the set time is 1 minute, and the threshold is 100 times. These values are only examples and should not be construed as limitations on the present application.
[0151] For example, each time the processor 110 executes an instruction, the number of occurrences of the running event corresponding to the instruction increases once, and the register used to store the memory address of the instruction also increases the address of the corresponding instruction. Therefore, each time the address in the third physical address is recorded, it means that the number of executions of the function corresponding to the address increases once.
[0152] exist Figure 3 Based on this, the present application provides an implementation method for determining a monitoring function from multiple functions, such as Figure 4 As shown, Figure 4 The flowchart of the monitoring function determination method provided by the present application is as follows: The method includes the following steps S410 to S420.
[0153] S410: The processor 110 determines the number of occurrences corresponding to the plurality of functions according to the second relationship and the addresses of the plurality of instructions.
[0154] For example, based on the second relationship and the addresses of multiple instructions, the processor 110 can obtain the correspondence between multiple addresses corresponding to multiple instructions and multiple functions, and then determine the execution count of each function according to the correspondence and the multiple addresses stored in the third physical address space, such as the execution count of function 1 is 200, the execution count of function 2 is 100, and the execution count of function 3 is 35, etc.
[0155] S420: The processor 110 determines a monitoring function among the multiple functions based on the number of occurrences corresponding to the multiple functions.
[0156] During the process of executing a function, each time the processor 110 reaches a specific node, the PMC corresponding to the specific node will be recorded, and then the PMU number corresponding to the PMC will be increased by 1 or a new record will be added.
[0157] For example, each time the processor 110 executes an instruction in a function, the PMC that records the address saves the address to a corresponding storage space, thereby recording a PMU event.
[0158] For another example, each time the processor 110 executes a jump instruction in a function, the PMC that records the number of instructions will record the number, and then the number of PMU events corresponding to the PMC will be increased by 1.
[0159] Exemplarily, based on the aforementioned threshold, the processor 110 uses the function whose occurrence times of the multiple functions is greater than or equal to the threshold as the monitoring function.
[0160] For example, the processor determines that function 1 and function 2 are monitoring function 1 and monitoring function 2 according to the aforementioned threshold, such as 100 times.
[0161] For example, it is determined that function 1 has a mapping relationship with address 1. When the third physical address includes address 1 and address 1 is recorded 200 times within the set time, it is determined that the number of executions of function 1 within the set time is 200. Therefore, function 1 is determined to be a monitoring function.
[0162] Based on the second relationship and the multiple addresses, the correspondence between the multiple addresses corresponding to the multiple instructions and the multiple functions can be obtained. Please refer to the description in the above S320 and will not be repeated here.
[0163] To avoid waste of resources caused by processor 130 monitoring processor 110 for a long time, in this embodiment, processor 110 determines one or more monitoring functions among multiple functions, and uses the monitoring function as an important factor to trigger processor 110 to generate an analysis request, thereby enabling processor 130 to perform targeted analysis on processor 110, reduce waste of resources, and improve analysis efficiency.
[0164] In another possible embodiment, the preset condition may be that the first n functions with the most execution times among all functions are monitoring functions. After the processor 110 determines the execution times corresponding to all functions through the aforementioned step S330, it sorts all functions from high to low according to the execution times, and uses the first n functions as monitoring functions.
[0165] In one possible scenario, after determining one or more monitoring functions, the processor 110 uses a tracepoint mechanism to insert handler functions at the beginning and end of the monitoring function to generate corresponding analysis requests and write them into the second physical address space.
[0166] S340: If the one or more monitoring functions are executed by the processor 110, the processor 110 writes an analysis request to the second physical address space.
[0167] Exemplarily, if the one or more monitoring functions are executed by the processor 110, the handler function triggers the generation of a corresponding analysis request and writes it into the second physical address space.
[0168] For example, if the one or more monitoring functions are executed by the processor 110 for the first time, the processor 110 generates an analysis request indicating to start the application performance analysis process and writes it into the second physical address space.
[0169] If at a second time after the one or more monitoring functions are executed by the processor 110, the processor 110 generates an analysis request indicating to stop the application performance analysis process and writes it into the second physical address space.
[0170] In order to avoid waste of resources caused by processor 130 monitoring processor 110 for a long time, in this embodiment, processor 110 determines multiple functions executed by processor 110 and the number of times each function corresponds to based on the second relationship, and then determines one or more monitoring functions that meet the conditions according to the number of times each function corresponds to. The monitoring function is executed as a key condition to trigger processor 110 to generate an analysis request and write the analysis request to shared memory, thereby enabling processor 130 to perform targeted analysis on processor 110, reduce resource waste, and improve analysis efficiency.
[0171] Regarding the above-mentioned preset condition that if the virtual address corresponding to the executed instruction belongs to the set address range, an analysis request is generated. The following provides an example of a possible implementation method, taking any one of the multiple monitoring functions as an example. After determining the monitoring function, the processor 110 can obtain multiple instructions corresponding to the monitoring function, and the instruction has a one-to-one correspondence with the address. Therefore, the monitoring function has a corresponding relationship with the address.
[0172] exist Figure 2 Before the processor 130 performs the analysis process, the present application also provides another possible implementation of the processor 110 generating an analysis request and writing it into the second physical address space, such as Figure 5 As shown, Figure 5 Schematic diagram of the analysis request writing method provided in this application Figure 2 Compared to Figure 3 The content shown, Figure 5 It also shows that the processor 110 determines the set address range of the monitoring function, and if the address at which the processor 110 executes the instruction belongs to the set address range, the processor 110 writes the analysis request to the second physical address space. Figure 5 Taking the method provided in this embodiment where the main processor is the processor 110 as an example, the method provided in this embodiment includes the following steps S510 to S550.
[0173] S510: The processor 110 obtains a second relationship.
[0174] For example, the processor 110 may read the second relationship from a set physical address space.
[0175] S520: The processor 110 determines a set address range of the monitoring function according to the second relationship and the monitoring function.
[0176] Exemplarily, the monitoring function is as above Figure 3 Since the second relationship indicates the relationship between multiple virtual addresses and multiple functions, the processor 110 can obtain the set address range corresponding to the monitoring function based on the second relationship and the determined monitoring function, and the address range is an area in the second virtual address space. For example, the set address range of monitoring function 1 is 0xC000000B-0xC000AC00, and the set address range of monitoring function 2 is 0xB0000B00-0xC000140B.
[0177] S530: The processor 110 obtains a plurality of virtual addresses in the third physical address space.
[0178] Regarding the content of the processor 110 acquiring multiple virtual addresses in the third physical address space, reference may be made to the description of the processor 110 acquiring addresses of multiple instructions in the above S310, which will not be elaborated here.
[0179] S540: The processor 110 determines a subordinate relationship between the multiple virtual addresses and a set address range.
[0180] Exemplarily, the processor 110 compares the multiple virtual addresses with the set address range in sequence to determine whether the virtual address belongs to the set address range. The present application does not limit how many virtual addresses the processor 110 compares with the set address range at one time. For example, the processor 110 may compare 10 of the multiple virtual addresses with the set address range at one time.
[0181] For example, one of the multiple virtual addresses is 0xC000000B-0xC00000AB, and the processor 110 compares the address with the set address ranges of the aforementioned monitoring function 1 and monitoring function 2 to obtain that the address belongs to the set address range of monitoring function 1.
[0182] S550: If at least one virtual address among the multiple virtual addresses belongs to the set address range, the processor 110 writes an analysis request to the second physical address space.
[0183] If a virtual address is found to belong to the set address range, the processor 110 generates an analysis request and writes the analysis request to the second physical address space.
[0184] In a possible scenario, the processor 110 writes an analysis request to the second physical address space each time it determines that a virtual address belongs to the set address range.
[0185] In another possible scenario, after the processor 110 determines that the first virtual address belongs to the set address range, it will not write an analysis request to the second physical address space within a preset time. After the preset time, if it is determined that another virtual address belongs to the set address range, it will write an analysis request to the second physical address space again, and so on, until multiple virtual addresses are determined.
[0186] In this embodiment, the processor 110 generates an analysis request and writes the analysis request to the shared memory in the first time by executing an instruction in the form where the address of the instruction belongs to the address range corresponding to the monitoring function, thereby enabling the processor 130 to perform targeted analysis on the processor 110 and improving the analysis efficiency.
[0187] In a possible scenario, while the processor 110 samples the PMC storing the address of the instruction executed by the processor 110, the processor 110 samples the data in other PMCs using the sampling mode of the perf_event_open system call to obtain low-frequency data. The low-frequency data can be stored in the third physical address space, and the processor 130 obtains the low-frequency data from the third physical address space and analyzes it.
[0188] For example, the sampling period of the processor 110 is 1M clock cycles.
[0189] For the content of the processor 130 analyzing the low-frequency data, reference may be made to the description of the processor 130 analyzing the operation information in the above S240 , which will not be described in detail here.
[0190] In another embodiment, the processor 110 may obtain low-frequency data from the third physical address space and perform analysis.
[0191] For the content of the processor 110 analyzing the low-frequency data, reference may be made to the description of the processor 130 analyzing the operation information in the above S240 , which will not be described in detail here.
[0192] Combined with the above Figures 1 to 5 , describes in detail the application performance analysis method provided by this application, and will be combined with Fig. 6A , Fig. 6A A schematic diagram of the structure of an application performance analysis device provided in this application Figure 1 , describes the application performance analysis device provided by the present application. The application performance analysis device 600 can be used to implement the functions of the computing device in the above method embodiment, and thus can also achieve the beneficial effects possessed by the above method embodiment.
[0193] like Fig. 6A As shown, the application performance analysis apparatus 600 is executed by a coprocessor in a computing device.
[0194] The application performance analysis device 600 includes a first acquisition module 610, a second acquisition module 620 and a determination module 630 applied to the coprocessor. The application performance analysis device 600 is used to implement the above Figures 2 to 5 The functions of the processor 110 and the processor 130 in the corresponding method embodiment. In a possible example, the specific process of the application performance analysis device 600 for implementing the above-mentioned application performance analysis method includes the following process:
[0195] The first acquisition module 610 is used to respond to an analysis request and obtain a first relationship. The analysis request is used to perform a performance analysis operation on an application running in a main processor of a computing device. The first relationship is used to record the correspondence between a physical address of a performance monitoring counter in the main processor and a virtual address associated with a coprocessor.
[0196] The second acquisition module 620 is used to acquire operation information according to the first relationship, where the operation information is used to indicate the number of occurrences of a performance monitoring unit event when the main processor runs an application, and one performance monitoring counter corresponds to one performance monitoring unit event.
[0197] The determination module 630 is used to determine the performance analysis result of the application according to the operation information.
[0198] To further achieve the above Figures 2 to 5 The present application also provides an application performance analysis device, such as Figure 6B As shown, Figure 6B A schematic diagram of the structure of an application performance analysis device provided in an embodiment of the present application Figure 2 The application performance analysis device 600 also includes a relationship establishment module 640 applied to the coprocessor.
[0199] The relationship establishing module 640 is used to obtain the physical address of the performance monitoring counter in the main processor, and to call the memory mapping function to establish a first relationship between the physical address and the virtual address associated with the coprocessor.
[0200] It is worth noting that the processor 110 and the processor 130 of the aforementioned embodiment may correspond to the application performance analysis device 600, and may correspond to executing the method according to the embodiment of the present application. Figure 2 to Figure 5 The corresponding corresponding subjects, and the operations and / or functions of each module in the application performance analysis device 600 are respectively to achieve Figures 2 to 5 For the sake of brevity, the corresponding processes of each method in the corresponding embodiments are not repeated here.
[0201] in addition, Fig. 6A or Figure 6B The application performance analysis device 600 shown can also be implemented by a communication device, where the communication device may refer to the computing device in the aforementioned embodiment, or, when the communication device is a chip or a chip system applied to a computing device, the application performance analysis device 600 can also be implemented by a chip or a chip system.
[0202] Exemplarily, when the application performance analysis apparatus 600 is implemented by the aforementioned computing device, the computing device may include one or more hardware, such as Figure 7 As shown, Figure 7 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. The computing device can be applied to Figure 1 The application performance analysis system shown.
[0203] like Figure 7 As shown, the computing device 700 may include a processor 710 , a memory 720 , a communication interface 730 , a bus 740 , etc. The processor 710 , the memory 720 , and the communication interface 730 are connected via the bus 740 .
[0204] The processor 710 is the computing core and control core of the computing device 700. The processor 710 may be a very large scale integrated circuit. An operating system and other software programs are installed in the processor 710, so that the processor 710 can access the memory 720 and various PCIe devices. The processor 710 includes one or more processor cores. The processor core in the processor 710 is, for example, a CPU or other specific integrated circuit ASIC. The processor 710 may also be other general-purpose processors, DSPs, FPGAs or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. In practical applications, the computing device 700 may also include multiple processors, such as Figure 1 The 3 processors shown in .
[0205] The memory 720 can be used to store computer executable program codes, which include instructions. The processor 710 executes various functional applications and data processing of the computing device 700 by running the instructions stored in the internal memory 720. The memory 720 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sending function, etc.), etc. The data storage area may store data (such as an analysis request) created during the use of the computing device 700, etc. In addition, the internal memory 720 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, a universal flash storage (UFS), etc.
[0206] The communication interface 730 is used to implement communication between the computing device 700 and external devices or components.
[0207] The bus 740 may include a path for transmitting information between the above-mentioned components (such as the processor 710, the memory 720, and the communication interface 730). In addition to the data bus, the bus 740 may also include a power bus, a control bus, and a status signal bus. However, for the sake of clarity, various buses are marked as bus 740 in the figure. Bus 740 may be a PCIe bus, or an EISA bus, UB, CXL, CCIX, etc. For example, the processor 710 can access these I / O devices via the PCIe bus. The processor 710 is connected to the memory 720 via a DDR bus. Here, different memories 720 may use different data buses to communicate with the processor 710, so the DDR bus may also be replaced by other types of data buses, and the embodiment of the present application does not limit the bus type.
[0208] It is worth mentioning that Figure 7 In the figure, the computing device 700 includes a processor 710 and a memory 720 as an example. Here, the processor 710 and the memory 720 are respectively used to indicate a type of device or equipment. In a specific embodiment, the number of each type of device or equipment can be determined according to business requirements.
[0209] The embodiment of the present application also provides a computer program product including instructions. The computer program product may be software or a program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the application performance analysis method.
[0210] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the application performance analysis method.
[0211] The present application also provides a chip system, which includes a control circuit and an interface circuit, wherein the control circuit is used to obtain an analysis request, and the interface circuit is used to implement the functions of the processor 110 and the processor 130 in the above method. In one possible design, the chip system also includes a memory for storing program instructions and / or data. The chip system can be composed of a chip, or it can include a chip and other discrete devices.
[0212] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is executed in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device or other programmable device. The computer program or instruction may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instruction may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium, for example, a floppy disk, a hard disk, a tape; it may also be an optical medium, for example, a digital video disc (DVD); it may also be a semiconductor medium, for example, a solid state drive (SSD).
[0213] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.< / pid>
Claims
1. A method for analyzing application performance, It is characterized in that The method is performed by a coprocessor in a computing device, and the method includes: In response to an analysis request, obtaining a first relationship, wherein the analysis request is used to perform a performance analysis operation on an application running in a main processor of the computing device, and the first relationship is used to record a correspondence between a physical address of a performance monitoring counter in the main processor and a virtual address associated with the coprocessor; Acquire operation information according to the first relationship, where the operation information is used to indicate the number of occurrences of a performance monitoring unit event when the main processor runs the application, and one performance monitoring counter corresponds to one performance monitoring unit event; A performance analysis result of the application is determined according to the operation information.
2. The application performance analysis method according to claim 1, It is characterized in that Before responding to the analysis request, the method further includes: Obtaining a physical address of a performance monitoring counter in the main processor; A first relationship between the physical address and a virtual address associated with the coprocessor is established.
3. The application performance analysis method according to claim 1 or 2, It is characterized in that The main processor includes a plurality of performance counters, and the physical address of each performance monitoring counter has a unique corresponding relationship with the virtual address associated with the coprocessor.
4. The application performance analysis method according to any one of claims 1 to 3, It is characterized in that The acquiring the operation information according to the first relationship includes: The operation information is obtained from the virtual address according to the first relationship at a first frequency, wherein the first frequency is greater than or equal to a set threshold.
5. The application performance analysis method according to any one of claims 1 to 4, It is characterized in that The determining the performance analysis result of the application according to the operation information includes: Determining the type of the operation information, and obtaining a setting analysis rule matching the type of the operation information; The operating information is subjected to performance analysis according to the set analysis rule to obtain the performance analysis result.
6. An application performance analysis device, It is characterized in that The application performance analysis device is applied to a coprocessor in a computing device, and the application performance analysis device comprises: a first acquisition module, a second acquisition module and a determination module; a first acquisition module, configured to acquire a first relationship in response to an analysis request for performing a performance analysis operation on an application running in a main processor of the computing device, the first relationship being configured to record a correspondence between a physical address of a performance monitoring counter in the main processor and a virtual address associated with the coprocessor; a second acquisition module, configured to acquire operation information according to the first relationship, wherein the operation information is used to indicate the number of occurrences of a performance monitoring unit event when the main processor runs the application, and one performance monitoring counter corresponds to one performance monitoring unit event; A determination module is used to determine a performance analysis result of the application according to the operation information.
7. The application performance analysis device according to claim 6, It is characterized in that The application performance analysis device further includes: a relationship establishment module, which is used to obtain the physical address of the performance monitoring counter in the main processor and establish a first relationship between the physical address and the virtual address associated with the coprocessor.
8. The application performance analysis device according to claim 6 or 7, It is characterized in that The main processor includes a plurality of performance counters, and the physical address of each performance monitoring counter has a unique corresponding relationship with the virtual address associated with the coprocessor.
9. The application performance analysis device according to any one of claims 6 to 8, It is characterized in that The second acquisition module is further used to acquire the operation information from the virtual address according to the first relationship at a first frequency, where the first frequency is greater than or equal to a set threshold.
10. The application performance analysis device according to any one of claims 6 to 9, It is characterized in that The determination module is further configured to determine the type of the operation information, obtain a set analysis rule matching the type of the operation information, and perform performance analysis on the operation information according to the set analysis rule to obtain the performance analysis result.
11. A chip, It is characterized in that The method comprises a control circuit and an interface circuit, wherein the interface circuit is used to obtain an analysis request, and the control circuit is used to execute the method according to any one of claims 1 to 5 according to the analysis request.
12. A computing device, It is characterized in that include: Processor and memory; The memory stores instructions, and the processor calls the instructions to implement the method according to any one of claims 1 to 5.
13. An application performance analysis system, It is characterized in that The application performance analysis system includes a main processor and a coprocessor; The main processor is used to send an analysis request; The coprocessor is used to respond to the analysis request and execute the method according to any one of claims 1 to 5 according to the analysis request.
14. A computer-readable storage medium, It is characterized in that The method comprises computer program instructions. When the computer program instructions are executed by an electronic device, the electronic device performs the method according to any one of claims 1 to 5.
Citation Information
Cited By
Microarchitecture performance analysis method and device, readable storage medium and program product
CN119621493A
Distributed service performance analysis method and system and storage medium
CN119621511A
Message transmission method and apparatus, electronic device, computer-readable storage medium, and product
WO2026200236A1
