Background time-consuming task determination method and device, electronic equipment and storage medium

By analyzing the code difference analysis results and dynamic time-consuming analysis, the deterioration points of background threads are determined, which solves the problems of system resource competition and increased thread scheduling overhead caused by high-frequency thread use, and effectively prevents deterioration and performance improvement of background threads.

CN119536922APending Publication Date: 2025-02-28BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311103637.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-29
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The high-frequency use of threads leads to increased system resource competition and thread scheduling overhead, and lacks effective means to discover and pre-intercept thread creation, which makes it difficult to solve the problem of background thread degradation.

Method used

By analyzing the code difference analysis results, we determine that the code submits additional candidate background tasks, execute the scene code associated with these candidate background tasks, dynamically analyze their time-consuming information, and determine the time-consuming background time-consuming tasks based on the time-consuming information.

Benefits of technology

Effectively prevent deterioration of background threads, and accurately determine the deterioration points of background threads through a combination of static analysis and dynamic analysis, reduce system resource competition and thread scheduling overhead, and improve application performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536922A_ABST
    Figure CN119536922A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a background time-consuming task determination method and device, electronic equipment and a storage medium. The background time-consuming task determination method comprises the steps that a code difference analysis result is analyzed, candidate background tasks added to code submission are determined, and the candidate background tasks are candidate background tasks causing time consuming; executing codes of scenes associated with the candidate background tasks, and determining time consumption information of the candidate background tasks; and based on the time consumption information, determining a background time-consuming task generating time consumption in the candidate background tasks. The background threads are effectively subjected to anti-degradation processing, the candidate background tasks submitted by the codes are analyzed statically, and then the time consumption information of the candidate background tasks is analyzed dynamically through dynamic operation. And the background time-consuming task submitted by the code is determined based on the time-consuming information, so that the degradation point of the background thread is determined.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to computer technology, and more particularly to a method, device, electronic device, and storage medium for determining a time-consuming background task. Background Art

[0002] At present, in order to reduce the pressure on the main thread, the most commonly used optimization strategy is to create a background thread and throw the unnecessary operations of the main thread to the background thread to complete, so as to fully schedule CPU resources and reduce the load of the main thread. However, high-frequency use of threads will lead to increased competition for system resources and increased thread scheduling overhead. Therefore, how to achieve anti-degradation of background threads is a technical problem that needs to be solved urgently. Summary of the invention

[0003] The present disclosure provides a method, device, electronic device and storage medium for determining a time-consuming background task, which effectively determine the degradation point of a background thread, that is, realizes the determination of a time-consuming background task.

[0004] In a first aspect, an embodiment of the present disclosure provides a method for determining a time-consuming background task, comprising:

[0005] Analyze the code difference analysis results to determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption;

[0006] Execute the code of the scenario associated with the candidate background task to determine the time consumption information of the candidate background task;

[0007] Based on the time-consuming information, a time-consuming background task that generates time consumption among the candidate background tasks is determined.

[0008] In a second aspect, the embodiment of the present disclosure further provides a device for determining a background time-consuming task, including:

[0009] An analysis module is used to analyze the code difference analysis results and determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption;

[0010] An execution module, used to execute the code of the scenario associated with the candidate background task and determine the time consumption information of the candidate background task;

[0011] A determination module is used to determine the time-consuming background tasks that consume time among the candidate background tasks based on the time-consuming information.

[0012] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:

[0013] one or more processing devices;

[0014] a storage device for storing one or more programs,

[0015] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method for determining background time-consuming tasks provided by the present disclosure.

[0016] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute a method for determining a background time-consuming task as provided in the present disclosure.

[0017] The disclosed embodiment analyzes the results of the code difference analysis to determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption; executes the code of the scenario associated with the candidate background tasks to determine the time consumption information of the candidate background tasks; and based on the time consumption information, determines the time-consuming background tasks that cause time consumption in the candidate background tasks. The background threads are effectively processed to prevent degradation, by statically analyzing the candidate background tasks submitted by the code, and then dynamically analyzing the time consumption information of the candidate background tasks through dynamic operation. The background time-consuming tasks submitted by the code are then determined based on the time consumption information, thereby realizing the determination of the degradation points of the background threads. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0019] Figure 1 It is a flowchart of a method for determining a background time-consuming task provided by an embodiment of the present disclosure;

[0020] Figure 2 It is a flowchart of another method for determining a background time-consuming task provided by an embodiment of the present disclosure;

[0021] Figure 3 is a schematic diagram of a scenario of environmental consistency provided by an embodiment of the present disclosure;

[0022] Figure 4 is a schematic diagram of a dynamic analysis scenario provided by an embodiment of the present disclosure;

[0023] Figure 5 is a flowchart of degradation attribution provided by an embodiment of the present disclosure;

[0024] Figure 6 is a schematic diagram of a newly added background thread provided by an embodiment of the present disclosure;

[0025] Figure 7 is a schematic diagram of a newly added background task provided by an embodiment of the present disclosure;

[0026] Figure 8 It is a schematic diagram of a background task newly added logic provided by an embodiment of the present disclosure;

[0027] Fig. 9 is a flow chart of a degradation analysis method provided by an embodiment of the present disclosure;

[0028] Fig.10 It is a schematic diagram of a scene directly created by a thread provided in an embodiment of the present disclosure;

[0029] Fig.11 It is a schematic diagram of a thread indirect creation scenario provided by an embodiment of the present disclosure;

[0030] Fig.12 A method for determining indirect thread creation provided by an embodiment of the present disclosure;

[0031] Fig.13 is a schematic diagram of a thread determination method set provided by an embodiment of the present disclosure;

[0032] Fig.14 is a call relationship diagram provided by an embodiment of the present disclosure;

[0033] Fig.15 It is a schematic diagram of determining a task method set provided by an embodiment of the present disclosure;

[0034] Fig.16 is a schematic diagram of determining a newly added task determined in an embodiment of the present disclosure;

[0035] Fig.17 is a schematic diagram of a scenario affected by a newly added task provided by an embodiment of the present disclosure;

[0036] Fig.18 is a schematic diagram of a scenario in which a new thread affects an embodiment of the present disclosure;

[0037] Fig.19 is a schematic diagram of determining a task provided by an embodiment of the present disclosure;

[0038] Fig. 20 is a mapping relationship diagram provided by an embodiment of the present disclosure;

[0039] Fig.21 is a schematic diagram of degradation transmissibility provided by an embodiment of the present disclosure;

[0040] Fig. 22 is a schematic diagram of a time-consuming analysis provided by an embodiment of the present disclosure;

