Task scheduling method, task scheduling device, storage medium and electronic equipment
By building a task space tree and using a backtracking algorithm, the task scheduling algorithm is optimized to determine the target scheduling scheme, the problem of waste of resources and unreasonable resource allocation caused by the large execution time gap in the task group is solved, and efficient execution and resources of the task queue are achieved Distribute evenly.
Patent Information
- Application Number
- CN202411327608.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-23
- Publication Date
- 2024-12-20
AI Technical Summary
In the prior art, in task scheduling, when the execution time gap within the task group is large, it will lead to waste of resources and unreasonable local resource allocation, and it will not be possible to effectively optimize the execution efficiency of the task queue.
By building a task space tree, using a backtracking algorithm to solve the task space tree, determine the target scheduling scheme, so that the total execution time of all tasks to be scheduled is the shortest and the execution time variance of the executor is the smallest, and the task scheduling algorithm is optimized to filter the total execution of the executor. The result with the smallest time variance.
On the premise of ensuring the original minimum total execution time, the resource waste caused by the large gap in the execution time distribution of the task queue is solved, and the uniformity of resource allocation and the efficiency of task scheduling are improved.
Smart Images

Figure CN119166310A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software task scheduling, and in particular, to a task scheduling method, a task scheduling device, a computer-readable storage medium, and an electronic device. Background Art
[0002] With the growth of users and data volume, a single server is far from meeting the requirements of Internet applications for hardware performance, response speed, etc. Therefore, multiple servers deploying the same service are often used to form a cluster, providing an access portal to the outside world to form a whole service. In cluster applications, one of the core technologies is task scheduling, which achieves the highest overall execution efficiency of tasks by reasonably sorting and grouping the tasks to be executed.
[0003] Since the execution time of each task is different, assuming that the performance of all executors is the same, the best scheduling strategy can be calculated based on the execution time of the task and the number of executors through the backtracking algorithm. When allocating tasks through the backtracking algorithm, that is, the current common backtracking algorithm can only judge the overall execution efficiency. If the execution time of some tasks is significantly different from that of other tasks, multiple sets of optimal solutions will appear. At this time, the existing technology cannot judge the execution efficiency differences within the optimal solution set, and the problem of unreasonable local resource allocation will occur. Summary of the invention
[0004] The main purpose of the present application is to provide a task scheduling method, a task scheduling device, a computer-readable storage medium and an electronic device, so as to at least solve the problems in the prior art of resource waste and unreasonable local resource allocation when the execution time difference within a task group is large.
[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a task scheduling method is provided, including: obtaining multiple tasks to be scheduled; obtaining multiple execution machines for executing the tasks to be scheduled, the number of the tasks to be scheduled is greater than the number of the execution machines; scheduling all the tasks to be scheduled according to the execution time of each of the tasks to be scheduled on the execution machines, and determining a target scheduling scheme so that the total execution time of all the tasks to be scheduled is the shortest and the variance of the execution time of all the execution machines is the smallest, the target scheduling scheme includes an execution task queue of each of the execution machines, and the execution task queue includes at least one of the tasks to be scheduled.
[0006] Optionally, all the tasks to be scheduled are scheduled according to the execution time of each of the tasks to be scheduled on the execution machine, and a target scheduling scheme is determined, including: constructing a task space tree based on the tasks to be scheduled and the execution machines; using a backtracking algorithm to solve the task space tree to obtain multiple solutions, each solution representing an initial scheduling scheme; executing multiple initial scheduling schemes in sequence to obtain the total execution time of each initial scheduling scheme and the execution time of each of the execution machines in the initial scheduling scheme; determining the target scheduling scheme according to the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme.
[0007] Optionally, a task space tree is constructed based on the tasks to be scheduled and the execution machines, including: determining the nodes of the task space tree according to the tasks to be scheduled; and determining the edges connecting the nodes of the task space tree according to the execution machines; wherein each branch of the task space tree represents a scheduling scheme, the nodes on the branches represent the tasks to be scheduled, and the edges connecting the current node and the next node on the branches represent the execution machines to which the tasks to be scheduled corresponding to the current node are assigned for execution.
[0008] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the currently executed initial scheduling scheme is equal to the cache execution time, comparing the current execution variance with the cache execution variance, the cache execution time being the total execution time of the last stored initial scheduling scheme executed, the current execution variance being the variance of the execution time of all the execution machines in the currently executed initial scheduling scheme executing the assigned tasks to be scheduled, and the cache execution variance being the variance of the execution time of all the execution machines in the last stored initial scheduling scheme executing the assigned tasks to be scheduled; when the current execution variance is less than the cache execution variance, determining the currently executed initial scheduling scheme as the preliminary scheduling scheme; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0009] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the currently executed initial scheduling scheme is less than the cache execution time, the currently executed initial scheduling scheme is determined as the preliminary scheduling scheme, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored; determine whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determine the preliminary scheduling scheme as the target scheduling scheme.
[0010] Optionally, the method further includes: when the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, continuing to execute the next initial scheduling scheme, the cache execution time being the total execution time of the last executed initial scheduling scheme stored.
[0011] Optionally, after all the tasks to be scheduled are scheduled according to the execution time of each task to be scheduled on the execution machine and the target scheduling scheme is determined, the method further includes: when the target execution machine has not yet completed the tasks to be scheduled and the non-target execution machines have completed the corresponding tasks to be scheduled, determining the remaining execution time of the target execution machine; when the remaining execution time of the target execution machine is greater than the execution time threshold, retaining the remaining execution time of the target execution machine until the next task scheduling process for scheduling.
[0012] According to another aspect of the present application, a task scheduling device is provided, including: a first acquisition unit, used to acquire multiple tasks to be scheduled; a second acquisition unit, used to acquire multiple execution machines for executing the tasks to be scheduled, the number of the tasks to be scheduled is greater than the number of the execution machines; a determination unit, used to schedule all the tasks to be scheduled according to the execution time of each of the tasks to be scheduled on the execution machines, and determine a target scheduling scheme so that the total execution time of all the tasks to be scheduled is the shortest and the variance of the execution time of all the execution machines is the smallest, the target scheduling scheme includes an execution task queue of each of the execution machines, and the execution task queue includes at least one of the tasks to be scheduled.
[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the task scheduling methods.
[0014] According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a method for executing any one of the task scheduling methods.
[0015] Applying the technical solution of the present application, the above-mentioned task scheduling method first obtains a plurality of tasks to be scheduled; then obtains a plurality of execution machines for executing the tasks to be scheduled, the number of tasks to be scheduled is greater than the number of execution machines; finally, according to the execution time of each task to be scheduled on the execution machine, all the tasks to be scheduled are scheduled, and the target scheduling scheme is determined so that the total execution time of all tasks to be scheduled is the shortest and the variance of the execution time of all execution machines is the smallest. The target scheduling scheme includes the execution task queue of each execution machine, and the execution task queue includes at least one task to be scheduled. This method aims at the problem of resource waste in the scheduling of task continuity, by optimizing the task scheduling algorithm, increasing the optimal solution set, screening the result with the smallest variance of the total execution time of the execution machine from the optimal result set, and synchronously completing the screening of the results during the scheduling process. Under the premise of ensuring the original minimum total execution time, the problem of resource waste and unreasonable local resource allocation when the execution time difference within the task group is large in the prior art is solved, and at the same time, the scheduling result of the normal task queue is not affected. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 A hardware structure block diagram of a mobile terminal for executing a task scheduling method provided in an embodiment of the present application is shown;
[0018] Figure 2 A schematic diagram of a task scheduling method provided according to an embodiment of the present application is shown;
[0019] Figure 3 A schematic diagram of the structure of a task space tree provided according to an embodiment of the present application is shown;
[0020] Figure 4 A schematic diagram of the structure of a task scheduling system provided according to an embodiment of the present application is shown;
[0021] Figure 5 A schematic diagram of a process flow of another task scheduling method provided according to an embodiment of the present application is shown;
[0022] Figure 6A structural block diagram of a task scheduling device provided according to an embodiment of the present application is shown.
[0023] The above drawings include the following reference numerals:
[0024] 01. Scheduler; 02. Executor; 03. Monitor; 04. Analyzer; 102. Processor; 104. Memory; 106. Transmission device; 108. Input and output devices. DETAILED DESCRIPTION
[0025] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0029] Task scheduling: Use a reasonable method to set the order and allocate resources for multiple tasks to be executed.
[0030] Executor: It is the executor of the task and has the hardware and software resources required to execute a certain task. In the present invention, the executor represents a server in a distributed service scenario and a thread in a single-machine multi-threaded scenario.
[0031] As introduced in the background technology, when the existing backtracking algorithm is used to complete task scheduling, only the overall optimal solution can be guaranteed. However, if there is a "large task" (referring to a task whose execution time is significantly longer than other tasks), it may lead to the existence of multiple groups of optimal solutions. An example is as follows: Assume that there are 3 execution machines, and there are 5 tasks to be scheduled, with execution times of 100, 18, 20, 12, and 10 respectively. The grouping is calculated by the backtracking algorithm, and the results are as follows: the task with an execution time of 100 is on the first execution machine, and the execution time is 100; the tasks with execution times of 18, 20, 12, and 10 are on the second execution machine, and the execution time is 60; the third execution machine has no assigned tasks, and the execution time is 0. In summary, the shortest execution time is 100.
[0032] From the above example, it can be seen that since the execution time of the "big task" exceeds the sum of all remaining tasks, the execution time of the "big task" is the minimum execution time of this group. The overall allocation result is in line with the optimal scheduling. However, from the local results of the second and third execution machines, the third execution machine is idle, resulting in uneven resource allocation, which is not conducive to the long-term development of task scheduling. Combined with the subsequent task allocation, it is not the optimal solution.
[0033] In order to solve the problems in the prior art of resource waste and unreasonable local resource allocation when there is a large difference in execution time within a task group, the embodiments of the present application provide a task scheduling method, a task scheduling device, a computer-readable storage medium and an electronic device.
[0034] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0035] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a task scheduling method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0036] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the task scheduling method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The transmission device 106 is used to receive or send data via a network. The above-mentioned specific example of the network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0037] In this embodiment, a task scheduling method running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0038] Figure 2 is a flowchart of a task scheduling method according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0039] Step S201, obtaining multiple tasks to be scheduled;
[0040] Specifically, the execution time of each task to be scheduled is different. When the execution time of each task to be scheduled is slightly different, the resource allocation of the execution machine is relatively uniform. However, when the execution time of one task to be scheduled is significantly different from the execution time of other tasks to be scheduled, the execution machine will have the problem of uneven resource allocation.
[0041] Step S202, obtaining a plurality of execution machines for executing the tasks to be scheduled, wherein the number of the tasks to be scheduled is greater than the number of the execution machines;
[0042] Specifically, the execution machine is the executor of the task, and has the hardware and software resources required to execute a certain task. In the present invention, the above-mentioned execution machine, if it is a distributed service scenario, represents a server; if it is a single-machine multi-threaded scenario, it represents a thread. In addition, the performance of all execution machines is the same.
[0043] Step S203, schedule all the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines, and determine the target scheduling plan so that the total execution time of all the above-mentioned tasks to be scheduled is the shortest and the variance of the execution time of all the above-mentioned execution machines is the smallest, the above-mentioned target scheduling plan includes the execution task queue of each of the above-mentioned execution machines, and the above-mentioned execution task queue includes at least one of the above-mentioned tasks to be scheduled.
[0044] Specifically, in the case where the execution time difference in the above task list is large, the allocation result may even result in a "big task" monopolizing the execution machine, and the execution time of this task exceeds the total execution time of the remaining tasks. In this case, the allocation of the remaining tasks in the allocation result will be random, and may be scattered among the remaining execution machines, or may be concentrated on a certain execution machine, resulting in a waste of resources.
[0045] In view of the above problems, it is also possible to perform a preliminary analysis and assign the "big tasks" to the execution machine first, and then assign the remaining task queues and execution machine queues according to the scheduling algorithm. However, the identification criteria and allocation strategy of "big tasks" are relatively complex, which reduces the execution efficiency of the scheduling itself and may affect the premise of minimizing the total execution time. Therefore, the task scheduling method provided in this embodiment is used to solve the problem of resource waste and unreasonable local resource allocation when the execution time difference within the task group is large in the prior art.
[0046] Among them, scheduling all the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machine, and determining the target scheduling plan, includes the following steps:
[0047] Step S301, constructing a task space tree based on the tasks to be scheduled and the execution machines;
[0048] Among them, based on the above-mentioned tasks to be scheduled and the above-mentioned execution machines, constructing a task space tree includes the following steps:
[0049] Step S3011, determining the nodes of the task space tree according to the tasks to be scheduled;
[0050] Step S3012, based on the above-mentioned execution machine, determine the edges connecting the above-mentioned nodes of the above-mentioned task space tree; wherein each branch of the above-mentioned task space tree represents a scheduling scheme, the nodes on the above-mentioned branches represent the above-mentioned tasks to be scheduled, and the edges connecting the current node and the next node on the above-mentioned branches represent the execution machine to which the above-mentioned tasks to be scheduled corresponding to the above-mentioned current node are assigned for execution.
[0051] Specifically, this can traverse all scheduling schemes and finally select the optimal scheduling scheme.
[0052] Among them, Figure 3 As shown in the figure, for the existing N tasks to be executed and the number of executors K, the solution space tree is a full K-fork tree with a depth of N. Assuming that the number of tasks N = 3 and the number of executors K = 2, the solution space tree is as follows: Figure 3 As shown in the figure. Using the depth-first traversal algorithm, the leaf node is traversed for the first time, and the maximum cumulative execution time of all current executors is recorded as the temporary optimal solution. When traversing again, if the cumulative execution time of the executor exceeds the execution time of the current temporary optimal solution when arranging an executor for a task, the next branch is traversed back to the next branch, i.e., the pruning operation. When all branches are traversed, the optimal solution for task scheduling is obtained.
[0053] Step S302, using a backtracking algorithm to solve the task space tree to obtain multiple solutions, each of which represents an initial scheduling solution;
[0054] Step S303, executing a plurality of the above initial scheduling schemes in sequence, and obtaining the total execution time of each of the above initial scheduling schemes and the execution time of each of the above execution machines in the above initial scheduling schemes;
[0055] Step S304: determining the target scheduling scheme according to the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme.
[0056] Specifically, since the best scheduling solution (with the shortest total execution time) obtained by the current backtracking algorithm is a result set, there must be a result in the result set where all execution machines are occupied and the execution time distribution of the remaining execution machines is relatively uniform when the execution machine where the "big task" is located is not considered. Therefore, the variance of the execution time of the task queue assigned to the execution machine is used to evaluate the uniformity of the task distribution. It can be concluded that the optimization solution of the scheduling algorithm is to select the result with the smallest variance in the total execution time of the execution machine queue in the minimum execution time result set.
[0057] According to the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, determining the target scheduling scheme includes the following steps:
[0058] Step S401, when the total execution time of the initial scheduling scheme currently being executed is equal to the cache execution time, compare the current execution variance with the cache execution variance, the cache execution time being the total execution time of the last stored initial scheduling scheme executed, the current execution variance being the variance of the execution time of the tasks to be scheduled that are assigned to all the execution machines in the current initial scheduling scheme executed, and the cache execution variance being the variance of the execution time of the tasks to be scheduled that are assigned to all the execution machines in the last stored initial scheduling scheme executed;
[0059] Step S402, when the current execution variance is smaller than the cache execution variance, determining the currently executed initial scheduling scheme as a preliminary scheduling scheme;
[0060] Step S403, determining whether all the above initial scheduling schemes have been executed. If all the above initial scheduling schemes have been executed, determining the above preliminary scheduling scheme as the above target scheduling scheme.
[0061] Specifically, in the task scheduling algorithm, the result with the smallest variance of the total execution time of the executor is selected from the optimal result set, and the result selection is completed synchronously during the scheduling process. Under the premise of ensuring the original minimum total execution time, the problem of resource waste caused by the large distribution gap of the task queue execution time is solved.
[0062] The cached execution time is the minimum total execution time of the current record. That is, when the total execution time of the currently executed scheduling scheme is equal to the minimum total execution time of the current record, the variance of the two execution times is compared. If the variance of the execution time of the currently executed scheduling scheme is smaller, the minimum total execution time and variance of the current record are updated. At the same time, when the original branch updates the minimum total execution time, the variance value is recorded synchronously to facilitate comparison with the next result.
[0063] According to the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, determining the target scheduling scheme includes the following steps:
[0064] Step S501, when the total execution time of the initial scheduling scheme currently being executed is less than the cache execution time, the initial scheduling scheme currently being executed is determined as a preliminary scheduling scheme, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored;
[0065] Step S502, determining whether all the above-mentioned initial scheduling schemes have been executed. In the case that all the above-mentioned initial scheduling schemes have been executed, determining the above-mentioned preliminary scheduling scheme as the above-mentioned target scheduling scheme.
[0066] Specifically, the resource waste problem caused by the large distribution of task queue execution time in the existing task scheduling algorithm is improved by adding optimal solution set screening.
[0067] Among them, the cached execution time is the minimum total execution time of the current record, that is, when the total execution time of the currently executed scheduling scheme is less than the cached execution time, it is proved that the currently executed scheduling scheme is a better scheduling scheme. Therefore, there is no need to compare the variance at this time, and the currently executed scheduling scheme is directly determined as the target scheduling scheme.
[0068] The method further includes: when the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, continuing to execute the next initial scheduling scheme, the cache execution time being the total execution time of the last executed initial scheduling scheme stored.
[0069] Specifically, in the task scheduling algorithm, the result with the smallest variance of the total execution time of the executor is selected from the optimal result set, and the result selection is completed synchronously during the scheduling process. Under the premise of ensuring the original minimum total execution time, the problem of resource waste caused by the large distribution gap of the task queue execution time is solved.
[0070] Among them, the cached execution time is the minimum total execution time of the current record, that is, when the total execution time of the currently executed scheduling scheme is greater than the cached execution time, it is proved that the currently executed scheduling scheme is a better scheduling scheme. Therefore, there is no need to compare the variance at this time, and the currently executed scheduling scheme is directly determined as the target scheduling scheme.
[0071] Wherein, after all the tasks to be scheduled are scheduled according to the execution time of each of the tasks to be scheduled on the execution machine and the target scheduling scheme is determined, the method further comprises the following steps:
[0072] Step S601, when the target execution machine has not yet completed the above-mentioned task to be scheduled and the non-target execution machines have completed the corresponding above-mentioned task to be scheduled, determining the remaining execution time of the above-mentioned target execution machine;
[0073] Step S602: When the remaining execution time of the target execution machine is greater than the execution time threshold, the remaining execution time of the target execution machine is reserved for scheduling in the next task scheduling process.
[0074] Specifically, except for the execution machine where the "big task" is located, the other execution machines have completed the execution. If we wait for the "big task" to finish execution or the remaining execution machines to participate in the scheduling of the next round of tasks alone, there will also be a waste of resources. Therefore, when the remaining execution machines have completed execution, the remaining execution time of the big task can be included in the next round of task set as a separate task, and all execution machines participate in task allocation together. This ensures the rationality of scheduling in the process of continuous task scheduling.
[0075] The above-mentioned task scheduling method of the present application first obtains a plurality of tasks to be scheduled; then obtains a plurality of execution machines for executing the tasks to be scheduled, the number of tasks to be scheduled is greater than the number of execution machines; finally, according to the execution time of each task to be scheduled on the execution machine, all the tasks to be scheduled are scheduled, and the target scheduling scheme is determined so that the total execution time of all tasks to be scheduled is the shortest and the variance of the execution time of all execution machines is the smallest. The target scheduling scheme includes the execution task queue of each execution machine, and the execution task queue includes at least one task to be scheduled. This method aims at the problem of resource waste in the scheduling of task continuity, by optimizing the task scheduling algorithm, increasing the optimal solution set, screening the result with the smallest variance of the total execution time of the execution machine from the optimal result set, and synchronously completing the screening of the results during the scheduling process. Under the premise of ensuring the original minimum total execution time, the problem of resource waste and unreasonable local resource allocation when the execution time difference within the task group is large in the prior art is solved, and at the same time, the scheduling result of the normal task queue is not affected.
[0076] After all tasks are assigned, the original scheduling algorithm calculates the maximum value of the total execution time of all execution machines in the current execution machine queue as the total execution time of the current assignment result. If it is less than the minimum total execution time of the current record, the record is updated. The optimized scheduling algorithm adds a branch judgment, as shown in Table 1, and uses Java language to implement the algorithms before and after optimization respectively, and uses multiple groups of data for verification: Assuming that there are 3 execution machines with the same performance, multiple groups of normal task queues and multiple groups of task queues with the above characteristics of the present invention are set, and the algorithms before and after optimization are used for scheduling respectively. Comparing the scheduling results before and after the algorithm is optimized, some test data are shown in Table 1. When there are five tasks to be scheduled and the execution time of the five tasks to be scheduled is not much different, the scheduling scheme before optimization and the scheduling scheme after optimization are not much different. However, when the execution time of one of the five tasks to be scheduled is much longer than that of the other tasks to be scheduled, it can be seen that one execution machine in the scheduling scheme before optimization is not assigned to a task, while each execution machine in the optimized scheme is assigned to a corresponding task, which is more conducive to the rationality of scheduling in the process of continuous scheduling of tasks.
[0077] Table 1. Schematic diagram of the effect of task scheduling method
[0078]
[0079] Taking Table 1 as an example, there are three execution machines, M1, M2 and M3. The execution time variance of the allocation results in the first task queue before optimization is 105, 84, 0 and 41, and the execution time variance of the allocation results after optimization is 105, 43 and 41. It is obvious that the execution time variance of the allocation results after optimization is smaller than the execution time variance of the allocation results before optimization.
[0080] That is, it can be seen from Table 1 that when there is a task in the task queue whose execution time is significantly longer than other tasks, the minimum execution time of the optimized scheduling result is the same as before optimization, but the allocation of M2 and M3 execution machines is more reasonable, and there is no waste of resources. When the execution time distribution in the task queue is relatively uniform, the scheduling result is the same and does not affect the original scheduling. The test results are in line with expectations.
[0081] Figure 4 This is a structural diagram of a task scheduling system, such as Figure 4 As shown, the task scheduling system includes a scheduler 01, an executor 02, a monitor 03 and an analyzer 04. The scheduler is used to execute the above-mentioned task scheduling method, receive a task set, group the task set according to the number of executors, obtain the optimal solution set for the overall execution time of the task set, and select the one with the most balanced task distribution from the optimal solution set, that is, the one with the highest utilization rate of the executor. The executor is used to set a queue for the task set and assign the executor to execute according to the calculation results in the scheduler. The monitor is used to monitor the execution of the task queues of all executors in the executor and determine the timing of triggering the next scheduling algorithm. The trigger conditions can be configured in the monitor according to the actual system conditions, for example: there are more than 50% idle machines, the number of tasks to be grouped, etc. The analyzer is used to analyze the task set to be scheduled and the tasks in execution and to be executed in the existing queue after the monitor issues a rescheduling instruction, and reorganize the task set. Reorganization includes merging the tasks to be executed with the task set to be scheduled, and the tasks in execution determine whether to participate in the next task scheduling according to the remaining execution time of the tasks. The threshold can be set for flexible adjustment. For example, if the threshold of the remaining execution time is set to 30s, then if the remaining execution time of the task in execution is greater than 30s, the remaining execution time of the task will be treated as an independent virtual task to participate in the next task scheduling. The reorganization operation of the task set ensures the continuity of task scheduling.
[0082] Through the scheduler, executor, analyzer, and monitor architecture, the scheduling trigger strategy can be flexibly controlled, and the remaining time of tasks that take too long to execute can be used together with new tasks in task scheduling. This supplements the resource waste caused by task continuity scheduling that cannot be solved by algorithm optimization, and provides an implementation plan for the optimization algorithm.
[0083] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the task scheduling method of the present application will be described in detail below in conjunction with specific embodiments.
[0084] This embodiment relates to a specific task scheduling method, such as Figure 5 As shown, the following steps are included:
[0085] Step S1: traverse the task queue to allocate execution machines, determine whether all tasks have been allocated, and if all tasks have been allocated, determine whether the total execution time of the current task is greater than the minimum total execution time of the cache. If the total execution time of the current task is greater than the minimum total execution time of the cache, execute step S2;
[0086] Step S2: Determine whether the result tree is traversed completely. If the result tree is traversed completely, determine the scheduling scheme corresponding to the cached minimum total execution time as the optimal scheduling result. If the result tree is not traversed completely, continue to traverse other branches of the result tree.
[0087] Step S3: if the total execution time of the current task is not greater than the minimum total execution time of the cache, determine whether the total execution time of the current task is equal to the minimum total execution time of the cache; if the total execution time of the current task is not equal to the minimum total execution time of the cache, update the cache using the currently executed scheduling scheme and the execution time variance as the temporary optimal scheduling scheme and the minimum variance, and then execute step S2;
[0088] Step S4: When the total execution time of the current task is equal to the minimum total execution time of the cache, calculate the variance of the execution time of the current task and compare it with the execution time variance of the minimum total execution time of the cache.
[0089] Step S5: When the calculated variance is smaller than the cached variance, the currently executed scheduling scheme and the execution time variance are used as the temporary optimal scheduling scheme and the minimum variance to update the cache, and then execute step S2; when the calculated variance is greater than or equal to the cached variance, directly execute step S2.
[0090] The present application embodiment also provides a kind of task scheduling device, it should be noted that the task scheduling device of the present application embodiment can be used to execute the task scheduling method provided by the present application embodiment. The device is used to implement the above-mentioned embodiment and preferred implementation mode, and the description has been made no more. As used below, the term "module" can implement the combination of software and / or hardware of the predetermined function. Although the device described in the following embodiments is preferably implemented with software, the implementation of hardware, or the combination of software and hardware is also possible and conceived.
[0091] The following is an introduction to the task scheduling device provided in the embodiment of the present application.
[0092] Figure 6 Schematic diagram of a task scheduling device according to an embodiment of the present application. Figure 6 As shown, the device includes a first acquisition unit 10, a second acquisition unit 20 and a determination unit 30, the first acquisition unit 10 is used to acquire multiple tasks to be scheduled; the second acquisition unit 20 is used to acquire multiple execution machines for executing the above-mentioned tasks to be scheduled, and the number of the above-mentioned tasks to be scheduled is greater than the number of the above-mentioned execution machines; the determination unit 30 is used to schedule all of the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines, and determine the target scheduling scheme so that the total execution time of all of the above-mentioned tasks to be scheduled is the shortest and the variance of the execution time of all of the above-mentioned execution machines is the smallest, and the above-mentioned target scheduling scheme includes an execution task queue of each of the above-mentioned execution machines, and the above-mentioned execution task queue includes at least one of the above-mentioned tasks to be scheduled.
[0093] The above-mentioned task scheduling device of the present application includes a first acquisition unit, a second acquisition unit and a determination unit. The first acquisition unit is used to acquire multiple tasks to be scheduled; the second acquisition unit is used to acquire multiple execution machines for executing the tasks to be scheduled, and the number of tasks to be scheduled is greater than the number of execution machines; the determination unit is used to schedule all the tasks to be scheduled according to the execution time of each task to be scheduled on the execution machine, and determine the target scheduling scheme so that the total execution time of all the tasks to be scheduled is the shortest and the variance of the execution time of all the execution machines is the smallest. The target scheduling scheme includes the execution task queue of each execution machine, and the execution task queue includes at least one task to be scheduled. The device aims at the problem of resource waste in the continuous scheduling of tasks, optimizes the task scheduling algorithm, increases the optimal solution set, and selects the result with the smallest variance of the total execution time of the execution machine from the optimal result set, and completes the result screening synchronously during the scheduling process. Under the premise of ensuring the original minimum total execution time, the problem of resource waste and unreasonable local resource allocation when the execution time difference within the task group is large in the prior art is solved, and at the same time, the scheduling result of the normal task queue is not affected.
[0094] In some instances, the determination unit includes a construction module, a solution module, a first execution module and a first determination module. The construction module is used to construct a task space tree based on the above-mentioned tasks to be scheduled and the above-mentioned execution machines; the solution module is used to solve the above-mentioned task space tree using a backtracking algorithm to obtain multiple solutions, each of which represents an initial scheduling scheme; the first execution module is used to execute multiple of the above-mentioned initial scheduling schemes in sequence to obtain the total execution time of each of the above-mentioned initial scheduling schemes and the execution time of each of the above-mentioned execution machines in the above-mentioned initial scheduling schemes; the first determination module is used to determine the above-mentioned target scheduling scheme based on the total execution time of the above-mentioned initial scheduling scheme and the variance of the execution time of all the above-mentioned execution machines in the above-mentioned initial scheduling scheme. It can be concluded that the optimization scheme of the scheduling algorithm is to select the result with the smallest variance of the total execution time of the execution machine queue in the minimum execution time result set.
[0095] In some examples, the construction module includes a second determination module and a third determination module, wherein the first determination module is used to determine the nodes of the task space tree according to the tasks to be scheduled; the second determination module is used to determine the edges connecting the nodes of the task space tree according to the execution machines; wherein each branch of the task space tree represents a scheduling scheme, the nodes on the branches represent the tasks to be scheduled, and the edges connecting the current node and the next node on the branches represent the execution machines to which the tasks to be scheduled corresponding to the current node are assigned for execution. In this way, all scheduling schemes can be traversed, and finally the optimal scheduling scheme can be selected.
[0096] In some examples, the first determination module includes a first comparison module, a first determination submodule, and a second determination submodule. The first comparison module is used to compare the current execution variance with the cache execution variance when the total execution time of the initial scheduling scheme currently being executed is equal to the cache execution time. The cache execution time is the total execution time of the last stored initial scheduling scheme executed. The current execution variance is the variance of the execution time of the above-mentioned tasks to be scheduled that are assigned to all the above-mentioned execution machines in the current initial scheduling scheme. The cache execution variance is the variance of the execution time of the above-mentioned tasks to be scheduled that are assigned to all the above-mentioned execution machines in the last stored initial scheduling scheme executed. The first determination submodule is used to determine the current initial scheduling scheme as a preliminary scheduling scheme when the current execution variance is less than the cache execution variance. The second determination submodule is used to determine whether all the above-mentioned initial scheduling schemes have been executed. When all the above-mentioned initial scheduling schemes have been executed, the preliminary scheduling scheme is determined as the target scheduling scheme. Under the premise of ensuring the original minimum total execution time, the problem of resource waste caused by the large gap in the distribution of the execution time of the task queue is solved.
[0097] In this embodiment, the first determination module includes a third determination submodule and a fourth determination submodule. The third determination submodule is used to determine the currently executed initial scheduling scheme as a preliminary scheduling scheme when the total execution time of the currently executed initial scheduling scheme is less than the cache execution time. The cache execution time is the total execution time of the last executed initial scheduling scheme stored. The fourth determination submodule is used to determine whether all the above initial scheduling schemes have been executed. When all the above initial scheduling schemes have been executed, the preliminary scheduling scheme is determined as the target scheduling scheme. By adding optimal solution set screening, the problem of resource waste caused by large distribution gaps in task queue execution time in the existing task scheduling algorithm is improved.
[0098] In an optional solution, the device further includes a second execution module, which is used to continue executing the next initial scheduling scheme when the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored. Under the premise of ensuring the original minimum total execution time, the problem of resource waste caused by the large gap in the distribution of task queue execution time is solved.
[0099] As an optional solution, the device further includes a fourth determination module and a processing module. The fourth determination module is used to schedule all the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machine. After determining the target scheduling scheme, if the target execution machine has not yet completed the above-mentioned tasks to be scheduled and the non-target execution machines have completed the corresponding tasks to be scheduled, determine the remaining execution time of the above-mentioned target execution machine; the processing module is used to reserve the remaining execution time of the above-mentioned target execution machine until the next task scheduling process when the remaining execution time of the above-mentioned target execution machine is greater than the execution time threshold. The scheduling rationality in the continuous scheduling process of tasks is ensured.
[0100] The task scheduling device includes a processor and a memory, and the first acquisition unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions. The modules are all located in the same processor; or, the modules are located in different processors in any combination.
[0101] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the kernel parameters can be adjusted to solve the problem of resource waste and unreasonable local resource allocation when the execution time difference within the task group is large in the prior art.
[0102] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0103] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the task scheduling method.
[0104] Specifically, the task scheduling method includes:
[0105] Step S201, obtaining multiple tasks to be scheduled;
[0106] Specifically, the execution time of each task to be scheduled is different. When the execution time of each task to be scheduled is slightly different, the resource allocation of the execution machine is relatively uniform. However, when the execution time of one task to be scheduled is significantly different from the execution time of other tasks to be scheduled, the execution machine will have the problem of uneven resource allocation.
[0107] Step S202, obtaining a plurality of execution machines for executing the tasks to be scheduled, wherein the number of the tasks to be scheduled is greater than the number of the execution machines;
[0108] Specifically, the execution machine is the executor of the task, and has the hardware and software resources required to execute a certain task. In the present invention, the above-mentioned execution machine, if it is a distributed service scenario, represents a server; if it is a single-machine multi-threaded scenario, it represents a thread. In addition, the performance of all execution machines is the same.
[0109] Step S203, schedule all the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines, and determine the target scheduling plan so that the total execution time of all the above-mentioned tasks to be scheduled is the shortest and the variance of the execution time of all the above-mentioned execution machines is the smallest, the above-mentioned target scheduling plan includes the execution task queue of each of the above-mentioned execution machines, and the above-mentioned execution task queue includes at least one of the above-mentioned tasks to be scheduled.
[0110] Specifically, in the case where the execution time difference in the above task list is large, the allocation result may even result in a "big task" monopolizing the execution machine, and the execution time of this task exceeds the total execution time of the remaining tasks. In this case, the allocation of the remaining tasks in the allocation result will be random, and may be scattered among the remaining execution machines, or may be concentrated on a certain execution machine, resulting in a waste of resources.
[0111] Optionally, all the tasks to be scheduled are scheduled according to the execution time of each of the tasks to be scheduled on the execution machines, and a target scheduling scheme is determined, including: constructing a task space tree based on the tasks to be scheduled and the execution machines; solving the task space tree using a backtracking algorithm to obtain multiple solutions, each of the solutions representing an initial scheduling scheme; executing multiple initial scheduling schemes in sequence to obtain the total execution time of each of the initial scheduling schemes and the execution time of each of the execution machines in the initial scheduling schemes; determining the target scheduling scheme based on the total execution time of the initial scheduling scheme and the variance of the execution time of all of the execution machines in the initial scheduling schemes.
[0112] Optionally, based on the above-mentioned tasks to be scheduled and the above-mentioned execution machines, a task space tree is constructed, including: determining the nodes of the above-mentioned task space tree according to the above-mentioned tasks to be scheduled; determining the edges connecting the above-mentioned nodes of the above-mentioned task space tree according to the above-mentioned execution machines; wherein each branch of the above-mentioned task space tree represents a scheduling scheme, the nodes on the above-mentioned branches represent the above-mentioned tasks to be scheduled, and the edges connecting the current node and the next node on the above-mentioned branches represent the execution machines to which the above-mentioned tasks to be scheduled corresponding to the above-mentioned current nodes are assigned for execution.
[0113] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the initial scheduling scheme currently being executed is equal to the cache execution time, comparing the current execution variance with the cache execution variance, the cache execution time being the total execution time of the last stored initial scheduling scheme executed, the current execution variance being the variance of the execution time of all the execution machines in the current initial scheduling scheme executing the assigned tasks to be scheduled, and the cache execution variance being the variance of the execution time of all the execution machines in the last stored initial scheduling scheme executing the assigned tasks to be scheduled; when the current execution variance is less than the cache execution variance, determining the initial scheduling scheme currently being executed as the preliminary scheduling scheme; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0114] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the currently executed initial scheduling scheme is less than the cache execution time, the currently executed initial scheduling scheme is determined as the preliminary scheduling scheme, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0115] Optionally, the method further includes: when the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, continuing to execute the next initial scheduling scheme, the cache execution time being the total execution time of the last executed initial scheduling scheme stored.
[0116] Optionally, after all the above-mentioned tasks to be scheduled are scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines and the target scheduling scheme is determined, the above-mentioned method also includes: when the target execution machine has not yet completed the execution of the above-mentioned tasks to be scheduled and the non-target execution machines have completed the execution of the corresponding tasks to be scheduled, determining the remaining execution time of the above-mentioned target execution machine; when the remaining execution time of the above-mentioned target execution machine is greater than the execution time threshold, retaining the remaining execution time of the above-mentioned target execution machine until the next task scheduling process for scheduling.
[0117] An embodiment of the present invention provides a processor, and the processor is used to run a program, wherein the task scheduling method is executed when the program is running.
[0118] Specifically, the task scheduling method includes:
[0119] Step S201, obtaining multiple tasks to be scheduled;
[0120] Specifically, the execution time of each task to be scheduled is different. When the execution time of each task to be scheduled is slightly different, the resource allocation of the execution machine is relatively uniform. However, when the execution time of one task to be scheduled is significantly different from the execution time of other tasks to be scheduled, the execution machine will have the problem of uneven resource allocation.
[0121] Step S202, obtaining a plurality of execution machines for executing the tasks to be scheduled, wherein the number of the tasks to be scheduled is greater than the number of the execution machines;
[0122] Specifically, the execution machine is the executor of the task, and has the hardware and software resources required to execute a certain task. In the present invention, the above-mentioned execution machine, if it is a distributed service scenario, represents a server; if it is a single-machine multi-threaded scenario, it represents a thread. In addition, the performance of all execution machines is the same.
[0123] Step S203, schedule all the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines, and determine the target scheduling plan so that the total execution time of all the above-mentioned tasks to be scheduled is the shortest and the variance of the execution time of all the above-mentioned execution machines is the smallest, the above-mentioned target scheduling plan includes the execution task queue of each of the above-mentioned execution machines, and the above-mentioned execution task queue includes at least one of the above-mentioned tasks to be scheduled.
[0124] Specifically, in the case where the execution time difference in the above task list is large, the allocation result may even result in a "big task" monopolizing the execution machine, and the execution time of this task exceeds the total execution time of the remaining tasks. In this case, the allocation of the remaining tasks in the allocation result will be random, and may be scattered among the remaining execution machines, or may be concentrated on a certain execution machine, resulting in a waste of resources.
[0125] Optionally, all the tasks to be scheduled are scheduled according to the execution time of each of the tasks to be scheduled on the execution machines, and a target scheduling scheme is determined, including: constructing a task space tree based on the tasks to be scheduled and the execution machines; solving the task space tree using a backtracking algorithm to obtain multiple solutions, each of the solutions representing an initial scheduling scheme; executing multiple initial scheduling schemes in sequence to obtain the total execution time of each of the initial scheduling schemes and the execution time of each of the execution machines in the initial scheduling schemes; determining the target scheduling scheme based on the total execution time of the initial scheduling scheme and the variance of the execution time of all of the execution machines in the initial scheduling schemes.
[0126] Optionally, based on the above-mentioned tasks to be scheduled and the above-mentioned execution machines, a task space tree is constructed, including: determining the nodes of the above-mentioned task space tree according to the above-mentioned tasks to be scheduled; determining the edges connecting the above-mentioned nodes of the above-mentioned task space tree according to the above-mentioned execution machines; wherein each branch of the above-mentioned task space tree represents a scheduling scheme, the nodes on the above-mentioned branches represent the above-mentioned tasks to be scheduled, and the edges connecting the current node and the next node on the above-mentioned branches represent the execution machines to which the above-mentioned tasks to be scheduled corresponding to the above-mentioned current nodes are assigned for execution.
[0127] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the initial scheduling scheme currently being executed is equal to the cache execution time, comparing the current execution variance with the cache execution variance, the cache execution time being the total execution time of the last stored initial scheduling scheme executed, the current execution variance being the variance of the execution time of all the execution machines in the current initial scheduling scheme executing the assigned tasks to be scheduled, and the cache execution variance being the variance of the execution time of all the execution machines in the last stored initial scheduling scheme executing the assigned tasks to be scheduled; when the current execution variance is less than the cache execution variance, determining the initial scheduling scheme currently being executed as the preliminary scheduling scheme; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0128] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the currently executed initial scheduling scheme is less than the cache execution time, the currently executed initial scheduling scheme is determined as the preliminary scheduling scheme, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0129] Optionally, the method further includes: when the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, continuing to execute the next initial scheduling scheme, the cache execution time being the total execution time of the last executed initial scheduling scheme stored.
[0130] Optionally, after all the above-mentioned tasks to be scheduled are scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines and the target scheduling scheme is determined, the above-mentioned method also includes: when the target execution machine has not yet completed the execution of the above-mentioned tasks to be scheduled and the non-target execution machines have completed the execution of the corresponding tasks to be scheduled, determining the remaining execution time of the above-mentioned target execution machine; when the remaining execution time of the above-mentioned target execution machine is greater than the execution time threshold, retaining the remaining execution time of the above-mentioned target execution machine until the next task scheduling process for scheduling.
[0131] An embodiment of the present invention provides a device, the device including a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:
[0132] Step S201, obtaining multiple tasks to be scheduled;
[0133] Step S202, obtaining a plurality of execution machines for executing the tasks to be scheduled, wherein the number of the tasks to be scheduled is greater than the number of the execution machines;
[0134] Step S203, schedule all the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines, and determine the target scheduling plan so that the total execution time of all the above-mentioned tasks to be scheduled is the shortest and the variance of the execution time of all the above-mentioned execution machines is the smallest, the above-mentioned target scheduling plan includes the execution task queue of each of the above-mentioned execution machines, and the above-mentioned execution task queue includes at least one of the above-mentioned tasks to be scheduled.
[0135] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0136] Optionally, all the tasks to be scheduled are scheduled according to the execution time of each of the tasks to be scheduled on the execution machines, and a target scheduling scheme is determined, including: constructing a task space tree based on the tasks to be scheduled and the execution machines; solving the task space tree using a backtracking algorithm to obtain multiple solutions, each of the solutions representing an initial scheduling scheme; executing multiple initial scheduling schemes in sequence to obtain the total execution time of each of the initial scheduling schemes and the execution time of each of the execution machines in the initial scheduling schemes; determining the target scheduling scheme based on the total execution time of the initial scheduling scheme and the variance of the execution time of all of the execution machines in the initial scheduling schemes.
[0137] Optionally, based on the above-mentioned tasks to be scheduled and the above-mentioned execution machines, a task space tree is constructed, including: determining the nodes of the above-mentioned task space tree according to the above-mentioned tasks to be scheduled; determining the edges connecting the above-mentioned nodes of the above-mentioned task space tree according to the above-mentioned execution machines; wherein each branch of the above-mentioned task space tree represents a scheduling scheme, the nodes on the above-mentioned branches represent the above-mentioned tasks to be scheduled, and the edges connecting the current node and the next node on the above-mentioned branches represent the execution machines to which the above-mentioned tasks to be scheduled corresponding to the above-mentioned current nodes are assigned for execution.
[0138] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the initial scheduling scheme currently being executed is equal to the cache execution time, comparing the current execution variance with the cache execution variance, the cache execution time being the total execution time of the last stored initial scheduling scheme executed, the current execution variance being the variance of the execution time of all the execution machines in the current initial scheduling scheme executing the assigned tasks to be scheduled, and the cache execution variance being the variance of the execution time of all the execution machines in the last stored initial scheduling scheme executing the assigned tasks to be scheduled; when the current execution variance is less than the cache execution variance, determining the initial scheduling scheme currently being executed as the preliminary scheduling scheme; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0139] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the currently executed initial scheduling scheme is less than the cache execution time, the currently executed initial scheduling scheme is determined as the preliminary scheduling scheme, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0140] Optionally, the method further includes: when the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, continuing to execute the next initial scheduling scheme, the cache execution time being the total execution time of the last executed initial scheduling scheme stored.
[0141] Optionally, after all the above-mentioned tasks to be scheduled are scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines and the target scheduling scheme is determined, the above-mentioned method also includes: when the target execution machine has not yet completed the execution of the above-mentioned tasks to be scheduled and the non-target execution machines have completed the execution of the corresponding tasks to be scheduled, determining the remaining execution time of the above-mentioned target execution machine; when the remaining execution time of the above-mentioned target execution machine is greater than the execution time threshold, retaining the remaining execution time of the above-mentioned target execution machine until the next task scheduling process for scheduling.
[0142] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing at least the following method steps:
[0143] Step S201, obtaining multiple tasks to be scheduled;
[0144] Step S202, obtaining a plurality of execution machines for executing the tasks to be scheduled, wherein the number of the tasks to be scheduled is greater than the number of the execution machines;
[0145] Step S203, schedule all the above-mentioned tasks to be scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines, and determine the target scheduling plan so that the total execution time of all the above-mentioned tasks to be scheduled is the shortest and the variance of the execution time of all the above-mentioned execution machines is the smallest, the above-mentioned target scheduling plan includes the execution task queue of each of the above-mentioned execution machines, and the above-mentioned execution task queue includes at least one of the above-mentioned tasks to be scheduled.
[0146] Optionally, all the tasks to be scheduled are scheduled according to the execution time of each of the tasks to be scheduled on the execution machines, and a target scheduling scheme is determined, including: constructing a task space tree based on the tasks to be scheduled and the execution machines; solving the task space tree using a backtracking algorithm to obtain multiple solutions, each of the solutions representing an initial scheduling scheme; executing multiple initial scheduling schemes in sequence to obtain the total execution time of each of the initial scheduling schemes and the execution time of each of the execution machines in the initial scheduling schemes; determining the target scheduling scheme based on the total execution time of the initial scheduling scheme and the variance of the execution time of all of the execution machines in the initial scheduling schemes.
[0147] Optionally, based on the above-mentioned tasks to be scheduled and the above-mentioned execution machines, a task space tree is constructed, including: determining the nodes of the above-mentioned task space tree according to the above-mentioned tasks to be scheduled; determining the edges connecting the above-mentioned nodes of the above-mentioned task space tree according to the above-mentioned execution machines; wherein each branch of the above-mentioned task space tree represents a scheduling scheme, the nodes on the above-mentioned branches represent the above-mentioned tasks to be scheduled, and the edges connecting the current node and the next node on the above-mentioned branches represent the execution machines to which the above-mentioned tasks to be scheduled corresponding to the above-mentioned current nodes are assigned for execution.
[0148] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the initial scheduling scheme currently being executed is equal to the cache execution time, comparing the current execution variance with the cache execution variance, the cache execution time being the total execution time of the last stored initial scheduling scheme executed, the current execution variance being the variance of the execution time of all the execution machines in the current initial scheduling scheme executing the assigned tasks to be scheduled, and the cache execution variance being the variance of the execution time of all the execution machines in the last stored initial scheduling scheme executing the assigned tasks to be scheduled; when the current execution variance is less than the cache execution variance, determining the initial scheduling scheme currently being executed as the preliminary scheduling scheme; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0149] Optionally, the target scheduling scheme is determined based on the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme, including: when the total execution time of the currently executed initial scheduling scheme is less than the cache execution time, the currently executed initial scheduling scheme is determined as the preliminary scheduling scheme, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored; determining whether all the initial scheduling schemes have been executed, and when all the initial scheduling schemes have been executed, determining the preliminary scheduling scheme as the target scheduling scheme.
[0150] Optionally, the method further includes: when the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, continuing to execute the next initial scheduling scheme, the cache execution time being the total execution time of the last executed initial scheduling scheme stored.
[0151] Optionally, after all the above-mentioned tasks to be scheduled are scheduled according to the execution time of each of the above-mentioned tasks to be scheduled on the above-mentioned execution machines and the target scheduling scheme is determined, the above-mentioned method also includes: when the target execution machine has not yet completed the execution of the above-mentioned tasks to be scheduled and the non-target execution machines have completed the execution of the corresponding tasks to be scheduled, determining the remaining execution time of the above-mentioned target execution machine; when the remaining execution time of the above-mentioned target execution machine is greater than the execution time threshold, retaining the remaining execution time of the above-mentioned target execution machine until the next task scheduling process for scheduling.
[0152] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0153] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0154] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0155] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0156] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0157] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0158] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0159] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0160] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0161] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0162] 1) The above-mentioned task scheduling method of the present application first obtains a plurality of tasks to be scheduled; then obtains a plurality of execution machines for executing the tasks to be scheduled, the number of tasks to be scheduled is greater than the number of execution machines; finally, according to the execution time of each task to be scheduled on the execution machine, all the tasks to be scheduled are scheduled, and the target scheduling scheme is determined so that the total execution time of all tasks to be scheduled is the shortest and the variance of the execution time of all execution machines is the smallest. The target scheduling scheme includes the execution task queue of each execution machine, and the execution task queue includes at least one task to be scheduled. This method aims at the problem of resource waste in the scheduling of continuous tasks, optimizes the task scheduling algorithm, increases the optimal solution set, and selects the result with the smallest variance of the total execution time of the execution machine from the optimal result set, and the screening of the results is completed synchronously during the scheduling process. Under the premise of ensuring the original minimum total execution time, the problem of resource waste and unreasonable local resource allocation when the execution time difference within the task group is large in the prior art is solved, and at the same time, the scheduling result of the normal task queue is not affected.
[0163] 2) The above-mentioned task scheduling device of the present application includes a first acquisition unit, a second acquisition unit and a determination unit. The first acquisition unit is used to acquire multiple tasks to be scheduled; the second acquisition unit is used to acquire multiple execution machines for executing the tasks to be scheduled, and the number of tasks to be scheduled is greater than the number of execution machines; the determination unit is used to schedule all the tasks to be scheduled according to the execution time of each task to be scheduled on the execution machine, and determine the target scheduling scheme so that the total execution time of all the tasks to be scheduled is the shortest and the variance of the execution time of all the execution machines is the smallest. The target scheduling scheme includes the execution task queue of each execution machine, and the execution task queue includes at least one task to be scheduled. The device aims at the problem of resource waste in the continuous scheduling of tasks, optimizes the task scheduling algorithm, increases the optimal solution set, and selects the result with the smallest variance of the total execution time of the execution machine from the optimal result set, and synchronously completes the result screening during the scheduling process. Under the premise of ensuring the original minimum total execution time, the problem of resource waste and unreasonable local resource allocation when the execution time difference within the task group is large in the prior art is solved, and at the same time, the scheduling result of the normal task queue is not affected.
[0164] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A task scheduling method, characterized in that: include: Get multiple tasks to be scheduled; Acquire multiple execution machines for executing the tasks to be scheduled, where the number of the tasks to be scheduled is greater than the number of the execution machines; All the tasks to be scheduled are scheduled according to the execution time of each task to be scheduled on the execution machine, and a target scheduling scheme is determined so that the total execution time of all the tasks to be scheduled is the shortest and the variance of the execution time of all the execution machines is the smallest. The target scheduling scheme includes an execution task queue of each execution machine, and the execution task queue includes at least one task to be scheduled.
2. The method according to claim 1, characterized in that According to the execution time of each of the tasks to be scheduled on the execution machine, all the tasks to be scheduled are scheduled to determine a target scheduling scheme, including: Based on the tasks to be scheduled and the execution machines, construct a task space tree; A backtracking algorithm is used to solve the task space tree to obtain multiple solutions, each of which represents an initial scheduling solution; Execute a plurality of the initial scheduling schemes in sequence to obtain a total execution time of each of the initial scheduling schemes and an execution time of each of the execution machines in the initial scheduling schemes; The target scheduling scheme is determined according to the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme.
3. The method according to claim 2, characterized in that Based on the tasks to be scheduled and the execution machines, a task space tree is constructed, including: Determine the nodes of the task space tree according to the task to be scheduled; Determine, according to the execution machine, the edges connecting the nodes of the task space tree; Among them, each branch of the task space tree represents a scheduling scheme, the nodes on the branch represent the tasks to be scheduled, and the edge connecting the current node and the next node on the branch represents the execution machine to which the tasks to be scheduled corresponding to the current node are assigned to execute.
4. The method according to claim 2, characterized in that: Determining the target scheduling scheme according to the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme includes: In the case where the total execution time of the currently executed initial scheduling scheme is equal to the cache execution time, compare the current execution variance with the cache execution variance, the cache execution time being the total execution time of the last stored initial scheduling scheme executed, the current execution variance being the variance of the execution time of the tasks to be scheduled that are assigned to all the execution machines in the currently executed initial scheduling scheme, and the cache execution variance being the variance of the execution time of the tasks to be scheduled that are assigned to all the execution machines in the last stored initial scheduling scheme executed; In a case where the current execution variance is smaller than the cache execution variance, determining the currently executed initial scheduling scheme as a preliminary scheduling scheme; It is determined whether all the initial scheduling schemes have been executed, and if all the initial scheduling schemes have been executed, the preliminary scheduling scheme is determined as the target scheduling scheme.
5. The method according to claim 2, characterized in that: Determining the target scheduling scheme according to the total execution time of the initial scheduling scheme and the variance of the execution time of all the execution machines in the initial scheduling scheme includes: In the case where the total execution time of the currently executed initial scheduling scheme is less than the cache execution time, the currently executed initial scheduling scheme is determined as the preliminary scheduling scheme, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored; It is determined whether all the initial scheduling schemes have been executed, and if all the initial scheduling schemes have been executed, the preliminary scheduling scheme is determined as the target scheduling scheme.
6. The method according to claim 2, characterized in that The method further comprises: When the total execution time of the currently executed initial scheduling scheme is greater than the cache execution time, the next initial scheduling scheme is continued to be executed, and the cache execution time is the total execution time of the last executed initial scheduling scheme stored.
7. The method according to claim 1, characterized in that After all the tasks to be scheduled are scheduled according to the execution time of each of the tasks to be scheduled on the execution machine and a target scheduling scheme is determined, the method further includes: When the target execution machine has not yet completed the task to be scheduled and the non-target execution machines have completed the corresponding tasks to be scheduled, determining the remaining execution time of the target execution machine; When the remaining execution time of the target execution machine is greater than the execution time threshold, the remaining execution time of the target execution machine is reserved for scheduling in the next task scheduling process.
8. A task scheduling device, characterized in that: include: A first acquisition unit, used to acquire a plurality of tasks to be scheduled; A second acquisition unit, used to acquire a plurality of execution machines for executing the tasks to be scheduled, wherein the number of the tasks to be scheduled is greater than the number of the execution machines; A determination unit is used to schedule all the tasks to be scheduled according to the execution time of each task to be scheduled on the execution machine, and determine a target scheduling plan so that the total execution time of all the tasks to be scheduled is the shortest and the variance of the execution time of all the execution machines is the smallest, the target scheduling plan includes an execution task queue of each execution machine, and the execution task queue includes at least one task to be scheduled.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the task scheduling method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a method for executing the task scheduling method described in any one of claims 1 to 7.
