Thread resource monitoring processing method and device, storage medium and electronic equipment

By adaptively adjusting the monitoring configuration parameters and performing multi-level thread usage monitoring, combined with thread exception analysis and self-repair modules, the roughness and performance impact of thread resource monitoring and processing in the existing technology is solved, and high-reliability thread resource monitoring and processing is achieved.

CN120144394APending Publication Date: 2025-06-13SHENZHEN TCL DIGITAL TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510137535.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-07
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

In the prior art, thread resource monitoring and processing methods are relatively rough in monitoring thread usage, and the monitoring and processing process is prone to negatively affecting the system performance, and cannot effectively repair thread resource leakage, resulting in weak monitoring and processing reliability.

Method used

By obtaining monitoring configuration parameters and adaptively adjusting according to the system's operating status, multi-level thread usage monitoring is carried out, thread exception analysis is performed, and the self-repair module is called for resource leakage self-repair.

Benefits of technology

It realizes fine-grained thread usage monitoring, improves the accuracy of thread exception analysis, and effectively repairs resource leakage through self-repair modules, improving the reliability of thread resource monitoring and processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144394A_ABST
    Figure CN120144394A_ABST
Patent Text Reader

Abstract

The invention discloses a thread resource monitoring processing method and device, a storage medium and electronic equipment, and relates to the technical field of operating systems, the method comprises the following steps: obtaining monitoring configuration parameters, and performing adaptive adjustment on the monitoring configuration parameters according to a system running state to obtain dynamic monitoring parameters; performing multi-level thread use monitoring through the unit embedded monitoring logic of the unit in each process under the system level and the application level to obtain monitored thread use information in the process; performing thread exception analysis processing on the thread use information in the process according to the dynamic monitoring parameters to obtain an exceptional thread analysis result; and calling a self-repairing module to perform resource leakage self-repairing according to resource leakage information in the abnormal thread analysis result. According to the method, the thread resource monitoring processing reliability can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of operating systems, and in particular, to a method, device, storage medium, and electronic device for monitoring and processing thread resources. Background Art

[0002] In an operating system such as the Android system, threads are widely used to execute various tasks, including processing the user interface, network communication, database operations, etc. Each thread needs to be allocated a certain amount of thread resources (such as memory and processor time, etc.). However, in some cases, threads may cause resource leakage due to incorrect resource release. The leakage of thread resources may lead to a decline in the performance of the process, an extension of the response time, or even a crash, etc.

[0003] In this regard, there are some thread resource monitoring and processing methods in the related art. Usually, thread resources are monitored and processed at the system level. The monitoring of thread usage is relatively rough, and at the same time, the monitoring and processing process is likely to have a negative impact on the system performance, and it is impossible to effectively repair the thread resource leakage, resulting in weak reliability of thread resource monitoring and processing. Summary of the Invention

[0004] An embodiment of this application provides a solution that can improve the reliability of thread resource monitoring and processing.

[0005] The embodiments of this application provide the following technical solutions:

[0006] According to an embodiment of this application, a method for monitoring and processing thread resources includes: obtaining monitoring configuration parameters, and adaptively adjusting the monitoring configuration parameters according to the system running state to obtain dynamic monitoring parameters; performing multi-level thread usage monitoring through unit embedded monitoring logics of units within each process at the system level and the application level to obtain the monitored thread usage information within the process; performing thread anomaly analysis and processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result; and calling a self-repair module to perform resource leakage self-repair according to the resource leakage information in the abnormal thread analysis result.

[0007] In some embodiments of this application, after performing thread anomaly analysis and processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result, the method further includes: hierarchically integrating and judging the abnormal thread information in the abnormal thread analysis result to obtain abnormal threads to be reported; reporting the thread-related data of the abnormal threads to be reported to the cloud so that the cloud performs resource leakage diagnosis and prediction according to the thread-related data to obtain predicted leakage information; receiving the predicted leakage information sent by the cloud, and saving the predicted leakage information to a preset leakage library.

[0008] In some embodiments of the present application, hierarchically integrating and judging the abnormal thread information in the analysis result of the abnormal thread to obtain the abnormal thread to be reported, including: hierarchically recording the thread information included in the abnormal thread information into corresponding local variables; comparing the local variables and global variables at the same level to obtain the different thread information between the local variables and the global variables, where the global variable is a variable used to record the thread information of the confirmed abnormal thread; determining the thread class corresponding to the different thread information as the abnormal thread to be reported.

[0009] In some embodiments of the present application, the dynamic monitoring parameter includes a thread number threshold; the analysis result of the abnormal thread includes abnormal thread information; the process of performing thread abnormal analysis processing on the thread usage information in the process according to the dynamic monitoring parameter to obtain the analysis result of the abnormal thread includes: obtaining the total number of threads and the started threads in a single process according to the thread usage information in the process; classifying the started threads in the single process to obtain at least one thread class; if the total number of threads is greater than the thread number threshold, determining whether the number of threads in each thread class is greater than a preset intra-class threshold; determining the thread information of the thread class with the number of threads in the class greater than the preset intra-class threshold as the abnormal thread information.

[0010] In some embodiments of the present application, the analysis result of the abnormal thread further includes resource leakage information; the method further includes: comparing the thread monitoring information of the thread class with the number of threads in the class greater than the thread class threshold with the preset thread information in a preset leakage library to obtain the preset thread information matching the thread monitoring information; determining the preset leakage information corresponding to the preset thread information matching the thread monitoring information as the resource leakage information.

[0011] In some embodiments of the present application, adaptively adjusting the monitoring configuration parameters according to the system running state to obtain dynamic monitoring parameters, including: calculating the system load according to the system running state; adjusting the thread number threshold in the monitoring configuration parameters according to the system load and a preset threshold adjustment coefficient to obtain an adjusted thread number threshold, where the dynamic monitoring parameter includes the adjusted thread number threshold.

[0012] In some embodiments of the present application, adjusting the threshold number of threads in the monitoring configuration parameters according to the system load and a preset adjustment coefficient to obtain an adjusted threshold number of threads includes: calculating the adjusted threshold number of threads according to the formula Threshold_d = Threshold_0 * (1 + α * Load), where Threshold_d refers to the adjusted threshold number of threads, Threshold_0 refers to the threshold number of threads in the monitoring configuration parameters, Load refers to the system load, and α refers to the preset threshold adjustment coefficient.

[0013] In some embodiments of the present application, the method further includes: adjusting the monitoring frequency in the monitoring configuration parameters according to the system load and a preset frequency adjustment coefficient to obtain an adjusted monitoring frequency, where the adjusted monitoring frequency is included in the dynamic monitoring parameters, so as to perform thread anomaly analysis processing on the thread usage information within the process according to the adjusted monitoring frequency.

