Thread identification method, thread identification device, storage medium and electronic device
By statistics and analyzing the thread characteristic data of the application, identifying key threads and reasonably allocating resources, the problem of rigid thread resource allocation in the existing technology is solved, and the system performance and user experience are improved.
Patent Information
- Application Number
- CN202110753560.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-02
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2041-07-02
AI Technical Summary
The prior art is difficult to effectively identify threads of different degrees of importance in a multi-threaded environment, resulting in rigid resource allocation and flexibly updating according to actual application conditions, resulting in performance problems such as lag and sound stuck.
By obtaining the static and dynamic information of the application, count the thread characteristic data of the thread to be identified within the preset time period, and identifying it based on this data to determine whether the thread is a critical thread, thereby reasonably allocating resources.
It realizes fast and accurate identification of threads of different degrees of importance, has a simple process, and can allocate resources according to the actual operation of the application, improving the system's resource utilization efficiency and user experience.
Smart Images

Figure CN113342505B_ABST
Abstract
Description
Background Art
[0002] In modern operating systems, in order to improve the operating efficiency of applications, multi-threaded operation of applications has gradually become a normal development. As the number of threads running simultaneously increases, the problem of resource competition between threads has emerged.
[0003] The existing technology usually requires certain rules to be set by the system or manually, such as a scheduling mechanism, to pre-set the requirements of different threads and allocate resources to threads according to the requirements. However, in this way, resource allocation is often rigid and cannot be flexibly updated according to the actual application operation or thread working conditions. For unused applications or processes, important threads may still face the risk of resource preemption, resulting in performance issues such as freezes and jams, affecting user experience.
[0004] Therefore, how to adopt an effective and accurate method to identify threads of different importance so as to reasonably allocate resources is a problem to be solved urgently in the prior art. Summary of the invention
[0005] The present disclosure provides a thread identification method, a thread identification device, a computer-readable storage medium and an electronic device, thereby at least to a certain extent improving the problem that the prior art lacks effective identification of threads of different importance levels and ensures reasonable allocation of resources.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] According to a first aspect of the present disclosure, a thread identification method is provided, comprising: obtaining a thread to be identified of a currently running application; counting thread feature data of the thread to be identified within a preset time period based on static information and dynamic information of the application; identifying the thread to be identified based on the thread feature data, and determining whether the thread to be identified is a critical thread.
[0008] According to a second aspect of the present disclosure, a thread identification device is provided, comprising: a to-be-identified thread acquisition module, used to acquire the to-be-identified thread of a currently running application; a thread feature data statistics module, used to count the thread feature data of the to-be-identified thread within a preset time period based on the static information and dynamic information of the application; and a to-be-identified thread identification module, used to identify the to-be-identified thread based on the thread feature data, and determine whether the to-be-identified thread is a critical thread.
[0009] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the thread identification method of the first aspect and possible implementation methods thereof are implemented.
[0010] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the thread identification method of the first aspect and possible implementation thereof by executing the executable instructions.
[0011] The technical solution disclosed in this disclosure has the following beneficial effects:
[0012] Obtain the thread to be identified of the currently running application; count the thread feature data of the thread to be identified within a preset time period according to the static information and dynamic information of the application; identify the thread to be identified based on the thread feature data, and determine whether the thread to be identified is a key thread. On the one hand, this exemplary embodiment proposes a new thread identification method, which can directly determine the identification result of the thread to be identified by processing the thread feature data. The process is simple and convenient, and can achieve fast and accurate distinction of threads of different importance, so as to facilitate reasonable resource allocation of threads; on the other hand, the thread feature data is related to the running state parameters of the application, so that this exemplary embodiment can determine the thread feature data to be counted according to the actual running situation and needs of the application, and ensure the validity of the thread feature data; on the other hand, the thread feature data is based on the statistical data obtained within the preset time period, and different preset time periods may obtain different thread feature data, which further ensures that this exemplary embodiment can effectively and accurately identify the thread to be identified related to the current application according to the specific thread running situation, and has strong timeliness.
[0013] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0015] Figure 1 A schematic diagram showing a system architecture in this exemplary embodiment;
[0016] Figure 2A structural diagram of an electronic device according to the exemplary embodiment is shown;
[0017] Figure 3 A flowchart of a thread identification method in this exemplary embodiment is shown;
[0018] Figure 4 A schematic diagram showing the architecture of a thread identification method in this exemplary embodiment;
[0019] Figure 5 A sub-flow chart of a thread identification method in this exemplary embodiment is shown;
[0020] Figure 6 A schematic diagram showing the wake-up relationship between different threads in this exemplary embodiment is shown;
[0021] Figure 7 A sub-flow chart showing another thread identification method in this exemplary embodiment;
[0022] Figure 8 A flowchart showing another thread identification method in this exemplary embodiment is shown;
[0023] Fig. 9 A structural diagram of a thread identification device in this exemplary embodiment is shown. DETAILED DESCRIPTION
[0024] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0025] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0026] An exemplary embodiment of the present disclosure provides a thread identification method. Figure 1 1 shows a system architecture diagram of the operating environment of this exemplary embodiment. Figure 1 As shown, the system architecture 100 may include a user terminal 110 and a server 120, which form a communication interaction through a network. For example, the server 120 can obtain thread data of an application in the user terminal 110 through the network, and can also send the identification result of the thread to be identified to the user terminal 110. The user terminal 110 refers to a terminal device with an application installed, including but not limited to a smart phone, a tablet computer, a game console, a wearable device, etc.; the server 120 refers to a background server that provides Internet services.
[0027] It should be understood that Figure 1 The number of each device is only exemplary. According to actual needs, any number of user terminals or service terminals, etc. can be set.
[0028] The thread identification method provided in the embodiment of the present disclosure may be executed by the user terminal 110. For example, the user terminal 110 may perform statistics on thread feature data of threads to be processed related to the currently running application, and then identify the threads to be identified. Alternatively, the user terminal 110 may first perform statistics on thread feature data of threads to be identified related to the currently running application, and send the data to the server 120. The server 120 may identify the threads to be identified, and return the identification results to the user terminal 110, so as to reduce the amount of calculation of the user terminal 110. The present disclosure does not make any specific limitation on this.
[0029] An exemplary embodiment of the present disclosure provides an electronic device for implementing a thread identification method, which may be Figure 1 The user terminal 110 or the server 120 in the electronic device comprises at least a processor and a memory, the memory is used to store executable instructions of the processor, and the processor is configured to execute the thread identification method by executing the executable instructions.
[0030] Below Figure 2Taking the mobile terminal 200 in the example, the structure of the above electronic device is exemplarily described. It should be understood by those skilled in the art that, in addition to the components specifically used for mobile purposes, Figure 2 The construction in can also be applied to fixed type equipment.
[0031] like Figure 2 As shown, the mobile terminal 200 may specifically include: a processor 210, an internal memory 221, an external memory interface 222, a USB (Universal Serial Bus) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 271, a receiver 272, a microphone 273, an earphone interface 274, a sensor module 280, a display screen 290, a camera module 291, an indicator 292, a motor 293, a button 294 and a SIM (Subscriber Identification Module) card interface 295, etc.
[0032] The processor 210 may include one or more processing units, for example, the processor 210 may include an AP (Application Processor), a modem processor, a GPU (Graphics Processing Unit), an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor and / or an NPU (Neural-Network Processing Unit), etc. The encoder may encode (i.e., compress) the image or video data; the decoder may decode (i.e., decompress) the bitstream data of the image or video to restore the image or video data.
[0033] In some implementations, the processor 210 may include one or more interfaces, and may be connected to other components of the mobile terminal 200 via different interfaces.
[0034] The internal memory 221 may be used to store computer executable program codes, which may include instructions. The internal memory 221 may include volatile memory, non-volatile memory, etc. The processor 210 executes various functional applications and data processing of the mobile terminal 200 by running instructions stored in the internal memory 221 and / or instructions stored in a memory provided in the processor.
[0035] The external memory interface 222 can be used to connect an external memory, such as a Micro SD card, to expand the storage capacity of the mobile terminal 200. The external memory communicates with the processor 210 through the external memory interface 222 to implement a data storage function, such as storing music, video and other files.
[0036] The USB interface 230 is an interface that complies with USB standard specifications and can be used to connect a charger to charge the mobile terminal 200, or to connect headphones or other electronic devices.
[0037] The charging management module 240 is used to receive charging input from a charger. While the charging management module 240 is charging the battery 242, it can also power the device through the power management module 241; the power management module 241 can also monitor the status of the battery.
[0038] The wireless communication function of the mobile terminal 200 can be implemented by antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modulation and demodulation processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. The mobile communication module 250 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the mobile terminal 200. The wireless communication module 260 can provide wireless communication solutions including WLAN (Wireless Local Area Networks) (such as Wi-Fi (Wireless Fidelity) network), BT (Bluetooth), GNSS (Global Navigation Satellite System), FM (Frequency Modulation), NFC (Near Field Communication), IR (Infrared) and the like applied to the mobile terminal 200.
[0039] The mobile terminal 200 can realize a display function and display a user interface through a GPU, a display screen 290 and an AP.
[0040] The mobile terminal 200 can realize the shooting function through the ISP, camera module 291, encoder, decoder, GPU, display screen 290 and AP, and can also realize the audio function through the audio module 270, speaker 271, receiver 272, microphone 273, headphone interface 274 and AP.
[0041] The sensor module 280 may include a depth sensor 2801 , a pressure sensor 2802 , a gyroscope sensor 2803 , an air pressure sensor 2804 , etc., to implement different sensing detection functions.
[0042] Indicator 292 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc. Motor 293 may generate vibration prompts, and may also be used for touch vibration feedback, etc. Buttons 294 include a power button, a volume button, etc.
[0043] The mobile terminal 200 may support one or more SIM card interfaces 295 for connecting a SIM card to implement functions such as calls and data communications.
[0044] Figure 3 An exemplary process of a thread identification method is shown, which can be performed by the user terminal 110 or the server 120, including the following steps S310 to S330:
[0045] Step S310, obtaining the thread to be identified of the currently running application.
[0046] Among them, the currently running application may refer to an application that is running a related task, or an application that is currently interacting with the user, such as a media application such as a video or music application running in the foreground, or a game application that has strong interaction with the user. When an application is executed, it will include multiple threads related to the currently running application. For example, when a game application is executed, it will include a main thread, a rendering thread, or other threads. When these threads are running, there may be resource grabbing. Therefore, all or part of the threads can be used as threads to be identified, and the key thread identification process can be performed.
[0047] Step S320: collecting statistics of thread characteristic data of the to-be-identified thread within a preset time period according to the static information and dynamic information of the application.
[0048] Among them, the static information of the application refers to the characteristic information that is fixed when the application is executed, such as the type of application (game application, information application or media application, etc.); dynamic information refers to the characteristic information that changes according to the running state of the application, such as the number of times the thread is in the runnable state or the number of times the thread is in the running state when the application is executed, the permission information of which threads the application can obtain which information, and the running environment information of the application, such as the current game scene in the game application, etc. The above static information and dynamic information can be considered separately. For example, the statistical thread characteristic data can be determined based on the ratio of the number of times the thread is in the runnable state and the number of times the thread is in the running state in the dynamic information, or the statistical thread characteristic data can be determined based on the type of application in the static information; it is also possible to determine which thread characteristic data needs to be counted based on the above static information combined with the above dynamic information.
[0049] The preset time period refers to a specific time period used for performing thread feature data statistics. The statistical time node and statistical duration of the preset time period can be customized according to actual needs. For example, the start time of the application can be set as the statistical starting node of the preset time period, or a certain time after the start of the application can be set as the statistical starting node of the preset time period, etc. The statistical duration of the preset time period can be set to 5 seconds or 8 seconds, etc. Specifically, it can be set according to the characteristics of the application or the actual situation, and the present disclosure does not make specific limitations on this.
[0050] Thread characteristic data refers to comprehensive data that can reflect the characteristics of the thread to be identified. This exemplary embodiment can count the characteristic data of the thread to be identified from one or more dimensions within a preset time period, and determine the thread characteristic data of the thread to be identified based on the characteristic data of the one or more dimensions, wherein the characteristic data of each dimension can be the acquired original data, such as the number of times the thread to be identified is called within the preset time period; or it can be data calculated based on the original data, such as calculating the load data at different frequency change points within the preset time period, determining the total load data of the preset time period, etc.
[0051] In this exemplary embodiment, thread feature data of one or more threads to be identified can be counted. To facilitate subsequent calculations, when thread feature data of one thread to be identified is counted, the thread feature data can be converted into a vector form; when thread feature data of multiple threads to be identified is counted, the thread feature data of each thread to be identified can be first converted into a corresponding vector form, and then feature matrices corresponding to the multiple threads to be identified can be determined based on the multiple vectors.
[0052] Step S330: Identify the thread to be identified based on the thread feature data, and determine whether the thread to be identified is a key thread.
[0053] Identifying thread feature data is the process of identifying the thread to be identified, so as to determine whether the thread to be identified is a critical thread. Among them, a critical thread refers to a thread responsible for important work in the system, such as a rendering thread in a game application, or a data processing thread in other applications that includes data packet reception and parsing, data distribution, and various interface processing. This example embodiment can identify whether the thread to be identified is a critical thread by identifying thread feature data, so as to ensure reasonable allocation of resources for it in the future.
[0054] In this exemplary embodiment, based on the thread feature data, a classification result of whether the thread to be identified is a critical thread, a common thread, or other thread can be obtained, which can be specifically represented by a number or letter identifier, for example, the identifier "0" can represent a common thread, and the identifier "1" can represent a critical thread, etc. Further, based on the identification result of whether the thread to be identified is a critical thread, a resource allocation strategy result of the thread to be identified can also be obtained, for example, based on further processing of the identification result and the thread feature data, it is determined that the thread to be identified can use the core binding operation strategy to implement resource allocation, etc.
[0055] In this exemplary embodiment, the identification and processing of thread feature data may include a variety of methods, such as pre-determining known key threads, and then classifying multiple threads to be identified by calculating the similarity of thread feature data of multiple threads to be identified, and determining the threads to be identified that are classified into the same category as the known key threads as key threads; or calculating the similarity of thread feature data of known key threads and threads to be identified, and determining threads to be identified whose similarity exceeds a certain threshold as key threads; or training a machine learning model with sample thread feature data and corresponding labels, and processing thread key data based on the machine learning model to obtain an identification result of the thread to be identified, etc. The present disclosure does not make specific limitations on this.
[0056] In an exemplary embodiment, the above step S330 may include:
[0057] Convert thread feature data into thread feature vectors;
[0058] A machine learning model is used to process the thread feature vector to determine whether the thread to be identified is a critical thread.
[0059] In this exemplary embodiment, a pre-trained machine learning model, such as a decision tree or a neural network model, can be directly used to directly process the thread feature vector converted from the thread feature data to obtain the classification result of the thread to be identified. The thread feature vector can also be processed by combining multiple models, for example, first using the first model to process the thread feature vector of the thread to be identified to obtain the classification result of the thread to be identified; then using the second model to further process the thread to be identified whose classification result is a key thread to obtain the result of which resource allocation decision can be used for prediction of the key thread, wherein the first model can be a classification model that outputs the classification result, and the second model can be a regression model that outputs the scores of different resource allocation decisions, and so on.
[0060] In an exemplary embodiment, the thread identification method may further include:
[0061] According to the identification result of the thread to be identified, resources are allocated to the thread to be identified.
[0062] According to the identification result, it can be determined to which level of importance the thread to be identified belongs. Furthermore, resources can be reasonably allocated to it. For example, when the thread to be identified is determined to be a critical thread, it can be bound to a core to improve the affinity between the critical thread and the core of a specific processor to ensure the normal priority operation of subsequent threads; or the kernel's scheduling level for the critical thread can be modified so that the critical thread can effectively schedule resources; or a mutually exclusive call can be set for the critical thread; or the frequency of the processor core corresponding to the critical thread can be increased, etc. The specific selection can be customized according to actual needs, and can also be combined with other algorithm models for reasonable prediction, etc. The present disclosure does not make specific limitations on this.
[0063] In summary, in this exemplary embodiment, the thread to be identified of the currently running application is obtained; according to the static information and dynamic information of the application, the thread feature data of the thread to be identified within a preset time period is counted; based on the thread feature data, the thread to be identified is identified, and it is determined whether the thread to be identified is a critical thread. On the one hand, this exemplary embodiment proposes a new thread identification method, which can directly determine the identification result of the thread to be identified by processing the thread feature data. The process is simple and convenient, and can achieve fast and accurate distinction of threads of different importance, so as to facilitate reasonable resource allocation of threads; on the other hand, the thread feature data is related to the running state parameters of the application, so that this exemplary embodiment can determine the thread feature data to be counted according to the actual running situation and needs of the application, and ensure the validity of the thread feature data; on the other hand, the thread feature data is based on the statistical data obtained within the preset time period, and different preset time periods may obtain different thread feature data, which further ensures that this exemplary embodiment can effectively and accurately identify the thread to be identified related to the current application according to the specific thread running situation, and has strong timeliness.
[0064] In an exemplary embodiment, the thread characteristic data may include one or more of thread attribute data, thread load data, thread call relationship data, thread state data, or thread priori data of a specific application.
[0065] Among them, the thread attribute data can reflect the importance category of the thread, for example, when the thread is a critical thread, it can be indicated by the identifier "1", when the thread is a common thread or an unknown thread, it can be indicated by the identifier "0", or when the thread is other threads, it can also be indicated by "2" or other identifiers, etc. Considering that some important critical threads can be predetermined, such as rendering threads, and other threads need to be identified before they can be determined to be critical threads, and non-critical threads in different scenarios may also be identified as critical threads, therefore, this exemplary embodiment can use thread attribute data as thread feature data. Critical threads can be predetermined by the platform, for example, game applications will have rendering threads responsible for drawing frames, and rendering threads can generally accurately obtain their thread IDs (Identify, unique identifiers) through the platform, such as in the Android system, the accurate critical thread IDs can be obtained through the queueBuffer (Buffer queue) in the libgui (C language GUI library) library, or the critical thread IDs can be obtained according to the schemes in cooperation with some application manufacturers, so as to mark these threads, etc.
[0066] Thread load data refers to data related to the load during thread operation, which can reflect the current thread operation status. Thread call relationship data refers to data about the thread to be identified being called by other threads or programs when the application is executed, such as the call level between the thread to be identified and the number of times it is called, etc. Thread status data can be determined by counting the real-time frame rate information of the thread to be identified. Specifically, the real-time frame rate of the thread to be identified can be compared with the preset frame rate to determine whether it is in a dropped frame state or a stuck state. The number of times it is in an operational state when in a stuck state is further used as thread status data.
[0067] In addition, depending on the type of application, in some special applications, such as game applications, since the game has strict index requirements for the performance of screen freezes, sounds, etc., and the game engine in the game application often creates its own working thread to handle the corresponding tasks, these working threads are often key threads. Considering the working threads created by the game engine, such as Unity, Unreal and other game engines, the created thread names are usually fixed, or have obvious characteristic values, etc. Therefore, this exemplary embodiment can use the thread prior information of the specific application as thread characteristic data according to actual needs, and the prior information can determine whether the thread to be identified is a thread with a specific name created by the execution of a specific application, such as NativeThread is an audio-related thread, WorkerThread is a working thread created by the main thread and the rendering thread, etc., and the prior conditions can be determined according to these thread IDs to obtain the prior information, which can be represented by specific characters, such as using the identifier "10" to indicate that the thread to be identified is a specific thread created by the game engine, and using the identifier "00" to indicate that the thread to be identified is not a specific thread created by the game engine, etc. It should be noted that if the thread to be identified is a specific thread created by the game engine, the probability of being identified as a key thread will also be relatively large.
[0068] It should be noted that, according to the actual operation of the application and scenario requirements, this exemplary embodiment can also obtain other thread feature data to increase the dimension of the thread feature data and improve the accuracy and effectiveness of identifying the thread to be identified. This disclosure does not make specific limitations on this.
[0069] Figure 4A schematic diagram of the architecture of a thread identification method in this exemplary embodiment is shown, which may specifically include a data acquisition module 410 for acquiring thread characteristic data, which may include one or more of thread attribute data 411, thread load data 412, thread call relationship data 413, thread state data 414 or thread prior data 415 of a specific application; a thread identification module 420 for identifying threads to be identified based on thread characteristic data; and a result processing module 430 for reasonably allocating resources to critical threads 431 and non-critical threads 432 based on the identification results.
[0070] Further, such as Figure 5 As shown, in an exemplary embodiment, when the thread characteristic data is thread load data, the above step S320 may include the following steps:
[0071] Step S510, counting the running time of the thread to be identified at each frequency change point within a preset time period;
[0072] Step S520, obtaining the reference computing power of the specified core of the processor;
[0073] Step S530, calculating the load data corresponding to each frequency change point according to the running time and the reference calculation force;
[0074] Step S540: Determine the load data of the thread to be identified within a preset time period based on the load data corresponding to each frequency change point.
[0075] As important information for identifying key threads, thread load data can be calculated through the running time and unit computing power of the thread to be identified. Considering that different applications can run in the cores of different processors, in order to ensure that the calculated load data is analyzable, it is necessary to adopt a unified standard to calculate the load data of the thread to be identified. In this exemplary embodiment, a specified core, such as a super-large core of a terminal device processor, is first determined, and then the computing power corresponding to the highest frequency in the super-large core is used as a reference computing power, and based on the reference computing power, the computing power of the thread to be identified within a preset time is normalized. Specifically, in this exemplary embodiment, each frequency change point within a preset time period can be used as a unit to count the running time of the thread to be identified at each frequency change point, wherein the frequency change point refers to the statistical time point at which the frequency value changes when the thread is running, for example, after the thread runs for a period of time at frequency value 1, it changes to frequency value 2, then the point where the frequency value 1 is located can be used as the frequency change point, and the point where the frequency value 2 is located can also be used as the frequency change point for data statistics. Then, based on the running time and the reference computing power, the load data corresponding to each frequency change point is calculated. Finally, according to the load data corresponding to each frequency change point, the load data of the thread to be identified within the preset time period is determined. This exemplary embodiment can use multiple methods to calculate the load data of the thread to be identified within the preset time period.
[0076] For example, the task of the current thread to be identified is running on the big core, the frequency change point is Freq1, and the corresponding unit computing power is pow1. After the thread runs for time t1 at the frequency change point Freq1, the frequency change point changes to Freq2, triggering a load data statistics, which can be calculated by the formula: The load data corresponding to the frequency change point Freq1 is calculated separately, where powMax represents the reference computing power, such as the computing power corresponding to the maximum frequency of the super-large core; after the thread to be identified runs for time t2 at the frequency change point Freq2, the frequency change point changes to Freq3, triggering a load data statistics, which can be calculated by the formula: The load data corresponding to the frequency change point Freq2 is calculated separately. Similarly, the load data corresponding to each frequency change point is calculated, and further calculated by the formula: Load T =Load1+Load2+……+Load k , determine the load data of the thread to be identified within a preset time period.
[0077] Alternatively, you can use the formula: Determine the load data of the thread to be identified within a preset time period, wherein: Indicates the load data corresponding to the current frequency change point n. n, which can represent the load data corresponding to each frequency change point, t n Indicates the time the thread to be identified runs at the frequency change point n, pow n Indicates the unit computing power corresponding to the frequency change point n, powMax indicates the reference computing power, Load T Indicates the total load data accumulated to the current frequency change point n. n-1 Indicates the total load data accumulated at the frequency change point n-1 before the frequency change point n. When n is the last frequency change point in the preset time period, Load T That is, the load data of the thread to be identified within a preset time period. That is, in this exemplary embodiment, the accumulated load data of the current frequency change point can be calculated based on the running time of the current frequency change point, the corresponding unit computing power, the reference computing power, and the accumulated load data of the previous frequency change point.
[0078] In an exemplary embodiment, when the thread characteristic data is thread call relationship data, the above step S320 may include:
[0079] Identify key threads of reference;
[0080] The call levels of the thread to be identified and the reference key thread and the number of calls of the thread to be identified are counted within a preset time period.
[0081] Among them, the reference key threads refer to some known key threads that are determined in advance, such as the main thread for processing tasks related to game logic and the rendering thread for processing rendering-related tasks in a game application. They are usually key threads and are relatively easy to determine. Therefore, these threads can be used as reference key threads, and based on the dependency relationship between the reference key threads and the key threads to be identified, the call relationship data of the threads to be identified can be determined. This exemplary embodiment can determine the thread call relationship data by counting the call levels and call times of the threads to be identified and the reference key threads within a preset time period.
[0082] like Figure 6As shown, a schematic diagram of the awakening relationship between multiple threads is shown, wherein the thread GLThread 610 is the rendering thread of the game, which can be a key thread, the thread MainThread 620, the thread WorkerThread 630, and the thread mali-cmar-backe 640 will directly wake up the thread GLThread 610, therefore, the thread MainThread 620, the thread WorkerThread 630, and the thread mali-cmar-backe 640 can be used as the first calling level, and the thread MainThread 620 will be awakened by the thread WorkerThread 650, the thread CoreThread 660, and the thread NativeThread 670, but it belongs to the second level relative to the thread GLthread 610, therefore, the thread WorkerThread 650, the thread CoreThread 660, and the thread NativeThread 670 can be used as the second calling level, and so on, the thread AudioTrace 680 can be used as the third calling level, and at the same time, Figure 6 The numbers in the table represent the number of times each thread is called within a preset time period.
[0083] In an exemplary embodiment, there may be multiple threads to be identified, such as Figure 7 As shown, the thread identification method may further include the following steps:
[0084] Step S710, determining the weight of each thread to be identified according to thread load data and / or thread call relationship data of the thread to be identified;
[0085] Further, step S340 may include:
[0086] Step S720 , processing thread feature data of multiple threads to be identified in combination with the weight of each thread to be identified, to identify whether each thread to be identified is a key thread.
[0087] That is, this exemplary embodiment can determine the weight of each thread to be identified based on thread load data, thread call relationship data, and thread load data and thread call relationship data, so as to identify threads to be identified in combination with different weights. Specifically, threads to be identified with heavy loads can be assigned higher weights; or threads to be identified that are called more times within a preset time period can be assigned higher weights; or threads to be identified with smaller call levels can be assigned higher weights; finally, the weights of threads to be identified can also be determined in combination with the above-mentioned factors, and the present disclosure does not make specific limitations on this. In addition, after determining the weights of different threads to be identified, in order to facilitate calculation, they can also be subjected to weight normalization processing, etc.
[0088] In addition, in addition to determining the weight of the thread to be identified according to the size of the call level, the present exemplary embodiment can also determine the weight of each thread to be identified according to the thread call relationship data by other means, such as searching for the call loop starting with the reference key thread, and determining the weight according to the call loop. For example, a reference key thread a is known, and when searching for the call relationship, it is found that there is a loop: thread a<-thread b<-thread c<-thread a (where "<-" means awakened), indicating that there is a working loop including the reference key thread a. If any thread in the loop fails to obtain resources in time, it may affect the operation of the reference key thread a. Therefore, it can be considered to give threads b and c higher weights, so that threads b and c are more easily classified into the same category as the reference key thread a, so as to increase the probability of threads b and c becoming key threads.
[0089] In an exemplary embodiment, the thread identification method may further include:
[0090] Obtain reference thread characteristic data of the reference key thread;
[0091] In the above step S720, the thread feature data of the multiple threads to be identified are identified and processed to obtain identification results of the multiple threads to be identified, including:
[0092] The reference key thread and the plurality of threads to be identified are clustered according to the reference thread feature data and the thread feature data, and the threads to be identified that are in the same category as the reference key thread are determined as key threads.
[0093] In this exemplary embodiment, reference thread characteristic data can also be determined for a predetermined reference critical thread, i.e., a known critical thread. The type of thread characteristic data can be the same as the thread characteristic data of the thread to be identified, for example, both can be thread call relationship data, thread load data, etc. Further, the thread characteristic data of the known critical thread and the thread to be identified are processed by a machine learning model or a clustering algorithm to classify them. Finally, the thread to be identified that belongs to the same category as the known critical thread in the classification result is the critical thread. In this exemplary embodiment, determining the reference thread characteristic data of the reference critical thread is equivalent to the process of pre-establishing a target category label for the classification result. On the one hand, it is convenient to accurately and quickly determine whether the thread to be identified is a critical thread through the classification result. On the other hand, based on the reference critical thread as the benchmark of the critical thread category, the accuracy and effectiveness are high.
[0094] In an exemplary embodiment, it is possible to set a periodic identification of whether the thread to be identified is a critical thread, and timely adjust resource allocation according to the running changes of the application. For example, the period can be set to 10-20 seconds, and the identification process of the critical thread is triggered every time the period condition is met. In particular, this exemplary embodiment can be applied to the scenario where the application is a game application. Further, the thread identification method can also include:
[0095] In response to the game application switching the game scene, trigger the execution to obtain the thread to be identified of the currently running application, so as to periodically identify the key thread of the thread to be identified of the game application.
[0096] Considering that game application scenarios often involve scene switching, the running status, importance or resource requirements of each thread may change in different game scenarios. For example, when the game scene is an indoor plot scene, thread 1 is a key thread and thread 2 is a common thread. When the game scene switches to an outdoor battle scene, thread 1 is a common thread and thread 2 is a key thread, or both thread 1 and thread 2 are key threads, etc. Based on this, this exemplary embodiment proposes a mechanism for periodically detecting whether the thread to be identified is a key thread. When it is detected that the game scene is switched, it can trigger the re-identification of the key thread of the thread of the current game application.
[0097] Figure 8 A flowchart of another thread identification method in this exemplary embodiment is shown, which may specifically include the following steps:
[0098] Step S810, obtaining multiple threads to be identified of the currently running application;
[0099] Step S820, obtaining thread feature data of each to-be-identified thread in multiple dimensions according to the static information and dynamic information of the application;
[0100] Step S830, determining the weight of each thread to be identified, and normalizing the weight;
[0101] Step S840, combining the weight of each thread to be identified, and processing the thread feature data of the multiple threads to be identified through a machine learning model;
[0102] Step S850, obtaining identification results of whether the multiple threads to be identified are key threads;
[0103] Step S860, detecting whether the application program has ended running;
[0104] If the application ends running, the recognition process of the thread to be recognized ends;
[0105] Step S870, detecting whether the preset period has been reached;
[0106] When the preset period is reached, step S820 is executed to reacquire thread feature data of each to-be-identified thread in multiple dimensions to re-identify the current to-be-identified thread.
[0107] When the preset period is not reached, the process may return to step S860 to re-determine whether the application program has ended running and to again determine whether the preset period has been reached.
[0108] The preset period can be customized as needed, for example, the period can be set to 20 seconds, etc.
[0109] The exemplary embodiment of the present disclosure also provides a thread identification device. Fig. 9 As shown, the thread identification device 900 may include: a to-be-identified thread acquisition module 910, used to acquire the to-be-identified thread of the currently running application; a thread feature data statistics module 920, used to count the thread feature data of the to-be-identified thread within a preset time period according to the static information and dynamic information of the application; and a to-be-identified thread identification module 930, used to identify the to-be-identified thread based on the thread feature data, and determine whether the to-be-identified thread is a critical thread.
[0110] In an exemplary embodiment, the thread characteristic data includes one or more of thread attribute data, thread load data, thread call relationship data, thread state data, or thread priori data of a specific application program.
[0111] In an exemplary embodiment, when the thread characteristic data is thread load data, the thread characteristic data statistics module includes: a running time statistics unit, which is used to count the running time of the thread to be identified at each frequency change point within a preset time period; a reference computing power acquisition unit, which is used to obtain the reference computing power of a specified core of the processor; a first calculation unit, which is used to calculate the load data corresponding to each frequency change point based on the running time and the reference computing power; and a second calculation unit, which is used to determine the load data of the thread to be identified within the preset time period based on the load data corresponding to each frequency change point.
[0112] In an exemplary embodiment, when the thread characteristic data is thread call relationship data, the thread characteristic data statistics module includes: a reference key thread determination unit, used to determine the reference key thread; a call data statistics unit, used to count the call level of the thread to be identified and the reference key thread and the number of calls of the thread to be identified within a preset time period.
[0113] In an exemplary embodiment, there are multiple threads to be identified, and the above-mentioned thread identification method also includes: a weight determination module, which is used to determine the weight of each thread to be identified based on the thread load data and / or thread call relationship data of the thread to be identified; the thread identification module to be identified includes: a thread identification unit, which is used to process the thread feature data of multiple threads to be identified in combination with the weight of each thread to be identified, so as to identify whether each thread to be identified is a critical thread.
[0114] In an exemplary embodiment, the above-mentioned thread identification method also includes: a reference thread feature data acquisition module, which is used to obtain reference thread feature data of a reference critical thread; a thread identification unit, including: a thread identification sub-unit, which is used to cluster the reference critical thread and multiple threads to be identified according to the reference thread feature data and the thread feature data, and determine the threads to be identified that are in the same category as the reference critical thread as critical threads.
[0115] In an exemplary embodiment, the thread identification module to be identified includes: a vector conversion unit, which is used to convert thread feature data into a thread feature vector; and a vector processing unit, which is used to process the thread feature vector using a machine learning model to determine whether the thread to be identified is a critical thread.
[0116] In an exemplary embodiment, the thread identification method further includes: a resource allocation module, configured to allocate resources to the thread to be identified according to the identification result of the thread to be identified.
[0117] In an exemplary embodiment, the above-mentioned application is a game application, and the above-mentioned thread identification method also includes: a periodic identification module, which is used to trigger the execution of obtaining the thread to be identified of the currently running application in response to the switching of the game scene by the game application, so as to periodically identify the key threads of the thread to be identified of the game application.
[0118] The specific details of each part of the above device have been described in detail in the implementation method part, so they will not be repeated here.
[0119] The exemplary embodiments of the present disclosure further provide a computer-readable storage medium, which can be implemented in the form of a program product, including program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification, for example, to execute Figure 3 , Figure 5 , Figure 7 or Figure 8 The program product may be in the form of a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0120] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory, a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0121] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0122] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0123] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0124] It will be appreciated by those skilled in the art that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or implementations combining hardware and software aspects, which may be collectively referred to herein as "circuit", "module" or "system". Those skilled in the art will readily think of other implementations of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptive changes of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and implementation are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0125] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A thread identification method, characterized in that: include: Get the thread to be identified of the currently running application; Collecting statistics of thread feature data of the to-be-identified thread within a preset time period according to the static information and dynamic information of the application; The thread characteristic data includes: one or more of thread attribute data, thread load data, thread call relationship data, thread state data or thread prior data of a specific application program; Identify the thread to be identified based on the thread feature data, and determine whether the thread to be identified is a key thread; When the thread characteristic data is the thread load data, the counting of the thread characteristic data of the to-be-identified thread within a preset time period includes: Counting the running time of the to-be-identified thread at each frequency change point within the preset time period; Get the reference computing power of the specified core of the processor; Calculate the load data corresponding to each frequency change point according to the running time and the reference calculation force; Based on the load data corresponding to each frequency change point, the load data of the thread to be identified within the preset time period is determined.
2. The method according to claim 1, characterized in that When the thread characteristic data is thread call relationship data, the counting of thread characteristic data of the to-be-identified thread within a preset time period includes: Identify key threads of reference; The calling levels of the to-be-identified thread and the reference key thread and the calling times of the to-be-identified thread are counted within the preset time period.
3. The method according to claim 1, characterized in that There are multiple threads to be identified, and the method further includes: Determining the weight of each thread to be identified according to the thread load data and / or thread call relationship data of the thread to be identified; The step of identifying the thread to be identified based on the thread feature data to determine whether the thread to be identified is a key thread includes: The thread feature data of the plurality of threads to be identified are processed in combination with the weight of each thread to be identified, so as to identify whether each thread to be identified is the key thread.
4. The method according to claim 3, characterized in that The method further comprises: Obtain reference thread characteristic data of the reference key thread; The processing of the thread feature data of the plurality of threads to be identified to identify whether each of the threads to be identified is the key thread includes: The reference critical thread and the plurality of threads to be identified are clustered according to the reference thread feature data and the thread feature data, and the threads to be identified that are in the same category as the reference critical thread are determined as the critical threads.
5. The method according to claim 1, characterized in that The step of identifying the thread to be identified based on the thread feature data and determining whether the thread to be identified is a key thread includes: Converting the thread feature data into a thread feature vector; The thread feature vector is processed using a machine learning model to determine whether the thread to be identified is the key thread.
6. The method according to claim 1, characterized in that The method further comprises: According to the identification result of the thread to be identified, resources are allocated to the thread to be identified.
7. The method according to claim 1, characterized in that The application is a game application; the method further comprises: In response to the game scene switching of the game application, the execution of obtaining the to-be-identified thread of the currently running application is triggered, so as to periodically identify the key thread of the to-be-identified thread of the game application.
8. A thread identification device, characterized in that: include: A to-be-identified thread acquisition module is used to acquire the to-be-identified thread of the currently running application; A thread feature data statistics module, used to count the thread feature data of the to-be-identified thread within a preset time period according to the static information and dynamic information of the application program; The thread characteristic data includes: one or more of thread attribute data, thread load data, thread call relationship data, thread state data or thread prior data of a specific application program; A to-be-identified thread identification module, used to identify the to-be-identified thread based on the thread feature data, and determine whether the to-be-identified thread is a key thread; When the thread characteristic data is the thread load data, the step of counting the thread characteristic data of the to-be-identified thread within a preset time period is configured as follows: Counting the running time of the to-be-identified thread at each frequency change point within the preset time period; Get the reference computing power of the specified core of the processor; Calculate the load data corresponding to each frequency change point according to the running time and the reference calculation force; Based on the load data corresponding to each frequency change point, the load data of the thread to be identified within the preset time period is determined.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 7 by executing the executable instructions.
Citation Information
Patent Citations
Information processing method and electronic equipment
CN104375896A
APP dynamic deep malicious behavior detection device, method and system
CN109829300A