[0041] Fig.23 A schematic diagram of the structure of a device for determining a time-consuming background task provided by an embodiment of the present disclosure;

[0042] Fig.24 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0043] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0044] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0045] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0046] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0047] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0048] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0049] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0050] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0051] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0052] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0053] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0054] Frequent use of threads can lead to the following problems:

[0055] Increased competition for system resources: Each thread requires a certain amount of system resources, such as CPU, memory, IO, etc. If too many threads are created, competition for system resources will increase, resulting in a decrease in application performance. For example, the Android system allocates about 1M of memory to each thread by default.

[0056] Increased thread scheduling overhead: Creating and destroying threads and switching between threads all require a certain amount of overhead, including CPU time slice switching, switching between kernel state and user state, etc. If too many threads are created, the thread scheduling overhead will increase significantly, resulting in a decrease in application performance.

[0057] There is no effective offline means to discover and pre-intercept thread creation. Therefore, it is necessary to build an offline thread degradation prevention solution to better pre-detect and intercept the use of unreasonable threads. Therefore, the present disclosure builds background thread degradation prevention capabilities in the branch merge request (MR) stage.

[0058] Figure 1It is a flow chart of a method for determining a background time-consuming task provided by an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the situation of determining a background time-consuming task. The method can be executed by a background time-consuming task determination device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.

[0059] like Figure 1 As shown, the method includes:

[0060] S110: Analyze the code difference analysis results to determine candidate background tasks added by code submission.

[0061] After the code is developed, the content of the developed code is merged into the branch that the code wants to be merged in a way of requesting a merge. This process is called MR. Code difference analysis will be performed in the MR stage. The objects of code difference analysis are the commit ID of the baseline (i.e., commit ID) and the commit ID of the update, and the difference between the codes of the two is analyzed. Among them, the commit ID of the baseline can represent the commit node before the modification. The commit ID of the update can represent the commit node after the code is modified based on the code corresponding to the commit ID of the baseline.

[0062] The code difference analysis result can be considered as the result of the code difference analysis. The code submission can be considered as the modified code submission for MR. The candidate background task is the candidate background task that causes time consumption.

[0063] This operation can be divided into three steps to determine the candidate background tasks: whether a new background task is added in the MR; whether the thread degradation will affect the core indicator path; whether the new background task is time-consuming. If all of them are true, the determined task can be determined as a candidate background task.

[0064] The purpose of creating a background thread is to execute corresponding tasks, such as running tasks, i.e., Runnable, or calling tasks, i.e., Callable. Threads and tasks do not correspond one to one. A thread may be used to execute multiple tasks. Therefore, an increase in the number of tasks will inevitably lead to thread degradation. Similarly, adding a large amount of time-consuming logic to a single task will inevitably lead to thread degradation. This embodiment converts the analysis of background thread degradation to background task analysis.

[0065] The process of analyzing the code difference analysis results in this operation can be considered as a process of statically analyzing the bytecode to determine whether there are background tasks that are suspected to be time-consuming. Candidate background tasks are also called suspected time-consuming tasks, that is, time-consuming tasks that are initially determined. Whether they are really time-consuming still needs further judgment.

[0066] S120: Execute the code of the scenario associated with the candidate background task to determine the time consumption information of the candidate background task.

[0067] The time-consuming information can be considered as information that represents the time-consuming. The associated scene can be the scene affected by the candidate background task. The dynamic task can be a task in the scene, and the specific task content can be determined based on the scene.

[0068] The process of executing the dynamic task in this operation can be considered as a dynamic analysis process, which is used to determine the static analysis result in S110, that is, the time consumption information of the candidate background task.

[0069] The dynamic tasks executed in this operation include candidate background tasks. After the dynamic tasks are executed, the time consumption information can be determined. Therefore, the time consumption information corresponding to the dynamic tasks is determined as the time consumption information of the corresponding candidate background tasks.

[0070] S130: Determine, based on the time-consuming information, a time-consuming background task among the candidate background tasks.

[0071] The time-consuming background tasks can be considered as the background tasks that actually consume time.

[0072] After determining the time-consuming information, this operation can analyze the time-consuming information, such as determining the value of the time-consuming information. If it is greater than a set threshold, the candidate background task corresponding to the time-consuming information can be considered as a background time-consuming task. After determining the background time-consuming task, the degradation point of the background thread is determined.

[0073] The technical solution of the embodiment of the present disclosure analyzes the results of code difference analysis to determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption; executes the code of the scenario associated with the candidate background tasks to determine the time consumption information of the candidate background tasks; and based on the time consumption information, determines the time-consuming background tasks that cause time consumption in the candidate background tasks. The background threads are effectively processed to prevent degradation, by statically analyzing the candidate background tasks submitted by the code, and then dynamically analyzing the time consumption information of the candidate background tasks through dynamic operation. The background time-consuming tasks submitted by the code are then determined based on the time consumption information, thereby realizing the determination of the degradation points of the background threads.

[0074] Figure 2 is a flowchart of another method for determining a background time-consuming task provided by an embodiment of the present disclosure. This embodiment further illustrates the operation of determining a candidate background task, including the following steps:

[0075] S210: Determine a thread method set for creating a background thread in an application, a task corresponding to the thread method set, a task method set for creating a task, and a task corresponding to the task method set.

[0076] The thread method set can be considered as a set of methods for creating background threads. The tasks corresponding to the thread method set can be considered as the tasks associated with the methods in the thread method set. The task method set can be considered as a set of methods for creating background tasks. The tasks corresponding to the task method set can be considered as the tasks associated with the methods for creating background tasks.

[0077] This step can determine the methods that can create background tasks and background threads in the application, which are used to determine candidate background threads. The determination can be made through a scheduled task.

[0078] The thread method set can be determined from two dimensions: thread class and thread pool interface. The thread method set is determined by the thread class and its associated subclasses. The task method set is determined by the thread pool interface and its associated subclasses.

[0079] The following methods can be used to determine the thread method set and task method set:

[0080] First, determine the application programming interface API corresponding to each set, such as the API corresponding to the thread method set is the thread creation API, and the API corresponding to the task method set is the task creation API.

[0081] Then, starting from the corresponding API, determine whether there is a method on the API call link that directly or indirectly calls the API. If so, determine the called method as an indirectly created method. Or determine a method that directly calls the API. If it exists, treat the method as a directly created method.

[0082] The method indirectly created by the thread method set is the second method, and the method directly created by the thread method set is the first method. The method directly created by the task method set is the third method. The method indirectly created by the task method set is the fourth method.

[0083] The set formed by the first method and the second method is a thread method set, and the set formed by the third method and the fourth method is a task method set.