[0014] In some embodiments of the present application, the system operating state includes the CPU usage rate and the memory usage rate; calculating the system load according to the system operating state includes: calculating the system load according to the formula Load = w_CPU * CPU_Usage + w_Mem * Memory_Usage, where Load refers to the system load, CPU_Usage refers to the CPU usage rate, w_CPU refers to the weight coefficient of the CPU usage rate, Memory_Usage refers to the memory usage rate, and w_Mem refers to the weight coefficient of the memory usage rate.

[0015] According to an embodiment of the present application, a thread resource monitoring and processing device includes: a parameter module configured to: obtain monitoring configuration parameters and adaptively adjust the monitoring configuration parameters according to the system operating state to obtain dynamic monitoring parameters; a monitoring module configured to: perform multi-level thread usage monitoring through unit-embedded monitoring logics of each unit within each process at the system level and the application level to obtain the monitored thread usage information within the process; an analysis module configured to: perform thread anomaly analysis processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result; a processing module configured to: according to the resource leakage information in the abnormal thread analysis result, call a self-repair module to perform resource leakage self-repair.

[0016] According to another embodiment of the present application, a storage medium stores a computer program, which, when executed by a processor of a device, causes the device to execute the method described in the embodiments of the present application.

[0017] According to another embodiment of the present application, an electronic device may include: a memory storing a computer program; and a processor reading the computer program stored in the memory to execute the method described in the embodiments of the present application.

[0018] According to another embodiment of the present application, a computer program product or a computer program includes computer instructions stored in a computer-readable storage medium. The processor of the device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the device executes the methods provided in the various alternative implementations described in the embodiments of the present application.

[0019] In the embodiments of the present application, monitoring configuration parameters are obtained, and the monitoring configuration parameters are adaptively adjusted according to the system operation state to obtain dynamic monitoring parameters; multi-level thread usage monitoring is performed through the unit-embedded monitoring logic of each unit in the process at the system level and the application level to obtain the monitored thread usage information within the process; thread exception analysis processing is performed on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result; and according to the resource leakage information in the abnormal thread analysis result, a self-repair module is called to perform resource leakage self-repair.

[0020] In this way, through multi-level thread usage monitoring by the unit-embedded monitoring logic of each unit in the process at the system level and the application level, fine-grained thread usage information within the process can be monitored; further, thread exception analysis processing is performed on the thread usage information within the process according to the dynamic monitoring parameters, and an abnormal thread analysis result reflecting thread usage anomalies can be accurately obtained on the basis of effectively avoiding the impact of thread resource monitoring processing activities on the performance and stability of the operating system; furthermore, through a preset self-repair module, the self-repair module can be effectively called according to the resource leakage information in the abnormal thread analysis result to perform resource leakage self-repair. Furthermore, the reliability of thread resource monitoring processing is effectively improved as a whole. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative efforts.

[0022] Figure 1 The flowchart of a thread resource monitoring processing method according to an embodiment of the present application is shown.

[0023] Figure 2 The flowchart of parameter adjustment according to an embodiment of the present application is shown.

[0024] Figure 3 Shows a flowchart of thread exception analysis according to an embodiment of the present application.

[0025] Figure 4 Shows a flowchart of intelligent diagnosis according to an embodiment of the present application.

[0026] Figure 5 Shows a flowchart of hierarchical integration judgment according to an embodiment of the present application.

[0027] Figure 6 Shows an architecture diagram of a thread resource monitoring and processing system applying an embodiment of the present application in a scenario.

[0028] Figure 7 Shows a flowchart of logical embedding according to an embodiment of the present application.

[0029] Figure 8 Shows a block diagram of a thread resource monitoring and processing device according to an embodiment of the present application.

[0030] Figure 9 Shows a block diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0031] The present disclosure will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments provided herein are only used to explain the present disclosure and are not used to limit the present disclosure. In addition, the embodiments provided below are partial embodiments for implementing the present disclosure, rather than all embodiments for implementing the present disclosure. Without conflict, the technical solutions described in the embodiments of the present disclosure can be implemented in any combination.

[0032] It should be noted that in the embodiments of the present disclosure, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, so that a method or device including a series of elements not only includes the elements clearly recited, but also includes other elements not explicitly listed, or further includes elements inherent to the implementation of the method or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of other related elements in the method or device including the element (for example, steps in the method or units in the device, and the unit can be a partial circuit, a partial processor, a partial program or software, etc.).

[0033] For example, the thread resource monitoring and processing method provided by the embodiments of the present disclosure includes a series of steps. However, the thread resource monitoring and processing method provided by the embodiments of the present disclosure is not limited to the recorded steps. Similarly, the thread resource monitoring and processing device provided by the embodiments of the present disclosure includes a series of units. However, the device provided by the embodiments of the present disclosure is not limited to including the explicitly recorded units, and may also include units required for obtaining relevant information or processing based on the information.

