Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and the like. In other instances, well-known technical solutions have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repetitive description will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
Exemplary embodiments of the present disclosure provide a thread identification method. FIG. 1 shows a system architecture diagram of an environment in which the exemplary embodiment operates. As shown in fig. 1, the system architecture 100 may include a user terminal 110 and a server 120, which form communication interaction with each other through a network, for example, the server 120 may obtain thread data of an application program in the user terminal 110 through the network, and may also send an identification result of a thread to be identified to the user terminal 110. The user terminal 110 refers to a terminal device installed with an application program, and includes but is not limited to a smart phone, a tablet computer, a game machine, a wearable device, and the like; the server 120 refers to a background server providing internet services.
It should be understood that the number of devices in fig. 1 is merely exemplary. Any number of user terminals or servers can be provided according to actual needs.
The thread identification method provided by the embodiment of the present disclosure may be executed by the user terminal 110, for example, the user terminal 110 performs statistics on the to-be-processed thread related to the currently running application program, and then identifies the to-be-identified thread; or the user terminal 110 may first perform statistics on the to-be-identified thread related to the currently running application program, send the statistics to the server 120, identify the to-be-identified thread by the server 120, and return the identification result to the user terminal 110, so as to reduce the amount of calculation of the user terminal 110, and the like.
The exemplary embodiment of the present disclosure provides an electronic device for implementing a thread recognition method, which may be the user terminal 110 or the server 120 in fig. 1. The electronic device includes at least a processor and a memory for storing executable instructions of the processor, the processor being configured to perform the thread identification method via execution of the executable instructions.
The structure of the electronic device is exemplarily described below by taking the mobile terminal 200 in fig. 2 as an example. It will be appreciated by those skilled in the art that the configuration of figure 2 can also be applied to fixed type devices, in addition to components specifically intended for mobile purposes.
As shown in fig. 2, 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 microphone 272, a microphone 273, an earphone interface 274, a sensor Module 280, a display screen 290, a camera Module 291, a pointer 292, a motor 293, a button 294, and a SIM (Subscriber identity Module) card interface 295.
Processor 210 may include one or more processing units, such as: 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) image or video data; the decoder may decode (i.e., decompress) the codestream data of the image or video to restore the image or video data.
In some embodiments, processor 210 may include one or more interfaces through which connections are made to other components of mobile terminal 200.
Internal memory 221 may be used to store computer-executable program code, which includes instructions. The internal memory 221 may include a volatile memory, a non-volatile memory, and the like. The processor 210 executes various functional applications of the mobile terminal 200 and data processing by executing instructions stored in the internal memory 221 and/or instructions stored in a memory provided in the processor.
The external memory interface 222 may be used to connect an external memory, such as a Micro SD card, for expanding the storage capability of the mobile terminal 200. The external memory communicates with the processor 210 through the external memory interface 222 to perform data storage functions, such as storing music, video, and other files.
The USB interface 230 is an interface conforming to the USB standard specification, and may be used to connect a charger to charge the mobile terminal 200, or connect an earphone or other electronic devices.
The charge management module 240 is configured to receive a charging input from a charger. While the charging management module 240 charges the battery 242, the power management module 241 may also supply power to the device; the power management module 241 may also monitor the status of the battery.
The wireless communication function of the mobile terminal 200 may be implemented by the antenna 1, the antenna 2, the mobile communication module 250, the wireless communication module 260, a modem processor, a baseband processor, and the like. The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. The mobile communication module 250 may provide a solution including 2G/3G/4G/5G wireless communication applied on the mobile terminal 200. The Wireless Communication module 260 may provide Wireless Communication solutions applied to the mobile terminal 200, including WLAN (Wireless Local Area Networks ) (e.g., Wi-Fi (Wireless Fidelity, Wireless Fidelity) Networks), BT (Bluetooth), GNSS (Global Navigation Satellite System), FM (Frequency Modulation), NFC (Near Field Communication), IR (Infrared technology), and the like.
The mobile terminal 200 may implement a display function through the GPU, the display screen 290, the AP, and the like, and display a user interface.
The mobile terminal 200 may implement a shooting function through the ISP, the camera module 291, the encoder, the decoder, the GPU, the display screen 290, the AP, and the like, and may also implement an audio function through the audio module 270, the speaker 271, the receiver 272, the microphone 273, the earphone interface 274, the AP, and the like.
The sensor module 280 may include a depth sensor 2801, a pressure sensor 2802, a gyroscope sensor 2803, a barometric pressure sensor 2804, etc. to implement different sensing functions.
Indicator 292 may be an indicator light that may be used to indicate a state of charge, a change in charge, or may be used to indicate a message, missed call, notification, etc. The motor 293 may generate a vibration cue, may also be used for touch vibration feedback, and the like. The keys 294 include a power-on key, a volume key, and the like.
The mobile terminal 200 may support one or more SIM card interfaces 295 for connecting to a SIM card to implement functions such as telephony and data communications.
Fig. 3 shows an exemplary flow of a thread identification method, which may be executed by the user terminal 110 or the server 120, and includes the following steps S310 to S330:
step S310, a thread to be identified of the currently running application program is obtained.
The currently running application may refer to an application running a related task, or an application currently having an interactive behavior with a user, for example, a media application such as video and music currently running in the foreground, or a game application having a strong interaction with the user. An application, when executed, may include multiple threads associated with a currently running application, e.g., a gaming application, may include a main thread, a rendering thread, or other threads, etc. when executed. The threads are all likely to have resource robbery during running, so all or part of the threads can be used as threads to be identified to execute the identification process of the critical threads.
Step S320, according to the static information and the dynamic information of the application program, counting the thread feature data of the thread to be identified in a preset time period.
The static information of the application refers to fixed characteristic information when the application is executed, such as the type of the application (game application, information application, media application, etc.); the dynamic information refers to characteristic information that changes according to the running state of the application, for example, the number of times that a thread is in a runnable state or a running state when the application is executed, authority information of which threads can be obtained by the application, and running environment information of the application, such as a current game scene in the game application. The static information and the dynamic information may be considered separately, for example, statistical thread feature data may be determined according to a ratio of the number of times that the thread is in the runnable state to the number of times that the thread is in the running state in the dynamic information, or the statistical thread feature data may be determined according to the type of the application program in the static information; and determining which thread characteristic data need to be counted according to the static information and the dynamic information.
The preset time period refers to a specific time period for performing thread feature data statistics, a statistical time node and a statistical duration of the preset time period may be set in a user-defined manner according to actual needs, for example, the statistical time node and the statistical duration may be set as a statistical start node of the preset time period when the application program starts to run, or a certain time after the application program starts to be set as a statistical start node of the preset time period, or the like, the statistical duration of the preset time period may be set to be 5 seconds or 8 seconds, or the like, specifically, the statistical time period may be specifically set according to characteristics or actual conditions of the application program, which is not specifically limited by the present disclosure.
The thread feature data refers to comprehensive data capable of reflecting features of the thread to be identified, and in the present exemplary embodiment, the feature data of the thread to be identified may be counted from one or more dimensions in a preset time period, and the thread feature data of the thread to be identified may be determined based on the feature data of the one or more dimensions, where the feature data of each dimension may be acquired original data, for example, the number of times the thread to be identified is called in the preset time period; or may be data calculated based on the original data, for example, load data at different frequency change points in a preset time period is calculated, and total load data in the preset time period is determined.
In the exemplary embodiment, the thread feature data of one or more threads to be identified may be counted, and for convenience of subsequent calculation, when the thread feature data of one thread to be identified is counted, the thread feature data may be converted into a vector form; when counting the thread feature data of a plurality of threads to be identified, the thread feature data of each thread to be identified may be converted into a corresponding vector form, and then a feature matrix and the like corresponding to the plurality of threads to be identified may be determined according to the plurality of vectors.
Step S330, identifying the thread to be identified based on the thread characteristic data, and determining whether the thread to be identified is a key thread.
And identifying the thread characteristic data, namely identifying the thread to be identified so as to determine whether the thread to be identified is a key thread. The key thread refers to a thread responsible for important work in the system, such as a rendering thread in a game application program, or a data processing thread including work such as receiving and analyzing data packets, processing various interfaces for data distribution, and the like in other application programs. By identifying the thread characteristic data, the embodiment of the example can identify whether the thread to be identified is a key thread, so as to ensure that the thread is reasonably allocated with resources subsequently.
In the present exemplary embodiment, according to the thread feature data, a classification result of whether the thread to be identified is a key thread, a normal thread, or another thread may be obtained, and specifically, the classification result may be represented by a numeral or a letter identifier, for example, a identifier "0" may represent a normal thread, a identifier "1" may represent a key thread, and the like. And further obtaining a resource allocation strategy result of the thread to be identified according to whether the thread to be identified is the identification result of the key thread, for example, further processing according to the identification result and the thread characteristic data, and determining that the thread to be identified can adopt a binding operation strategy to realize resource allocation.
In the present exemplary embodiment, the identifying process for the thread feature data may include a plurality of methods, for example, a known key thread may be determined in advance, then the plurality of threads to be identified are classified by calculating the similarity of the thread feature data of the plurality of threads to be identified, and the threads to be identified classified as a class with the known key thread are determined as the key threads; or calculating the similarity of the thread characteristic data of the known key thread and the thread to be identified, and determining the thread to be identified with the similarity exceeding a certain threshold value as the key thread; and then, training a machine learning model through the sample thread characteristic data and the corresponding label, and processing the thread key data based on the machine learning model to obtain an identification result of the thread to be identified, and the like, which is not specifically limited by the disclosure.
In an exemplary embodiment, the step S330 may include:
converting the thread feature data into thread feature vectors;
and processing the thread characteristic vector by adopting a machine learning model, and determining whether the thread to be identified is a key thread.
In the exemplary embodiment, a pre-trained machine learning model, such as a decision tree or a neural network model, may be directly adopted to directly process the thread feature vector converted from the thread feature data, so as to obtain the classification result of the thread to be identified. The thread feature vector can also be processed in a mode of combining a plurality of models, for example, the thread feature vector of the thread to be identified is processed by adopting the first model to obtain the classification result of the thread to be identified; and further processing the thread to be identified with the classification result as the key thread by adopting a second model to obtain a result of predicting which resource allocation decision can be specifically adopted by the key thread, wherein the first model can be a classification model and outputs the classification result, and the second model can be a regression model and outputs scores of different resource allocation decisions and the like.
In an exemplary embodiment, the thread identification method may further include:
and according to the identification result of the thread to be identified, carrying out resource allocation on the thread to be identified.
According to the identification result, the thread to be identified can be determined to belong to which important degree, further, the thread can be reasonably allocated with resources, for example, when the thread to be identified is determined to be a key thread, the thread can be bound, the affinity of the key thread and the core of a specific processor is improved, and the normal preferential operation of subsequent threads is ensured; or modifying the scheduling level of the key thread by the inner core so that the key thread can effectively schedule the resources; or setting mutually exclusive calling for the key thread; or performing operations such as frequency boosting on the processor core corresponding to the key thread, specifically, performing user-defined selection according to actual requirements, performing reasonable prediction by combining other algorithm models, and the like, which is not specifically limited in this disclosure.
To sum up, in the present exemplary embodiment, a thread to be identified of a currently running application is acquired; according to the static information and the dynamic information of the application program, counting the thread characteristic data of the thread to be identified in a preset time period; and identifying the thread to be identified based on the thread characteristic data, and determining whether the thread to be identified is a key thread. On one hand, the exemplary embodiment provides a new thread identification method, which can directly determine the identification result of the thread to be identified by processing the thread characteristic data, has simple and convenient flow, and can realize the rapid and accurate distinction of threads with different importance degrees, thereby facilitating the reasonable resource allocation of the threads; on the other hand, the thread characteristic data is related to the running state parameters of the application program, so that the thread characteristic data to be counted can be determined in a targeted manner according to the actual running condition and the requirement of the application program, and the effectiveness of the thread characteristic data is ensured; on the other hand, the thread feature data is statistical data obtained in a preset time period, and different thread feature data may be obtained in different preset time periods, so that it is further ensured that the exemplary embodiment can effectively and accurately identify the thread to be identified related to the current application program according to a specific thread running condition, and has strong timeliness.
In an exemplary embodiment, the thread feature data may include: one or more of thread attribute data, thread load data, thread invocation relationship data, thread state data, or thread prior data for a particular application.
The thread attribute data may reflect the importance category of the thread, for example, when the thread is a critical thread, the thread may be represented by a flag "1", when the thread is a normal thread or an unknown thread, the thread may be represented by a flag "0", when the thread is another thread, the thread may be represented by a flag "2" or another flag, and the like. Considering that some important critical threads may be predetermined, such as rendering threads, and other threads need to be identified to determine whether the critical threads are critical threads, non-critical threads in different scenarios may also be identified as critical threads, so the exemplary embodiment may use thread attribute data as thread feature data. The key threads may be predetermined by the platform, for example, the game application may have rendering threads responsible for frame drawing, and the rendering threads may generally have their thread IDs (identification) accurately accessible by the platform, for example, in an android system, the ID of the accurate key thread may be accessible through a queue Buffer (Buffer queue) in a libgui (C language GUI library) library, or the ID of the key thread may be obtained according to a scheme cooperating with some application vendors, so as to tag the threads, and so on.
The thread load data refers to data related to load capacity in the process of thread running, and can reflect the running state of the current thread. The thread call relation data refers to data called by other threads or programs when the application program executes by the thread to be identified, such as the calling level between the thread and the key thread or the called times, and the like. The thread state data may be determined by counting real-time frame rate information of the thread to be identified, specifically, the real-time frame rate of the thread to be identified may be compared with a preset frame rate to determine whether the thread is in a frame drop state or a stuck state, and further, the number of times that the thread is in a runnable state when the thread is in the stuck state may be used as the thread state data.
In addition, according to the type of the application program, in some special application programs, for example, in a game application program, since a game has strict performance index requirements on picture stutter, sound, and the like, a game engine in the game application program often creates its own work thread to process a corresponding task, and these work threads are often critical threads. Considering that the name of a thread created by a game engine, such as a game engine of Unity, unregeal, etc., is usually fixed, or has an obvious characteristic value, etc., therefore, the present exemplary embodiment may use, according to actual needs, thread prior information of a specific application as thread characteristic data, where the prior information is capable of determining whether a thread to be identified is a thread of a specific name created by the specific application for execution, such as NativeThread is an audio-related thread, WorkerThread is a worker thread created by a main thread and a rendering thread, etc., prior information may be determined according to these thread IDs, and may be represented by a specific character, for example, using an identifier "10" to represent that the thread to be identified is a specific thread created by the game engine, using an identifier "00" to represent 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 particular thread created by the game engine, the probability of being identified as a critical thread may also be relatively high.
It should be noted that, according to the actual operating condition and the scene requirement of the application program, other thread feature data may also be obtained in the present exemplary embodiment, so as to increase the dimension of the thread feature data and improve the accuracy and effectiveness of identifying the thread to be identified, which is not specifically limited by the present disclosure.
Fig. 4 shows an architecture diagram of a thread identification method in the present exemplary embodiment, which may specifically include a data obtaining module 410, configured to obtain thread feature data, which may include one or more of thread attribute data 411, thread load data 412, thread invocation relation data 413, thread state data 414, or thread prior data 415 of a specific application; the thread identification module 420 is configured to identify a thread to be identified according to the thread feature data; and a result processing module 430, configured to perform reasonable resource allocation on the critical thread 431 and the non-critical thread 432 according to the identification result.
Further, as shown in fig. 5, in an exemplary embodiment, when the thread characteristic data is thread load data, the step S320 may include the following steps:
step S510, counting the running time of the thread to be identified at each frequency change point in a preset time period;
step S520, acquiring reference calculation force of a processor appointed core;
step S530, calculating load data corresponding to each frequency change point according to the operation time and the reference calculation force;
and step S540, determining the load data of the thread to be identified in a preset time period based on the load data corresponding to each frequency change point.
The thread load data is used as important information for identifying the key thread and can be obtained by calculating the running time and the unit computing power of the thread to be identified. Considering that different application programs can run in cores of different processors, in order to ensure that load data obtained by calculation has analyzability, load data of threads to be identified needs to be calculated by adopting a uniform standard. The exemplary embodiment may first determine a designated core, for example, an oversized core of a terminal device processor, then use a computing force corresponding to a highest frequency in the oversized core as a reference computing force, and normalize the computing force of the thread to be identified within a preset time based on the reference computing force. Specifically, in the present exemplary embodiment, the running time of the thread to be identified at each frequency change point may be counted by taking each frequency change point within a preset time period as a unit, where the frequency change point refers to a statistical time point at which the frequency value changes when the thread runs, for example, the frequency value of the thread changes to 2 after the frequency value of 1 runs for a period of time, and then the point at which the frequency value of 1 is located may be taken as the frequency change point, and the point at which the frequency value of 2 is located may also be taken as the frequency change point, so as to perform data statistics. Then, based on the running time and the reference calculation force, load data corresponding to each frequency change point is calculated, and finally, load data of the thread to be identified in the preset time period is determined according to the load data corresponding to each frequency change point.
For example, the task of the current thread to be identified runs on a big core, and the frequency change point is Freq
1Corresponding unit calculated force is pow
1The thread is at the frequency change point Freq
1Has run for a time t
1After that, the frequency change point becomes Freq
2Triggering and counting the primary load data, which can be represented by the formula:
the frequency change point Freq is obtained by single calculation
1Corresponding load data, wherein powMax represents a reference computational effort, such as a computational effort corresponding to a maximum frequency of the supercooled core; the thread to be identified changes Freq at the frequency change point
2And run for time t
2After that, the frequency change point becomes Freq
3Triggering and counting the primary load data, which can be represented by the formula:
the frequency change point Freq is obtained by single calculation
2Corresponding load data. And analogizing in turn, calculating to obtain load data corresponding to each frequency change point, and further obtaining the load data through a formula: load
T=Load
1+Load
2+……+Load
kAnd determining the load data of the thread to be identified in a preset time period.
In addition, the formula may also be employed:
determining the load data of the thread to be identified in a preset time period, wherein,
load data Load corresponding to the current frequency change point n
nI.e. load data, t, corresponding to each frequency change point can be represented
nRepresents the time, pow, of the thread to be identified running at the frequency change point n
nDenotes a unit calculation force corresponding to the frequency change point n, powMax denotes a reference calculation force, Load
TIndicating the total Load data, Load, accumulated over a period of time up to the current frequency change point n
n-1Representing the total Load data accumulated at the previous frequency change point n-1 of the frequency change point n, and when n is the last frequency change point in the preset time period, Load
TNamely the load data of the thread to be identified in the preset time period. That is, in the present exemplary embodiment, the accumulated load data of the current frequency change point may be calculated based on the operation time of the current frequency change point, the corresponding unit calculation force, the reference calculation force, and the accumulated load data of the previous frequency change point.
In an exemplary embodiment, when the thread feature data is thread call relationship data, the step S320 may include:
determining a reference key thread;
and counting the calling levels of the thread to be identified and the reference key thread and the calling times of the thread to be identified in a preset time period.
The reference critical threads refer to some known predetermined critical threads, for example, in a game application program, a main thread for processing tasks related to game logic and rendering threads for processing the rendering related tasks generally belong to the critical threads and are relatively easy to determine, so that the threads can be used as the reference critical threads, and the calling relationship data of the threads to be identified is determined based on the dependency relationship between the reference critical threads and the critical threads to be identified. The exemplary embodiment may count the calling levels and the calling times of the thread to be identified and the reference key thread within a preset time period to determine the thread calling relationship data.
As shown in fig. 6, a schematic diagram of the wake relationship among multiple threads is shown, where thread GLThread 610 is a rendering thread of a game, which may be a key thread, and thread MainThread 620, thread WorkerThread 630, and thread mali-cmar-back 640 directly wake thread GLThread 610, so that thread MainThread 620, thread WorkerThread 630, and thread mali-cmar-back 640 may be used as a first call level, while thread MainThread 620 is woken by thread WorkerThread 650, thread CoreThread 660, and thread NativeThread 670, but belongs to a second level with respect to thread GLThread 610, so that thread 650, thread CoreThread 660, and NativeThread 670 may be used as a second call level, and so on, thread is used as a third call level, and the number of times of calls in fig. 6 is represented by a preset number.
In an exemplary embodiment, the number of the threads to be identified may be multiple, and as shown in fig. 7, the thread identification method may further include the following steps:
step S710, determining the weight of each thread to be identified according to the thread load data and/or the thread calling relation data of the thread to be identified;
further, step S340 may include:
step S720, combining the weight of each thread to be identified, processing the thread characteristic data of a plurality of threads to be identified so as to identify whether each thread to be identified is a key thread.
That is, the present exemplary embodiment may determine the weight of each thread to be identified according to the thread load data, the thread invocation relation data, and the thread load data and the thread invocation relation data, so as to identify the thread to be identified by combining different weights. Specifically, the heavily loaded thread to be identified may be given a higher weight; or the more times of the threads to be identified are called in the preset time period, the higher weight can be given to the threads to be identified; or a thread to be identified with a smaller calling level can be endowed with higher weight; finally, the above factors may be combined to determine the weight of the thread to be identified, and the like, which is not specifically limited in this disclosure. In addition, after the weights of the different threads to be identified are determined, for convenience of calculation, weight normalization processing and the like can be performed on the threads to be identified.
In addition to determining the weight of the thread to be identified according to the size of the call hierarchy, the exemplary embodiment may also determine the weight of each thread to be identified through other manners according to the thread call relationship data, for example, a reference key thread is used as an initial search call loop, and the weight is determined according to the call loop, for example, it is known that a reference key thread a finds that there is a loop when searching for a call relationship: the thread a < -the thread b < -the thread c < -the thread a (wherein < - > indicates that the thread a is awakened), which indicates that a working loop containing the reference key thread a exists, any thread of the loop does not obtain resources in time and the running of the reference key thread a can be influenced, therefore, the thread b and the thread c can be considered to be endowed with higher weight, so that the thread b and the thread c are more easily classified into the same class as the reference key thread a, and the probability that the thread b and the thread c become the key threads is improved.
In an exemplary embodiment, the thread identification method may further include:
acquiring reference thread characteristic data of a reference key thread;
in the step S720, the identifying the thread feature data of the multiple threads to be identified to obtain the identification results of the multiple threads to be identified includes:
and clustering the reference key thread and the multiple threads to be identified according to the reference thread characteristic data and the thread characteristic data, and determining the threads to be identified which are in the same category as the reference key thread as the key threads.
In this exemplary embodiment, reference thread feature data may also be determined for a predetermined reference critical thread, that is, a known critical thread, and the type of the thread feature data may be the same as the thread feature data of the thread to be identified, for example, the thread feature data may be thread call relationship data, thread load data, and the like. Further, the thread feature data of the known key thread and the thread to be identified are processed through a machine learning model or a clustering algorithm to be classified, and finally the thread to be identified, which belongs to the same category as the known key thread, in the classification result is the key thread.
In an exemplary embodiment, whether the thread to be identified is a critical thread or not can be periodically identified, and the resource allocation can be adjusted according to the running change of the application program. For example, the period may be set to 10 to 20 seconds, and the identification process of the critical thread is triggered each time the period condition is met, and in particular, the present exemplary embodiment may be applied to a scenario where the application program is a game application program, and further, the thread identification method may further include:
and triggering and executing to acquire the thread to be identified of the currently running application program in response to the switching of the game scene of the game application program, so as to periodically identify the thread to be identified of the game application program.
Considering the situation that a scene switch is often involved in a game application scene, the running state, the importance degree, or the resource demand of each thread may change in different game scenes, for example, when a game scene is an indoor scenario scene, thread 1 is a key thread, thread 2 is a normal thread, when a game scene is switched to an outdoor battle scene, thread 1 is a normal thread, thread 2 is a key thread, or both thread 1 and thread 2 are key threads, and so on. Based on this, the exemplary embodiment provides a mechanism for periodically detecting whether the thread to be identified is a critical thread, and when detecting that the game scene is switched, the mechanism may trigger the thread of the current game application to be identified again as the critical thread.
Fig. 8 is a flowchart illustrating another thread identification method in the present exemplary embodiment, which may specifically include the following steps:
step S810, acquiring a plurality of threads to be identified of the currently running application program;
step S820, acquiring thread characteristic data of each thread to be identified in multiple dimensions according to the static information and the dynamic information of the application program;
step S830, determining the weight of each thread to be identified, and normalizing the weight;
step 840, combining the weight of each thread to be identified, processing the thread characteristic data of a plurality of threads to be identified through a machine learning model;
step S850, obtaining the identification result of whether a plurality of threads to be identified are key threads;
step S860, detecting whether the application program finishes running;
if the application program finishes running, finishing the identification process of the thread to be identified;
step S870, detecting whether the current period reaches a preset period;
when the preset period is reached, step S820 is executed to obtain the thread feature data of each thread to be identified in multiple dimensions again, so as to identify the current thread to be identified again.
When the preset period is not reached, the process may return to step S860 to determine whether the application program ends running again and determine whether the preset period is reached again.
The preset period may be set by a user according to needs, for example, the period may be set to 20 seconds.
Exemplary embodiments of the present disclosure also provide a thread identifying apparatus. As shown in fig. 9, the thread identifying apparatus 900 may include: a thread to be identified obtaining module 910, configured to obtain a thread to be identified of a currently running application; the thread characteristic data counting module 920 is configured to count thread characteristic data of the thread to be identified within a preset time period according to the static information and the dynamic information of the application program; and the thread to be identified identifying module 930 configured to identify the thread to be identified based on the thread feature data, and determine whether the thread to be identified is a key thread.
In an exemplary embodiment, the thread characterization data includes: one or more of thread attribute data, thread load data, thread invocation relationship data, thread state data, or thread prior data for a particular application.
In an exemplary embodiment, when the thread characteristic data is thread load data, the thread characteristic data statistics module includes: the running time counting unit is used for counting the running time of the thread to be identified at each frequency change point in a preset time period; a reference calculation force acquisition unit for acquiring a reference calculation force of a processor-specified core; a first calculation unit for calculating load data corresponding to each frequency change point according to the operation time and the reference calculation force; and the second calculating unit is used for determining the load data of the thread to be identified in a preset time period based on the load data corresponding to each frequency change point.
In an exemplary embodiment, when the thread feature data is thread call relation data, the thread feature data statistics module includes: a reference key thread determining unit for determining a reference key thread; and the calling data counting unit is used for counting the calling levels of the thread to be identified and the reference key thread and the calling times of the thread to be identified in a preset time period.
In an exemplary embodiment, the number of the threads to be identified is multiple, and the thread identification method further includes: the weight determining module is used for determining the weight of each thread to be identified according to the thread load data and/or the thread calling relation data of the thread to be identified; the thread recognition module to be recognized comprises: and the thread identification unit is used for processing the thread characteristic data of the multiple threads to be identified by combining the weight of each thread to be identified so as to identify whether each thread to be identified is a key thread.
In an exemplary embodiment, the thread identification method further includes: the reference thread characteristic data acquisition module is used for acquiring reference thread characteristic data of a reference key thread; a thread identification unit comprising: and the thread identification subunit is used for clustering the reference key thread and the multiple threads to be identified according to the reference thread characteristic data and the thread characteristic data, and determining the threads to be identified which are in the same category as the reference key thread as the key threads.
In an exemplary embodiment, the thread to be identified identification module: the vector conversion unit is used for converting the thread characteristic data into thread characteristic vectors; and the vector processing unit is used for processing the thread characteristic vector by adopting a machine learning model and determining whether the thread to be identified is a key thread.
In an exemplary embodiment, the thread identification method further includes: and the resource allocation module is used for allocating resources to the thread to be identified according to the identification result of the thread to be identified.
In an exemplary embodiment, the application is a game application, and the thread identifying method further includes: and the period identification module is used for triggering execution and acquisition of the thread to be identified of the currently running application program in response to the switching of the game scene of the game application program, so as to periodically identify the key thread of the thread to be identified of the game application program.
The specific details of each part in the above device have been described in detail in the method part embodiments, and thus are not described again.
Exemplary embodiments of the present disclosure also provide a computer-readable storage medium, which may be implemented in the form of a program product, including program code, for causing a terminal device to perform the steps according to various exemplary embodiments of the present disclosure described in the above-mentioned "exemplary method" section of this specification, when the program product is run on the terminal device, for example, any one or more of the steps in fig. 3, fig. 5, fig. 7 or fig. 8 may be performed. The program product may employ a portable compact disc 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 that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having 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 disc read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
A computer readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any kind 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).
As will be appreciated by one skilled in the art, aspects of the present disclosure may be embodied as a system, method or program product. Accordingly, various aspects of the present disclosure may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system. Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements 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 to be limited only by the following claims.