[0084] The corresponding tasks can be determined by analyzing the bytecode of the method to determine the tasks included in the method or the newly added tasks.

[0085] S220, determining whether the newly added method in the code difference analysis result is included in the thread method set or the task method set, and if so, executing S230.

[0086] The code difference analysis result includes the newly added method in the code, that is, the newly added method. This operation matches the newly added method with the thread method set and the task method set. If the newly added method is included in the thread method set and / or in the task method set, it can be considered that a background task is added, and then S230 is executed.

[0087] S230, determining whether the task corresponding to the newly added method is associated with a scene, and if so, executing S240.

[0088] The scenario associated with this operation may be a directly associated scenario, such as a scenario directly affected by thread degradation. If the task corresponding to the newly added method is included in the method set of the scenario, it can be considered that the task will have an impact on the scenario. Then, S240 can be further executed.

[0089] S240, determining whether the task is time-consuming, and if so, executing S250.

[0090] After determining whether to add a task, determine whether the added task will affect the scene. If so, this operation further determines whether the task generates time consumption, that is, whether the task directly or indirectly includes time-consuming features. Time-consuming features can be considered as features that generate time consumption. Among them, directly including time-consuming features can be considered as the task itself including time-consuming features. Indirectly including time-consuming features can be considered as whether the function directly or indirectly called by the task includes time-consuming features.

[0091] S250: Determine the task as a candidate background task.

[0092] When it is determined that the newly added task affects the scenario and consumes time, the task can be determined as a candidate background task, that is, a background task that may consume time during dynamic runtime and is determined by statically analyzing the bytecode.

[0093] S260: Execute the code of the scenario associated with the candidate background task to determine the time consumption information of the candidate background task.

[0094] S270: Determine, based on the time-consuming information, a time-consuming background task among the candidate background tasks.

[0095] This embodiment further illustrates the means of determining candidate background tasks. When determining candidate background tasks, it is possible to first determine whether a new background task is added, then determine whether the new background task affects the scene, and finally determine whether it will take time. If all of them are true, the background task can be determined as a candidate background task for determining background time-consuming tasks. Through the above method for determining candidate background tasks, the determined candidate background tasks can be made more accurate, providing an accurate data basis for the subsequent determination of background time-consuming tasks.

[0096] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.

[0097] In one embodiment, determining a thread method set for creating a background thread in an application includes:

[0098] Determine thread creation application programming interfaces for various classes in a first class set, wherein the first class set includes a thread class and subclasses of the thread class;

[0099] Determine whether there is a method to create a thread directly through the thread creation application programming interface, and if so, determine the method as a first method to directly create a thread;

[0100] determining a method in a call chain of the thread creation application programming interface that directly or indirectly calls the thread creation application programming interface,

[0101] Analyze the bytecodes of the method that calls the thread creation application programming interface in the call link layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a second method for indirectly creating a thread, and if so, end the analysis of the method in the call link;

[0102] A set formed by the first method and the second method is determined as a thread method set.

[0103] The first type of collection can be considered as a collection formed by the thread class and its subclasses, wherein the thread class can be the Thread class.

[0104] The thread creation application programming interface can be considered as an application programming interface for creating a thread. The thread creation application programming interface can be a start method, that is, a start method.

[0105] This embodiment first collects the thread creation application programming interface of each category in the first category set in the application, and then determines whether there is a method to directly call it, and if so, it is used as the first method. It is determined layer by layer whether there is a method to call the thread creation application programming interface in the call link of the thread creation application programming interface, and if so, it is used as the second method.

[0106] In one embodiment, determining a task method set for creating a task in an application includes:

[0107] Determine task creation application programming interfaces for various categories in a second category set, wherein the second category set includes a thread pool interface and subclasses of the thread pool interface;

[0108] Determine whether there is a method to create a task directly through the task creation application programming interface, and if so, determine the method to be a third method to directly create a task;

[0109] determining a method in a call link of the task creation application programming interface that directly or indirectly calls the task creation application programming interface,

[0110] Analyze the bytecodes of the method that calls the task creation application programming interface in the call chain layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a fourth method for indirectly creating a task, and if so, end the analysis of the method in the call chain;

[0111] A set formed by the third method and the fourth method is determined as a thread method set.

[0112] The second type of set can be considered as a set formed by the thread pool interface and the subclasses of the thread pool interface. The thread pool interface can be an executor interface, namely Executor, and an executor service interface, namely ExecutorService.

[0113] The task creation API can be considered as an API for creating tasks. The task creation API can include an execution method (i.e., execute), a submission method (i.e., submit), and a call method (i.e., invoke).

[0114] The means for determining the third method in this embodiment can refer to the means for determining the first method, and the means for determining the fourth method can refer to the means for determining the second method. In the determination process, the thread creation application program interface is replaced with the task creation application program interface.

[0115] In one embodiment, determining whether the task is time-consuming includes:

[0116] Determine whether the function on the call link of the task includes a time-consuming feature, and if so, determine that the task is time-consuming.

[0117] The time-consuming feature is a feature that generates time consumption. If the function on the task call link includes the time-consuming feature, the task will generate time consumption due to the transitivity of the time consumption. The task call link can be a link that represents the calling relationship between the task and other methods. The function on the task call link can be a function called by the task. If the function has the time-consuming feature, the task will also generate time consumption due to transitivity.

[0118] In one embodiment, before executing the code of the scenario associated with the candidate background task and determining the time consumption information of the candidate background task, the method further includes:

[0119] Perform frequency locking, core locking, and network hardening operations.

[0120] After knowing which time-consuming background tasks are added to the scene, the next step is to obtain the actual time consumption of the corresponding tasks. In order to reduce the interference of other factors, consistency processing will be performed in the software and hardware dimensions, among which frequency locking and core locking (i.e. locking frequency and locking core) and network solidification are two measures to achieve consistency.

[0121] Regarding frequency locking and core locking: The CPU will be down-clocked or over-clocked according to the load of the device, which may lead to performance differences when the same test package is run multiple times, and the method execution time fluctuation increases, affecting the accuracy. Therefore, during the test, the device's CPU will be kept running at a constant frequency. At the same time, Android devices distinguish between large and small cores or large, medium and small cores, and different core types have different main frequencies. In order to keep the device running at a fixed frequency, the runtime core type needs to be fixed.

[0122] Regarding network solidification: In dynamic tasks, it is necessary to control the stability of the network and experimental variables so that the benchmark package and the tested package can execute the same code path as much as possible to improve the credibility of subsequent data comparison. If the network variables are unstable, then the same network request may return inconsistent responses in multiple runs, or the same experiment may hit different experimental groups, which may affect the execution time of the newly added background tasks.