[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this disclosure belongs. The terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this disclosure.

[0035] It can be understood that in the specific implementation of this application, when it comes to relevant data, when the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.

[0036] Figure 1 The flowchart of the thread resource monitoring and processing method according to an embodiment of the present application is schematically shown. The execution subject of this thread resource monitoring and processing method can be any device with processing capabilities, such as a TV, a computer, a mobile phone, a smart watch, and household appliances, etc.

[0037] As Figure 1 shown, this thread resource monitoring and processing method may include step S110 to step S140.

[0038] Step S110, obtain monitoring configuration parameters, and adaptively adjust the monitoring configuration parameters according to the system operation state to obtain dynamic monitoring parameters;

[0039] Step S120, perform multi-level thread usage monitoring through the unit-embedded monitoring logic of each process unit at the system level and the application level to obtain the monitored thread usage information within the process;

[0040] Step S130, perform thread anomaly analysis and processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result;

[0041] Step S140, according to the resource leakage information in the abnormal thread analysis result, call the self-healing module to perform resource leakage self-healing.

[0042] Monitoring configuration parameters are parameters used for monitoring and processing thread resources. For example, the timer period required for resource monitoring, the threshold of the number of threads, the threshold of unit resources, and so on. The system running state is the running state of the operating system. For example, the running states related to CPU, memory, the number of threads, etc. Relevant users can set the monitoring configuration parameters, and the set monitoring configuration parameters can be adaptively adjusted according to the system running state in real time, so as to obtain dynamic monitoring parameters that are more suitable for the system running state.

[0043] Furthermore, the units included in each process at the system level (i.e., system processes), such as in-process modules or components like the Bluetooth module and the wifi module, embed unit-embedded monitoring logic for monitoring thread usage. The units included in each process at the application level (i.e., application processes), such as application modules or components, also embed unit-embedded monitoring logic for monitoring thread usage.

[0044] Through the unit-embedded monitoring logic of each process unit at the system level and the application level, it is possible to monitor the thread usage of in-process units in a fine-grained manner at the system level and the application level respectively, realizing multi-level fine-grained thread usage monitoring at the system level and the application level, and obtaining the in-process thread usage information of one or more monitored processes. The in-process thread usage information is the information about the thread usage of the units included in the process. For example, the name and quantity of the threads started by the units included in the process.

[0045] Furthermore, thread exception analysis and processing are performed on the in-process thread usage information according to the dynamic monitoring parameters to obtain the exception thread analysis result. On the one hand, the dynamic monitoring parameters are more suitable for the system running state. Using the dynamic monitoring parameters for processing can effectively avoid the impact of thread resource monitoring and processing activities on the performance and stability of the operating system. On the other hand, the in-process thread usage information is monitored through the unit-embedded monitoring logic of each process unit at the system level and the application level, and can reflect the thread usage in a fine-grained manner. Therefore, the accuracy of the exception thread analysis result can be further ensured.

[0046] The exception thread analysis result is information reflecting thread usage exceptions. The exception thread analysis result may include resource leakage information and / or exception thread information. A self-repair module for self-repairing thread resource leakage is preset in the operating system. According to the resource leakage information in the exception thread analysis result, calling the self-repair module can effectively perform self-repair of resource leakage (for example, recycling the leaked resources or migrating the leaked resources to other available spaces), thus effectively repairing the thread resource leakage problem.

[0047] In this way of the embodiments of the present application, multi-level thread usage monitoring is performed through the unit-embedded monitoring logic of each unit within each process at the system level and application level, and fine-grained in-process thread usage information can be monitored. Further, based on the dynamic monitoring parameters, thread anomaly analysis and processing are performed on the in-process thread usage information, and on the basis of effectively avoiding the impact of thread resource monitoring and processing activities on the performance and stability of the operating system, an anomaly thread analysis result reflecting thread usage anomalies can be accurately obtained. Further, through a preset self-healing module, according to the resource leakage information in the anomaly thread analysis result, the self-healing module can be called to effectively perform resource leakage self-healing. Thus, the reliability of thread resource monitoring and processing is effectively improved overall.

[0048] The following describes Figure 1 Specific optional embodiments of each step when performing thread resource monitoring and processing in the embodiments.

[0049] In one embodiment, referring to Figure 2 , the adaptive adjustment of the monitoring configuration parameters according to the system operation state to obtain dynamic monitoring parameters may include: step S210, calculating the system load according to the system operation state; step S220, adjusting the thread number threshold in the monitoring configuration parameters according to the system load and a preset threshold adjustment coefficient to obtain an adjusted thread number threshold, and the adjusted thread number threshold is included in the dynamic monitoring parameters.

[0050] The thread number threshold in the monitoring configuration parameters is a threshold configured by the user for use in thread anomaly analysis and processing. The thread number threshold in the monitoring configuration parameters is adjusted according to the system load and a preset threshold adjustment coefficient to obtain an adjusted thread number threshold. This adjusted thread number threshold is more suitable for the system operation state, and the adjusted thread number threshold will be used for analysis and processing during the thread anomaly analysis and processing, which can effectively avoid the impact of thread resource monitoring and processing activities on the performance and stability of the operating system.

[0051] In one implementation manner, the system operation state includes the central processing unit usage rate and the memory usage rate; the calculating the system load according to the system operation state may specifically include: calculating the system load according to the formula Load = w_CPU * CPU_Usage + w_Mem * Memory_Usage, where Load refers to the system load, CPU_Usage refers to the central processing unit usage rate, w_CPU refers to the weight coefficient of the central processing unit usage rate, Memory_Usage refers to the memory usage rate, and w_Mem refers to the weight coefficient of the memory usage rate.

[0052] The system load Load is calculated according to the formula Load = w_CPU * CPU_Usage + w_Mem * Memory_Usage. When the system load Load is used to adjust the thread count threshold in the monitoring configuration parameters to obtain the adjusted thread count threshold, the thread count threshold can be flexibly and reliably adjusted to make it more suitable for the status of the central processing unit (CPU) and content during system operation, further effectively avoiding the impact of thread resource monitoring and processing activities on the performance and stability of the operating system.

[0053] Among them, the weight coefficient w_CPU of the central processing unit usage rate and the weight coefficient w_Mem of the memory usage rate can be set according to the actual situation, and w_CPU + w_Mem = 1 is satisfied. In some examples, since the CPU load has a greater impact on thread resources than the memory load, at this time, w_CPU can be greater than w_Mem.

[0054] Optionally, in some other implementation manners, the system operation status includes the central processing unit usage rate and the memory usage rate; calculating the system load according to the system operation status may include: system load = predetermined total system load - unoccupied system resources.

[0055] In one implementation manner, adjusting the thread count threshold in the monitoring configuration parameters according to the system load and a preset adjustment coefficient to obtain the adjusted thread count threshold may specifically include: calculating the adjusted thread count threshold according to the formula Threshold_d = Threshold_0 * (1 + α * Load), where Threshold_d refers to the adjusted thread count threshold, Threshold_0 refers to the thread count threshold in the monitoring configuration parameters, Load refers to the system load, and α refers to the preset threshold adjustment coefficient.

[0056] Calculating the adjusted thread count threshold Threshold_d according to the formula Threshold_d = Threshold_0 * (1 + α * Load) can extremely effectively implement the adjustment of the thread count threshold in the monitoring configuration parameters according to the system load and the preset adjustment coefficient. The adjusted thread count threshold Threshold_d is used in the process of thread exception analysis and processing, which can extremely effectively avoid the impact of thread resource monitoring and processing activities on the performance and stability of the operating system.

[0057] Among them, the preset threshold adjustment coefficient α can be set according to the actual situation, and the range of α can be 0 < α ≤ 1. For example, if the actual online project performance of the system is good and the operating memory is large, α can be increased, and vice versa, it can be decreased.

[0058] Further, in one embodiment, the adaptive adjustment of the monitoring configuration parameters according to the system operating state to obtain dynamic monitoring parameters may further include:

[0059] Adjust the monitoring frequency in the monitoring configuration parameters according to the system load and a preset frequency adjustment coefficient to obtain an adjusted monitoring frequency, and the adjusted monitoring frequency is included in the dynamic monitoring parameters, so as to perform thread exception analysis processing on the thread usage information within the process according to the adjusted monitoring frequency.

[0060] Adjusting the monitoring frequency in the monitoring configuration parameters according to the system load and a preset frequency adjustment coefficient to obtain an adjusted monitoring frequency, and performing thread exception analysis processing on the thread usage information within the process according to the adjusted monitoring frequency can further effectively avoid the impact of the thread resource monitoring and processing activities on the performance and stability of the operating system. Among them, performing thread exception analysis processing on the thread usage information within the process according to the adjusted monitoring frequency. For example, if the adjusted monitoring frequency is once every S hours, then the thread exception analysis processing on the thread usage information within the process can be performed every S hours.

[0061] Further, adjusting the monitoring frequency in the monitoring configuration parameters according to the system load and a preset frequency adjustment coefficient to obtain an adjusted monitoring frequency may be: calculating the adjusted thread number threshold according to the formula P_d = P_0*(1 + β*Load), where P_d refers to the adjusted monitoring frequency, P_0 refers to the monitoring frequency in the monitoring configuration parameters, Load refers to the system load, and β refers to the preset frequency adjustment coefficient.

[0062] In one embodiment, refer to Figure 3 , the dynamic monitoring parameters include a thread number threshold; the abnormal thread analysis result includes abnormal thread information; the process of performing thread exception analysis processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result may include:

[0063] Step S310, obtaining the total number of threads and the started threads within a single process according to the thread usage information within the process; Step S320, classifying the started threads within the single process to obtain at least one thread class; Step S330, if the total number of threads is greater than the thread number threshold, determine whether the number of threads within each thread class is greater than a preset within-class threshold; Step S340, determine the thread information of the thread class with the number of threads within the class greater than the preset within-class threshold as the abnormal thread information.

[0064] The information on the threads within each process can include the total number of threads started within a single process, the thread names of the started threads, and so on. Classify the threads started within a single process to obtain at least one thread class. For example, the 200 threads started within Process 1 can be classified into a first thread class and a second thread class. The first thread class can include 50 threads, and the second thread class can include 150 threads.

[0065] If the total number of threads is greater than the thread number threshold, it indicates that the threads within this single process are suspected of being abnormal. Further, determine whether the number of threads within each thread class is greater than the preset threshold within the class. If the number of threads within a certain thread class is greater than the preset threshold within the class, it indicates that this certain thread class is abnormal. For example, if the number of threads within the first thread class is 50 and the preset threshold within the class is 32, it indicates that the first thread class is abnormal.

[0066] According to this method, the abnormal thread class (i.e., the thread class with the number of threads within the class greater than the preset threshold within the class, that is, the thread class very likely to have the possibility of thread resource leakage) can be accurately determined. Determine the thread information of the thread class with the number of threads within the class greater than the preset threshold within the class as abnormal thread information, and further accurate resource leakage analysis can be carried out based on this abnormal thread information. Among them, the thread information of the thread class can at least include thread identifiers such as the names of the threads included in the thread class.

[0067] In one implementation, classify the threads started within the single process to obtain at least one thread class. Specifically, it can be: classify the threads with the same thread name main body within the single process into one class to obtain at least one thread class. For example, the thread name Thread-1 and the thread name Thread-ABC have the same thread name main body Thread, and the Thread-1 thread and the Thread-ABC thread can be classified into a thread class (Thread class), and the number of threads within this Thread class is 2.

[0068] Further, the abnormal thread analysis result also includes resource leakage information; the method further includes: comparing the thread monitoring information of the thread class with the number of threads within the class greater than the thread class threshold with the preset thread information in the preset leakage library to obtain the preset thread information that matches the thread monitoring information; determining the preset leakage information corresponding to the preset thread information that matches the thread monitoring information as the resource leakage information.

[0069] The preset leakage library stores some preset leakage information and the corresponding preset thread information of the preset leakage information. The preset leakage information can be a resource leakage point, and the preset thread information can be the preset buried point data or the preset log-related data of the thread that causes the resource leakage point to appear. By comparing the thread monitoring information (the currently monitored buried point data or log-related data) of the thread class whose currently determined number of threads within the class is greater than the thread class threshold with the preset thread information in the preset leakage library, the preset thread information that matches the thread monitoring information can be obtained (that is, the resource leakage scenario corresponding to the thread monitoring information is the same as the resource leakage scenario corresponding to the preset thread information). Furthermore, the preset leakage information corresponding to the preset thread information that matches the thread monitoring information can be determined as the resource leakage information. According to this resource leakage information, the self-repair module can be called to perform resource leakage self-repair on the resource leakage point indicated by the resource leakage information.

[0070] Further, in one embodiment, refer to Figure 4 , after performing thread anomaly analysis and processing on the in-process thread usage information according to the dynamic monitoring parameters to obtain an abnormal thread analysis result, the method may further include: Step S410, performing hierarchical integration and judgment on the abnormal thread information in the abnormal thread analysis result to obtain the abnormal threads to be reported; Step S420, reporting the thread-related data of the abnormal threads to be reported to the cloud so that the cloud can perform resource leakage diagnosis and prediction based on the thread-related data to obtain predicted leakage information; Step S430, receiving the predicted leakage information sent by the cloud and storing the predicted leakage information in the preset leakage library.

[0071] The abnormal thread information in the abnormal thread analysis result may include the thread information of the thread class within the process at the system level (i.e., the system process) and the thread information of the thread class within the process at the application level (i.e., the application process).

[0072] Performing hierarchical integration and judgment on the abnormal thread information in the abnormal thread analysis result, that is, integrating and judging the thread information of the thread class within the system process in the abnormal thread information according to the integration and judgment method corresponding to the system level, and / or integrating and judging the thread information of the thread class within the application process in the abnormal thread information according to the integration and judgment method corresponding to the application level. By performing hierarchical integration and judgment, the abnormal thread information at the system level and the application level can be judged separately, effectively ensuring the judgment accuracy. Thus, through hierarchical integration and judgment, the abnormal threads to be reported that need to be reported to the cloud for further intelligent diagnosis can be accurately obtained. The abnormal threads to be reported can be the thread classes enabled by the units within the system process and / or the thread classes enabled by the units within the application process.

[0073] Report the thread-related data (such as buried point or log data) of the abnormal thread to be reported to the cloud. The cloud can use an AI diagnosis and prediction model to perform resource leakage diagnosis and prediction based on the thread-related data to obtain predicted leakage information. The predicted leakage information can include the predicted resource leakage points and corresponding repair suggestions. The cloud sends the predicted leakage information obtained from the diagnosis and prediction to the device.

[0074] The device receives the predicted leakage information sent by the cloud and saves the predicted leakage information as preset leakage information in a preset leakage library. Thus, when it is found later that a thread class with the number of threads in the class greater than the thread class threshold is an abnormal thread to be reported, the preset leakage information matching the abnormal thread to be reported can be matched from the preset leakage library, and the self-repair module is called according to the preset leakage information to perform efficient and accurate self-repair on the predicted resource leakage points.

[0075] Further, in an embodiment, refer to Figure 5 , hierarchically integrating and judging the abnormal thread information in the analysis result of the abnormal thread to obtain the abnormal thread to be reported, which may specifically include: Step S510, hierarchically record the thread information included in the abnormal thread information into corresponding local variables; Step S520, compare the local variables and global variables at the same level to obtain the different thread information between the local variables and the global variables, where the global variable is a variable used to record the thread information of the confirmed abnormal threads; Step S530, determine the thread class corresponding to the different thread information as the abnormal thread to be reported.

[0076] Hierarchically record the thread information included in the abnormal thread information into corresponding local variables. For example, record the thread information of the thread class enabled by the unit within the process at the system level into the local variable mapA, and record the thread information of the thread class enabled by the unit within the process at the application level into the local variable mapB.

[0077] Set a corresponding global variable mContrastSystemMap at the system level, and record the thread information of the confirmed abnormal threads (i.e., the thread classes that can match the corresponding preset leakage information from the preset leakage library) at the system level in the global variable mContrastSystemMap. Set a corresponding global variable mContrastApplicationMap at the application level, and record the thread information of the confirmed abnormal threads (i.e., the thread classes that can match the corresponding preset leakage information from the preset leakage library) at the application level in the global variable mContrastApplicationMap.

[0078] Compare the local variables and global variables at the same level to obtain the differential thread information in the local variables and global variables. For example, by comparing the local variable mapA and the global variable mContrastSystemMap, the differential thread information 1 can be determined. The differential thread information 1 is the thread information that exists in the local variable mapA but does not exist in the global variable mContrastSystemMap.

[0079] The thread class corresponding to the differential thread information is the thread class of a newly emerging problem and cannot match the corresponding preset leakage information from the preset leakage library. By determining the thread class corresponding to the differential thread information as the exception thread to be reported, the AI diagnosis and prediction model can be used in the cloud to perform resource leakage diagnosis and prediction based on its thread-related data to obtain the predicted leakage information. According to the predicted leakage information, the self-repair module can be called to self-repair the predicted resource leakage points in the predicted leakage information.

[0080] To facilitate better implementation of the thread resource monitoring and processing method provided in the embodiments of the present application, the following further describes the process and system architecture of thread resource monitoring and processing in combination with an application of the foregoing embodiments of the present application in a scenario. The meanings of the terms are the same as those in the above thread resource monitoring and processing method, and the specific implementation details can refer to the description in the method embodiments. Figure 6 Shows the system architecture diagram of the thread resource monitoring and processing system applying the embodiments of the present application in this scenario.

[0081] Refer to Figure 6 , the thread resource monitoring and processing system may include a device side 610 and a cloud side 620. The device side 610 may include a framework layer (frameworks) 611 and a native layer (Native) 612. The framework layer may include the unit-embedded monitoring logic 6111 and communication service 6112 of each in-process unit. The native layer (Native) 621 may include a client (which can be represented as HeClient) 6121, a server (which can be represented as HeServer) 6122, and a self-repair module 62123 of the system-wide exception monitoring and processing toolkit (which can be represented as HERA SDK). The client 6121 and the server 6122 may communicate through a socket, and the server 6122 and the self-repair module 6123 may communicate through a socket. The server 6122 may include a daemon process, a multi-level alarm mechanism, a main processing function module, an adaptive monitoring strategy, and a database. The cloud side 620 may include a dynamic configuration service, a data receiving module, a model training module, and an intelligent diagnosis engine.

[0082] The process of thread resource monitoring and processing based on this thread resource monitoring and processing system can specifically include steps (1) to (5).

[0083] (1) The device determines whether the dynamic configuration service in the cloud is enabled through the communication service 6112. If it is enabled, the device obtains the monitoring configuration parameters configured by the user from the dynamic configuration service in the cloud through the communication service 6112, and passes the monitoring configuration parameters to the daemon process in the server 6212 via the client 6211 through the communication service 6112. Among them, the device can obtain the monitoring configuration parameters configured by the user from the dynamic configuration service at regular intervals corresponding to the timer through the communication service 6112.

[0084] (2) Start the adaptive monitoring strategy in the server 6212. The adaptive monitoring strategy adaptively adjusts the monitoring configuration parameters according to the system operation state at regular intervals to obtain dynamic monitoring parameters, and can synchronize the dynamic monitoring parameters to the database.

[0085] Among them, adaptively adjusting the monitoring configuration parameters according to the system operation state to obtain dynamic monitoring parameters may include: calculating the system load according to the system operation state; adjusting the thread number threshold in the monitoring configuration parameters according to the system load and a preset threshold adjustment coefficient to obtain an adjusted thread number threshold, and the dynamic monitoring parameters include the adjusted thread number threshold.

[0086] The system operation state includes the central processor usage rate and the memory usage rate; calculating the system load according to the system operation state may specifically include: calculating the system load according to the formula Load = w_CPU * CPU_Usage + w_Mem * Memory_Usage, where Load refers to the system load, CPU_Usage refers to the central processor usage rate, w_CPU refers to the weight coefficient of the central processor usage rate, Memory_Usage refers to the memory usage rate, and w_Mem refers to the weight coefficient of the memory usage rate.

[0087] Adjusting the thread number threshold in the monitoring configuration parameters according to the system load and a preset adjustment coefficient to obtain an adjusted thread number threshold may specifically include: calculating the adjusted thread number threshold according to the formula Threshold_d = Threshold_0 * (1 + α * Load), where Threshold_d refers to the adjusted thread number threshold, Threshold_0 refers to the thread number threshold in the monitoring configuration parameters, Load refers to the system load, and α refers to the preset threshold adjustment coefficient.

[0088] Adapting and adjusting the monitoring configuration parameters according to the system operation status to obtain dynamic monitoring parameters may further include: adjusting the monitoring frequency in the monitoring configuration parameters according to the system load and a preset frequency adjustment coefficient to obtain an adjusted monitoring frequency, where the adjusted monitoring frequency is included in the dynamic monitoring parameters, so as to perform thread anomaly analysis and processing on the thread usage information within the process according to the adjusted monitoring frequency.

[0089] (3) Performing multi-level thread usage monitoring through the unit embedded monitoring logic 6111 of each unit within each process at the system level and application level in the framework layer to obtain the monitored thread usage information within the process; the unit embedded monitoring logic transmits the monitored thread usage information to the daemon process in the server 6212 through the communication service 6112 via the client 6211 along with the monitoring configuration parameters.

[0090] Within each process at the system level (i.e., system processes), units (such as in-process modules or components like the Bluetooth module, wifi module, etc.) include unit embedded monitoring logic for monitoring thread usage, and within each process at the application level (i.e., application processes), units (such as application modules or components) also include unit embedded monitoring logic for monitoring thread usage.

[0091] Refer to Figure 7 , The specific ways to implement the unit embedded monitoring logic in each unit may include: Step S710, defining the thread monitoring interfaces corresponding to each unit; Step S720, implementing the unit embedded monitoring logic corresponding to each unit; Step S730, connecting the corresponding unit embedded monitoring logic in each unit (module or component). Specifically, in Step S710, interfaces for recording thread start (onThreadStart(String moduleName, String threadName)), for recording thread close (onThreadFinish(String moduleName, String threadName)), and for printing thread usage (i.e., thread usage logs) (logThreadUsage(String moduleName)) can be defined, where moduleName is the name of the unit and threadName is the name of the thread. In Step S720, implement the unit embedded monitoring logic for recording thread start (onThreadStart method), for recording thread close (onThreadFinish method), and for printing thread usage (logThreadUsage method); in Step S730, connect the above unit embedded monitoring logic in the unit.

[0092] When the monitoring logic embedded in each unit detects that the number of threads enabled in its unit exceeds the reporting threshold, it can then pass the monitored in-process thread usage information to the daemon process in the server 6212 via the communication service 6112 and the client 6211 by passing the monitoring configuration parameters.

[0093] (4) Through a multi-level alarm mechanism: perform thread anomaly analysis and processing on the in-process thread usage information according to the dynamic monitoring parameters to obtain the anomaly thread analysis result; and pass the anomaly thread analysis result to the main processing function module.

[0094] The anomaly thread analysis result includes anomaly thread information; performing thread anomaly analysis and processing on the in-process thread usage information according to the dynamic monitoring parameters to obtain the anomaly thread analysis result may include: obtaining the total number of threads and the enabled threads in a single process according to the in-process thread usage information; classifying the enabled threads in a single process to obtain at least one thread class; if the total number of threads is greater than the thread number threshold, determining whether the number of threads in each thread class is greater than the preset in-class threshold; and determining the thread information of the thread class with the number of threads in the class greater than the preset in-class threshold as the anomaly thread information.

[0095] Classifying the enabled threads in a single process to obtain at least one thread class may specifically be: classifying the threads with the same thread name main body in the enabled threads in a single process into one class to obtain at least one thread class. For example, the thread name Thread-1 and the thread name Thread-ABC have the same thread name main body Thread, and the Thread-1 thread and the Thread-ABC thread can be classified into the thread class (Thread class), and the number of threads in the class in this Thread class is 2.

[0096] The anomaly thread analysis result also includes resource leakage information; performing thread anomaly analysis and processing on the in-process thread usage information according to the dynamic monitoring parameters to obtain the anomaly thread analysis result may also include: comparing the thread monitoring information of the thread class with the number of threads in the class greater than the thread class threshold with the preset thread information in the preset leakage library to obtain the preset thread information that matches the thread monitoring information; and determining the preset leakage information corresponding to the preset thread information that matches the thread monitoring information as the resource leakage information.

[0097] (5) Main processing function module: According to the resource leakage information in the analysis result of the abnormal thread, call the self-repair module to perform self-repair of resource leakage; perform hierarchical integration and judgment on the abnormal thread information in the analysis result of the abnormal thread to obtain the abnormal thread to be reported; report the thread-related data of the abnormal thread to be reported to the cloud, so that the cloud can perform resource leakage diagnosis and prediction based on the thread-related data to obtain predicted leakage information; receive the predicted leakage information sent by the cloud and save the predicted leakage information to a preset leakage library.

[0098] Perform hierarchical integration and judgment on the abnormal thread information in the analysis result of the abnormal thread to obtain the abnormal thread to be reported, which may specifically include: hierarchically record the thread information included in the abnormal thread information to corresponding local variables; compare the local variables and global variables at the same level to obtain the different thread information in the local variables and global variables, and the global variable is a variable used to record the thread information of the confirmed abnormal thread; determine the thread class corresponding to the different thread information as the abnormal thread to be reported.

[0099] For example, record the thread information of the thread class enabled by the unit within the process at the system level to the local variable mapA, and record the thread information of the thread class enabled by the unit within the process at the application level to the local variable mapB. Set the corresponding global variable mContrastSystemMap at the system level, and the global variable mContrastSystemMap records the thread information of the confirmed abnormal thread (that is, the thread class that can match the corresponding preset leakage information from the preset leakage library) at the system level. Set the corresponding global variable mContrastApplicationMap at the application level, and the global variable mContrastApplicationMap records the thread information of the confirmed abnormal thread (that is, the thread class that can match the corresponding preset leakage information from the preset leakage library) at the application level. Compare the local variables and global variables at the same level to obtain the different thread information in the local variables and global variables. For example, compare the local variable mapA and the global variable mContrastSystemMap to determine the different thread information 1, and the different thread information 1 is the thread information that exists in the local variable mapA but does not exist in the global variable mContrastSystemMap.

[0100] The cloud uses an AI diagnosis and prediction model through an intelligent diagnosis engine to perform resource leakage diagnosis and prediction based on the thread-related data to obtain predicted leakage information. The predicted leakage information may include the predicted resource leakage point and the corresponding repair suggestion. The cloud sends the predicted leakage information obtained by the diagnosis and prediction to the device. The cloud receives the thread-related data through a data receiving module.

[0101] Applying the embodiments of the present application for thread resource monitoring and processing in this scenario has at least the following beneficial effects: By using the unit-embedded monitoring logic of each unit within each process at the system level and application level for multi-level thread usage monitoring, fine-grained thread usage information within the process can be monitored; further, based on the dynamic monitoring parameters, thread anomaly analysis and processing are performed on the thread usage information within the process, and on the basis of effectively avoiding the impact of thread resource monitoring and processing activities on the performance and stability of the operating system, an abnormal thread analysis result reflecting thread usage anomalies can be accurately obtained; furthermore, through a preset self-healing module, according to the resource leakage information in the abnormal thread analysis result, the self-healing module can be called to effectively perform resource leakage self-healing. Thus, the reliability of thread resource monitoring and processing is effectively improved overall.

[0102] To facilitate better implementation of the thread resource monitoring and processing method provided by the embodiments of the present application, the embodiments of the present application also provide a thread resource monitoring and processing device based on the above thread resource monitoring and processing method. The meanings of the terms are the same as those in the above thread resource monitoring and processing method, and the specific implementation details can be referred to the description in the method embodiments. Figure 8 The block diagram of a thread resource monitoring and processing device according to an embodiment of the present application is shown.

[0103] As Figure 8 shown, the thread resource monitoring and processing device 800 may include: A parameter module 810 may be configured to: obtain monitoring configuration parameters, and adaptively adjust the monitoring configuration parameters according to the system running state to obtain dynamic monitoring parameters; A monitoring module 820 may be configured to: perform multi-level thread usage monitoring through the unit-embedded monitoring logic of each unit within each process at the system level and application level to obtain the monitored thread usage information within the process; An analysis module 830 may be configured to: perform thread anomaly analysis and processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result; A processing module 840 may be configured to: according to the resource leakage information in the abnormal thread analysis result, call the self-healing module to perform resource leakage self-healing.

[0104] In some embodiments of the present application, after performing thread anomaly analysis and processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain an abnormal thread analysis result, the device further includes a prediction module, configured to: hierarchically integrate and judge the abnormal thread information in the abnormal thread analysis result to obtain abnormal threads to be reported; report the thread-related data of the abnormal threads to be reported to the cloud, so that the cloud performs resource leakage diagnosis and prediction based on the thread-related data to obtain predicted leakage information; receive the predicted leakage information sent by the cloud and save the predicted leakage information to a preset leakage library.

[0105] In some embodiments of the present application, the prediction module is configured to: hierarchically record the thread information included in the abnormal thread information into corresponding local variables; compare the local variables and global variables at the same level to obtain the different thread information between the local variables and the global variables, where the global variable is a variable used to record the thread information of the confirmed abnormal threads; and determine the thread class corresponding to the different thread information as the abnormal thread to be reported.

[0106] In some embodiments of the present application, the dynamic monitoring parameters include a thread number threshold; the abnormal thread analysis result includes abnormal thread information; the analysis module may be configured to: obtain the total number of threads and the started threads within a single process according to the thread usage information within the process; classify the threads started within the single process to obtain at least one thread class; if the total number of threads is greater than the thread number threshold, determine whether the number of threads within each thread class is greater than a preset within-class threshold; and determine the thread information of the thread class with the number of threads within the class greater than the preset within-class threshold as the abnormal thread information.

[0107] In some embodiments of the present application, the abnormal thread analysis result further includes resource leakage information; the analysis module may be configured to: compare the thread monitoring information of the thread class with the number of threads within the class greater than the thread class threshold with the preset thread information in a preset leakage library to obtain the preset thread information matching the thread monitoring information; and determine the preset leakage information corresponding to the preset thread information matching the thread monitoring information as the resource leakage information.

[0108] In some embodiments of the present application, the parameter module may be configured to: calculate the system load according to the system operation state; adjust the thread number threshold in the monitoring configuration parameters according to the system load and a preset threshold adjustment coefficient to obtain an adjusted thread number threshold, and the dynamic monitoring parameters include the adjusted thread number threshold.

[0109] In some embodiments of the present application, the parameter module may be configured to calculate the adjusted thread number threshold according to the formula Threshold_d = Threshold_0 * (1 + α * Load), where Threshold_d refers to the adjusted thread number threshold, Threshold_0 refers to the thread number threshold in the monitoring configuration parameters, Load refers to the system load, and α refers to the preset threshold adjustment coefficient.

[0110] In some embodiments of the present application, the parameter module may be configured to: adjust the monitoring frequency in the monitoring configuration parameters according to the system load and a preset frequency adjustment coefficient to obtain an adjusted monitoring frequency, where the adjusted monitoring frequency is included in the dynamic monitoring parameters, so as to perform thread anomaly analysis processing on the thread usage information within the process according to the adjusted monitoring frequency.

[0111] In some embodiments of the present application, the system operating state includes the CPU usage rate and the memory usage rate; the parameter module may be configured to: calculate the system load according to the formula Load = w_CPU * CPU_Usage + w_Mem * Memory_Usage, where Load refers to the system load, CPU_Usage refers to the CPU usage rate, w_CPU refers to the weight coefficient of the CPU usage rate, Memory_Usage refers to the memory usage rate, and w_Mem refers to the weight coefficient of the memory usage rate.

[0112] It should be noted that although several modules or units of a device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of the two or more modules or units described above may be embodied in one module or unit. Conversely, the features and functions of one module or unit described above may be further divided and embodied by multiple modules or units.

[0113] In addition, an embodiment of the present application further provides an electronic device, as Figure 9 shown, Figure 9 which shows a block diagram of an electronic device according to an embodiment of the present application. Specifically:

[0114] The electronic device may include a processor 901 with one or more processing cores, a memory 902 with one or more computer-readable storage media, a power supply 903, an input unit 904, and other components. Those skilled in the art can understand that Figure 9 the structure of the electronic device shown in

[0115] does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.

[0116] The processor 901 is the control center of the electronic device, connecting various parts of the entire computer device through various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 902, and by invoking the data stored in the memory 902, it executes various functions of the computer device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 901 may include one or more processing cores; preferably, the processor 901 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interfaces, and application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into the processor 901 either.

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

[0118] The electronic device further includes a power supply 903 for powering each component. Preferably, the power supply 903 can be logically connected to the processor 901 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 903 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.

[0119] The electronic device may further include an input unit 904, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0120] Although not shown, the electronic device may further include a display unit and the like, which will not be elaborated here. Specifically, in this embodiment, the processor 901 in the electronic device will, according to the following instructions, load the executable files corresponding to the processes of one or more computer programs into the memory 902, and the processor 901 will run the computer programs stored in the memory 902, so as to implement various functions in the foregoing embodiments of the present application. For example, the processor 901 may execute the following steps:

