Application exception attribution method and device, equipment, medium and product
By periodically obtaining and analyzing the running status of the target application, combining the time points in the exception information, the accuracy of ANR exception attribution is solved, and the credibility of exception attribution and the efficiency of application updates is improved.
Patent Information
- Application Number
- CN202411216194.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-06
AI Technical Summary
The prior art is difficult to accurately attribute and analyze application unresponsive (ANR) anomalies that cause user interface freezing, resulting in lack of certainty and credibility in the analysis results, and it is difficult to find the root cause of the problem.
By periodically obtaining the running status of the target application, combining the start and end time points in the exception information, determining the start and end points of the exception, and attributing based on the difference in the running status, achieving accurate attribution of application exceptions.
It improves the credibility of exception attribution, can lock out exception periods and causes more accurately, and improves the efficiency and effectiveness of application updates.
Smart Images

Figure CN119088705A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an attribution method, device, equipment, medium and product for application anomaly. Background Art
[0002] Application Not Responding (ANR) is a type of exception, which specifically refers to the situation where the application on the terminal cannot respond to the user's interactive operations within the specified time when performing some time-consuming operations on the main thread, such as key presses, touches, etc., resulting in the freezing of the user interface. Therefore, it is necessary to provide an attribution method for application not responding exceptions to analyze application not responding in order to better update the application. Summary of the invention
[0003] In view of this, the present invention provides an application abnormality attribution method, device, equipment, medium and product to solve the problem of attribution of unresponsive applications in terminals.
[0004] In a first aspect, the present invention provides an attribution method for application anomalies, comprising: periodically acquiring the running state of a target application to obtain a first running state corresponding to a periodic measurement point; if abnormal information of the target application is received, acquiring the running state of the target application to obtain a second running state corresponding to the abnormal measurement point, wherein the abnormal information includes the start and end time points of the target application anomaly; based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points, determining a first measurement point and a second measurement point, wherein the first measurement point is used to characterize the start point of the target application anomaly, and the second measurement point is used to characterize the end point of the target application anomaly; and attributing the target application anomaly based on the difference in the running states corresponding to the first measurement point and the second measurement point.
[0005] In a second aspect, the present invention provides an attribution device for application anomalies, comprising: a first acquisition module, used to periodically acquire the running state of a target application, and obtain a first running state corresponding to a periodic measurement point; a second acquisition module, used to acquire the running state of the target application if abnormal information of the target application is received, and obtain a second running state corresponding to the abnormal measurement point, wherein the abnormal information includes the start and end time points of the target application abnormality; a measurement point determination module, used to determine a first measurement point and a second measurement point based on a time relationship between periodic measurement points and / or abnormal measurement points and the start and end time points, wherein the first measurement point is used to characterize the starting point of the target application abnormality, and the second measurement point is used to characterize the end point of the target application abnormality; and an attribution module, used to attribute the target application abnormality based on the difference in the running states corresponding to the first measurement point and the second measurement point.
[0006] In a third aspect, the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method for attributing application anomalies of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0007] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to cause a computer to execute the method for attributing application anomalies according to the first aspect or any corresponding embodiment thereof.
[0008] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the method for attributing application anomalies according to the first aspect or any corresponding embodiment thereof.
[0009] The attribution method, device, equipment, medium and product of application anomaly provided by the embodiment of the present invention acquires the first running state of the target application at each periodic measurement point to realize high-frequency collection of the first running state of the target application, so as to facilitate accurate collection of the abnormal measurement point where the application has an abnormality. When the abnormal information is obtained, the second running state corresponding to the abnormal measurement point is acquired, and the first measurement point used to characterize the start of the abnormality and the second measurement point used to characterize the end of the abnormality are determined in combination with the periodic measurement point, the abnormal measurement point and the start and end time of the target application abnormality, so that the abnormal period of the target application can be determined according to the difference in the running state of the first measurement point and the second measurement point, so that the abnormal period can be attributed according to the target application data generated during the abnormal period, thereby combining the actual collected running state data to realize accurate attribution of the target application abnormality, improve the credibility of the abnormal attribution, so as to facilitate better updating of the application. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0011] Figure 1 It is a schematic diagram of a scenario in which an ANR abnormality is determined in an embodiment of the present disclosure;
[0012] Figure 2 It is a schematic diagram of attributing the ANR abnormality in the related art;
[0013] Figure 3is a flow chart of an application anomaly attribution method according to an embodiment of the present invention;
[0014] Figure 4 is a schematic diagram of attributing an ANR anomaly according to an embodiment of the present invention;
[0015] Figure 5 is a flow chart of another application anomaly attribution method according to an embodiment of the present invention;
[0016] Figure 6 is a flow chart of another attribution method for application anomalies according to an embodiment of the present invention;
[0017] Figure 7 is a structural block diagram of an application anomaly attribution device according to an embodiment of the present invention;
[0018] Figure 8 It is a schematic diagram of the hardware structure of the electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0020] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0021] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0022] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0023] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0024] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0025] ANR is a type of exception. Usually, the system determines this type of exception in the following way: the interactive system receives user input and forwards it to the window system; the window system packages the input event and sends it to the main thread of the foreground application, and sets a timer, usually 5 seconds; if the main thread processes the input event in time and sends the receipt message back to the window system, the window system stops the timer, otherwise it will trigger the timer timeout, which will then trigger the application unresponsive process, such as Figure 1 shown.
[0026] For the exception of application unresponsiveness, it is actually necessary to understand the status and activity of the main thread during the period between the distribution of input events and the timeout to analyze why the input event cannot be executed. However, since the occurrence of ANR cannot be predicted, it is impossible to measure in advance, resulting in the time range of the debugging information not matching the time period when the exception occurred. Either the time range of the debugging information is too long, or the measurement time is outdated, making it difficult to correctly reflect the accurate information during the exception process.
[0027] Therefore, compared with crash exceptions, the causes of application unresponsiveness are more complicated and the difficulty of debugging is also higher.
[0028] For ANR type of anomalies, we can actually solve it by frequently measuring at a very small time granularity. However, because many applications will run simultaneously in the system, and the occurrence of application unresponsiveness events is probabilistic, if the system adopts a high-frequency collection strategy, it will greatly increase the system load and seriously affect the performance and power consumption of the device. In order not to affect the performance and power consumption of the device, the current ANR anomaly is usually solved by inference, such as Figure 2 As shown, the activity of the application within 1 minute can be collected in measurement 1, and the operating status of the system and application during the abnormal period can be inferred from the data collected in measurement 1; or the activity information within 1 to 10 seconds after the unresponsive event occurs can be collected in measurement 2 (such as the activity information between abnormal measurement 1 and abnormal measurement 2), and the operating status of the system and application during the abnormal period can be inferred from the activity information. This leads to a lack of certainty and accuracy in the ANR problem, reduces the credibility of the analysis results, and makes it difficult to find the root cause of the problem.
[0029] From the perspective of the application, it only needs to collect its own main thread information, and the collection scope is much smaller than the system. Therefore, the application can actually perform relatively high-frequency collection. Based on this, the disclosed technical solution relies on the high-frequency collection of the application itself to achieve accurate measurement of the abnormal period, so that the no response anomaly can be attributed according to the target application data generated during the abnormal period. In this way, combined with the actual collected running status data, accurate attribution of the target application anomaly is achieved, and the credibility of the anomaly attribution is improved.
[0030] According to an embodiment of the present invention, an embodiment of a method for attributing an application anomaly is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0031] In this embodiment, a method for attributing application anomalies is provided, which can be used in electronic devices such as mobile phones, tablet computers, and computers. Figure 3 is a flow chart of a method for attributing application anomalies according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0032] Step S101, periodically acquiring the running state of the target application to obtain a first running state corresponding to a periodic measurement point.
[0033] The first running state is characterized by running data, and whether the running of the target application is abnormal can be determined based on the running data. Specifically, the running data may include CPU usage, memory usage, number of threads, request processing speed, error rate and other performance indicator data related to the target application. The target application is deployed in an electronic device. Depending on the type of the target application and the running environment in which it is located, a thread for monitoring the running state can be deployed in the target application, and a monitoring period for the thread can be set, such as 1 second, 3 seconds, 5 seconds, etc. The monitoring period is not specifically limited here, and those skilled in the art can set it according to actual needs.
[0034] Each cycle corresponds to a cycle measurement point. During the operation of the target application, the operation data of the target application is periodically monitored by the monitoring thread to obtain the operation data of each cycle measurement point, such as Figure 3 Then, the electronic device can analyze the operation data and extract data related to the operation status to obtain the first operation status of the target application at each periodic measurement point.
[0035] Furthermore, after obtaining the first operating state of the target application at each periodic measurement point, data of the first operating state may be stored, for example, in a database, a file or a log system, to facilitate subsequent analysis and query.
[0036] Step S102: if the abnormal information of the target application is received, the running state of the target application is acquired to obtain a second running state corresponding to the abnormal measurement point, wherein the abnormal information includes the start and end time points of the abnormality of the target application.
[0037] Combined with the first running state of the target application at each periodic measurement point, it is determined whether the target application is in an abnormal state of no response. The second running state is characterized by the abnormal running data monitored during the abnormality. The abnormal measurement point is the time point when the target application is measured when the abnormal information is received, such as Figure 4 When the electronic device receives the abnormal information of the target application, the monitoring thread deployed in the target application can be controlled to obtain the abnormal operation data generated by the target application at the abnormal measurement point, and the second operation state when the target application is abnormal can be determined by analyzing the abnormal operation data.
[0038] When an exception occurs in the target application, it will generate exception information and send it to the electronic device. Correspondingly, the electronic device can receive the exception information of the target application. Among them, the exception information includes the start and end time points of the target application exception, that is, the start time point of the exception and the end time point of the exception. The abnormal time period when the target application exception occurs can be determined by the start and end time points of the exception, which is convenient for attributing the abnormality of the target application according to the operating data of the abnormal time period.
[0039] Step S103: determining a first measurement point and a second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points.
[0040] The first measurement point is used to characterize the starting point of the target application exception, and the second measurement point is used to characterize the ending point of the target application exception.
[0041] Periodic measurement points are generated based on periodic measurements, and the time interval between each periodic measurement point is fixed. Figure 4 As shown, if the set period is 3s, the time interval between period measurement point n-3 and period measurement point n-2 is 3s, the time interval between period measurement point n-2 and period measurement point n-1 is 3s, and the time interval between period measurement point n-1 and period measurement point n is 3s.
[0042] Abnormal measurement points are measurement points where the operating status is monitored immediately when an abnormality occurs, such as Figure 3As shown, after an abnormality occurs, the operating status needs to be measured immediately.
[0043] When an exception occurs in the target application, in order to lock the exception segment where the exception occurs, the first measurement point and the second measurement point can be determined by combining the distance between the periodic measurement point and the exception start time point, the distance between the periodic measurement point and the exception end time point, and the distance between the exception measurement point and the exception end time point.
[0044] Step S104: attributing the target application abnormality based on the difference in the running status corresponding to the first measurement point and the second measurement point.
[0045] The running status of the target application obtained from the first measurement point and the second measurement point are compared to determine the data with differences, such as CPU usage, memory usage, network latency, error rate, etc. Then, based on the differences in the running status, the possible causes of the abnormality of the target application are analyzed.
[0046] For example, by detecting the difference in running status, it is determined that the CPU or memory usage at the second measurement point is too high compared to the first measurement point, which may be due to insufficient resources causing the target application to be abnormal; or by detecting the difference in running status, it is determined that certain operations (such as database queries, network requests, etc.) have performance degradation at the second measurement point, which may be due to a performance bottleneck causing the target application to be abnormal.
[0047] After determining the difference of one or more data based on the difference in the running status, the difference data can be further analyzed to conduct troubleshooting and verification to determine the root cause of the abnormality of the target application.
[0048] The attribution method of application anomalies provided in this embodiment acquires the first running state of the target application at each periodic measurement point to achieve high-frequency acquisition of the first running state of the target application, so as to facilitate accurate acquisition of the abnormal measurement point where the abnormality occurs. When the abnormal information is obtained, the second running state corresponding to the abnormal measurement point is acquired, and the first measurement point used to characterize the start of the abnormality and the second measurement point used to characterize the end of the abnormality are determined in combination with the periodic measurement point, the abnormal measurement point and the start and end time of the target application abnormality, so that the abnormal period of the target application can be determined according to the difference in the running state between the first measurement point and the second measurement point, so that the abnormality can be attributed according to the target application data generated during the abnormal period, thereby combining the actual collected running state data to achieve accurate attribution of the target application abnormality, improve the credibility of the abnormal attribution, so as to facilitate better updating of the application.
[0049] In this embodiment, a method for attributing application anomalies is provided, which can be used in electronic devices such as mobile phones, tablet computers, and computers. Figure 5 is a flow chart of a method for attributing application anomalies according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:
[0050] Step S201, periodically obtain the running state of the target application program, and obtain the first running state corresponding to the periodic measurement point. Figure 3 Step S101 of the illustrated embodiment will not be described in detail here.
[0051] Step S202: If the abnormal information of the target application is received, the running state of the target application is obtained, and the second running state corresponding to the abnormal measurement point is obtained. The abnormal information includes the start and end time points of the abnormality of the target application. Figure 3 Step S102 of the illustrated embodiment will not be described in detail here.
[0052] Step S203: determining a first measurement point and a second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points.
[0053] The first measurement point is used to characterize the start point of the target application exception, and the second measurement point is used to characterize the end point of the target application exception.
[0054] Specifically, the start and end time points include a start time point and an end time point, and the above step S203 includes:
[0055] Step S2031: determine a first period measurement point closest to the start time point among the period measurement points, and determine the first period measurement point as the first measurement point.
[0056] Each periodic measurement point is compared with the start time point of no response to determine the periodic measurement point that is closer to the start time point of no response, and the periodic measurement point is used as the first measurement point. Figure 4 As shown, assuming that the duration of the abnormal state is 5 seconds and the time interval of periodic monitoring is 3 seconds, if abnormal information is monitored between periodic measurement point n-1 and periodic measurement point n, a point closer to the start time of the abnormality can be taken from periodic measurement point n-2 and periodic measurement point n-1 as the first measurement point.
[0057] Step S2032: determining a second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the end time point.
[0058] Each periodic measurement point and abnormal measurement point is compared with the abnormal end time point to determine a periodic measurement point or abnormal measurement point closer to the abnormal end time point, and the periodic measurement point or abnormal measurement point is used as the second measurement point.
[0059] Specifically, take the no response exception as an example, such as Figure 4 As shown, assuming that the duration of the unresponsive abnormal state is 5 seconds and the time interval of the periodic monitoring is 3 seconds, if unresponsive abnormal information is monitored between the periodic measurement point n-1 and the periodic measurement point n, a point closer to the end time point of the unresponsive abnormality can be selected from the periodic measurement point n-1 and the periodic measurement point n as the second measurement point; the periodic measurement point closer to the start time point of the unresponsive abnormality can also be selected from the periodic measurement points as the first measurement point, and a point closer to the end time point of the unresponsive abnormality can be selected from the periodic measurement points and the abnormal measurement points as the second measurement point.
[0060] The abnormal time period when the target program is abnormal is locked by the first measurement point and the second measurement point, so that the cause of the abnormality of the target application program can be analyzed according to the difference in running status between the first measurement point and the second measurement point.
[0061] In some optional implementations, the above step S2032 includes: determining the abnormal measurement point as the second measurement point.
[0062] If, after receiving the abnormal information, the electronic device can respond immediately to start monitoring the unresponsive state, then compared with the periodic measurement point, the distance between the abnormal measurement point and the end time point of the abnormal state will be very close, that is, the abnormal measurement point is almost the second measurement point. At this time, the abnormal measurement point can be directly used as the second measurement point.
[0063] In the above implementation, the abnormal measurement point is directly determined as the second measurement point, which ensures the accuracy of the end time point of the target application abnormality, further improves the accurate locking of the abnormal time period, and facilitates the subsequent accurate determination of the cause of the abnormality.
[0064] In some optional implementations, the above step S2032 includes:
[0065] Step a1: determine a second period measurement point closest to the end time point among the period measurement points.
[0066] Step a2, respectively determining a first time difference between the second period measurement point and the end time point, and a second time difference between the abnormal measurement point and the end time point.
[0067] Step a3, determining the minimum absolute value of the first time difference and the second time difference.
[0068] Step a4: determine the time point corresponding to the minimum absolute value as the second measurement point.
[0069] Since the periodic measurement point may just hit the abnormal end point of the target application, in order to determine the point between the periodic measurement point and the abnormal measurement point that is closest to the end time point, it is necessary to further compare the distance between the periodic measurement point and the abnormal measurement point and the end time point in order to obtain an accurate second measurement point.
[0070] Specifically, by comparing the distance between each period measurement point and the abnormal end time point, the period measurement point closest to the end time point (i.e., the second period measurement point) is determined. The time difference between the second period measurement point and the end time point (i.e., the first time difference) is calculated, and the time difference between the abnormal measurement point and the end time point (i.e., the second time difference) is calculated. The absolute values of the first time difference and the second time difference are compared, and the time point with the smaller absolute value is determined as the second measurement point.
[0071] like Figure 4 As shown, the periodic measurement point n is used as the second periodic measurement point, and the first time difference t1 between the periodic measurement point n and the end time point, and the second time difference t2 between the abnormal measurement point and the end time point are calculated respectively. The absolute values of the first time difference t1 and the second time difference t2 are compared to determine the minimum absolute value, and the measurement point corresponding to the minimum absolute value is used as the second measurement point. If the absolute value of the second time difference is the smallest, the abnormal measurement point is used as the second measurement point, and if the absolute value of the first time difference is the smallest, the second periodic measurement point is used as the second measurement point.
[0072] In the above implementation, the second measurement point is determined by combining the first time difference between the second period measurement point and the end time point, and the second time difference between the abnormal measurement point and the end time point, so as to accurately lock the end time of the abnormality, thereby restoring the real unresponsive scene and achieving more accurate attribution.
[0073] Step S204: Attributing the target application exception based on the difference in the running status corresponding to the first measurement point and the second measurement point. Figure 3 Step S104 of the illustrated embodiment will not be described in detail here.
[0074] The attribution method for application anomalies provided in this embodiment uses the first period measurement point closest to the start time point as the first measurement point, and determines the second measurement point based on the time relationship between the period measurement point and / or the anomaly measurement point and the end time point, thereby accurately locating the abnormal time period in which the anomaly occurs, facilitating subsequent anomaly attribution for the abnormal time period.
[0075] In this embodiment, a method for attributing application anomalies is provided, which can be used in electronic devices such as mobile phones, tablet computers, and computers. Figure 6 is a flow chart of a method for attributing application anomalies according to an embodiment of the present invention. Figure 6 As shown, the process includes the following steps:
[0076] Step S301, periodically obtain the running state of the target application program, and obtain the first running state corresponding to the periodic measurement point. Figure 5 Step S201 of the illustrated embodiment will not be described in detail here.
[0077] Step S302: If the abnormal information of the target application is received, the running state of the target application is obtained, and the second running state corresponding to the abnormal measurement point is obtained. The abnormal information includes the start and end time points of the abnormality of the target application. Figure 5 Step S202 of the illustrated embodiment will not be described in detail here.
[0078] Step S303: Determine the first measurement point and the second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points. The first measurement point is used to characterize the start point of the target application abnormality, and the second measurement point is used to characterize the end point of the target application abnormality. Figure 5 Step S203 of the illustrated embodiment will not be described in detail here.
[0079] Step S304: attributing the target application abnormality based on the difference in the running status corresponding to the first measurement point and the second measurement point.
[0080] Specifically, the running state of the target application includes the time information of the main thread of the target application, and the time information is used to represent the running time of the main thread of the target application. Accordingly, the above step S304 includes:
[0081] Step S3041: determine the time difference between the time information corresponding to the second measurement point and the time information corresponding to the first measurement point.
[0082] After determining the first measurement point and the second measurement point, since the second measurement point is a measurement point determined after the abnormality occurs and used to characterize the abnormal end time point, the time information collected at the second measurement point can be compared with the time information collected at the first measurement point to determine the time difference between the second measurement point and the first measurement point.
[0083] In some optional implementations, the time information of the main thread includes the total running time and the total waiting time, wherein the total running time indicates the total time the main thread runs on the CPU, and the total waiting time indicates the total time the main thread waits on the CPU, and the total running time and the total waiting time can be obtained by a monitoring thread deployed in the target application. Accordingly, the above step S3041 includes:
[0084] Step b1, calculating the difference between the total running time corresponding to the second measuring point and the total running time corresponding to the first measuring point to obtain the running time.
[0085] Step b2, calculating the difference between the total running time corresponding to the second measuring point and the total waiting time corresponding to the first measuring point to obtain the waiting time.
[0086] Step b3, calculating the measurement time between the second measurement point and the first measurement point.
[0087] Step b4, obtaining the sleep duration based on the difference between the measured duration and the running duration and the waiting duration, wherein the time difference includes the running duration, the waiting duration and the sleep duration.
[0088] The total running time corresponding to the second measurement point is subtracted from the total running time corresponding to the first measurement point to obtain the running time generated by the main thread between the first measurement point and the second measurement point. At the same time, the total waiting time corresponding to the second measurement point is subtracted from the total waiting time corresponding to the first measurement point to obtain the waiting time generated by the main thread between the first measurement point and the second measurement point.
[0089] The measurement duration represents the time interval between the first measurement point and the second measurement point, that is, the measurement duration between the first measurement point and the second measurement point can be obtained by performing a difference processing between the time point corresponding to the second measurement point and the time point corresponding to the first measurement point.
[0090] The sleep duration of the main thread can be calculated by combining the difference between the measured duration, the running duration, and the waiting duration.
[0091] Specifically, taking time T1 as the time point of the first measurement point and time T2 as the time point of the second measurement point, the measurement duration is T2-T1; the monitoring thread deployed in the target application can obtain the total running time Exec1 and the total waiting time Wait1 of the current main thread at time T1, and the total running time Exec2 and the total waiting time Wait2 of the main thread at time T2 through the set monitoring node, then within the running period from time T1 to time T2, the running time Exec=Exec2-Exec1 and the waiting time Wait=Wait2-Wait1 of the current main thread can be determined. Furthermore, the sleep duration Sleep=(T2-T1)-Exec-Wait=(T2-T1)-(Exec2-Exec1)-(Wait2-Wait1) can be calculated.
[0092] In the above implementation, by calculating the running time, waiting time, measuring time and sleeping time, the state of the main thread of the target application when executing tasks and waiting for resources can be determined, which facilitates the subsequent determination of the cause of the application exception through this state.
[0093] Step S3042, attributing the target application exception based on the time difference.
[0094] Based on the time difference, it can be determined whether there is an abnormality in the target application at the time level. If there is an abnormality at the time level, unresponsiveness analysis can be performed in combination with the specific time difference to determine the specific cause of the abnormality.
[0095] In some optional implementations, the above step S3042 includes:
[0096] Step c1, calculating the ratio of the running time to the measuring time to obtain the running ratio.
[0097] Step c2, calculating the ratio of the waiting time to the measurement time to obtain the waiting ratio.
[0098] Step c3, calculating the ratio of the sleep duration to the measured duration to obtain the sleep ratio.
[0099] Step c4, attributing the target application exception based on the running ratio, the waiting ratio, and the sleeping ratio.
[0100] The run ratio indicates the proportion of time the main thread is in the running state. The run ratio of the main thread can be calculated by combining the running time and the measurement time.
[0101] The waiting ratio indicates the proportion of time the main thread is in the waiting state. The waiting ratio of the main thread can be calculated by combining the running time and the waiting time.
[0102] The sleep ratio indicates the proportion of time the main thread is in sleep state. The sleep ratio of the main thread can be calculated by combining the sleep duration and the wait duration.
[0103] A high Run Ratio indicates that the main thread is performing a lot of calculations or processing tasks, which may be a normal workload or may indicate a performance bottleneck or resource contention. If the Run Ratio increases suddenly or remains high, you may need to investigate further to see if there is a process or task that is taking up too much CPU resources.
[0104] The wait state usually means that the main thread is waiting for some resources (such as I / O operations, locks, signals, etc.) to be available. A higher wait ratio may indicate a resource bottleneck, I / O busy or contention. If the wait ratio is abnormally high, you need to check the usage of related resources, such as disk I / O, network bandwidth, memory, etc., to determine whether there is a problem of insufficient resources or contention.
[0105] The sleep state usually means that the process is temporarily not executing, waiting for an event or condition to occur. A high sleep ratio may indicate that the system is idle or does not have enough workload. However, if the sleep ratio suddenly drops or remains at a low level, it may mean that there is an abnormal situation in the system, such as a process being blocked, deadlocked, or other problems that prevent it from entering the sleep state.
[0106] Therefore, combining the running ratio, waiting ratio, and sleeping ratio can provide clues and indications for the abnormalities of the target application, so that the specific cause of the abnormality can be quickly analyzed, thereby improving the efficiency of abnormality attribution.
[0107] In the above implementation, by calculating the running ratio, the waiting ratio and the sleeping ratio, the running state of the main thread of the target application can be accurately determined, so that the abnormality can be accurately attributed according to the running state.
[0108] In some optional implementations, the running state of the target application further includes the kernel running time and the user state running time, and the above step S304 further includes:
[0109] Step S3043: Attributing the target application exception based on the kernel running time and the user mode running time between the first measurement point and the second measurement point.
[0110] The kernel running time indicates the running time of the main thread in kernel state, and the user state running time indicates the running time of the main thread in user state. The monitoring thread deployed in the target application can obtain the running time of the main thread in user state and kernel state through the set running monitoring node, and determine the time spent by the main thread in kernel state or user state through the running time.
[0111] Furthermore, the running ratio of the main thread in kernel mode can be determined by combining the kernel running time, and the running ratio of the main thread in user mode can be determined by combining the user running time. Therefore, it is possible to determine whether other threads of the same process are currently preempting the main thread based on the running ratio. In this way, the exception attribution for the target application can be achieved from the preemption level of the main thread.
[0112] In some optional implementations, the running state of the target application further includes a page fault exception, and the above step S304 further includes:
[0113] Step S3044: attributing the target application exception based on the page fault exception between the first measurement point and the second measurement point.
[0114] Page fault exceptions can reflect the target application's activity in memory requests and input / output (IO) activity. Specifically, page fault exceptions include minor page fault exceptions and major page fault exceptions. A minor page fault exception occurs when a page is already in physical memory, but for some reason (such as the page being swapped out to disk), it needs to be reloaded into memory. A major page fault exception occurs when a page is not in physical memory and needs to be read from disk and loaded into memory. When designing and implementing the target application, the occurrence of page fault exceptions should be reduced as much as possible to improve the performance and stability of the target application.
[0115] The monitoring thread deployed in the target application can detect whether a page fault exception occurs in the target application. When an exception occurs, the detection results of the second measurement point and the first measurement point in terms of the page fault exception are retrieved to determine whether a page fault exception occurs. Thus, when an exception occurs in the target application, the abnormality attribution of the target application can be achieved from the page fault exception level by detecting the page fault exception.
[0116] In some optional implementations, the running state of the target application further includes a memory state, and the above step S304 further includes:
[0117] Step S3045: attributing the target application exception based on the change in the memory state between the first measurement point and the second measurement point.
[0118] Changes in memory status include changes in virtual memory and physical memory. The target application can request the use of virtual memory and physical memory through the interface provided by the operating system. The operating system will allocate physical memory or virtual memory to the target application and reclaim it after the target application releases the memory to ensure the normal operation of the target application.
[0119] The change in the memory state can reflect whether the target application's memory usage is excessive, thereby monitoring the change in the memory state at the second measurement point compared to the first measurement point to achieve abnormal attribution of the target application's memory usage.
[0120] In some optional implementations, the duration between adjacent periodic measurement points is less than the timeout duration of the target application exception.
[0121] The abnormal timeout duration indicates the duration of the abnormal state after the abnormality occurs, such as 5 seconds, 8 seconds, 10 seconds, etc. Here, by setting the duration between adjacent periodic measurement points to be less than the abnormal timeout duration, it is possible to ensure that the abnormal state of the target application is monitored through the periodic measurement points, which facilitates the effective collection of operating data under the abnormal state of the target application.
[0122] The attribution method of application exceptions provided in this embodiment determines the cause of the current exception of the target application through the time difference between the time information corresponding to the second measurement point and the time information corresponding to the first measurement point, thereby realizing the attribution of the exception to the target application from the difference in running time, and facilitating the debugging and analysis of the exception of the target application based on the time difference. Whether there is preemption of the main thread is determined through the kernel running time and the user state running time, thereby realizing the attribution of the exception of the target application in the kernel state and the user state by analyzing the kernel running time and the user state running time. Thus, by analyzing the abnormal length of page faults, the attribution of the exception of the target application in memory application is realized. The change of memory state can reflect whether the memory usage of the target application is too much, thereby realizing the attribution of the exception of the target application in memory usage by analyzing the change of memory state.
[0123] In this embodiment, an attribution device for application anomalies is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0124] This embodiment provides an application abnormality attribution device, such as Figure 7 As shown, including:
[0125] The first acquisition module 501 is used to periodically acquire the running state of the target application program to obtain a first running state corresponding to a periodic measurement point.
[0126] The second acquisition module 502 is used to acquire the running state of the target application program if the abnormal information of the target application program is received, and obtain the second running state corresponding to the abnormal measurement point, wherein the abnormal information includes the start and end time points of the abnormality of the target application program.
[0127] The measurement point determination module 503 is used to determine the first measurement point and the second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points, wherein the first measurement point is used to characterize the start point of the target application abnormality, and the second measurement point is used to characterize the end point of the target application abnormality.
[0128] The attribution module 504 is used to attribute the target application exception based on the difference in the running status corresponding to the first measurement point and the second measurement point.
[0129] In some optional implementations, the start and end time points include a start time point and an end time point, and the measurement point determination module 503 includes:
[0130] The first measurement point determination unit is used to determine a first period measurement point closest to the start time point among the period measurement points, and determine the first period measurement point as the first measurement point.
[0131] The second measurement point determination unit is used to determine the second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the end time point.
[0132] In some optional implementations, the second measurement point determination unit includes:
[0133] The determination subunit is used to determine the abnormal measurement point as the second measurement point.
[0134] In some optional implementations, the second measurement point determination unit includes:
[0135] The period measurement point determination subunit is used to determine the second period measurement point closest to the end time point among the period measurement points.
[0136] The time difference determination subunit is used to respectively determine a first time difference between a second period measurement point and an end time point, and a second time difference between an abnormal measurement point and an end time point.
[0137] The minimum value determination subunit is used to determine the minimum absolute value of the first time difference value and the second time difference value.
[0138] The second measurement point determination subunit is used to determine the time point corresponding to the minimum absolute value as the second measurement point.
[0139] In some optional implementations, the running state of the target application includes time information of the main thread of the target application, and the attribution module 504 includes:
[0140] The time difference determining unit is used to determine the time difference between the time information corresponding to the second measurement point and the time information corresponding to the first measurement point.
[0141] The first attribution unit is used to attribute the target application exception based on the time difference.
[0142] In some optional implementations, the time information of the main thread includes the total running time and the total waiting time, and the time difference determining unit includes:
[0143] The running time calculation subunit is used to calculate the difference between the total running time corresponding to the second measurement point and the total running time corresponding to the first measurement point to obtain the running time.
[0144] The waiting time calculation subunit is used to calculate the difference between the total running time corresponding to the second measurement point and the total waiting time corresponding to the first measurement point to obtain the waiting time.
[0145] The measurement duration calculation subunit is used to calculate the measurement duration between the second measurement point and the first measurement point.
[0146] The sleep duration calculation subunit is used to obtain the sleep duration based on the difference between the measured duration and the running duration and the waiting duration, where the time difference includes the running duration, the waiting duration and the sleep duration.
[0147] In some optional implementations, the first attribution unit includes:
[0148] The operation ratio calculation subunit is used to calculate the ratio of the operation time to the measurement time to obtain the operation ratio.
[0149] The waiting ratio calculation subunit is used to calculate the ratio of the waiting time to the measured time to obtain the waiting ratio.
[0150] The sleep ratio calculation subunit is used to calculate the ratio of the sleep duration to the measured duration to obtain the sleep ratio.
[0151] The unresponsiveness attribution unit is used to attribute target application exceptions based on the running ratio, waiting ratio, and sleeping ratio.
[0152] In some optional implementations, the running state of the target application further includes kernel running time and user state running time, and the attribution module 504 further includes:
[0153] The second attribution unit is used to attribute the target application exception based on the kernel running time and the user state running time between the first measurement point and the second measurement point.
[0154] In some optional implementations, the running state of the target application further includes a page fault exception, and the attribution module 504 further includes:
[0155] The third attribution unit is used to attribute the target application exception based on the page fault exception between the first measurement point and the second measurement point.
[0156] In some optional implementations, the running state of the target application further includes a memory state, and the attribution module 504 further includes:
[0157] The fourth attribution unit is used to attribute the target application exception based on the change of the memory state between the first measurement point and the second measurement point.
[0158] In some optional implementations, the duration between adjacent periodic measurement points is less than the timeout duration of the target application exception.
[0159] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0160] The attribution device for application anomalies in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0161] The attribution device for application anomalies provided in this embodiment acquires the first running state of the target application at each periodic measurement point to achieve high-frequency acquisition of the first running state of the target application, so as to facilitate accurate acquisition of the unresponsive abnormal measurement point. When the unresponsive information is obtained, the second running state corresponding to the abnormal measurement point is acquired, and the first measurement point used to characterize the start of the abnormality and the second measurement point used to characterize the end of the abnormality are determined in combination with the periodic measurement point, the abnormal measurement point and the start and end time of the target application abnormality, so that the abnormal period of the target application can be determined according to the difference in the running state between the first measurement point and the second measurement point, so that the abnormality can be attributed according to the target application data generated during the abnormal period, thereby combining the actual collected running state data to achieve accurate attribution of the target application abnormality, improve the credibility of the abnormal attribution, so as to facilitate better updating of the application.
[0162] The embodiment of the present invention also provides an electronic device having the above Figure 7 The attribution device of the application anomaly shown.
[0163] See also Figure 8 , Figure 8 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Figure 8 As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 10 is taken as an example.
[0164] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0165] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0166] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0167] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0168] The electronic device further includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.
[0169] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0170] The electronic device also includes a communication interface, which is used for the electronic device to communicate with other devices or a communication network.
[0171] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0172] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0173] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for attributing application anomalies, characterized in that: The method comprises: Periodically acquiring the running state of the target application to obtain a first running state corresponding to a periodic measurement point; If the abnormal information of the target application is received, the running state of the target application is acquired to obtain a second running state corresponding to the abnormal measurement point, wherein the abnormal information includes the start and end time points of the abnormality of the target application; Based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points, determine a first measurement point and a second measurement point, wherein the first measurement point is used to characterize the start point of the target application abnormality, and the second measurement point is used to characterize the end point of the target application abnormality; The target application exception is attributed based on a difference in the running status corresponding to the first measurement point and the second measurement point.
2. The method according to claim 1, characterized in that The start and end time points include a start time point and an end time point, and determining the first measurement point and the second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points includes: Determine a first period measurement point closest to the start time point among the period measurement points, and determine the first period measurement point as the first measurement point; The second measurement point is determined based on a time relationship between the periodic measurement point and / or the abnormal measurement point and the end time point.
3. The method according to claim 2, characterized in that The determining the second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the end time point includes: The abnormal measurement point is determined as the second measurement point.
4. The method according to claim 2, characterized in that: The determining the second measurement point based on the time relationship between the periodic measurement point and / or the abnormal measurement point and the end time point includes: Determining a second period measurement point closest to the end time point among the period measurement points; respectively determining a first time difference between the second period measurement point and the end time point, and a second time difference between the abnormal measurement point and the end time point; Determine the minimum absolute value of the first time difference and the second time difference; The time point corresponding to the minimum absolute value is determined as the second measurement point.
5. The method according to claim 1, characterized in that The running state of the target application includes time information of a main thread of the target application, and attributing the abnormality of the target application based on the difference between the running states corresponding to the first measurement point and the second measurement point includes: determining a time difference between the time information corresponding to the second measurement point and the time information corresponding to the first measurement point; The target application anomaly is attributed based on the time difference.
6. The method according to claim 5, characterized in that The time information of the main thread includes a total running time and a total waiting time, and determining a time difference between the time information corresponding to the second measurement point and the time information corresponding to the first measurement point includes: Calculate the difference between the total running time corresponding to the second measurement point and the total running time corresponding to the first measurement point to obtain the running time; Calculate the difference between the total running time corresponding to the second measuring point and the total waiting time corresponding to the first measuring point to obtain the waiting time; calculating a measurement time between the second measurement point and the first measurement point; The sleep duration is obtained based on the difference between the measured duration and the operation duration and the waiting duration, and the time difference includes the operation duration, the waiting duration and the sleep duration.
7. The method according to claim 6, characterized in that The attributing the target application exception based on the time difference includes: Calculating the ratio of the running time to the measured time to obtain a running ratio; Calculating the ratio of the waiting time to the measurement time to obtain a waiting ratio; Calculating the ratio of the sleep duration to the measured duration to obtain a sleep ratio; The target application exception is attributed based on the running ratio, the waiting ratio, and the sleeping ratio.
8. The method according to claim 1, characterized in that: The running state of the target application further includes kernel running time and user state running time, and attributing the target application exception based on the difference between the running states corresponding to the first measurement point and the second measurement point further includes: The target application exception is attributed based on the kernel running time and the user mode running time between the first measurement point and the second measurement point.
9. The method according to claim 1, characterized in that: The running state of the target application further includes a page fault exception, and the attributing the target application exception based on the difference between the running states corresponding to the first measurement point and the second measurement point further includes: Based on the page fault exception between the first measurement point and the second measurement point, the target application exception is attributed.
10. The method according to claim 1, characterized in that The running state of the target application further includes a memory state, and attributing the abnormality of the target application based on the difference between the running states corresponding to the first measurement point and the second measurement point further includes: The target application exception is attributed based on the change of the memory state between the first measurement point and the second measurement point.
11. The method according to any one of claims 1 to 10, characterized in that The duration between adjacent periodic measurement points is less than the timeout duration of the target application exception.
12. A device for attributing application anomalies, characterized in that: The device comprises: A first acquisition module, used to periodically acquire the running state of the target application program to obtain a first running state corresponding to a periodic measurement point; A second acquisition module, configured to acquire the operating state of the target application program if the abnormal information of the target application program is received, and obtain a second operating state corresponding to the abnormal measurement point, wherein the abnormal information includes the start and end time points of the abnormality of the target application program; a measurement point determination module, configured to determine a first measurement point and a second measurement point based on a time relationship between the periodic measurement point and / or the abnormal measurement point and the start and end time points, wherein the first measurement point is used to characterize a start point of the target application abnormality and the second measurement point is used to characterize an end point of the target application abnormality; An attribution module is used to attribute the target application exception based on the difference in the running status corresponding to the first measurement point and the second measurement point.
13. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the application anomaly attribution method according to any one of claims 1 to 11 by executing the computer instructions.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the application anomaly attribution method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method for attributing application anomalies according to any one of claims 1 to 11.