[0123] Figure 3 is a schematic diagram of a scenario of environmental consistency provided by an embodiment of the present disclosure, see Figure 3 , shows a schematic diagram of the scenario of network solidification through recording and playback. Figure 4 is a schematic diagram of a dynamic analysis scenario provided by an embodiment of the present disclosure, see Figure 4 MR performance testing requires building Apk packages for the MR to be tested and the benchmark MR respectively. Both the package to be tested and the benchmark package use performance analysis and tracking tools to perform function instrumentation. The platform provides the ability to test the rack, and performs operations such as locking the screen and core and solidifying the network before the dynamic task runs to ensure the consistency of the environment for multiple runs. According to the previous process, the specific scenarios affected by the newly added background tasks are known. The performance testing service is used to run the dynamic tasks of the corresponding scenarios to obtain tracking (i.e. trace) information, such as dynamic data. Dynamic data can be considered as data generated during the dynamic execution process.

[0124] In one embodiment, determining the time-consuming background tasks among the candidate background tasks based on the time-consuming information includes:

[0125] When the value of the time-consuming information is greater than a set threshold, the candidate background task corresponding to the time-consuming information is determined as the time-consuming background task that generates time.

[0126] The set threshold may be a preset value. Different scenarios may correspond to different set thresholds. When the value of the time-consuming information is greater than the set threshold, it may be considered that the candidate background task is time-consuming and may be determined as a time-consuming background task.

[0127] Static analysis is used to determine whether a new background task has been added to the scenario, and dynamic operation is used to obtain specific tracking information for the indicator scenario. Figure 5 is a flowchart of degradation attribution provided by an embodiment of the present disclosure, see Figure 5 First, use static analysis and dynamic analysis capabilities to generate new background task reports (such as candidate background tasks) and tracking information of baseline packages and comparison packages, namely dynamic Trace; then, match the dynamic Trace of the comparison package (including background tasks) with the new background tasks in the static analysis results, and supplement the time-consuming information of the background tasks; finally, match the background task time consumption with the embedded degradation threshold (i.e., the preset threshold). When the threshold is reached, the degradation point (i.e., the background time-consuming task) is notified to Research and Development (RD).

[0128] The following is an exemplary description of the present disclosure. The method for determining time-consuming background tasks provided by the present disclosure can be considered as a technical solution for preventing background thread degradation in the MR stage. For background threads, it is necessary to know whether there is any new degradation in the background threads in the core indicator path (such as the indicator path of the scenario of interest, which can be pre-set), as well as the specific degradation range. From the perspective of static analysis, it can be broken down into the following three questions:

[0129] Whether new background tasks are added in MR; whether thread degradation will affect the core indicator path; whether the new background tasks are time-consuming.

[0130] After knowing which time-consuming background tasks are added to the core indicator scenarios (such as the scenarios of interest), the next step is to obtain the actual time consumption of the corresponding tasks. In order to reduce the interference of other factors, consistency processing will be performed in the software and hardware dimensions, among which frequency locking, core locking and network solidification are the two most important measures.

[0131] In summary, through the results of static analysis and dynamic analysis, we can know the specific time consumption of the newly added background tasks in the core scenarios.

[0132] In order to better discover and intercept background thread degradation in core indicator scenarios during the MR phase, we first need to make a simple classification of thread degradation. Thread degradation is mainly divided into the following three scenarios:

[0133] Figure 6Schematic diagram of adding a background thread provided by an embodiment of the present disclosure. Adding a background thread: directly adding background thread logic in the core indicator scenario. Figure 6 Based on the creation method of the activity component (that is, the oncreate method of the activity component), including method B and method C, a new start method, such as Thread#start, is added.