[0121] Obtain monitoring configuration parameters, and adaptively adjust the monitoring configuration parameters according to the system operation state to obtain dynamic monitoring parameters; perform multi-level thread usage monitoring through the unit-embedded monitoring logic in each unit within the processes at the system level and the application level to obtain the monitored thread usage information within the processes; perform thread exception analysis and processing on the thread usage information within the processes according to the dynamic monitoring parameters to obtain an abnormal thread analysis result; and call the self-repair module to perform resource leakage self-repair according to the resource leakage information in the abnormal thread analysis result.

[0122] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the foregoing embodiments can be completed by a computer program or by controlling related hardware through a computer program. The computer program can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0123] Therefore, an embodiment of the present application further provides a storage medium, in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any one of the methods provided by the embodiments of the present application.

[0124] Among them, the storage medium may be a computer-readable storage medium, and the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), a magnetic disk, an optical disc, or the like.

[0125] Since the computer program stored in the storage medium can execute the steps in any one of the methods provided by the embodiments of the present application, the beneficial effects that can be achieved by the methods provided by the embodiments of the present application can be realized. For details, see the foregoing embodiments and will not be elaborated here.

[0126] After considering the specification and practicing the disclosed embodiments here, those skilled in the art will readily think of other implementation manners of the present application. The present application is intended to cover any variations, uses, or adaptations of the present application, and these variations, uses, or adaptations follow the general principles of the present application and include the common general knowledge or conventional technical means in the technical field not disclosed in the present application.

