Task scheduling method, device and equipment
By dynamically adjusting the delay breaking range of tasks, the problems of unsmooth task execution caused by fixed delay time intervals in the prior art are solved, and flexible task scheduling and efficient application response are achieved .
Patent Information
- Application Number
- CN202310981420.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-04
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, a fixed delay time interval is used to disperse the delay of tasks, resulting in poor execution of tasks when users operate frequently, and some tasks cannot be executed for a long time when users operate frequently, affecting functions.
Dynamically determine the system load data based on the load evaluation indicators of the target application, dynamically adjust the delay breaking amplitude of the task, and specifically through the control parameters in the control unit (such as initial execution time, execution window time, execution interval time, execution concurrency number and execution Timeout time) to achieve flexible scheduling of tasks.
Dynamically adjust the delay breaking range of tasks according to the system load situation, ensure that tasks are executed as soon as possible and avoid blockage caused by poor execution, improving the application's response speed and functional stability.
Smart Images

Figure CN119440747A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a task scheduling method, device and equipment. Background Art
[0002] Usually, when an application is running, the application backend will perform a variety of tasks. For example, after the application is started and before the application page is loaded, the application will initialize the processing module and load the function. Usually, the application will encapsulate the module initialization and function loading into a task, and execute the task when the application starts.
[0003] For applications with complex functions, the number of tasks that need to be executed simultaneously may be large. In order to avoid the application taking too long due to the execution of a large number of tasks at the same time, a large number of tasks will be classified, and tasks that do not need to be executed immediately will be executed in a delayed and scattered manner.
[0004] In the current delay dispersion method, a fixed delay time interval is used to delay and disperse tasks. The delay time can be used to characterize the delay dispersion range of tasks. When users frequently use the application, the fixed delay time may be too short and the delay dispersion range is small. In this case, the task execution will occupy too many computing resources and the task execution will not be smooth. When users do not frequently use the application, the fixed delay time may be too long and the delay dispersion range is large. In this case, some tasks will not be executed for a long time, affecting the corresponding functions. Summary of the invention
[0005] In view of this, the present application provides a task scheduling method, apparatus and device for realizing flexible task scheduling.
[0006] To solve the above problems, the technical solutions provided by this application are as follows:
[0007] In a first aspect, the present application provides a task scheduling method, the method comprising:
[0008] Based on at least one load assessment indicator of the target application, determining system load data of the target application under each load assessment indicator;
[0009] Adding the control unit corresponding to the load evaluation index when the system load data meets the preset load range to the control unit set; the control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application; the control parameters are used to indicate the delay dispersion range of the task;
[0010] Selecting the next task of the currently executed task from the task selection queue of the target application, and selecting the control unit corresponding to the next task from the control unit set;
[0011] The delayed execution result of the next task is determined according to the control parameters in the control unit corresponding to the next task.
[0012] In a second aspect, the present application provides a task scheduling device, the device comprising:
[0013] A first determining unit, configured to determine system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application;
[0014] An adding unit, used for adding a control unit corresponding to the load evaluation index when the system load data meets a preset load range to a control unit set; the control parameters in the control unit include an initial execution time, an execution window time, an execution interval time, a number of concurrent executions, and an execution timeout time of a task in the target application; the control parameters are used to indicate a delay dispersion range of the task;
[0015] A selection unit, configured to select a next task of a currently executed task from a task selection queue of the target application, and select a control unit corresponding to the next task from the control unit set;
[0016] The second determining unit is used to determine the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task.
[0017] In a third aspect, the present application provides an electronic device, including:
[0018] one or more processors;
[0019] a storage device having one or more programs stored thereon,
[0020] When the one or more programs are executed by the one or more processors, the one or more processors implement any of the task scheduling methods.
[0021] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements any of the task scheduling methods described above when executed by a processor.
[0022] It can be seen that this application has the following beneficial effects:
[0023] The present application provides a task scheduling method, device and equipment. Whether the user frequently uses the application operation can affect the system load of the application. The present application first determines the system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application. The determined system load data is used to represent the current system load of the target application. There is at least one load evaluation indicator, and each load evaluation indicator can be used to evaluate the system load of the target application. Determine whether the system load data obtained by each load evaluation indicator meets the preset load range, and add the control unit corresponding to the load evaluation indicator when the system load data meets the preset load range to the control unit set. The control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application. The control parameters in different control units may be different, and the control parameters can represent the delay dispersion range of the task. Select the next task of the currently executed task from the task selection queue of the target application, and select the control unit corresponding to the next task from the control unit set, and determine the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task.
[0024] It can be seen that, according to the current system load conditions, the control units added to the control unit set meet the preset load range, so that the control parameters of each control unit in the control unit set are dynamically determined according to the system load conditions. That is, the delay dispersion amplitude represented by the control parameters of each control unit in the control unit set is also dynamically determined according to the system load conditions. At this time, the control parameters of the control unit corresponding to the next task selected from the control unit set can represent the delay dispersion amplitude of the next task under the current system load conditions, and the control parameters are used to determine the delayed execution result of the next task. In this way, the delay dispersion amplitude of the task is dynamically determined according to the system load conditions, which can make the task execute as quickly as possible while avoiding the blockage caused by the unsmooth execution of the task as much as possible. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A schematic diagram of a framework of an exemplary application scenario provided in an embodiment of the present application;
[0026] Figure 2 A flowchart of a task scheduling method provided in an embodiment of the present application;
[0027] Figure 3 A flowchart of a control unit corresponding to a next task provided in an embodiment of the present application;
[0028] Figure 4 A flowchart for determining the delayed execution result of the next task provided in an embodiment of the present application;
[0029] Figure 5 A schematic diagram of determining a delayed execution result of a next task provided in an embodiment of the present application;
[0030] Figure 6 A schematic diagram of the structure of a task scheduling device provided in an embodiment of the present application;
[0031] Figure 7 A schematic diagram of the basic structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0033] In order to facilitate the understanding and explanation of the technical solutions provided by the embodiments of the present application, the background technology of the present application will be described below.
[0034] It is understandable that before using the technical solutions of each embodiment of the present disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved will be informed to the user in an appropriate manner, and the user's authorization will be obtained.
[0035] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly remind the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can independently 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.
[0036] As an optional but non-limiting implementation, in response to receiving the user's active request, 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.
[0037] 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 relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0038] Usually, when an application (such as an application installed in the Android system) is running, the application backend will perform various tasks. For example, after the application is started and before the application page is loaded, the application will initialize the processing module and load the function. Usually, the application will encapsulate the module initialization and function loading into a task, and execute the task when the application is started.
[0039] Task scheduling refers to the process in which the system automatically completes tasks and the application executes tasks at a specific agreed time. Task scheduling enables applications to automatically execute tasks. For applications with complex functions, the number of tasks that need to be executed simultaneously may be large. In order to avoid the application taking too long due to the execution of a large number of tasks at the same time (which may affect the time it takes for users to enter the application page), a large number of tasks will be classified in task scheduling, and tasks that do not need to be executed immediately will be executed in a delayed and scattered manner.
[0040] In the current delay dispersion method, a fixed delay time interval is used to delay and disperse tasks, and the delay time can be used to characterize the delay dispersion range of tasks. For example, the fixed delay time interval between tasks is 1s, and the delay time for the first task execution is 4s, then the delay time for the second task is 5s, the delay time for the third task is 6s, and so on. In actual applications, the operations of users using applications are not fixed. For example, when users use applications frequently, the fixed delay time may be too small. At this time, the task execution will occupy too many computing resources and the task execution will not be smooth; when users do not use applications frequently, the fixed delay time may be too large. At this time, some tasks will not be executed for a long time, affecting the corresponding functions.
[0041] Based on this, the embodiment of the present application provides a task scheduling method, device and equipment. Whether the user frequently uses the application operation can affect the system load of the application. The present application first determines the system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application. The determined system load data is used to represent the current system load of the target application. There is at least one load evaluation indicator, and each load evaluation indicator can be used to evaluate the system load of the target application. Determine whether the system load data obtained by each load evaluation indicator meets the preset load range, and add the control unit corresponding to the load evaluation indicator when the system load data meets the preset load range to the control unit set. The control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application. The control parameters in different control units may be different, and the control parameters can represent the delay dispersion range of the task. Select the next task of the currently executed task from the task selection queue of the target application, and select the control unit corresponding to the next task from the control unit set, and determine the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task.
[0042] It can be seen that, according to the current system load conditions, the control units added to the control unit set meet the preset load range, so that the control parameters of each control unit in the control unit set are dynamically determined according to the system load conditions. That is, the delay dispersion amplitude represented by the control parameters of each control unit in the control unit set is also dynamically determined according to the system load conditions. At this time, the control parameters of the control unit corresponding to the next task selected from the control unit set can represent the delay dispersion amplitude of the next task under the current system load conditions, and the control parameters are used to determine the delayed execution result of the next task. In this way, the delay dispersion amplitude of the task is dynamically determined according to the system load conditions, which can make the task execute as quickly as possible while avoiding the blockage caused by the unsmooth execution of the task as much as possible.
[0043] It is understandable that the defects in the above solutions are the results obtained by the applicant after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed in the embodiments of the present application for the above problems below should be the contributions made by the applicant to the embodiments of the present application during the application process.
[0044] In order to facilitate understanding of the task scheduling method provided in the embodiment of the present application, Figure 1 See the example scenario shown. Figure 1 As shown, this figure is a schematic diagram of the framework of an exemplary application scenario provided by an embodiment of the present application. The method can be applied to a terminal device and / or a server, and is not limited here. Among them, the terminal device includes but is not limited to a smart phone, a tablet computer, a laptop computer, a smart watch, etc. The server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms. Specifically, it can be applied to the back end of the target application installed in the terminal device and / or server. The target application is an application installed in the terminal device and / or server, and the target application is not limited here.
[0045] In practical applications, such as Figure 1 As shown, the backend of the target application will submit tasks to the task selection queue based on the user's front-end operations in the application. For example, when a user opens an application, the application will initialize the processing module and load the functions, encapsulate the module initialization and function loading into a task, and submit the task to the task selection queue; in another example, when a user switches pages in the application, the display of the new page will also be encapsulated into a task, and the task will be submitted to the task selection queue. It can be seen that the content of the task is not limited here and can be determined according to the actual situation. It is only used as an example here. Figure 1As shown, the tasks submitted to the task selection queue include task 1, task 2, task 3, etc. The tasks in the task selection queue will be executed according to the task scheduling, and the next task to be executed immediately will be submitted to the task execution queue for immediate execution.
[0046] The task scheduling method in this application can determine the delayed execution of the next task of the currently executed task in the task selection queue. If the task is selected for the first time, it is determined that the currently executed task is empty, and the next task of the currently executed task is the first selected task. Specifically, the delayed execution of the tasks in the task selection queue is determined according to the load of the application.
[0047] First, determine at least one load assessment indicator of the target application, which is used to assess the current load condition of the target application, and then determine the system load data of the target application based on each load assessment indicator. The system load data determined by different load assessment indicators may be different, so each system load data is compared with a preset load range, and the control unit corresponding to the load assessment indicator when the system load data meets the preset load range is added to the control unit set. For example, when the system load data obtained by load assessment indicator 1 meets the preset load range, the control unit corresponding to load assessment indicator 1 is added to the control unit set. It is understandable that when the system load data obtained by load assessment indicator 1 does not meet the preset load range, load assessment indicator 1 does not have a corresponding control unit.
[0048] The control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application. That is, the five control parameters of the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task constitute a control unit. The control parameters in different control units may be different, and the control parameters can characterize the delay dispersion range of the task. Based on this, the control parameters of each control unit in the control unit set are dynamically determined according to the system load conditions. That is, the delay dispersion range represented by the control parameters of each control unit in the control unit set is also dynamically determined according to the system load conditions.
[0049] Then, the next task of the currently executed task is selected from the task selection queue of the target application, and the control unit corresponding to the next task is selected from the control unit set. For example, if the next task is task 1, its corresponding control unit is Figure 1 The control unit 1 in the control unit set in the next task (such as task 1) is then Figure 1The control parameters in the control unit 1) in the control unit 1) determine the delayed execution result of the next task (such as task 1). It can be understood that if the delayed execution result of the next task is immediate execution, the next task is submitted to the task execution queue for immediate execution.
[0050] Those skilled in the art will understand that Figure 1 The framework diagram shown is only an example in which the embodiments of the present application can be implemented. The scope of application of the embodiments of the present application is not limited by any aspect of the framework.
[0051] To facilitate understanding of the present application, a task scheduling method provided in an embodiment of the present application is described below in conjunction with the accompanying drawings.
[0052] See also Figure 2 As shown in FIG. 1 , this figure is a flowchart of a task scheduling method provided by an embodiment of the present application. The method can be applied to the terminal device and / or server shown in the above embodiment, and can be specifically applied to the backend of the target application installed in the terminal device and / or server. Figure 2 As shown, the method may include S201-S204:
[0053] S201: Based on at least one load evaluation indicator of the target application, determine system load data of the target application under each load evaluation indicator.
[0054] The embodiment of the present application dynamically adjusts the delay dispersion of task execution based on the system load of the target application. Based on this, it is necessary to first determine the system load of the target application. Specifically, the system load data of the target application is determined based on the load evaluation index, and the system load data is used to represent the system load. The specific form of the system load data is not limited here, as long as it can represent the system load. For example, the specific form of the system load data can be the workload of the system central processing unit CPU.
[0055] There is at least one load assessment indicator. As an optional example, an embodiment of the present application evaluates the load of the target application from one or more dimensions, and the load assessment indicator includes user operations on the target application, and / or the resource utilization rate of the target application. User operations on the target application are load assessment indicators of one dimension, and the resource utilization rate of the target application is a load assessment indicator of another dimension. When the user operation is a page sliding operation, the page sliding operation can be considered as an indicator value of the load assessment indicator. When the resource utilization rate is 30%, 30% can also be considered as an indicator value of the load assessment indicator.
[0056] Among them, user operations are operations performed by users on the front end of the target application, such as operations on the front end page, including trigger operations, air gesture operations, mouse hover operations, page switching operations, page sliding operations, etc. on the front end page, which are not limited here. When the resource is a computing resource, the resource can be a CPU resource, a memory resource, a hard disk resource, a network resource, etc. Taking CPU resources as an example, the resource utilization rate is specifically the CPU utilization rate.
[0057] It is understandable that user operations on the target application may increase the tasks to be performed by the application backend, which will affect the system load of the target application. Different user operations on the target application, accompanied by different core logic execution of system CPU and other resources, have different effects on the system load of the target application. Some user operations may cause a high system load. The resource utilization rate of the target application can directly reflect the system load of the target application. The higher the resource utilization rate, the higher the system load.
[0058] Based on the above content, the embodiment of the present application provides a specific implementation method of determining the system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application, including:
[0059] Determine the system load data of the target application based on whether the user operation matches the target user operation;
[0060] and / or,
[0061] Based on whether the resource usage rate meets a preset usage rate range, the system load data of the target application is determined.
[0062] Different user operations in the application will have different effects on the system load, and the target user operation can lead to a higher system load. The target user operation corresponds to "the system load data meets the preset load range", which can be regarded as the indicator value that is focused on. Among them, the preset load range is used to characterize a higher load range, for example, a range that exceeds the load threshold. The specific load range and load threshold are not limited here and can be determined according to actual conditions. Then, based on whether the user operation meets the target user operation, the system load data of the target application is determined, including: when the user operation meets the target user operation, determining that the system load data meets the preset load range. In addition, it also includes determining that the system load data of the target application does not meet the preset load range when the user operation does not meet the target user operation.
[0063] The target user operation is the user's operation at the key node of the application. The operation at the key node is usually accompanied by the switching of pages or functional interfaces, and the execution of core logic such as interface layout that consumes more system CPU resources. Therefore, it can be considered that the overall system load of the target application is high for a period of time after the key node operation.
[0064] In one or more embodiments, the target user operation includes at least one of the following: application page switching operation (i.e., page Activity switching operation), triggering operation of the navigation bar at the bottom of the application homepage (i.e., triggering operation of the Tab at the bottom of the homepage), triggering operation of the navigation bar at the top of the application homepage (i.e., triggering operation of the Tab at the top of the homepage), and sliding operation of the application homepage message source (i.e., sliding operation of the homepage Feed). This is only an example, and the specific content and number of the target user operation can also be adapted to the setting according to different target applications. Among them, the triggering operation can be a click operation, which is not limited here.
[0065] Different resource usage rates will have different effects on the system load, and resource usage rates that meet the preset usage rate range can lead to a higher system load. It can be considered that "the resource usage rate meets the preset usage rate range" corresponds to "the system load data of the target application meets the preset load range". Then, based on whether the resource usage rate meets the preset usage rate range, determining the system load data of the target application includes: when the resource usage rate meets the preset usage rate range, determining that the system load data meets the preset load range. In addition, it also includes determining that the system load data of the target application does not meet the preset load range when the resource usage rate does not meet the preset usage rate range.
[0066] Among them, when the resource is a CPU resource, the method for obtaining the CPU usage rate is as follows: at the beginning of CPU monitoring, the overall CPU usage time 1 and the CPU usage time 1 of the current process are read from the proc file. At the end of monitoring, the overall CPU usage time 2 and the CPU usage time 2 of the current process are read again. The time at the beginning and the end are subjected to difference processing (diff processing), the increased CPU usage time of the current process is the difference between the CPU usage time 2 of the current process and the CPU usage time 1 of the current process, and the overall increased CPU time is the difference between the overall CPU usage time 2 and the overall CPU usage time 1. Furthermore, the increased CPU usage time of the current process is divided by the overall increased CPU time as the CPU usage rate during the CPU monitoring time period. It can be understood that when the target application is installed on the Android system, the method for obtaining the CPU usage rate is also this method.
[0067] It should be understood that the acquisition of CPU usage (collecting CPU usage time, calculating CPU usage, etc.) itself will occupy certain system CPU and other resources. When the interval for collecting CPU usage time is short and the frequency is high, the calculated CPU usage is more accurate, but it consumes more system CPU resources. When the interval for collecting CPU usage time is long and the frequency is low, the accuracy of the calculated CPU usage will decrease, but it consumes less system CPU resources. Therefore, it is necessary to control the collection interval of CPU usage time to avoid excessive occupation of system resources. Therefore, when collecting CPU usage time, it is necessary to comprehensively consider factors such as the accuracy of CPU usage and the consumed system CPU resources.
[0068] Based on the above, when identifying the system load, multi-dimensional load evaluation indicators (such as user operations and system resource usage) can be used to comprehensively evaluate the system load of the target application to improve the accuracy of the system load evaluation. It is understandable that the acquisition of the system load data of the target application can be obtained in real time or periodically, which is not limited here.
[0069] S202: Add the control unit corresponding to the load evaluation index when the system load data meets the preset load range to the control unit set; the control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application; the control parameters are used to indicate the delay dispersion range of the task.
[0070] In actual applications, after each load evaluation indicator is determined, a corresponding control unit and control timeout period are configured for each load evaluation indicator.
[0071] In a possible implementation, the embodiment of the present application provides a specific implementation of pre-configuring a control unit corresponding to a load evaluation indicator and controlling a timeout time, including:
[0072] A control unit and a control timeout period corresponding to a target user operation are pre-configured, and a control unit and a control timeout period corresponding to a resource usage rate are pre-configured.
[0073] It is understandable that when the target user operation is different, the corresponding control unit and control timeout period are different. For example, the control unit and control timeout period corresponding to the application page switching operation, the triggering operation of the navigation bar at the bottom of the application homepage, the triggering operation of the navigation bar at the top of the application homepage, and the sliding operation of the application homepage message source may be different. The control unit and control timeout period corresponding to different target user operations can be determined according to the actual scenario and are not limited here.
[0074] In addition, if the target user operation is the same and the lower-level operation of the target user operation is different, the impact on the system load will also be different, so different control units and control timeouts can also be corresponding, which can be determined according to the actual situation. For example, for the application page switching operation, when switching different pages, the corresponding control unit and control timeout are different. For example, the operation of switching page 1 to page 2 (the lower-level operation of the application page switching operation) corresponds to control unit 1 and control timeout 1; the operation of switching page 2 to page 3 (the lower-level operation of the application page switching operation) corresponds to control unit 2 and control timeout 2. For another example, for the sliding operation of the application homepage message source, when the sliding operation is performed for different message sources, the corresponding control unit and control timeout are different. For example, the operation of sliding message source 1 (the lower-level operation of the sliding operation of the application homepage message source) corresponds to control unit 3 and control timeout 3; the operation of sliding message source 2 (the lower-level operation of the sliding operation of the application homepage message source) corresponds to control unit 4 and control timeout 4. In this way, the lower-level operation of the target user operation is subdivided, so that the set control unit and control timeout are more accurate.
[0075] As an optional example, each time period after the target application is started corresponds to a resource usage collection frequency, and the resource usage collection frequency of each time period corresponds to a control unit and a control timeout. The control unit corresponding to the resource usage is determined according to the collection frequency corresponding to the resource usage collection time period. The resource usage time collection frequency can be considered as the resource usage collection frequency.
[0076] For example, within 0-10 minutes after the target application is started, the resource usage time is collected using collection frequency 1, and within 10 minutes to 20 minutes, the resource usage time is collected using collection frequency 2, etc. Collection frequency 1 corresponds to a control unit 5 and a control timeout 5, and collection frequency 2 corresponds to a control unit 6 and a control timeout 6. Based on this, the control unit corresponding to the resource usage rate is determined according to the collection frequency corresponding to the collection time period of the resource usage rate. For example, if the resource usage rate 1 meets the preset usage rate range, and the collection time period of the resource usage rate 1 is within 0-10 minutes after the target application is started, and the corresponding collection frequency is collection frequency 1, then the control unit and control timeout corresponding to the resource usage rate 1 are control unit 5 and control timeout 5.
[0077] The control unit and control timeout corresponding to the load assessment indicator can be configured according to some rules, specifically "the higher the system load data of the target application under the load assessment indicator, the longer the initial execution time, the smaller the execution window time, the larger the execution interval time, the smaller the number of concurrent executions, and the longer the execution timeout time in the control unit corresponding to the load assessment indicator", and "the longer the duration that the system load data under the load assessment indicator meets the preset load range, the longer the control timeout time of the control unit corresponding to the load assessment indicator; the control timeout time corresponding to the control unit is greater than the duration time". Please see below for details.
[0078] As an optional example, the control unit is composed of five control parameters, and each group of five control parameters serves as a control unit. The five control parameters include the initial execution time, execution window time, execution interval time, execution concurrency number, and execution timeout time of the task in the target application. Among them, the units of the initial execution time, execution window time, execution interval time, and execution timeout time are duration.
[0079] The five control parameters of the control unit are described as follows:
[0080] (1) The initial execution time is the time when the task is delayed when it is first added.
[0081] Among them, adding a task for the first time refers to submitting / adding a task to the task selection queue for the first time. The task added for the first time can be called the first task in the task selection queue. It can be understood that when the first task is added to the task selection queue, it corresponds to the time when the first task is added to the task selection queue. The initial execution time is the delayed execution time of the first task, which is equivalent to waiting for at least an initial execution time after the first task is submitted / added to the task selection queue, and then executing the first task (in practice, the first task is submitted to the task execution queue and executed immediately). For example, the time when the first task is added to the task selection queue is 12:00:00, and the delayed execution time is 3s, then wait until at least 12:00:03 before executing the first task.
[0082] It is understandable that when the first task in the task selection queue is delayed, the execution time of the next task of the first task can be the time of the first task delay plus a time interval between the first task and the next task, that is, the next task of the first task can also be considered to be delayed. Subsequent tasks are similar and will not be repeated here.
[0083] The first task in the task selection queue is delayed, which can be called task delay; starting from the second task, after the previous task is executed, there may be a period of time before the next task is executed, which can be called task scattering. Therefore, the above situations can be collectively referred to as "delay" and "scattering" of tasks in the delayed scattering method.
[0084] In actual applications, there may be one or more task selection queues. When there are multiple task selection queues, the initial execution time of the first task in each task selection queue can be set to prevent the first task in each task selection queue from being executed concurrently, so as to avoid the high concurrency caused by the simultaneous execution of the first tasks in multiple task selection queues when the task is triggered, so as to make the system load more even. In addition, it is also possible to avoid multiple task selection queues being empty at the same time at the beginning.
[0085] For example, if the time when the first task in each task selection queue is added to the corresponding queue is the same, the initial execution time of the first task in different task selection queues can be different. For example, the initial execution time can be staggered, such as the initial execution time of task selection queue 1 is 1s, the initial execution time of task selection queue 1 is 2s, and so on. In this way, by staggering the initial execution time of the first task in different task selection queues, it is possible to avoid the first tasks in multiple task selection queues from being executed simultaneously when the task execution is triggered.
[0086] (2) The execution window time is the maximum cumulative time that the same batch of tasks can be executed continuously.
[0087] If some tasks in the task selection queue are determined to be executed continuously (that is, the continuous tasks in the task selection queue can be executed immediately), then when the tasks are executed continuously, the next task will be executed immediately after the previous task is executed. In actual applications, if multiple tasks in the task selection queue need to be executed, they will be executed in batches. Multiple batches can be executed in parallel, and tasks in the same batch will be executed serially. The tasks of the previous batch will be executed continuously for a period of time, and then the next batch of tasks will be executed after a period of time (see the description of the execution interval below. When the cumulative execution time exceeds the execution window time, wait according to the execution interval time).
[0088] It is understandable that some tasks can be executed continuously within the execution window time, so that based on the execution window time, it is possible to avoid as much as possible that when there are too many short-time tasks, the overall task execution is too fragmented, resulting in some tasks being unable to be executed for a long time.
[0089] (3) The execution interval is a type of interval time. If the tasks in the current batch are completed and their cumulative execution time exceeds the execution window time, the system will wait for a period of time before processing the next batch of tasks. The waiting period is the execution interval, that is, the system will wait according to the execution interval.
[0090] Specifically, the execution interval is the interval between the start execution times of two tasks. When executing tasks in batches, the execution interval is the interval between the execution of the current batch of tasks and the execution of the next batch of tasks, specifically the interval between the start execution time of the last task in the current batch of tasks and the start execution time of the first task in the next batch of tasks.
[0091] (4) The number of concurrent executions is the number of task batches that are executed at the same time when the task is actually executed. The number of concurrent executions is -1, 0, or greater than 0. Among them, "-1" is an identification symbol, which does not mean a number minus one, but means that the number of concurrent executions is infinite.
[0092] When the execution concurrency is -1, the execution concurrency is infinite. At this time, there is no limit on the number of task batches executed at the same time. The number of task batches executed at the same time will always be less than the execution concurrency. The control will ignore the execution window time, execution interval time and execution timeout time. Tasks will be executed concurrently immediately. The degree of concurrency of task execution is only limited by the system resources provided to task processing (corresponding to the maximum number of threads in the configured thread pool). When the execution concurrency is greater than 0, if the number of task batches currently being executed is greater than or equal to the execution concurrency, the execution of subsequent tasks will be controlled according to the execution timeout time (see the description of the execution timeout time below), and the single task will be counted as an independent batch in the number of concurrent execution batches. When the execution concurrency is 0, it is considered that the number of task batches actually executed at the same time is always greater than the execution concurrency, and the execution of subsequent tasks is controlled according to the execution timeout time.
[0093] Among them, "a single task is counted as an independent batch in the number of concurrent execution batches" can be understood as, when the number of task batches executed simultaneously is greater than or equal to the number of concurrent executions, since the execution timeout is usually long, the next batch of tasks may be executed after the execution timeout, which is equivalent to the previous batch of tasks being executed for a long time, and the task processing can continue. At this time, the next batch of tasks is constrained to include only one task. Until the number of task batches running simultaneously is less than the number of concurrent executions, the next batch of tasks will be processed according to the execution interval, and the next batch of tasks may include multiple tasks.
[0094] For example, if the number of concurrent executions is 2, there are 5 tasks in the first batch and 4 tasks in the second batch. Since the number of batches executed simultaneously is 2, which is equal to the number of concurrent executions, the execution timeout is used for control. After the execution timeout, a third batch of tasks may be added, and there is only one task in the third batch. Based on this, the "subsequent tasks" mentioned above refer to the next batch of tasks to be executed selected from the task selection queue, and there is only one task in the next batch of tasks.
[0095] It can be seen that the concurrency of task batches will lead to the concurrency of tasks in different task batches. For example, task batch A includes five tasks A1-A5, and task batch B includes five tasks B1-B5. If task batch A and task batch B are executed concurrently, then there will be tasks in task batch A that will be executed concurrently with tasks in task batch B, for example, A1 in task batch A and B1 in task batch B will be executed concurrently.
[0096] (5) Execution timeout means that when the number of task batches executed simultaneously is greater than or equal to the number of concurrent executions, the execution of subsequent tasks (see the description of "subsequent tasks" in point (4)) will be based on the earliest start time of the tasks in all batches currently being executed, and will be executed at intervals corresponding to the execution timeout.
[0097] For example, task batch A includes five tasks A1-A5, task batch B includes five tasks B1-B5, and tasks in the same batch are executed in serial order. Then, when the number of task batches executed simultaneously is greater than or equal to the number of concurrent executions, the earliest start time of tasks in all batches currently being executed is the start time of tasks A1 or B1. If the start time of tasks A1 is earlier than the start time of tasks B1, the earliest start time of tasks in all batches currently being executed is the start time of tasks A1.
[0098] It is understandable that the execution timeout is set to avoid as much as possible the situation where tasks are continuously piled up in the task queue and cannot be executed for a long time due to the long execution time of some tasks.
[0099] As an optional example, the initial execution time in the constraint control unit is less than the execution interval time, the execution window time is less than the execution interval time, and the execution interval time is less than the execution timeout time.
[0100] Regarding "initial execution time is less than execution interval time", it should be understood that the initial execution time is the delay time when the first task in the task selection queue is executed, and the execution interval time is the interval between the execution of the current batch of tasks and the execution of the next batch of tasks (it can also be understood as the interval between the start execution time of two tasks). When the initial execution time is greater than the execution interval time, the delay time when the first task is executed is larger, and the interval time between subsequent tasks is smaller, which will produce a jump phenomenon from large to small. Based on this, the initial execution time in the constraint control unit is less than the execution interval time, so that the delay time when the first task is executed will not be too large.
[0101] Regarding "the execution window time is less than the execution interval time", it should be understood that if the execution window time is greater than the execution interval time, the task will be executed continuously within the execution window time, and the execution interval time is not needed at this time, and the effect of the execution interval time is not great. When the effect of the execution interval time is small, the effect of the delay dispersion control of the task will become smaller. Based on this, the execution window time in the constraint control unit is less than the execution interval time, so as to enhance the delay dispersion control of the task based on the control unit.
[0102] Regarding "the execution interval is less than the execution timeout", it should be understood that the execution timeout is also a kind of interval. When the batch of tasks executed simultaneously in practice is less than the number of concurrent executions (that is, the number of concurrent executions has not been reached), the interval uses the execution interval. When the batch of tasks executed simultaneously in practice is greater than or equal to the number of concurrent executions, the interval uses the execution timeout. It is understandable that the larger the number of task batches executed simultaneously in practice, the greater the system load pressure. Based on this, it is necessary to make the execution interval less than the execution timeout, that is, the execution interval used when the number of task batches executed simultaneously in practice is small is smaller than the execution timeout used when the number of task batches executed simultaneously in practice is large. In this way, when the number of task batches executed simultaneously in practice is large, the execution timeout is larger, which can relieve the system load pressure as soon as possible, reduce the load more quickly, and enable the target application to respond faster.
[0103] It can be understood that the five-element control parameter is used to describe the delay dispersion control of the task, and it can also be understood that the control parameter is used to represent the delay dispersion range of the task.
[0104] As an optional example, the higher the system load data of the target application under the load evaluation index, the longer the initial execution time, the smaller the execution window time, the larger the execution interval time, the smaller the number of concurrent executions, and the larger the execution timeout time in the control unit corresponding to the load evaluation index, so as to increase the delay dispersion of task execution. Based on this, the control units corresponding to different load evaluation indicators can be configured.
[0105] The control timeout period is used to indicate the validity period of the control unit. The control unit becomes effective when it is added to the control unit set and becomes invalid when the control timeout period is exceeded.
[0106] As an optional example, the longer the duration that the system load data under the load evaluation index meets the preset load range, the longer the control timeout time of the control unit corresponding to the load evaluation index; the control timeout time corresponding to the control unit is greater than the duration time. In this way, the control is broken up to meet the delay of the task. For example, when a user slides a page once, the system load under the page sliding operation continues to be high (that is, the system load data meets the preset load range) for 1s, then the control timeout time of the control unit corresponding to the page sliding operation will be set to be slightly longer than 1s. Moreover, the longer the system load continues to be high, the longer the control timeout time of the corresponding control unit.
[0107] Based on the above content, after obtaining the system load data obtained by each load evaluation indicator, the system load data obtained by each load evaluation indicator is compared with the preset load range respectively. The control unit corresponding to the load evaluation indicator when the system load data meets the preset load range is added to the control unit set.
[0108] In a possible implementation, the embodiment of the present application provides a specific implementation of adding a control unit corresponding to a load evaluation indicator when system load data meets a preset load range to a control unit set, including:
[0109] The control unit corresponding to the user operation when the system load data meets the preset load range is added to the control unit set, and / or the control unit corresponding to the resource utilization rate when the system load data meets the preset load range is added to the control unit set.
[0110] That is, if the user operation meets the target user operation, the system load data meets the preset load range, and the user operation at this time is the target user operation, and then the control unit corresponding to the user operation is added to the control unit set. For example, if the user operation is a page sliding operation, and the page sliding operation is the target user operation, then the control unit corresponding to the target user operation is added to the control unit set.
[0111] If the resource usage rate meets the preset usage rate range, the system load data meets the preset load range, and the control unit corresponding to the resource usage rate is added to the control unit set. Specifically, the control unit corresponding to the resource usage rate can be determined by the collection frequency corresponding to the collection time period of the resource usage rate (see the above description of the collection frequency).
[0112] In summary, when the system load is too high as identified by each type of system load evaluation indicator, the competition for system resources (such as CPU resources) among threads will become more serious, and the time slices allocated to threads by system resources will be reduced accordingly. At this time, the corresponding control unit (and control timeout) will be added to the control unit set. The delay dispersion range of the tasks represented by the control parameters of the control units in the control unit set is relatively large, so the control units in the control unit set can reduce the occupation of system resources by increasing the delay dispersion range of some task executions, and avoid blocking the execution of tasks as much as possible. Specifically, the control algorithm will be followed and the control units in the control unit set will be used to act on the subsequent task delay dispersion control process (see S203 and S204 below for details).
[0113] S203: Selecting the next task of the currently executed task from the task selection queue of the target application, and selecting a control unit corresponding to the next task from the control unit set.
[0114] In one or more embodiments, whether a task can be executed immediately or delayed can be determined by a control algorithm, which includes a delay-scattering amplitude determination algorithm and a task control execution algorithm.
[0115] The task control execution algorithm can be understood as a loop process when controlling the execution of the target application's tasks. That is, select the task in the task selection queue, first select the control unit corresponding to the task from the control unit set through the delay fragmentation amplitude determination algorithm, and then make a judgment according to the task control process. If the task execution conditions are met, the task will be executed immediately, otherwise it will wait for a certain period of time to enter the next cycle (i.e., delay fragmentation). Among them, selecting the control unit corresponding to the task from the control units in the control unit set is the content of the delay fragmentation amplitude determination algorithm.
[0116] The currently executed task in this step is the task that can be executed immediately in the task selection queue. After that, the next task is selected from the task selection queue for judgment. When the next task is the first task in the task selection queue, the currently executed task is considered to be empty.
[0117] In a possible implementation, the embodiment of the present application provides a specific implementation of selecting a control unit corresponding to a next task from a control unit set, including:
[0118] The control unit with the largest delay dispersion is selected from the control unit set as the control unit corresponding to the next task.
[0119] The control unit with the largest delay dispersion amplitude indicates that the delay dispersion amplitude of the next task can be controlled by the control parameters of the control unit. It can be seen that the control parameters in the control units in the control unit set (for example, the number of concurrent executions may be infinite, may be greater than 0, or may be equal to 0) depend on the system load conditions evaluated by the load evaluation index and the control unit corresponding to the load evaluation index. It is understandable that when the system load is high, the corresponding control unit is added to the control unit set, so the delay dispersion amplitude represented by the control parameters of any control unit in the control unit set is large. However, after comparing the delay dispersion amplitudes of each control unit in the control unit set, the control unit with the largest delay dispersion amplitude can still be determined. Using the control unit with the largest delay dispersion amplitude as the control unit corresponding to the next task can alleviate the system load pressure to the greatest extent and quickly reduce the system load.
[0120] Specifically, the control unit with the largest delay dispersion corresponding to the next task can be selected according to the following rules: When the number of concurrent executions in the control unit is infinite, the task will be executed immediately. At this time, the system load pressure can be relieved as quickly as possible, and it can be considered that the delay dispersion of the control unit is the largest. When the number of concurrent executions in at least one control unit is greater than 0, the delay dispersion is negatively correlated with the number of concurrent executions in the control unit and positively correlated with the interval time, which is the execution interval time or the execution timeout time. Among them, when the number of tasks in the current batch when the task is actually executed is greater than or equal to the number of concurrent executions, the interval time is the execution interval time; when the number of tasks in the current batch when the task is actually executed is less than the number of concurrent executions, the interval time is the execution timeout time. For example, if the number of concurrent executions in control units 1 and 2 is greater than 0, the size of the delay dispersion of control units 1 and 2 is related to the number of concurrent executions and the interval time in control units 1 and 2.
[0121] When the number of concurrent executions in at least one control unit is equal to 0, the delay dispersion amplitude is positively correlated with the execution timeout period in the control unit. For example, if the number of concurrent executions in control units 3 and 4 are both equal to 0, then the size of the delay dispersion amplitude of control units 3 and 4 is related to the execution timeout period in control units 3 and 4. When the number of concurrent executions in at least one control unit is greater than 0 or equal to 0, the delay dispersion amplitude is negatively correlated with the number of concurrent executions in the control unit. For example, if the number of concurrent executions of control unit 5 is greater than 0 and the number of concurrent executions of control unit 6 is equal to 0, then it is considered that the number of concurrent executions of control unit 5 is greater than the number of concurrent executions of control unit 6, and at this time, the delay dispersion amplitude of control unit 6 is larger. On the contrary, if the number of concurrent executions of control unit 5 is equal to 0 and the number of concurrent executions of control unit 6 is greater than 0, then the delay dispersion amplitude of control unit 5 is larger.
[0122] In a possible implementation, an embodiment of the present application provides an implementation method of selecting a control unit with the largest delay dispersion from a set of control units as the control unit corresponding to the next task, see S301-S308 below for details.
[0123] It is understandable that each control unit corresponds to a control timeout. The control timeout is used to set the length of time that the control unit can be effective. From the moment the control unit takes effect, when the control unit continues to be effective for longer than the corresponding control timeout, the control unit will automatically become invalid. Based on this, the control unit corresponding to the next task selected is the control unit that has not expired.
[0124] In addition, a default control unit will be set in the control unit set. If the default control unit does not correspond to a control timeout, then when no other control unit is effective, the execution of the task will be controlled by this control unit by default.
[0125] S204: Determine the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task.
[0126] The delayed execution result of the next task is determined according to the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time in the control unit corresponding to the next task. In specific implementation, the delayed execution result of the next task is comprehensively determined by combining the control parameters in the control unit and the current time, the number of task batches currently being executed simultaneously, and the cumulative duration of each task in the current batch of tasks being executed simultaneously.
[0127] It is understandable that there is no limitation on how to comprehensively determine the delayed execution result of the next task. For example, the delayed execution result of the next task can be determined according to a correspondence table. The correspondence table records the correspondence between the control parameters of the control unit, the current time, the number of task batches currently being executed simultaneously, the cumulative task duration of each task being executed simultaneously in the current batch of tasks, and the delayed execution result of the task. When the control unit corresponding to the next task and the current time, the number of task batches currently being executed simultaneously, and the cumulative task duration of each task being executed simultaneously in the current batch of tasks are determined, the corresponding delayed execution result can be found according to the correspondence table. The correspondence table is pre-marked.
[0128] In this step, when the next task has not been executed, the delayed execution result of the next task is determined according to the control parameters in the control unit corresponding to the next task. The delayed execution result is the result of whether the next task is delayed. If so, it is delayed and the delayed execution time is determined; if not, the next task is taken out of the task selection queue and added to the task execution queue for immediate execution. In practical applications, the delayed execution result can also be reflected in whether the next task is executed immediately. If so, it is executed immediately; if not, it is determined that the next task is delayed and the delay time of the next task is determined.
[0129] In summary, the embodiments of the present application can detect the load conditions of the system from multiple dimensions, and dynamically control the delay dispersion range of task execution according to the load conditions based on the multiple delay dispersion parameters (control parameters) in the control unit, thereby achieving an increase in the task delay dispersion range under high load conditions, and controlling the tasks in the target application to be executed within a certain time without affecting the interaction between the user and the target application.
[0130] In a possible implementation, an embodiment of the present application provides an implementation method for determining the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task in S204, see S401-S402 below for details.
[0131] Based on the above S201-S204 related content, it can be known that the present application provides a task scheduling method. Whether the user frequently uses the application operation can affect the system load of the application. The present application first determines the system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application. The determined system load data is used to represent the current system load of the target application. There is at least one load evaluation indicator, and each load evaluation indicator can be used to evaluate the system load of the target application. Determine whether the system load data obtained by each load evaluation indicator meets the preset load range, and add the control unit corresponding to the load evaluation indicator when the system load data meets the preset load range to the control unit set. The control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application. The control parameters in different control units may be different, and the control parameters can represent the delay dispersion amplitude of the task. Select the next task of the currently executed task from the task selection queue of the target application, and select the control unit corresponding to the next task from the control unit set, and determine the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task.
[0132] It can be seen that, according to the current system load conditions, the control units added to the control unit set meet the preset load range, so that the control parameters of each control unit in the control unit set are dynamically determined according to the system load conditions. That is, the delay dispersion amplitude represented by the control parameters of each control unit in the control unit set is also dynamically determined according to the system load conditions. At this time, the control parameters of the control unit corresponding to the next task selected from the control unit set can represent the delay dispersion amplitude of the next task under the current system load conditions, and the control parameters are used to determine the delayed execution result of the next task. In this way, the delay dispersion amplitude of the task is dynamically determined according to the system load conditions, which can make the task execute as quickly as possible while avoiding the blockage caused by the unsmooth execution of the task as much as possible.
[0133] See also Figure 3 , Figure 3 A flowchart of selecting a control unit corresponding to a next task provided in an embodiment of the present application.
[0134] In one possible implementation, combining Figure 3 The embodiment of the present application provides a specific implementation method of selecting the control unit with the largest delay dispersion from the control unit set as the control unit corresponding to the next task in S203, including:
[0135] S301: Select a valid control unit from the control unit set as a target control unit.
[0136] It is understandable that the control units applied to task control are all effective control units. Therefore, when executing this step, the control units selected from the control unit set are all effective control units.
[0137] A control unit that is in effect is initially selected from the control unit set, and the control unit is used as the target control unit. For example, the target control unit may be marked as control unit x. It should be understood that the embodiment of the present application does not limit the control unit that is initially selected and in effect. For example, it may be randomly selected from the control unit set.
[0138] In this embodiment, the target control unit is the control unit with the largest delay dispersion.
[0139] S302: Select the remaining effective control units from the control unit set in turn, take the currently selected effective control unit as the pre-selected control unit, take the delay dispersion range of the pre-selected control unit as the first value, and take the delay dispersion range of the target control unit as the second value.
[0140] The embodiment of the present application does not limit how to sequentially select the remaining effective control units from the control unit set. For example, each time the remaining effective control units are selected, they may be selected randomly.
[0141] The currently selected effective control unit is used as the preselected control unit. For example, the preselected control unit is marked as control unit a. At this time, it is necessary to compare the delay dispersion amplitude of the preselected control unit with the delay dispersion amplitude of the target control unit. The delay dispersion amplitude of the preselected control unit is used as the first value, and the delay dispersion amplitude of the target control unit is used as the second value, so as to compare the first value and the second value.
[0142] S303: If the execution concurrency of the pre-selected control unit is infinite, the pre-selected control unit is used as the updated target control unit, and the target step and subsequent steps are re-executed. The target step is to select the remaining effective control units from the control unit set in sequence.
[0143] When the execution concurrency of the preselected control unit is infinite (i.e., the execution concurrency of control unit a is -1), it can be considered that the delay dispersion amplitude of the preselected control unit is greater than the delay dispersion amplitude of the target control unit (i.e., the delay dispersion amplitude of control unit a is greater than the delay dispersion amplitude of control unit x). At this time, the target control unit is updated, and the preselected control unit is used as the updated target control unit (i.e., control unit a is recorded as control unit x), and S302 and subsequent steps are re-executed.
[0144] S304: If the number of concurrent executions of the target control unit is infinite, determine that the delay dispersion of the target control unit is the largest, and use the target control unit as the control unit corresponding to the next task.
[0145] When the execution concurrency of the target control unit is infinite (i.e., the execution concurrency of control unit x is -1), the delay dispersion range of the currently determined target control unit is considered to be the largest control unit in the control unit set. At this time, the target control unit is used as the control unit corresponding to the next task, and the loop ends.
[0146] S305: If the execution concurrency number of the preselected control unit and the execution concurrency number of the target control unit are both greater than 0, then when it is determined according to the target correlation that the first value is greater than the second value, the preselected control unit is used as the updated target control unit, and the target step and subsequent steps are re-executed; when it is determined according to the target correlation that the first value is equal to the second value, it is determined whether the execution timeout time of the preselected control unit is greater than the execution timeout time of the target control unit. If so, the preselected control unit is used as the updated target control unit, and the target step and subsequent steps are re-executed; if not, the target step and subsequent steps are re-executed; when it is determined according to the target correlation that the first value is less than the second value, the target step and subsequent steps are re-executed.
[0147] When the execution concurrency of the preselected control unit and the execution concurrency of the target control unit are both greater than 0 (that is, the execution concurrency of control unit a and control unit x are both greater than 0), the delay dispersion amplitude of the preselected control unit and the delay dispersion amplitude of the target control unit are determined based on the following rules.
[0148] That is, whether the first value is greater than the second value is determined according to the target correlation relationship. The target correlation relationship is that the delay dispersion amplitude of the control unit is negatively correlated with the number of concurrent executions in the control unit and positively correlated with the execution interval time in the control unit.
[0149] If the first value is greater than the second value, it means that the delay dispersion amplitude of the preselected control unit is greater than the delay dispersion amplitude of the target control unit. At this time, the target control unit is updated, the preselected control unit is used as the updated target control unit, and S302 and subsequent steps are re-executed. S302 and subsequent steps are re-executed, that is, the next control unit is selected from the control unit set for judgment.
[0150] If the first value is equal to the second value, determine whether the execution timeout of the preselected control unit is greater than the execution timeout of the target control unit. If the execution timeout of the preselected control unit is greater than the execution timeout of the target control unit, and the execution timeout is positively correlated with the delay dispersion amplitude, then the delay dispersion amplitude of the preselected control unit is greater than the delay dispersion amplitude of the target control unit. At this time, update the target control unit, use the preselected control unit as the updated target control unit, and re-execute S302 and subsequent steps. Otherwise, re-execute S302 and subsequent steps.
[0151] If the first value is smaller than the second value, it means that the delay dispersion range of the preselected control unit is smaller than the delay dispersion range of the target control unit (ie, the delay dispersion range of control unit a is smaller than the delay dispersion range of control unit x). At this time, S302 and subsequent steps are re-executed.
[0152] As an optional example, the first value is obtained by a first formula, and the second value is obtained by a second formula.
[0153] The first formula is the execution interval time of the preselected control unit minus the execution window time of the preselected control unit, the difference is multiplied by the execution window time of the target control unit, and the product is divided by the number of concurrent executions of the preselected control unit. That is, ((the execution interval time of the preselected control unit-the execution window time of the preselected control unit)×the execution window time of the target control unit) / the number of concurrent executions of the preselected control unit.
[0154] The second formula is the execution interval time of the target control unit minus the execution window time of the target control unit, the difference is multiplied by the execution window time of the pre-selected control unit, and the product is divided by the number of concurrent executions of the target control unit. It can be seen that the comparison between the value of the first formula and the value of the second formula is used to characterize the target correlation relationship. That is, ((execution interval time of the target control unit-execution window time of the target control unit)×execution window time of the pre-selected control unit / number of concurrent executions of the target control unit.
[0155] It can be seen from the first formula and the second formula that the delay dispersion range of the control unit satisfies the target correlation relationship. It is understandable that the window time of the control unit in the first formula can be normalized first, and then the first value and the second value can be compared based on the first formula and the second formula, which will not be repeated here.
[0156] S306: If the execution concurrency number of the preselected control unit and the execution concurrency number of the target control unit are both equal to 0, determine whether the execution timeout of the preselected control unit is greater than the execution timeout of the target control unit. If so, use the preselected control unit as the updated target control unit and re-execute the target step and subsequent steps. If not, re-execute the target step and subsequent steps.
[0157] When the execution concurrency of the preselected control unit and the execution concurrency of the target control unit are both equal to 0, it means that the number of batch tasks actually executed simultaneously must be greater than the execution concurrency of the control unit. At this time, the execution timeout of the control unit is used for judgment. The execution timeout is positively correlated with the delay dispersion range.
[0158] If the execution timeout of the preselected control unit is greater than the execution timeout of the target control unit, the delay dispersion of the preselected control unit is greater than the delay dispersion of the target control unit, then the target control unit is updated, the preselected control unit is used as the updated target control unit, and S302 and subsequent steps are re-executed. Otherwise, S302 and subsequent steps are re-executed.
[0159] S307: If the execution concurrency of the preselected control unit is greater than 0 and the execution concurrency of the target control unit is equal to 0, re-execute the target step and subsequent steps; if the execution concurrency of the preselected control unit is equal to 0 and the execution concurrency of the target control unit is greater than 0, use the preselected control unit as the updated target control unit, and re-execute the target step and subsequent steps.
[0160] When the execution concurrency of the preselected control unit is greater than 0 and the execution concurrency of the target control unit is equal to 0, it means that the execution concurrency of the preselected control unit is greater than the execution concurrency of the target control unit. Since the execution concurrency of the control unit is negatively correlated with the delay dispersion amplitude of the control unit, the delay dispersion amplitude of the target control unit is greater than the delay dispersion amplitude of the preselected control unit. At this time, re-execute S302 and subsequent steps.
[0161] When the execution concurrency of the preselected control unit is equal to 0 and the execution concurrency of the target control unit is greater than 0, it means that the execution concurrency of the preselected control unit is less than the execution concurrency of the target control unit. At this time, the delay dispersion amplitude of the preselected control unit is greater than the delay dispersion amplitude of the target control unit. At this time, the target control unit is updated, the preselected control unit is used as the updated target control unit, and S302 and subsequent steps are re-executed.
[0162] S308: until all valid control units in the control unit set are selected, the last updated target control unit is used as the control unit corresponding to the next task.
[0163] When all the effective control units in the control unit set are selected, the final target control unit is used as the control unit corresponding to the next task. The final target control unit is the control unit with the largest delay dispersion in the control unit set. It can be understood that the greater the delay dispersion of the control unit, the more it can relieve the load pressure of the system, so that the load can be reduced more quickly, and the target application will respond faster.
[0164] Based on the above content, when S301-S308 is executed and the control unit corresponding to the next task is selected, the timeout failure of the control unit will be processed. That is, the failed control units in the control unit set are cleared, and the failed control unit is the control unit whose continuous validity time exceeds the control timeout time. In this way, all the control units in the control unit set are in effect.
[0165] See also Figure 4 , Figure 4 A flowchart for determining the delayed execution result of the next task provided in an embodiment of the present application.
[0166] In one possible implementation, combining Figure 4 The embodiment of the present application provides a specific implementation method of determining the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task in S204, including:
[0167] S401: When the next task is the first task in the task selection queue, determine whether the first time interval between the time when the next task is added to the task selection queue and the current time is greater than the initial execution time in the control unit corresponding to the next task. If so, determine that the next task is executed immediately; if not, take the difference between the initial execution time and the first time interval in the control unit corresponding to the next task as the first waiting period. After the first waiting period, re-select the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the re-selected control unit corresponding to the next task.
[0168] It is understandable that there is a time for a task to be submitted to the task selection queue, and the initial execution time in the control unit is equivalent to the first task being submitted to the task selection queue, and it needs to wait for at least an initial execution time before executing. Therefore, when the next task is the first task in the task selection queue, it is necessary to determine whether the first time interval between the time when the next task is added to the task selection queue and the current time is greater than the initial execution time in the control unit corresponding to the next task.
[0169] If yes, it means that at least an initial execution time has been waited, and the first task in the task selection queue is executed immediately. If no, it means that an initial execution time has not been waited, and at this time, the first waiting time is calculated, and the first waiting time is the difference between the initial execution time and the first time interval. Furthermore, after the first waiting time, the control unit corresponding to the next task is reselected from the control unit set, and the delayed execution result of the next task is re-determined based on the control unit corresponding to the reselected next task. It is understandable that after the first waiting time, the system load may change, and the control unit of the next task may also change. It is necessary to reselect the control unit corresponding to the next task. It is understandable that it is considered that after the first waiting time, the control unit corresponding to the next task has not yet failed.
[0170] S402: When the next task is not the first task in the task selection queue, the delayed execution result of the next task is determined based on the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently executed simultaneously.
[0171] When the next task is not the first task in the task selection queue, the currently executed task and the next task will be scattered. At this time, the delayed execution result of the next task is determined based on the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently executed simultaneously. Specifically, it can be determined according to the following S4021-S4023.
[0172] S4021: When the result of comparing the number of concurrent executions in the control unit corresponding to the next task and the number of concurrent executions in the control unit corresponding to the next task with the number of task batches currently being executed simultaneously satisfies any of the following conditions, the next task is determined to be executed immediately:
[0173] Case 1: The number of concurrent executions in the control unit corresponding to the next task is infinite.
[0174] It can be understood that when the number of concurrent executions in the control unit corresponding to the next task is infinite, the control will ignore the execution window time, execution interval time and execution timeout time, and the task will be executed concurrently immediately. The degree of concurrency of the task is only limited by the system resources provided for task processing (the maximum number of threads in the corresponding configured thread pool).
[0175] Case 2: The number of task batches currently being executed simultaneously is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task, and the difference between the current time and the earliest start time of the start times of the tasks currently being executed simultaneously is greater than the execution timeout in the control unit corresponding to the next task.
[0176] From the above content, it can be seen that if the number of task batches currently being executed simultaneously is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task, the execution of the next task will be controlled according to the execution timeout. In order to achieve scattered control, at least wait for an execution timeout before executing. Then determine whether the difference between the current time and the earliest start time of the start time of each task currently being executed simultaneously is greater than the execution timeout in the control unit corresponding to the next task. If so, then wait for an execution timeout, achieve scattered control between tasks, and determine that the next task will be executed immediately.
[0177] Case 3: The execution concurrency number in the control unit corresponding to the next task is 0 and the difference between the current time and the earliest start time of the start times of the tasks currently being executed simultaneously is greater than the execution timeout time in the control unit corresponding to the next task.
[0178] In the same situation 2, when the execution concurrency in the control unit corresponding to the next task is 0, it is considered that the number of task batches currently being executed simultaneously is always greater than the execution concurrency. At this time, the execution of the next task will also be controlled according to the execution timeout. Therefore, it is also determined whether the difference between the current time and the earliest start time of the start time of each task currently being executed simultaneously is greater than the execution timeout in the control unit corresponding to the next task. If so, an execution timeout is waited, the scattered control between tasks is realized, and the next task is determined to be executed immediately.
[0179] Case 4: The number of task batches currently being executed simultaneously is less than the concurrent execution number in the control unit corresponding to the next task, the concurrent execution number in the control unit corresponding to the next task is greater than 0, and the number of task batches that have been executed within the first time range is less than the concurrent execution number in the control unit corresponding to the next task.
[0180] If the number of concurrent executions in the control unit corresponding to the next task is greater than 0 and the number of task batches currently being executed simultaneously is less than the number of concurrent executions in the control unit corresponding to the next task, it means that the number of concurrent executions in the control unit has not yet been reached. At this time, a judgment is made as to whether the number of task batches that have been executed within the first time range is less than the number of concurrent executions in the control unit corresponding to the next task. Among them, the first time range is specifically from the start of the target application to the current time. This judgment is mainly to deal with the situation where the number of task batches has not reached the number of concurrent executions as a whole when the target application starts to execute tasks after starting. If so, it means that within a period of time after the target application starts to execute tasks, the number of task batches has not reached the number of concurrent executions. At this time, in order to avoid the failure of the number of concurrent executions of the control unit and in order to quickly reach a certain task concurrency state, a new task batch is directly opened, and the next task is immediately executed in the new task batch.
[0181] Case 5: The number of task batches currently being executed simultaneously is less than the concurrent execution number in the control unit corresponding to the next task, the concurrent execution number in the control unit corresponding to the next task is greater than 0, the number of task batches that have been executed within the first time range is greater than or equal to the concurrent execution number in the control unit corresponding to the next task, and the cumulative task duration of the tasks in the task batches that have been executed within the second time range is not greater than the execution window time in the control unit corresponding to the next task.
[0182] Similar to situation 4, when the number of task batches executed within the first time range is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task, it means that a long period of time has passed since the task execution of the target application, and now we focus on the task batches executed within the second time range. Usually, the second time range is smaller than the first time range, and the second time range is the most recent period before the current time. The interval between the second time range and the current time can be considered shorter (for example, the interval is smaller than the interval threshold, and the interval threshold is a smaller time interval).
[0183] At this time, it is determined whether the cumulative duration of the tasks in the task batch that have been executed within the second time range is the execution window time in the control unit corresponding to the next task. If not, it means that there are still tasks that can be executed within the execution window time, then the next task in the task batch that has been executed within the second time range is executed immediately.
[0184] For example, if the number of concurrent executions is 6, and within the second time range, there are 4 task batches being executed simultaneously, and 2 task batches within the second time range have been completed. If the cumulative task duration of tasks in one of the two task batches is not greater than the execution window time in the control unit corresponding to the next task, the next task in the task batch will be executed immediately.
[0185] It is understandable that, since the tasks in the currently concurrently executed task batch are being executed, in order to allow the next task to be executed immediately, the next task will not be inserted into the currently concurrently executed task batch.
[0186] S4022: If the number of task batches currently being executed simultaneously is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task and the difference between the current time and the earliest start time of the start times of the tasks currently being executed simultaneously is not greater than the execution timeout time in the control unit corresponding to the next task, calculate the second interval time between the earliest start time and the current time; take the difference between the execution timeout time and the second interval time in the control unit corresponding to the next task as the second waiting period; after the second waiting period, re-select the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the re-selected control unit corresponding to the next task.
[0187] Compared with situation 2, if the number of task batches currently being executed simultaneously is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task and the difference between the current time and the earliest start time of the start times of the tasks currently being executed simultaneously is not greater than the execution timeout in the control unit corresponding to the next task, it means that an execution timeout has not yet been waited for.
[0188] At this time, calculate the second waiting time. The second waiting time is the difference between the execution timeout time in the control unit corresponding to the next task and the second interval time. Furthermore, after the second waiting time, reselect the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the reselected control unit corresponding to the next task. It is understandable that after the second waiting time, the system load may change, and the control unit of the next task may also change. Then it is necessary to reselect the control unit corresponding to the next task. It is understandable that it is considered that after the second waiting time, the control unit corresponding to the next task has not yet failed.
[0189] S4023: If the number of task batches currently being executed simultaneously is less than the number of concurrent executions in the control unit corresponding to the next task, the number of concurrent executions in the control unit corresponding to the next task is greater than 0, the number of task batches that have been executed within the first time range is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task, and the cumulative task duration of the tasks in the task batches that have been executed within the second time range is greater than the execution window time in the control unit corresponding to the next task, select the shorter of the control timeout time and the execution interval time corresponding to the control unit corresponding to the next task as the third waiting time; after the third waiting time, re-select the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the re-selected control unit corresponding to the next task.
[0190] Compared with situation 5, if the concurrent execution number in the control unit corresponding to the next task is greater than 0, the number of task batches currently being executed simultaneously is less than the concurrent execution number in the control unit corresponding to the next task, and the number of task batches that have been executed within the first time range is greater than or equal to the concurrent execution number in the control unit corresponding to the next task, then it is further determined whether the cumulative task duration of the tasks in the task batches that have been executed within the second time range is greater than the execution window time. If it is greater, it means that the remaining tasks cannot be executed within the execution window time.
[0191] At this time, the third waiting time is obtained. The third waiting time is the shorter time between the control timeout time and the execution interval time corresponding to the control unit corresponding to the next task. Furthermore, after the third waiting time, the control unit corresponding to the next task is reselected from the control unit set, and the delayed execution result of the next task is re-determined based on the control unit corresponding to the reselected next task. It is understandable that after the third waiting time, the system load may change, and the control unit of the next task may also change. Then it is necessary to reselect the control unit corresponding to the next task.
[0192] Among them, when the control timeout of the control unit corresponding to the next task is less than the execution interval, the control unit corresponding to the next task may fail in a short time, and then the control timeout is used as the third waiting time. After the third waiting time, the control unit corresponding to the next task fails. At this time, the control unit corresponding to the next task is reselected and the delayed execution result of the next task is re-determined. When the control timeout of the control unit corresponding to the next task is not less than the execution interval, wait for an execution interval. At this time, the control unit corresponding to the next task is still effective, but the system load may change, and the control unit of the next task may also change. Then it is necessary to reselect the control unit corresponding to the next task.
[0193] Based on the above content, it can be seen that the judgment of subsequent tasks will not begin until the next task is determined to be executed.
[0194] See also Figure 5 , Figure 5 A schematic diagram of determining a delayed execution result of a next task provided in an embodiment of the present application.
[0195] In one possible implementation, combining Figure 5 As well as the contents of S401-S402, the embodiment of the present application provides a specific implementation method of determining the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task in 204, including:
[0196] S501: selecting a control unit from a control unit set according to a delay scattering amplitude determination algorithm;
[0197] S502: Determine whether the next task is the first task in the task selection queue, if so, execute S503, if not, execute S504.
[0198] S503: Determine whether the first time interval between the time when the next task is added to the task selection queue and the current time is greater than the initial execution time in the control unit corresponding to the next task. If so, determine that the next task is executed immediately. If not, use the difference between the initial execution time in the control unit corresponding to the next task and the first time interval as the first waiting time. After the first waiting time, re-execute S501 to select the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the re-selected control unit corresponding to the next task.
[0199] S504: Determine whether the execution concurrency of the control unit corresponding to the next task is infinite, if so, determine that the next task is executable. If not, it means that the execution concurrency of the control unit corresponding to the next task is greater than or equal to 0, and then execute S505.
[0200] S505: Determine whether the number of task batches currently being executed simultaneously is greater than or equal to the concurrent execution number in the control unit corresponding to the next task, or whether the concurrent execution number of the control unit corresponding to the next task is equal to 0. If so, it means that the number of task batches currently being executed simultaneously is greater than or equal to the concurrent execution number in the control unit corresponding to the next task, or the concurrent execution number of the control unit corresponding to the next task is equal to 0. At this time, execute S506; if not, it means that the number of task batches currently being executed simultaneously is less than the concurrent execution number in the control unit corresponding to the next task and the concurrent execution number of the control unit corresponding to the next task is greater than 0, and execute S507 at this time.
[0201] S506: Determine whether the difference between the current time and the earliest start time among the start times of the tasks currently being executed simultaneously is greater than the execution timeout time in the control unit corresponding to the next task; if so, determine that the next task is executable; if not, calculate the target interval time between the earliest start time and the current time, and use the execution timeout time and the target interval time in the control unit corresponding to the next task as the second waiting period. After the second waiting period, re-select the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the re-selected control unit corresponding to the next task.
[0202] S507: Determine whether the number of task batches that have been executed within the first time range is less than the concurrent execution number in the control unit corresponding to the next task; if so, it means that the number of task batches currently being executed simultaneously is less than the concurrent execution number in the control unit corresponding to the next task, the concurrent execution number in the control unit corresponding to the next task is greater than 0, and the number of task batches that have been executed within the first time range is less than the concurrent execution number in the control unit corresponding to the next task, and determine that the next task is executable; if not, it means that the number of task batches that are currently being executed simultaneously is less than the concurrent execution number in the control unit corresponding to the next task, the concurrent execution number in the control unit corresponding to the next task is greater than 0, and the number of task batches that have been executed within the first time range is greater than or equal to the concurrent execution number in the control unit corresponding to the next task, and execute S508.
[0203] S508: Determine whether the cumulative task duration of the tasks in the task batches that have been executed within the second time range is greater than the execution window time in the control unit corresponding to the next task; if not, it means that the number of task batches currently being executed simultaneously is less than the execution concurrency number in the control unit corresponding to the next task, the execution concurrency number in the control unit corresponding to the next task is greater than 0, the number of task batches that have been executed within the first time range is greater than or equal to the execution concurrency number in the control unit corresponding to the next task, and the cumulative task duration of the tasks in the task batches that have been executed within the second time range is not greater than the execution window time in the control unit corresponding to the next task, and determine that the next task is executable; if so, select the shorter time between the control timeout time and the execution interval time corresponding to the control unit corresponding to the next task as the third waiting time, and after the third waiting time, re-select the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the re-selected control unit corresponding to the next task.
[0204] It can be seen that the contents of S501-S508 can refer to the above-mentioned embodiments S401-S402 (S4021-S4023), which will not be repeated here.
[0205] It is understandable that in actual applications, before executing S501, the next task is selected from the task selection queue. If the next task cannot be selected from the task selection queue, it is necessary to wait until a task is added to the task selection queue and enter the next cycle.
[0206] It can also be understood that when it is determined that the next task is not to be executed immediately, the judgment will continue in a loop until the next task is determined to be executed, and then the judgment of the subsequent tasks will begin.
[0207] It can also be understood that when it is determined that the next task is not to be executed immediately, the first waiting time, the second waiting time and the third waiting time mentioned above can all be considered as the time for delaying and breaking up the task.
[0208] Based on the implementations provided in the above aspects, the present application can also be further combined to provide more implementations.
[0209] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0210] Based on a task scheduling method provided in the above method embodiment, the present application embodiment also provides a task scheduling device, which will be described below in conjunction with the accompanying drawings. Since the principle of the device in the embodiment of the present disclosure to solve the problem is similar to the above task scheduling method in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0211] See also Figure 6 As shown in FIG. 1 , this figure is a schematic diagram of the structure of a task scheduling device provided in an embodiment of the present application. Figure 6 As shown, the task scheduling device includes:
[0212] A first determining unit 601 is configured to determine system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application;
[0213] An adding unit 602 is used to add the control unit corresponding to the load evaluation index when the system load data meets the preset load range to the control unit set; the control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application; the control parameters are used to indicate the delay dispersion range of the task;
[0214] A selection unit 603 is used to select a next task of a currently executed task from the task selection queue of the target application, and select a control unit corresponding to the next task from the control unit set;
[0215] The second determining unit 604 is used to determine the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task.
[0216] In a possible implementation, the load assessment indicator includes user operations on the target application and / or resource usage of the target application;
[0217] The first determining unit 601 includes:
[0218] A first determining subunit, configured to determine system load data of the target application based on whether the user operation conforms to a target user operation;
[0219] and / or,
[0220] The second determining subunit is used to determine the system load data of the target application based on whether the resource usage rate meets a preset usage rate range.
[0221] In a possible implementation manner, the first determining subunit is specifically configured to:
[0222] When the user operation matches the target user operation, determining that the system load data meets a preset load range;
[0223] The second determining subunit is specifically used for:
[0224] When the resource usage rate meets the preset usage rate range, determining that the system load data meets the preset load range;
[0225] The adding unit 602 is specifically used for:
[0226] The control unit corresponding to the user operation when the system load data meets the preset load range is added to the control unit set, and / or the control unit corresponding to the resource utilization rate when the system load data meets the preset load range is added to the control unit set.
[0227] In a possible implementation manner, the device further includes:
[0228] A configuration unit, used to pre-configure a control unit corresponding to a load evaluation indicator and a control timeout period;
[0229] The configuration unit comprises:
[0230] A first configuration subunit is used to pre-configure a control unit and a control timeout period corresponding to a target user operation; the control timeout period is used to indicate the validity period of the control unit, and the control unit becomes effective from the time it is added to the control unit set and becomes invalid when the control timeout period is exceeded;
[0231] The second configuration subunit is used to pre-configure the control unit corresponding to the resource usage rate and the control timeout period.
[0232] In a possible implementation manner, the target user operation includes at least one of the following:
[0233] Application page switching operations, triggering operations of the navigation bar at the bottom of the application homepage, triggering operations of the navigation bar at the top of the application homepage, and sliding operations of the message source on the application homepage;
[0234] Each time period after the target application is started corresponds to a resource usage collection frequency, and the resource usage collection frequency in each time period corresponds to a control unit and a control timeout period;
[0235] The control unit corresponding to the resource usage rate is determined according to the collection frequency corresponding to the collection time period of the resource usage rate.
[0236] In a possible implementation, the initial execution time in the control unit is less than the execution interval time, the execution window time is less than the execution interval time, and the execution interval time is less than the execution timeout time;
[0237] The higher the system load data of the target application under the load evaluation index, the longer the initial execution time in the control unit corresponding to the load evaluation index, the smaller the execution window time, the longer the execution interval time, the smaller the execution concurrency number, and the longer the execution timeout time;
[0238] The longer the duration that the system load data under the load assessment indicator meets the preset load range, the longer the control timeout time of the control unit corresponding to the load assessment indicator; the control timeout time corresponding to the control unit is greater than the duration.
[0239] In a possible implementation, the selection unit 603 includes:
[0240] A first selection subunit is used to select a control unit with the largest delay dispersion from the control unit set as the control unit corresponding to the next task;
[0241] Among them, when the number of concurrent executions in the control unit is infinite, the delay dispersion amplitude of the control unit is the largest; when the number of concurrent executions in at least one of the control units is greater than 0, the delay dispersion amplitude is negatively correlated with the number of concurrent executions in the control unit, and positively correlated with the interval time, and the interval time is the execution interval time or the execution timeout time; when the number of concurrent executions in at least one of the control units is equal to 0, the delay dispersion amplitude is positively correlated with the execution timeout time in the control unit; when the number of concurrent executions in at least one of the control units is greater than 0 or equal to 0, the delay dispersion amplitude is negatively correlated with the number of concurrent executions in the control unit.
[0242] In a possible implementation, the first selecting subunit includes:
[0243] A second selection subunit is used to select a valid control unit from the control unit set as a target control unit;
[0244] A third determining subunit is used to sequentially select the remaining effective control units from the control unit set, use the currently selected effective control unit as the pre-selected control unit, use the delay dispersion amplitude of the pre-selected control unit as the first value, and use the delay dispersion amplitude of the target control unit as the second value;
[0245] The fourth determination subunit is used to, if the execution concurrency of the pre-selected control unit is infinite, use the pre-selected control unit as the updated target control unit, and re-execute the target step and subsequent steps; if the execution concurrency of the target control unit is infinite, determine that the delay dispersion amplitude of the target control unit is the largest, and use the target control unit as the control unit corresponding to the next task; the target step is to select the remaining effective control units from the control unit set in sequence;
[0246] a fifth determination subunit, configured to: if the execution concurrency number of the preselected control unit and the execution concurrency number of the target control unit are both greater than 0, then when it is determined according to the target correlation relationship that the first value is greater than the second value, use the preselected control unit as the updated target control unit and re-execute the target step and subsequent steps; when it is determined according to the target correlation relationship that the first value is equal to the second value, determine whether the execution timeout time of the preselected control unit is greater than the execution timeout time of the target control unit, and if so, use the preselected control unit as the updated target control unit and re-execute the target step and subsequent steps; if not, re-execute the target step and subsequent steps; when it is determined according to the target correlation relationship that the first value is less than the second value, re-execute the target step and subsequent steps;
[0247] The target correlation relationship is that the delay dispersion amplitude is negatively correlated with the concurrent execution number in the control unit and positively correlated with the execution interval time;
[0248] A sixth determination subunit is used to determine whether the execution timeout of the preselected control unit is greater than the execution timeout of the target control unit if the execution concurrency number of the preselected control unit and the execution concurrency number of the target control unit are both equal to 0, and if so, use the preselected control unit as the updated target control unit to re-execute the target step and subsequent steps, and if not, re-execute the target step and subsequent steps;
[0249] A seventh determination subunit is used to re-execute the target step and subsequent steps if the execution concurrency of the pre-selected control unit is greater than 0 and the execution concurrency of the target control unit is equal to 0; if the execution concurrency of the pre-selected control unit is equal to 0 and the execution concurrency of the target control unit is greater than 0, use the pre-selected control unit as the updated target control unit and re-execute the target step and subsequent steps;
[0250] The eighth determination subunit is used to select all effective control units in the control unit set, and use the updated target control unit finally obtained as the control unit corresponding to the next task.
[0251] In a possible implementation, the first value is obtained by a first formula, and the second value is obtained by a second formula; a comparison between a value of the first formula and a value of the second formula is used to characterize the target correlation relationship;
[0252] The first formula is the execution interval time of the pre-selected control unit minus the execution window time of the pre-selected control unit, the difference is multiplied by the execution window time of the target control unit, and the product is divided by the execution concurrency number of the pre-selected control unit;
[0253] The second formula is the execution interval time of the target control unit minus the execution window time of the target control unit, the difference is multiplied by the execution window time of the pre-selected control unit, and the product is divided by the execution concurrency number of the target control unit.
[0254] In a possible implementation manner, the device further includes:
[0255] A clearing unit is used to clear the failed control units in the control unit set.
[0256] In a possible implementation, the second determining unit 604 includes:
[0257] A ninth determination subunit is used for determining, when the next task is the first task in the task selection queue, whether a first time interval between the time when the next task is added to the task selection queue and the current time is greater than an initial execution time in the control unit corresponding to the next task, and if so, determining that the next task is to be executed immediately; if not, taking the difference between the initial execution time in the control unit corresponding to the next task and the first time interval as a first waiting time, and after the first waiting time has elapsed, reselecting the control unit corresponding to the next task from the control unit set, and re-determining the delayed execution result of the next task based on the reselected control unit corresponding to the next task;
[0258] The tenth determination subunit is used to determine the delayed execution result of the next task when the next task is not the first task in the task selection queue, based on the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently being executed simultaneously.
[0259] In a possible implementation manner, the tenth determining subunit includes:
[0260] An eleventh determination subunit is used to determine that the next task is to be executed immediately when the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently executed simultaneously meet the target situation;
[0261] The target situation is any of the following:
[0262] The number of concurrent executions in the control unit corresponding to the next task is infinite;
[0263] The number of task batches currently being executed simultaneously is greater than the number of concurrent executions in the control unit corresponding to the next task, and the difference between the current time and the earliest start time of the start times of the tasks currently being executed simultaneously is greater than the execution timeout time in the control unit corresponding to the next task;
[0264] The number of task batches currently being executed simultaneously is less than or equal to the number of concurrent executions in the control unit corresponding to the next task, and the number of concurrent executions in the control unit corresponding to the next task is 0;
[0265] The number of task batches currently being executed simultaneously is less than the number of concurrent executions in the control unit corresponding to the next task and the number of concurrent executions in the control unit corresponding to the next task is greater than 0;
[0266] The number of task batches currently being executed simultaneously is equal to the execution concurrency number in the control unit corresponding to the next task, the execution concurrency number in the control unit corresponding to the next task is greater than 0, and the cumulative task duration of each task executed simultaneously in the current batch of tasks is not greater than the execution window time in the control unit corresponding to the next task.
[0267] In a possible implementation manner, the tenth determining subunit includes:
[0268] A twelfth determination subunit is used for, when the next task is not the first task in the task selection queue, if the number of task batches currently being executed simultaneously is greater than the number of concurrent executions in the control unit corresponding to the next task and the difference between the current time and the earliest start time among the start times of the tasks currently being executed simultaneously is not greater than the execution timeout time in the control unit corresponding to the next task, calculating a second interval time between the earliest start time and the current time;
[0269] A thirteenth determining subunit is configured to use the difference between the execution timeout time in the control unit corresponding to the next task and the second interval time as the second waiting time;
[0270] The first reselection subunit is used to reselect the control unit corresponding to the next task from the control unit set after the second waiting period has passed, and re-determine the delayed execution result of the next task based on the reselected control unit corresponding to the next task.
[0271] In a possible implementation manner, the tenth determining subunit includes:
[0272] A fourteenth determination subunit is used for, when the next task is not the first task in the task selection queue, if the number of task batches currently being executed simultaneously is equal to the execution concurrency number in the control unit corresponding to the next task, the execution concurrency number in the control unit corresponding to the next task is greater than 0, and the cumulative task duration of each task executed simultaneously in the current batch of tasks is greater than the execution window time in the control unit corresponding to the next task, select the shorter time between the control timeout time and the execution interval time corresponding to the control unit corresponding to the next task as the third waiting duration;
[0273] The second reselection subunit is used to reselect the control unit corresponding to the next task from the control unit set after the third waiting period, and re-determine the delayed execution result of the next task based on the reselected control unit corresponding to the next task.
[0274] It should be noted that the specific implementation of each unit in this embodiment can refer to the relevant description in the above method embodiment. The division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. The functional units in the embodiment of the present application can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. For example, in the above embodiment, the processing unit and the sending unit can be the same unit or different units. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0275] Based on a task scheduling method provided in the above method embodiment, the present application also provides an electronic device, including: one or more processors; a storage device, on which one or more programs are stored, when the one or more programs are executed by the one or more processors, the one or more processors implement the task scheduling method described in any of the above embodiments.
[0276] Reference below Figure 7 , which shows a schematic diagram of the structure of an electronic device 700 suitable for implementing the embodiment of the present application. The terminal device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0277] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0278] Typically, the following devices may be connected to the I / O interface 705: an input device 706 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 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 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.
[0279] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 709, or installed from the storage device 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0280] The electronic device provided in the embodiment of the present application and the task scheduling method provided in the above embodiment belong to the same inventive concept. 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.
[0281] Based on a task scheduling method provided by the above method embodiment, an embodiment of the present application provides a computer-readable medium on which a computer program is stored, wherein when the program is executed by a processor, the task scheduling method as described in any of the above embodiments is implemented.
[0282] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of 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 of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The 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 for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0283] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text 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.
[0284] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0285] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the task scheduling method.
[0286] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination 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 via 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).
[0287] 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 application. 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 alternative implementations, 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.
[0288] The units involved in the embodiments described in this application may be implemented by software or hardware. The name of a unit / module does not limit the unit itself in some cases. For example, a voice data acquisition module may also be described as a "data acquisition module".
[0289] 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.
[0290] In the context of the present application, 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.
[0291] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0292] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0293] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0294] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0295] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A task scheduling method, characterized in that: The method comprises: Based on at least one load assessment indicator of the target application, determining system load data of the target application under each load assessment indicator; Adding the control unit corresponding to the load evaluation index when the system load data meets the preset load range to the control unit set; the control parameters in the control unit include the initial execution time, execution window time, execution interval time, execution concurrency number and execution timeout time of the task in the target application; the control parameters are used to indicate the delay dispersion range of the task; Selecting the next task of the currently executed task from the task selection queue of the target application, and selecting the control unit corresponding to the next task from the control unit set; The delayed execution result of the next task is determined according to the control parameters in the control unit corresponding to the next task.
2. The method according to claim 1, characterized in that The load assessment indicator includes user operations on the target application and / or resource usage of the target application; The step of determining the system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application includes: Determining system load data of the target application based on whether the user operation conforms to a target user operation; and / or, Based on whether the resource usage rate meets a preset usage rate range, system load data of the target application is determined.
3. The method according to claim 2, characterized in that The determining the system load data of the target application based on whether the user operation conforms to the target user operation includes: When the user operation matches the target user operation, determining that the system load data meets a preset load range; The determining the system load data of the target application based on whether the resource usage rate meets a preset usage rate range includes: When the resource usage rate meets the preset usage rate range, determining that the system load data meets the preset load range; The step of adding the control unit corresponding to the load evaluation indicator when the system load data satisfies the preset load range to the control unit set includes: The control unit corresponding to the user operation when the system load data meets the preset load range is added to the control unit set, and / or the control unit corresponding to the resource utilization rate when the system load data meets the preset load range is added to the control unit set.
4. The method according to claim 1, characterized in that: The method further comprises: Pre-configure the control unit corresponding to the load evaluation index and the control timeout period; The control unit corresponding to the pre-configured load evaluation indicator and the control timeout period include: Pre-configure the control unit and control timeout time corresponding to the target user operation; the control timeout time is used to indicate the validity period of the control unit. The control unit becomes effective from the time it is added to the control unit set and becomes invalid when the control timeout time is exceeded; A control unit corresponding to the resource usage rate and a control timeout period are preconfigured.
5. The method according to claim 4, characterized in that The target user operation includes at least one of the following: Application page switching operations, triggering operations of the navigation bar at the bottom of the application homepage, triggering operations of the navigation bar at the top of the application homepage, and sliding operations of the message source on the application homepage; Each time period after the target application is started corresponds to a resource usage collection frequency, and the resource usage collection frequency in each time period corresponds to a control unit and a control timeout period; The control unit corresponding to the resource usage rate is determined according to the collection frequency corresponding to the collection time period of the resource usage rate.
6. The method according to claim 4, characterized in that The initial execution time in the control unit is less than the execution interval time, the execution window time is less than the execution interval time, and the execution interval time is less than the execution timeout time; The higher the system load data of the target application under the load evaluation index, the longer the initial execution time in the control unit corresponding to the load evaluation index, the smaller the execution window time, the longer the execution interval time, the smaller the execution concurrency number, and the longer the execution timeout time; The longer the duration that the system load data under the load assessment indicator meets the preset load range, the longer the control timeout time of the control unit corresponding to the load assessment indicator; the control timeout time corresponding to the control unit is greater than the duration.
7. The method according to claim 1, characterized in that The selecting a control unit corresponding to the next task from the control unit set includes: Selecting a control unit with the largest delay dispersion from the control unit set as the control unit corresponding to the next task; Among them, when the number of concurrent executions in the control unit is infinite, the delay dispersion amplitude of the control unit is the largest; when the number of concurrent executions in at least one of the control units is greater than 0, the delay dispersion amplitude is negatively correlated with the number of concurrent executions in the control unit, and positively correlated with the interval time, and the interval time is the execution interval time or the execution timeout time; when the number of concurrent executions in at least one of the control units is equal to 0, the delay dispersion amplitude is positively correlated with the execution timeout time in the control unit; when the number of concurrent executions in at least one of the control units is greater than 0 or equal to 0, the delay dispersion amplitude is negatively correlated with the number of concurrent executions in the control unit.
8. The method according to claim 7, characterized in that The step of selecting a control unit with the largest delay dispersion from the control unit set as the control unit corresponding to the next task includes: Selecting a valid control unit from the control unit set as a target control unit; Select the remaining effective control units from the control unit set in sequence, use the currently selected effective control unit as the preselected control unit, use the delay dispersion amplitude of the preselected control unit as the first value, and use the delay dispersion amplitude of the target control unit as the second value; If the number of concurrent executions of the pre-selected control unit is infinite, the pre-selected control unit is used as the updated target control unit, and the target step and subsequent steps are re-executed; if the number of concurrent executions of the target control unit is infinite, it is determined that the delay dispersion of the target control unit is the largest, and the target control unit is used as the control unit corresponding to the next task; the target step is to select the remaining effective control units from the control unit set in turn; If the execution concurrency number of the preselected control unit and the execution concurrency number of the target control unit are both greater than 0, then when it is determined according to the target correlation that the first value is greater than the second value, the preselected control unit is used as the updated target control unit, and the target step and subsequent steps are re-executed; when it is determined according to the target correlation that the first value is equal to the second value, it is determined whether the execution timeout time of the preselected control unit is greater than the execution timeout time of the target control unit, if so, the preselected control unit is used as the updated target control unit, and the target step and subsequent steps are re-executed, if not, the target step and subsequent steps are re-executed; when it is determined according to the target correlation that the first value is less than the second value, the target step and subsequent steps are re-executed; The target correlation relationship is that the delay dispersion amplitude is negatively correlated with the concurrent execution number in the control unit and positively correlated with the execution interval time; If the execution concurrency number of the preselected control unit and the execution concurrency number of the target control unit are both equal to 0, determine whether the execution timeout of the preselected control unit is greater than the execution timeout of the target control unit. If so, use the preselected control unit as the updated target control unit and re-execute the target step and subsequent steps. If not, re-execute the target step and subsequent steps. If the execution concurrency of the preselected control unit is greater than 0 and the execution concurrency of the target control unit is equal to 0, re-execute the target step and subsequent steps; if the execution concurrency of the preselected control unit is equal to 0 and the execution concurrency of the target control unit is greater than 0, use the preselected control unit as the updated target control unit and re-execute the target step and subsequent steps; Until all valid control units in the control unit set are selected, the updated target control unit finally obtained is used as the control unit corresponding to the next task.
9. The method according to claim 8, characterized in that The first value is obtained by a first formula, and the second value is obtained by a second formula; a comparison between the value of the first formula and the value of the second formula is used to characterize the target correlation relationship; The first formula is the execution interval time of the pre-selected control unit minus the execution window time of the pre-selected control unit, the difference is multiplied by the execution window time of the target control unit, and the product is divided by the execution concurrency number of the pre-selected control unit; The second formula is the execution interval time of the target control unit minus the execution window time of the target control unit, the difference is multiplied by the execution window time of the pre-selected control unit, and the product is divided by the execution concurrency number of the target control unit.
10. The method according to claim 8, characterized in that The method further comprises: The failed control units in the control unit set are cleared.
11. The method according to any one of claims 1 to 10, characterized in that: The step of determining the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task includes: When the next task is the first task in the task selection queue, determine whether a first time interval between the time when the next task is added to the task selection queue and the current time is greater than an initial execution time in the control unit corresponding to the next task, and if so, determine that the next task is executed immediately; if not, take the difference between the initial execution time in the control unit corresponding to the next task and the first time interval as a first waiting time, and after the first waiting time has passed, reselect the control unit corresponding to the next task from the control unit set, and re-determine the delayed execution result of the next task based on the reselected control unit corresponding to the next task; When the next task is not the first task in the task selection queue, the delayed execution result of the next task is determined based on the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently executed simultaneously.
12. The method according to claim 11, characterized in that The determining the delayed execution result of the next task according to the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently being executed simultaneously includes: When the number of concurrent executions in the control unit corresponding to the next task and the comparison result between the number of concurrent executions in the control unit corresponding to the next task and the number of task batches currently being executed simultaneously meet the target situation, determining that the next task is to be executed immediately; The target situation is any of the following: The number of concurrent executions in the control unit corresponding to the next task is infinite; The number of task batches currently being executed simultaneously is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task, and the difference between the current time and the earliest start time of the start times of the tasks currently being executed simultaneously is greater than the execution timeout time in the control unit corresponding to the next task; The execution concurrency number in the control unit corresponding to the next task is 0 and the difference between the current time and the earliest start time of the start times of the tasks currently being executed simultaneously is greater than the execution timeout time in the control unit corresponding to the next task; The number of task batches currently being executed simultaneously is less than the number of concurrent executions in the control unit corresponding to the next task, the number of concurrent executions in the control unit corresponding to the next task is greater than 0, and the number of task batches that have been executed within the first time range is less than the number of concurrent executions in the control unit corresponding to the next task; The number of task batches currently being executed simultaneously is less than the concurrent execution number in the control unit corresponding to the next task, the concurrent execution number in the control unit corresponding to the next task is greater than 0, the number of task batches that have been executed within the first time range is greater than or equal to the concurrent execution number in the control unit corresponding to the next task, and the cumulative task duration of the tasks in the task batches that have been executed within the second time range is not greater than the execution window time in the control unit corresponding to the next task.
13. The method according to claim 12, characterized in that The determining the delayed execution result of the next task according to the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently being executed simultaneously includes: If the number of task batches currently being executed simultaneously is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task and the difference between the current time and the earliest start time among the start times of the tasks currently being executed simultaneously is not greater than the execution timeout time in the control unit corresponding to the next task, calculate a second interval time between the earliest start time and the current time; Using the difference between the execution timeout time in the control unit corresponding to the next task and the second interval time as the second waiting time; After the second waiting period has elapsed, the control unit corresponding to the next task is reselected from the control unit set, and the delayed execution result of the next task is re-determined based on the reselected control unit corresponding to the next task.
14. The method according to claim 12 or 13, characterized in that The determining the delayed execution result of the next task according to the execution concurrency number in the control unit corresponding to the next task and the comparison result between the execution concurrency number in the control unit corresponding to the next task and the number of task batches currently being executed simultaneously includes: If the number of task batches currently being executed simultaneously is less than the number of concurrent executions in the control unit corresponding to the next task, the number of concurrent executions in the control unit corresponding to the next task is greater than 0, the number of task batches that have been executed within the first time range is greater than or equal to the number of concurrent executions in the control unit corresponding to the next task, and the cumulative task duration of the tasks in the task batches that have been executed within the second time range is greater than the execution window time in the control unit corresponding to the next task, select the shorter time between the control timeout time and the execution interval time corresponding to the control unit corresponding to the next task as the third waiting duration; After the third waiting period has elapsed, the control unit corresponding to the next task is reselected from the control unit set, and the delayed execution result of the next task is re-determined based on the reselected control unit corresponding to the next task.
15. A task scheduling device, characterized in that: The device comprises: A first determining unit, configured to determine system load data of the target application under each load evaluation indicator based on at least one load evaluation indicator of the target application; An adding unit, used for adding a control unit corresponding to the load evaluation index when the system load data meets a preset load range to a control unit set; the control parameters in the control unit include an initial execution time, an execution window time, an execution interval time, a number of concurrent executions, and an execution timeout time of a task in the target application; the control parameters are used to indicate a delay dispersion range of the task; A selection unit, configured to select a next task of a currently executed task from a task selection queue of the target application, and select a control unit corresponding to the next task from the control unit set; The second determining unit is used to determine the delayed execution result of the next task according to the control parameters in the control unit corresponding to the next task.
16. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the task scheduling method as described in any one of claims 1-14.
17. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the task scheduling method as described in any one of claims 1 to 14 is implemented.
Citation Information
Cited By
Task scheduling method and device, storage medium and electronic equipment
CN119781945A