[0134] Figure 7 is a schematic diagram of a newly added background task provided by an embodiment of the present disclosure. New background task: A new background task is added to the background thread in the core indicator scenario. Figure 7 The creation method of the activity component includes the start task of the message passing thread (ie, handlerThread#start), and adds a message sending task, namely, handler#post.

[0135] Figure 8 It is a schematic diagram of a background task newly added logic provided by an embodiment of the present disclosure. The background task newly added logic: the task execution logic of the background thread originally exists in the core scenario, but the time-consuming logic is newly added to the original trace. Figure 8 The task in Runnable#run already exists, including method B and method A. The code change leads to the addition of method C, so the background thread's resource preemption will be aggravated.

[0136] This paper designs an anti-degradation solution for newly added background threads and tasks.

[0137] Fig. 9 is a flow chart of the degradation analysis method provided by the embodiment of the present disclosure. Fig. 9 ,The main process of the MR-level background thread anti-degradation solution is divided into the following three parts: static ,analysis, dynamic analysis and degradation attribution.

[0138] Static analysis: When a user submits an MR, the static analysis service is triggered to discover background threads and tasks that may be added to the scenario:

[0139] Using the background thread scanning service, determine whether the code of background threads and background tasks is added in the path of the core indicator scenario (i.e., determine whether the indicator path is affected) (i.e., determine whether new background threads and tasks are added), that is, determine the thread method set for creating background threads in the application, the tasks corresponding to the thread method set, the task method set for creating tasks, and the tasks corresponding to the task method set; determine whether the newly added method in the code difference analysis result is included in the thread method set or the task method set; if so, determine whether the task corresponding to the newly added method is associated with the scenario;

[0140] The static time-consuming analysis service is triggered to analyze whether the newly added background thread task will be time-consuming (i.e. determine whether the task will be time-consuming, also known as determining whether the background task has time-consuming characteristics) through pre-designed static time-consuming rules, thereby generating a static analysis report.

[0141] Dynamic analysis: When static analysis finds that there is a new background thread on the core indicator path and the background thread task has time-consuming characteristics, the dynamic anti-degradation test will be triggered to obtain the trace information of the scenario:

[0142] First, the dynamic operating environment needs to rely on the ability of network solidification. Through network solidification, the branches of the benchmark package and the test package are ensured to be consistent, and the variables are controlled to reduce the interference of network factors. The purpose of locking the frequency and core is to ensure the consistency of the hardware and prevent the dynamic task function from fluctuating too much in time. Finally, according to the indicator scenario affected by the background thread task, the dynamic task of the corresponding scenario is triggered (that is, the indicator scenario is dynamically run), and the trace information under the scenario is obtained, that is, the code of the scenario associated with the candidate background task is executed, the time information of the candidate background task is determined, and a dynamic analysis report is produced.

[0143] Degradation attribution: Use the combined dynamic and static attribution service capabilities to determine whether the newly added background thread introduces effective degradation (i.e., based on the time-consuming information, determine the time-consuming background tasks that generate time in the candidate background tasks). If effective, generate an attribution report to notify relevant developers to handle it.

[0144] The static analysis is as follows:

[0145] Whether new background threads or tasks are added. In the Android system, thread creation includes thread creation at the Java layer.

[0146] Java layer thread creation: thread creation classes, such as message passing threads, namely HandlerThread and thread pool executor ThreadPoolExecutor. They are all based on threads, that is, some encapsulation of Thread, and essentially need to create thread resources through Thread. Java threads are implemented based on Native threads, and ultimately threads are created through thread creation methods, such as pthread_create.

[0147] This disclosure is aimed at the problem of background thread degradation at the Java level. Background tasks are closely related to background threads. The above Java thread creation methods all have corresponding background task creation methods. Therefore, based on the differences in thread creation and task scheduling, the background thread degradation analysis is divided into the following two categories:

[0148] Use threads through the Thread class; use threads through the ThreadPoolExecutor, i.e., the thread pool.

[0149] The timer thread, i.e., lightweight thread frameworks such as TimerThread and HandlerThread, is essentially also a Thread sequence, and is inherited from the thread class of the Java long package, i.e., java.lang.Thread, but the lightweight thread framework has its own task management framework. This disclosure handles two scenarios: thread and thread pool.

[0150] For the use of threads by the Thread class, the process of Thread thread creation: the creation of each Java Thread is actually started when the start() function is called. At the same time, the execution logic of the Runnable task is also triggered by the start() function, collecting all subclasses of java.lang.Thread.

[0151] After collecting all java.lang.Thread subclasses, just monitor the corresponding start() method. Later, you only need to monitor the start() of this class collection (that is, the thread creation application programming interface of each class in the first class collection) in the core indicator scenario and add a new call.

[0152] The new calling scenarios of threads can be divided into two scenarios: direct creation and indirect creation.

[0153] Direct thread creation: directly through the Thread class and its subclasses (i.e. the first class collection), by calling its start() method (i.e. the thread creation API). This direct creation scenario can be covered by the above-mentioned new call to the start method of the Thread class and its subclasses.

[0154] Fig.10 is a schematic diagram of a thread directly creating a scene provided by an embodiment of the present disclosure, Fig.10 It shows the direct creation of a newly added thread. On the basis of the creation methods of the activity component including method B and method C, a start method of the thread class, namely, the start method of the Thread class, is added. Fig.11 is a schematic diagram of a thread indirect creation scenario provided by an embodiment of the present disclosure, Fig.11 It shows that the thread is indirectly created. The start() method (ie, the start method) of the Thread class and its subclasses is not directly called. Instead, the call of method A is added, and the processing of the newly added thread is performed on the link of method A.

[0155] For the scenario of indirect thread creation, we need to discuss it on a case-by-case basis. If all methods that create threads in the method call chain are included in the monitoring, and threads are created by default every time a related method is newly called, many false positives will be generated. For example, although the initialization method, init(), contains the logic of creating threads, each new init() method call does not necessarily create threads, because it may return after determining that it has been initialized, without executing the logic of creating threads. Therefore, if the init() method is included in the monitoring, the detection accuracy will be reduced.

[0156] In order to ensure that new function calls will result in the creation of background threads, when collecting functions that indirectly create threads, starting from this function until the thread creation function is called, it is necessary to ensure that there are no return bytecode instructions such as RETURN on the link, and jump bytecode instructions such as GOTO need to ensure that the jump location is before Thread#start() is executed.

[0157] For example, in the following two situations, in Case 1, the a() method calls the b() method. Although the b() method calls Thread#start(), which is the thread creation application programming interface, before calling Thread#start(), it is necessary to determine whether to end the method directly based on the status of the f() return value. Therefore, we cannot include the b() method in the monitoring, and then the a() method cannot be included in the monitoring.

[0158] In Case 2, the c() method calls the d() method, and d() calls Thread#start(). Unlike Case 1, there is no bytecode for method return or jump from c() until Thread#start() is called. Therefore, both d() and c() methods need to be included in the monitoring. If new calls to the c() and d() methods are found in the core scenarios later, it needs to be paid attention to.

[0159] Fig.12 A method for determining indirect thread creation provided by an embodiment of the present disclosure. Fig.12 , it is clear which methods belong to the indirect thread creation method. Then take the start method of the thread class, that is, Thread#start(), as the source. According to the call chain, we know that it is called by method d, that is, d(). Then analyze the bytecode of the d() method, and analyze it from the call of Thread#start() upwards. If bytecode instructions such as method return are encountered, the process terminates. Otherwise, take d() as the key function for creating a thread, and then use the d() function as the source to analyze method c. And so on, collect all the indirect thread creation methods.

[0160] Fig.13 is a schematic diagram of a thread determination method set provided by an embodiment of the present disclosure, see Fig.13 , collect the method set of Thread class and its subclasses to directly and indirectly create background threads. The overall process is as follows:

[0161] 1. Take the thread class of the Java long package, that is, the java.lang.Thread class, as the source, collect related subclasses through inheritance relationships, and obtain the thread method set;

[0162] 2. Build the application's call relationship graph, also known as the call graph, or CallGraph, to determine the call relationship between methods;

[0163] a. The core solution for building CallGraph is to use bytecode static analysis to determine the method call path. Based on the open source library Soot pointer analysis algorithm, the method reachability analysis tool is implemented to support any entry method to automatically analyze all methods directly or indirectly called by the method, and connect the call relationship of all functions in a code segment through the call chain to form a graph. Fig.14 is a call relationship diagram provided by an embodiment of the present disclosure, Fig.14 The CallGraph shown shows the calling relationship between methods, that is, the calling chain.

[0164] 3. After knowing the call link of the caller of the thread creation API, it is necessary to analyze each caller from the method start to the final call to the thread creation API link to ensure that there are no bytecode instructions such as method return in the middle, and generate a collection of methods for indirect thread creation, that is, determine the method that directly or indirectly calls the thread creation application programming interface in the call link of the thread creation application programming interface, analyze the bytecode of the method that calls the thread creation application programming interface in the call link layer by layer, and determine whether there is a bytecode of the method return instruction. If not, determine the method as the second method for indirect thread creation. If so, end the analysis of the method in the call link;

[0165] 4. Finally, the methods for direct and indirect thread creation are aggregated together to form a thread creation collection related to the Thread class, that is, the set formed by the first method and the second method is determined as a thread method set.

[0166] Using threads for thread pools: Since the thread pool reuses threads, the degradation caused by adding new threads is limited, and the thread creation process in the thread pool has been encapsulated, so the degradation caused by adding new background tasks can be considered.

[0167] The top-level interface in the inheritance relationship of thread pool related classes is Executor. The top-level interface Executor provides an idea: decoupling task submission and task execution. Users do not need to worry about how to create threads or how to schedule threads to execute tasks. Users only need to provide task objects and submit the task's running logic to Executor. The Executor framework completes the thread allocation and task execution.

[0168] The ExecutorService interface adds some capabilities: expanding the ability to execute tasks, for example, providing a method for generating Futures from one or a batch of asynchronous tasks; the present disclosure considers the execute, submit, and invoke methods in the Executor and ExecutorService interfaces (i.e., thread pool interfaces), i.e., task creation application programming interfaces, which are the core APIs for thread pools to create tasks.

[0169] After finding the core API for creating tasks, the remaining process is similar to Thread, collecting the methods of the thread pool to directly and indirectly create background tasks. The overall process is as follows, the difference includes the different task scheduling APIs of the thread pool.

[0170] Fig.15 This is a schematic diagram of determining a task method set provided by an embodiment of the present disclosure. Through the thread pool and its subclass task scheduling API, the thread pool-related monitoring method collection (task method set) is determined. For the specific process in this example, see Fig.13 , which will not be elaborated here.

[0171] Determine whether a new thread or task has been added Through the above steps, we have learned the methods related to creating threads and adding new tasks. What we need to do next is to combine the modified code to determine whether there are new related methods. Fig.16 is a schematic diagram of determining a newly added task determined in an embodiment of the present disclosure, Fig.16 As shown, first you need to create a scheduled task to regularly collect methods that can directly or indirectly create background tasks and threads in the application, that is, determine the thread method set and task method set. Then, based on the product of code difference analysis, analyze one by one whether the newly added methods in MR belong to the task addition or thread creation method set (that is), and finally produce relevant reports.

[0172] Whether thread degradation affects core indicators: The direct impact of thread degradation on core scenarios, that is, thread degradation directly affects a certain scenario. Fig.17 is a schematic diagram of a scenario affected by a newly added task provided by an embodiment of the present disclosure, Fig.18 It is a schematic diagram of a scenario affected by a newly added thread provided by an embodiment of the present disclosure. Fig.17 It shows that the newly added thread class start method in the first refresh scenario adds a running task, and the child nodes under the running task include method A and method B. In the first refresh scenario, a background thread task is added, and some time-consuming operations are performed in this task, so it will compete with the main thread of the first refresh for CPU resources, thus causing an impact. Fig.18 In the method B and method C of the first refresh scene, a start method of the new thread class is added. For the directly affected scenes, as long as the background task is added or the thread creation method is found in the modified code and responds to the method set of the scene indicator path, it is considered that a certain scene is affected.

[0173] Check whether the background task has time-consuming operations:

[0174] First, find the newly added background tasks from the results of bytecode difference analysis, and break the problem down into two dimensions: direct addition and indirect addition for processing.

[0175] Direct addition: You can directly identify the newly added background tasks from the results of bytecode difference analysis. For scenarios where background threads are directly added, the tasks to be executed can be determined by analyzing the specific bytecodes.

[0176] Indirect addition: In order to save computing power and time, the static analysis of MR uses the results of bytecode difference analysis as input, so only the modified code will be further analyzed. Therefore, compared with the directly added scenarios, which have sufficient background task information, the indirectly added scenarios lack context, and it is difficult to analyze which specific background threads have been added from the modified code. Therefore, we can only know that the newly added methods will indirectly create threads or background tasks.

[0177] A method d is added directly to method c, and other codes are not modified. Then, after bytecode difference analysis, we can only know from the code diff result that method d is added, but other context information is missing. It is impossible to perceive which background task is added to method d, and it is impossible to determine the impact of the background task.

[0178] Fig.19 This is a schematic diagram of determining a task provided by an embodiment of the present disclosure. In the process of collecting methods for indirectly creating background tasks and threads, the task information corresponding to the relevant threads is analyzed at the same time. Then, each time a new method d is added to MR, it is known that a new running task A, that is, the task RunnableA, will be added. Similarly, since the method c calls the method d, since this mapping relationship is transitive, each time a new method c is added, it means that the task RunnableA is added. Therefore, a mapping table will be generated in the end to maintain the relationship between the method for indirectly creating threads and its corresponding background tasks. Fig. 20is a mapping relationship diagram provided by an embodiment of the present disclosure, Fig. 20 The relationship between methods and tasks is shown, and the relationship between tasks corresponding to the thread method set and tasks corresponding to the task method set is shown. For example, method d, also known as method d, and method c, also known as method c, are both associated with running task A.

[0179] Task time consumption analysis: To determine whether adding background tasks may cause degradation, it is necessary to determine which operations may cause degradation: According to the analysis, the general characteristics that may cause method time consumption are locks, loops, and special method calls. Special method calls include IO, Native methods, and thread-related.

[0180] Table 1 is an example table of time-consuming features provided by an embodiment of the present disclosure.

[0181]

[0182] Fig.21 is a schematic diagram of degradation transfer provided by an embodiment of the present disclosure, see Fig.21 , the newly added running task, Runnable#run itself, has no time-consuming operation and is indirectly caused by method D. Therefore, it is necessary to obtain the complete method call path through static analysis of the call relationship graph to find all suspected time-consuming operations, that is, to find the time-consuming function.

[0183] Fig. 22 is a schematic diagram of a time-consuming analysis provided by an embodiment of the present disclosure, see Fig. 22 The specific process of background task time-consuming analysis service analysis is as follows:

[0184] Using the previously created scheduled tasks, we collect the methods that can create background tasks and threads in the application, and analyze the corresponding task information to generate a corresponding mapping table, that is, a method-task mapping relationship table, and combine the bytecode difference analysis results to obtain the newly added tasks. For the call graph of the newly added task, the static time analysis tool analyzes layer by layer whether the functions on the task call link hit the time-consuming features to implement time-consuming function detection. If it hits, the task will be marked as a suspected time-consuming task. Finally, the results are organized into a static time analysis report, which mainly involves which time-consuming operations are involved in the newly added background tasks.

[0185] The present disclosure locates and discovers the background threads that cause performance degradation by combining dynamic operation and static analysis. By means of static analysis, the API for thread creation is analyzed to find out whether a background thread is newly added to the core scene.

[0186] Fig.23 A schematic diagram of the structure of a device for determining a time-consuming background task provided by an embodiment of the present disclosure is shown in FIG. Fig.23As shown, the device comprises:

[0187] An analysis module 2310 is used to analyze the code difference analysis result and determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption;

[0188] An execution module 2320, configured to execute the code of the scenario associated with the candidate background task and determine the time consumption information of the candidate background task;

[0189] The determination module 2330 is used to determine the time-consuming background tasks that consume time among the candidate background tasks based on the time-consuming information.

[0190] The technical solution provided by the embodiment of the present disclosure effectively performs anti-degradation processing on the background thread, statically analyzes the candidate background tasks submitted by the code, and then dynamically analyzes the time-consuming information of the candidate background tasks through dynamic operation. Then, the time-consuming background tasks submitted by the code are determined based on the time-consuming information, thereby determining the degradation point of the background thread.

[0191] The background time-consuming task determination device provided in the embodiments of the present disclosure can execute the background time-consuming task determination method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0192] In one embodiment, the analysis module 2310 includes:

[0193] A first determining unit is used to determine a thread method set for creating a background thread in an application, a task corresponding to the thread method set, a task method set for creating a task, and a task corresponding to the task method set;

[0194] A second determination unit, used to determine whether a newly added method in the code difference analysis result is included in the thread method set or the task method set;

[0195] A third determining unit, configured to determine whether the task corresponding to the newly added method is associated with a scenario;

[0196] A fourth determining unit, configured to determine whether the task is time-consuming if yes;

[0197] A fifth determining unit is configured to, if yes, determine the task as a candidate background task.

[0198] In one embodiment, the first determining unit is specifically configured to:

[0199] Determine thread creation application programming interfaces for various classes in a first class set, wherein the first class set includes a thread class and subclasses of the thread class;

[0200] Determine whether there is a method to directly create a thread through the thread creation application programming interface, and if so, determine the method as a first method to directly create a thread;

[0201] determining a method in a call chain of the thread creation application programming interface that directly or indirectly calls the thread creation application programming interface,

[0202] Analyze the bytecodes of the method that calls the thread creation application programming interface in the call link layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a second method for indirectly creating a thread, and if so, end the analysis of the method in the call link;

[0203] A set formed by the first method and the second method is determined as a thread method set.

[0204] In one embodiment, the first determining unit is specifically configured to:

[0205] Determine task creation application programming interfaces for various categories in a second category set, wherein the second category set includes a thread pool interface and subclasses of the thread pool interface;

[0206] Determine whether there is a method to create a task directly through the task creation application programming interface, and if so, determine the method to be a third method to directly create a task;

[0207] determining a method in a call link of the task creation application programming interface that directly or indirectly calls the task creation application programming interface,

[0208] Analyze the bytecodes of the method that calls the task creation application programming interface in the call chain layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a fourth method for indirectly creating a task, and if so, end the analysis of the method in the call chain;

[0209] A set formed by the third method and the fourth method is determined as a thread method set.

[0210] In one embodiment, the fourth determining unit is specifically configured to:

[0211] Determine whether the function on the call link of the task includes a time-consuming feature, and if so, determine that the task is time-consuming.

[0212] In one embodiment, the device further includes a consistency module for performing frequency locking, core locking, and network solidification operations before executing the code of the scenario associated with the candidate background task and determining the time-consuming information of the candidate background task.

[0213] In one embodiment, the determination module 2330 is specifically configured to:

[0214] When the value of the time-consuming information is greater than a set threshold, the candidate background task corresponding to the time-consuming information is determined as the time-consuming background task that generates time.

[0215] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.

[0216] Fig.24 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Fig.24 , which shows an electronic device (eg, Fig.24 A schematic diagram of the structure of a terminal device or server) 500.

[0217] The electronic device 500 includes: one or more processing devices 501;

[0218] The storage device 508 is used to store one or more programs.

[0219] When the one or more programs are executed by the one or more processing devices 501, the one or more processing devices 501 implement the method provided in the embodiment of the present disclosure.

[0220] The terminal devices in the embodiments of the present disclosure may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., as well as fixed terminals such as digital TVs, desktop computers, etc. Fig.24 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0221] like Fig.24 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An edit / output (I / O) interface 505 is also connected to the bus 504.

[0222] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.24 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0223] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0224] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0225] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0226] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the method provided by the above embodiments is implemented.

[0227] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two.

[0228] The computer storage medium may be a storage medium of computer executable instructions, which, when executed by a computer processor, are used to perform the methods provided by the present disclosure.

[0229] Computer readable storage media may be, for example, but not limited to: electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination thereof. More specific examples of computer readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), 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 thereof. In the present disclosure, a computer readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer 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 thereof. A computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate, or transmit a program used by or in combination with an instruction execution system, device, or device. The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wire, optical cable, RF (radio frequency), etc., or any suitable combination of the foregoing.

[0230] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0231] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0232] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:

[0233] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: analyzes the code difference analysis result to determine candidate background tasks added by the code submission, where the candidate background tasks are candidate time-consuming background tasks;

[0234] Execute the code of the scenario associated with the candidate background task to determine the time consumption information of the candidate background task;

[0235] Based on the time-consuming information, a time-consuming background task that generates time consumption among the candidate background tasks is determined.

[0236] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or combinations thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0237] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0238] The modules or units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a module or unit does not limit the unit itself in some cases.

[0239] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0240] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), 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 foregoing.

[0241] According to one or more embodiments of the present disclosure, [Example 1] provides a method for determining a background time-consuming task, including:

[0242] Analyze the code difference analysis results to determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption;

[0243] Execute the code of the scenario associated with the candidate background task to determine the time consumption information of the candidate background task;

[0244] Based on the time-consuming information, a time-consuming background task that generates time consumption among the candidate background tasks is determined.

[0245] According to one or more embodiments of the present disclosure, [Example 2] provides the method described in Example 1, wherein analyzing the code difference analysis results to determine the candidate background tasks added by the code submission includes:

[0246] Determine a thread method set for creating a background thread in an application, a task corresponding to the thread method set, a task method set for creating a task, and a task corresponding to the task method set;

[0247] Determine whether the newly added method in the code difference analysis result is included in the thread method set or the task method set;

[0248] If so, determining whether the task corresponding to the newly added method is associated with a scenario;

[0249] If so, determining whether the task is time-consuming;

[0250] If so, the task is determined as a candidate background task.

[0251] According to one or more embodiments of the present disclosure, [Example 3] provides the method described in 2, which determines a thread method set for creating a background thread in an application, including:

[0252] Determine thread creation application programming interfaces for various classes in a first class set, wherein the first class set includes a thread class and subclasses of the thread class;