[0127] It should be understood that the present application is not limited to the embodiments described above and shown in the drawings, and various modifications and changes can be made without departing from its scope.

Claims

1. A thread resource monitoring and processing method, characterized in that: include: Acquire monitoring configuration parameters, and adaptively adjust the monitoring configuration parameters according to the system operation status to obtain dynamic monitoring parameters; Multi-level thread usage monitoring is performed through the unit embedded monitoring logic of each unit in each process at the system level and the application level to obtain the thread usage information of the monitored process; Performing thread abnormality analysis on the thread usage information within the process according to the dynamic monitoring parameters to obtain abnormal thread analysis results; According to the resource leakage information in the abnormal thread analysis result, a self-repair module is called to perform resource leakage self-repair.

2. The method according to claim 1, characterized in that After performing thread abnormality analysis processing on the thread usage information within the process according to the dynamic monitoring parameters to obtain abnormal thread analysis results, the method further includes: Perform hierarchical integration and judgment on the abnormal thread information in the abnormal thread analysis result to obtain the abnormal thread to be reported; Reporting the thread-related data of the abnormal thread to be reported to the cloud, so that the cloud performs resource leakage diagnosis and prediction based on the thread-related data to obtain predicted leakage information; Receive the predicted leakage information sent by the cloud, and save the predicted leakage information in a preset leakage library.

3. The method according to claim 2, characterized in that The step of performing hierarchical integration and judgment on the abnormal thread information in the abnormal thread analysis result to obtain the abnormal thread to be reported includes: Recording the thread information included in the abnormal thread information hierarchically to corresponding local variables; Compare local variables and global variables at the same level to obtain difference thread information between the local variables and the global variables, wherein the global variables are variables used to record thread information of confirmed abnormal threads; The thread class corresponding to the difference thread information is determined as the abnormal thread to be reported.

4. The method according to claim 1, characterized in that: The dynamic monitoring parameters include a thread number threshold; the abnormal thread analysis result includes abnormal thread information; the abnormal thread analysis processing is performed on the thread usage information in the process according to the dynamic monitoring parameters to obtain the abnormal thread analysis result, including: Obtaining the total number of threads and enabled threads in a single process according to the thread usage information in the process; Classifying threads opened in the single process to obtain at least one thread class; If the total number of threads is greater than the thread number threshold, determining whether the number of threads in each thread class is greater than a preset class threshold; The thread information of a thread class whose number of threads in the class is greater than the preset class threshold is determined as the abnormal thread information.

5. The method according to claim 4, characterized in that The abnormal thread analysis result also includes resource leakage information; the method also includes: Compare the thread monitoring information of the thread class whose number of threads in the class is greater than the thread class threshold with the preset thread information in the preset leakage library to obtain the preset thread information matched by the thread monitoring information; The preset leakage information corresponding to the preset thread information matched by the thread monitoring information is determined as the resource leakage information.