[0253] Determine whether there is a method to directly create a thread through the thread creation application programming interface, and if so, determine the method as a first method to directly create a thread;

[0254] determining a method in a call chain of the thread creation application programming interface that directly or indirectly calls the thread creation application programming interface,

[0255] Analyze the bytecodes of the method that calls the thread creation application programming interface in the call link layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a second method for indirectly creating a thread, and if so, end the analysis of the method in the call link;

[0256] A set formed by the first method and the second method is determined as a thread method set.

[0257] According to one or more embodiments of the present disclosure, [Example 4] provides the method described in 2, which determines a task method set for creating a task in an application, including:

[0258] Determine task creation application programming interfaces for various categories in a second category set, wherein the second category set includes a thread pool interface and subclasses of the thread pool interface;

[0259] Determine whether there is a method to create a task directly through the task creation application programming interface, and if so, determine the method to be a third method to directly create a task;

[0260] determining a method in a call link of the task creation application programming interface that directly or indirectly calls the task creation application programming interface,

[0261] Analyze the bytecodes of the method that calls the task creation application programming interface in the call chain layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a fourth method for indirectly creating a task, and if so, end the analysis of the method in the call chain;

[0262] A set formed by the third method and the fourth method is determined as a thread method set.

[0263] According to one or more embodiments of the present disclosure, [Example 5] provides the method described in 2, which determines whether the task is time-consuming, including:

[0264] Determine whether the function on the call link of the task includes a time-consuming feature, and if so, determine that the task is time-consuming.

[0265] According to one or more embodiments of the present disclosure, [Example 6] provides the method described in 1, which further includes: before executing the code of the scenario associated with the candidate background task and determining the time-consuming information of the candidate background task:

[0266] Perform frequency locking, core locking, and network hardening operations.

[0267] According to one or more embodiments of the present disclosure, [Example 7] provides the method described in 1, wherein determining the time-consuming background task among the candidate background tasks based on the time-consuming information includes:

[0268] When the value of the time-consuming information is greater than a set threshold, the candidate background task corresponding to the time-consuming information is determined as the time-consuming background task that generates time.

[0269] According to one or more embodiments of the present disclosure, [Example 8] provides a device for determining a background time-consuming task, characterized in that it includes:

[0270] An analysis module is used to analyze the code difference analysis results and determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption;

[0271] An execution module, used to execute the code of the scenario associated with the candidate background task and determine the time consumption information of the candidate background task;

[0272] A determination module is used to determine the time-consuming background tasks that consume time among the candidate background tasks based on the time-consuming information.

[0273] According to one or more embodiments of the present disclosure, [Example 9] provides an electronic device, characterized in that the electronic device includes:

[0274] one or more processing devices;

[0275] a storage device for storing one or more programs,

[0276] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method for determining the background time-consuming task as described in any one of Examples 1-7.

[0277] According to one or more embodiments of the present disclosure, [Example 10] provides a storage medium containing computer executable instructions, which, when executed by a computer processor, are used to execute the background time-consuming task determination method as described in any one of Examples 1-7.

[0278] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0279] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0280] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for determining time-consuming background tasks, characterized in that: include: Analyze the code difference analysis results to determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption; Execute the code of the scenario associated with the candidate background task to determine the time consumption information of the candidate background task; Based on the time-consuming information, a time-consuming background task that generates time consumption among the candidate background tasks is determined.

2. The method according to claim 1, characterized in that The code difference analysis results are analyzed to determine the candidate background tasks added by the code submission, including: Determine a thread method set for creating a background thread in an application, a task corresponding to the thread method set, a task method set for creating a task, and a task corresponding to the task method set; Determine whether the newly added method in the code difference analysis result is included in the thread method set or the task method set; If so, determining whether the task corresponding to the newly added method is associated with a scenario; If so, determining whether the task is time-consuming; If so, the task is determined as a candidate background task.

3. The method according to claim 2, characterized in that Determine the set of thread methods that create background threads in your application, including: Determine thread creation application programming interfaces for various classes in a first class set, wherein the first class set includes a thread class and subclasses of the thread class; Determine whether there is a method to directly create a thread through the thread creation application programming interface, and if so, determine the method as a first method to directly create a thread; determining a method in a call chain of the thread creation application programming interface that directly or indirectly calls the thread creation application programming interface, Analyze the bytecodes of the method that calls the thread creation application programming interface in the call link layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a second method for indirectly creating a thread, and if so, end the analysis of the method in the call link; A set formed by the first method and the second method is determined as a thread method set.

4. The method according to claim 2, characterized in that: Determine the set of task methods for creating tasks in the application, including: Determine task creation application programming interfaces for various categories in a second category set, wherein the second category set includes a thread pool interface and subclasses of the thread pool interface; Determine whether there is a method to create a task directly through the task creation application programming interface, and if so, determine the method to be a third method to directly create a task; determining a method in a call link of the task creation application programming interface that directly or indirectly calls the task creation application programming interface, Analyze the bytecodes of the method that calls the task creation application programming interface in the call chain layer by layer to determine whether there is a bytecode of a method return instruction, if not, determine the method as a fourth method for indirectly creating a task, and if so, end the analysis of the method in the call chain; A set formed by the third method and the fourth method is determined as a thread method set.

5. The method according to claim 2, characterized in that: Determining whether the task is time-consuming includes: Determine whether the function on the call link of the task includes a time-consuming feature, and if so, determine that the task is time-consuming.

6. The method according to claim 1, characterized in that Before executing the code of the scenario associated with the candidate background task and determining the time-consuming information of the candidate background task, the method further includes: Perform frequency locking, core locking, and network hardening operations.

7. The method according to claim 1, characterized in that The determining, based on the time-consuming information, the time-consuming background tasks among the candidate background tasks includes: When the value of the time-consuming information is greater than a set threshold, the candidate background task corresponding to the time-consuming information is determined as the time-consuming background task that generates time.

8. A device for determining a background time-consuming task, characterized in that: include: An analysis module is used to analyze the code difference analysis results and determine the candidate background tasks added by the code submission, where the candidate background tasks are candidate background tasks that cause time consumption; An execution module, used to execute the code of the scenario associated with the candidate background task and determine the time consumption information of the candidate background task; A determination module is used to determine the time-consuming background tasks that consume time among the candidate background tasks based on the time-consuming information.

9. An electronic device, characterized in that: The electronic device comprises: one or more processing devices; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the method for determining background time-consuming tasks as described in any one of claims 1-7.

10. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the method for determining background time-consuming tasks according to any one of claims 1 to 7 when executed by a computer processor.