6. The method according to claim 1, characterized in that The adaptively adjusting the monitoring configuration parameters according to the system operation status to obtain dynamic monitoring parameters includes: Calculating system load according to the system operation status; The thread number threshold in the monitoring configuration parameter is adjusted according to the system load and the preset threshold adjustment coefficient to obtain an adjusted thread number threshold, and the dynamic monitoring parameter includes the adjusted thread number threshold.

7. The method according to claim 6, characterized in that The step of adjusting the thread number threshold in the monitoring configuration parameter according to the system load and the preset adjustment coefficient to obtain the adjusted thread number threshold includes: The adjusted thread number threshold is calculated according to the formula Threshold_d=Threshold_0*(1+α*Load), wherein Threshold_d refers to the adjusted thread number threshold, Threshold_0 refers to the thread number threshold in the monitoring configuration parameters, Load refers to the system load, and α refers to the preset threshold adjustment coefficient.

8. The method according to claim 6, characterized in that The method further comprises: The monitoring frequency in the monitoring configuration parameters is adjusted according to the system load and the preset frequency adjustment coefficient to obtain an adjusted monitoring frequency. The dynamic monitoring parameters include the adjusted monitoring frequency, so as to perform thread exception analysis on the thread usage information within the process according to the adjusted monitoring frequency.

9. The method according to claim 6, characterized in that The system operation status includes a CPU usage rate and a memory usage rate; and the calculating the system load according to the system operation status includes: The system load is calculated according to the formula Load=w_CPU*CPU_Usage+w_Mem*Memory_Usage, wherein Load refers to the system load, CPU_Usage refers to the central processing unit usage, w_CPU refers to the weight coefficient of the central processing unit usage, Memory_Usage refers to the memory usage, and w_Mem refers to the weight coefficient of the memory usage.

10. A thread resource monitoring and processing device, characterized in that: include: The parameter module is used to obtain monitoring configuration parameters and adaptively adjust the monitoring configuration parameters according to the system operation status to obtain dynamic monitoring parameters; The monitoring module is used to: perform multi-level thread usage monitoring through the unit embedded monitoring logic of each process unit at the system level and the application level, and obtain the monitored process thread usage information; An analysis module is used to: perform thread abnormality analysis on the thread usage information in the process according to the dynamic monitoring parameters to obtain abnormal thread analysis results; The processing module is used to call the self-repair module to perform resource leakage self-repair according to the resource leakage information in the abnormal thread analysis result.

11. A storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of the device, the device is caused to execute the method according to any one of claims 1 to 9.

12. An electronic device, characterized in that: include: a memory storing a computer program; A processor reads a computer program stored in a memory to execute the method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Thread resource monitoring processing method and apparatus, and storage medium and electronic device

    WO2026166145A1