Task scheduling method and device, computer device and storage medium

CN122963708APending Publication Date: 2026-10-23TENCENT TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510519334.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0004]上述方法中,由于一旦任务满足执行条件便可以启动任务,这样前期需要处理的任务量多,而后期需要处理的任务量越来越少,因此任务分配不均衡,进而导致处理资源的整体利用率偏低

Benefits of technology

[0087]本申请实施例提供的方案,任务集群包括多个任务链路,每个任务链路包括具有依赖关系的多个任务,在对任务集群进行调度时,以任务链路为单位进行处理,每次为一个任务链路中的多个任务分配执行时段,按照分配顺序依次分配多个任务链路。每个任务链路的分配过程考虑已分配任务的执行时段和任务链路中的多个任务之间的依赖关系,以保证能够合理分配。而由于在为任务链路进行分配需要考虑已分配任务的执行时段,那么多个任务链路的分配顺序不同,最终所确定的分配结果也不同。因此,可以按照多种不同的分配顺序,确定出多个不同的分配结果,进而从多个分配结果中,筛选出满足调度条件的目标分配结果,有利于从多个分配结果中筛选出任务集群的执行时段更加均衡的分配结果,从而提高了处理资源的整体利用率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122963708A_ABST
    Figure CN122963708A_ABST
Patent Text Reader

Abstract

The application discloses a task scheduling method and device, computer equipment and a storage medium, and belongs to the technical field of computers. The method comprises the following steps: determining a task cluster, the task cluster comprising a plurality of task links, each task link in the plurality of task links comprising a plurality of tasks having a dependency relationship; in each of a plurality of allocation sequences, in the plurality of task links, based on the execution period of the currently allocated task and the dependency relationship between the plurality of tasks in each task link, the execution period of the task in each task link is allocated in turn, and an allocation result under each allocation sequence is obtained; in the allocation results under the plurality of allocation sequences, a target allocation result meeting a scheduling condition is determined; and according to the target allocation result, the plurality of tasks in the task cluster are scheduled. The application is beneficial to screening the allocation result of the task cluster from the plurality of allocation results, so that the overall utilization rate of the processing resource is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a task scheduling method, apparatus, computer device, and storage medium. Background Technology

[0002] In multi-task scenarios, multiple tasks in a task cluster typically exist in the form of a tree structure. These tree-structured tasks have dependencies during execution. Any task depends on its predecessor task, and the execution condition of a task includes the completion of the task it depends on.

[0003] In related technologies, for such a task cluster, a task can be started and processing resources can be requested when the execution conditions are met. Therefore, the task that starts first has priority in requesting and occupying processing resources, and if all processing resources are occupied, it can only enter a waiting state.

[0004] In the above method, since a task can be started once the execution conditions are met, there are many tasks to be processed in the early stages, while the number of tasks to be processed decreases in the later stages. Therefore, the task allocation is unbalanced, which leads to a low overall utilization rate of processing resources. Summary of the Invention

[0005] This application provides a task scheduling method, apparatus, computer device, and storage medium, which can improve the overall utilization of processing resources. The technical solution is as follows:

[0006] On the one hand, a task scheduling method is provided, the method comprising:

[0007] A task cluster is defined, the task cluster includes multiple task links, each of the multiple task links includes multiple tasks with dependencies, and the execution condition of each of the multiple tasks includes that all the tasks that the task depends on have been completed.

[0008] According to each of the multiple allocation orders, in the multiple task links, based on the execution time of the currently allocated task and the dependency relationship between the multiple tasks in each task link, the execution time of the task in each task link is allocated, and the allocation result under each allocation order is obtained. The allocation result includes the execution time of each task in the multiple task links.

[0009] Among the allocation results under the various allocation orders, determine the target allocation result that satisfies the scheduling conditions;

[0010] According to the target allocation result, schedule multiple tasks in the task cluster.

[0011] Optionally, the number of tasks in the task chain is M, where M is an integer greater than 1; the determination of multiple candidate allocation results based on the earliest start time of the multiple tasks, the latest end time of the multiple tasks, the execution duration of each of the multiple tasks, and the dependencies between the multiple tasks includes:

[0012] Based on the dependencies between the M tasks, the traversal order of the M tasks is determined so that, after arranging them in the traversal order, the i-th task does not depend on any task after the i-th task, where i is a positive integer not greater than M.

[0013] For the i-th task being traversed, determine the optional execution time period for the i-th task, and among the optional execution time periods for the i-th task, determine the execution time period for the i-th task that has not yet been selected;

[0014] Specifically, after traversing the M tasks once, a candidate allocation result for the task chain is obtained.

[0015] Optionally, determining the second equilibrium parameter for each candidate allocation sub-result based on the execution time of the assigned task and the execution time indicated by each candidate allocation sub-result includes:

[0016] For each candidate allocation sub-result, a second equilibrium parameter for the candidate allocation sub-result is determined based on the resource occupancy information of each execution period of the allocated task and the resource occupancy information of each execution period corresponding to the candidate allocation sub-result.

[0017] The resource usage information during the execution period indicates the amount of processing resources required to execute the task during that execution period.

[0018] On the other hand, a task scheduling apparatus is provided, the apparatus comprising:

[0019] The first determining module is used to determine a task cluster, the task cluster including multiple task links, each of the multiple task links including multiple tasks with dependencies, and the execution condition of each of the multiple tasks including that all the tasks that the task depends on have been completed.

[0020] The allocation module is used to allocate execution time periods for tasks in each of the multiple task chains according to each of the multiple allocation orders, based on the execution time periods of the currently allocated tasks and the dependencies between the multiple tasks in each task chain, to obtain the allocation result under each allocation order, wherein the allocation result includes the execution time period of each task in the multiple task chains;

[0021] The second determining module is used to determine the target allocation result that satisfies the scheduling conditions among the allocation results under the multiple allocation orders;

[0022] The task scheduling module is used to schedule multiple tasks in the task cluster according to the target allocation result.

[0023] Optionally, the allocation result under the allocation order includes the allocation sub-results of each of the multiple task links; the allocation module is used for:

[0024] For each of the allocation orders, the following operations are performed sequentially on each of the plurality of task chains, according to the allocation order:

[0025] Based on the earliest start time, latest end time, execution duration, and dependencies between tasks in the task chain, execution time periods are allocated to the tasks to obtain the allocation sub-result of the task chain under the allocation order.

[0026] Optionally, the task chain includes M tasks, where M is an integer greater than 1; the allocation module is used to:

[0027] Based on the dependencies between the M tasks, the traversal order of the M tasks is determined so that, after arranging them according to the traversal order, the i-th task does not depend on the tasks after the i-th task, where i is a positive integer not greater than M;

[0028] For the currently traversed i-th task, determine the optional execution time period of the i-th task, and within the optional execution time period of the i-th task, determine the execution time period of the i-th task based on the execution time period of the currently assigned tasks;

[0029] The execution time periods of the M tasks in the task chain are determined as the allocation sub-results of the task chain.

[0030] Optionally, the allocation module is used for:

[0031] Based on the execution time of each of the (i+1)th to the Mth tasks, determine the total execution time of the (i+1)th to the Mth tasks;

[0032] Subtract the total execution time from the latest execution time of the M tasks to obtain the latest execution time of the i-th task;

[0033] When i equals 1, the time period between the earliest start time of the M tasks and the latest end time of the i-th task is determined as the optional execution time period of the i-th task;

[0034] When i is greater than 1, the time period between the end time of the execution period of the (i-1)th task and the latest end time of the execution of the i-th task is determined as the optional execution period of the i-th task.

[0035] Optionally, the allocation module is used for:

[0036] Among the selectable execution periods of the i-th task, multiple candidate execution periods for the i-th task are determined;

[0037] Based on the execution time period of the assigned tasks and each candidate execution time period, a first balance parameter is determined for each candidate execution time period. The first balance parameter is used to reflect the degree of distribution balance of all currently assigned tasks after allocation according to the candidate execution time period.

[0038] Among the multiple candidate execution periods, the execution periods that satisfy the balance condition of the first balance parameter are selected.

[0039] Optionally, the allocation module is used for:

[0040] For each candidate execution period, a first equilibrium parameter corresponding to the candidate execution period is determined based on the resource occupancy information of each execution period of the assigned tasks and the resource occupancy information of the candidate execution period.

[0041] The resource usage information during the execution period indicates the amount of processing resources required to execute the task during that execution period.

[0042] Optionally, the allocation module is used for:

[0043] Based on the earliest start time of the multiple tasks, the latest end time of the multiple tasks, the execution duration of each of the multiple tasks, and the dependencies between the multiple tasks, multiple candidate allocation results are determined, and the candidate allocation results represent the execution time periods of each of the multiple tasks.

[0044] Based on the execution time of the assigned tasks and the execution time indicated by each candidate allocation result, a second balance parameter is determined for each candidate allocation result. The second balance parameter is used to reflect the degree of allocation balance of all currently assigned tasks after allocation according to the candidate allocation result.

[0045] Among the various candidate allocation results, the allocation result that satisfies the equilibrium condition for the second equilibrium parameter is selected.

[0046] Optionally, the number of tasks in the task chain is M, where M is an integer greater than 1; the allocation module is used to:

[0047] Based on the dependencies between the M tasks, the traversal order of the M tasks is determined so that, after arranging them in the traversal order, the i-th task does not depend on any task after the i-th task, where i is a positive integer not greater than M.

[0048] For the i-th task being traversed, determine the optional execution time period for the i-th task, and among the optional execution time periods for the i-th task, determine the execution time period for the i-th task that has not yet been selected;

[0049] Specifically, after traversing the M tasks once, a candidate allocation result for the task chain is obtained.

[0050] Optionally, the allocation module is used for:

[0051] For each candidate allocation sub-result, a second equilibrium parameter for the candidate allocation sub-result is determined based on the resource occupancy information of each execution period of the allocated task and the resource occupancy information of each execution period corresponding to the candidate allocation sub-result.

[0052] The resource usage information during the execution period indicates the amount of processing resources required to execute the task during that execution period.

[0053] Optionally, the allocation result under the allocation order includes the allocation sub-results of each of the multiple task links; the allocation module is used for:

[0054] For each of the allocation orders, the following operations are performed sequentially on each of the plurality of task chains, according to the allocation order:

[0055] For each task in the task chain, if the task does not have a preset execution time period set, an execution time period is assigned to the task based on the execution time period of the currently assigned task and the dependency relationship between multiple tasks in the task chain. If the task has a preset execution time period set, the preset execution time period of the task is determined as the execution time period of the task.

[0056] The execution time periods of multiple tasks in the task chain are determined as the allocation sub-results of the task chain.

[0057] Optionally, the task chain includes a leaf task and at least one non-leaf task that the leaf task depends on, the at least one non-leaf task includes at least one root task, the leaf task has no child tasks, the root task has no parent task, and any of the child tasks depends on the parent task of the child task.

[0058] Optionally, the second determining module is configured to:

[0059] Based on the multiple execution periods indicated by each allocation result, a third equilibrium parameter is determined for each allocation result. The third equilibrium parameter is used to reflect the degree of allocation balance of multiple tasks in the task cluster after allocation according to the allocation result.

[0060] Based on the third equilibrium parameter of each allocation result, a target allocation result that satisfies the scheduling conditions is determined.

[0061] Optionally, the second determining module is configured to:

[0062] For each allocation result, resource occupancy information under multiple execution periods indicated by the allocation result is determined, wherein the resource occupancy information under the execution period represents the amount of processing resources required to execute the task during the execution period;

[0063] Based on the resource usage information under the multiple execution periods, a third equilibrium parameter is determined for the allocation result.

[0064] Optionally, the second determining module is further configured to:

[0065] Based on the multiple execution periods indicated by each allocation result, a timeout parameter is determined for each allocation result, the timeout parameter being used to reflect the number of tasks that cannot be completed before the latest execution end time.

[0066] The second determining module is used for:

[0067] For each of the allocation results, the scheduling score of the allocation result is obtained by fusing the third equilibrium parameter of the allocation result and the timeout parameter of the allocation result.

[0068] Among multiple allocation results, the target allocation result that satisfies the scheduling conditions is determined.

[0069] Optionally, each of the plurality of task links has its own priority; the second determining module is configured to:

[0070] Based on the multiple execution periods indicated by the allocation results, the number of timed-out tasks corresponding to each of the multiple priorities is determined. The number of timed-out tasks corresponding to the priority refers to the number of tasks belonging to the priority that cannot be completed before the latest execution end time.

[0071] Based on the weights corresponding to the multiple priorities, the number of timeout tasks corresponding to the multiple priorities is weighted and fused to obtain the timeout parameter, and the weights corresponding to the priorities are positively correlated with the priorities.

[0072] Optionally, the allocation module is used for:

[0073] A set of allocation orders is determined, wherein the set of allocation orders includes N randomly determined allocation orders, where N is an integer greater than 1;

[0074] The following iterative process is performed: according to each allocation order in the allocation order set, in the plurality of task links, based on the execution time of the currently allocated task and the dependency relationship between the multiple tasks in each task link, an execution time is allocated to the task in each task link, and the allocation result under each allocation order in the allocation order set is obtained; if the iteration stopping condition is not met, the N allocation orders in the allocation order set are randomly transformed to obtain a transformed allocation order set; if the iteration stopping condition is met, the iteration process is stopped.

[0075] The second determining module is used for:

[0076] After stopping the iteration process, among the allocation results corresponding to the N allocation orders in the current allocation order set, determine the target allocation result that satisfies the scheduling conditions.

[0077] Optionally, the allocation module is used for:

[0078] If the first allocation order and the second allocation order among the N allocation orders satisfy the crossover condition, perform a crossover operation on the first allocation order and the second allocation order to obtain the transformed first allocation order and the transformed second allocation order, and add the transformed first allocation order and the transformed second allocation order to the set of transformed allocation orders;

[0079] If the third allocation order among the N allocation orders satisfies the mutation condition, a mutation operation is performed on the third allocation order to obtain the transformed third allocation order, and the transformed third allocation order is added to the set of transformed allocation orders.

[0080] If the fourth allocation order among the N allocation orders satisfies the retention condition, the fourth allocation order is added to the transformed allocation order set.

[0081] Optionally, the iteration stopping condition includes any one of the following:

[0082] Among the N allocation orders in the current allocation order set, there exists a target allocation result that satisfies the scheduling conditions;

[0083] The current iteration count has reached the preset number.

[0084] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to perform the operations performed by the task scheduling method as described above.

[0085] On the other hand, a computer-readable storage medium is provided that stores at least one computer program, which is loaded and executed by a processor to perform the operations performed by the task scheduling method described above.

[0086] On the other hand, a computer program product is provided, including a computer program that is loaded and executed by a processor to perform the operations performed by the task scheduling method as described above.

[0087] The solution provided in this application embodiment includes a task cluster comprising multiple task links, each task link comprising multiple tasks with dependencies. When scheduling the task cluster, processing is performed on a task link basis, allocating execution time slots for multiple tasks within a single task link each time, and allocating multiple task links sequentially according to the allocation order. The allocation process for each task link considers the execution time slots of the allocated tasks and the dependencies between the multiple tasks within the task link to ensure reasonable allocation. Since the allocation of task links needs to consider the execution time slots of the allocated tasks, different allocation orders for multiple task links will result in different final allocation results. Therefore, multiple different allocation results can be determined according to various allocation orders, and then the target allocation result that meets the scheduling conditions can be selected from these multiple allocation results. This facilitates the selection of a more balanced allocation result for the execution time slots of the task cluster, thereby improving the overall utilization rate of processing resources. Attached Figure Description

[0088] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0089] Figure 1 This is a schematic diagram of a computer system provided in an embodiment of this application;

[0090] Figure 2 This is a flowchart of a task scheduling method provided in an embodiment of this application;

[0091] Figure 3 This is a flowchart of a task scheduling method provided in an embodiment of this application;

[0092] Figure 4 This is a schematic diagram of a task cluster provided in an embodiment of this application;

[0093] Figure 5 This is a flowchart of a leaf task determination method provided in an embodiment of this application;

[0094] Figure 6 This is a comparison chart of the task quantity distribution provided in an embodiment of this application;

[0095] Figure 7 This is a comparison chart of CPU usage distribution provided in an embodiment of this application;

[0096] Figure 8 This is a comparison chart of memory usage distribution provided in an embodiment of this application;

[0097] Figure 9 This is a comparison chart of task scheduling metrics provided in an embodiment of this application;

[0098] Figure 10 This is a flowchart of another task scheduling method provided in an embodiment of this application;

[0099] Figure 11 This is a schematic diagram of a traversal order provided in an embodiment of this application;

[0100] Figure 12 This is a schematic diagram of another task scheduling method provided in an embodiment of this application;

[0101] Figure 13 This is a schematic diagram of another task scheduling method provided in an embodiment of this application;

[0102] Figure 14 This is a flowchart of another task scheduling method provided in an embodiment of this application;

[0103] Figure 15 This is a schematic diagram of a task scheduling result provided in an embodiment of this application;

[0104] Figure 16 This is a schematic diagram of a task scheduling result provided in an embodiment of this application;

[0105] Figure 17 This is a flowchart of another task scheduling method provided in an embodiment of this application;

[0106] Figure 18 This is a flowchart illustrating task scheduling based on a genetic algorithm, provided in an embodiment of this application.

[0107] Figure 19 This is a schematic diagram of genetic algorithm parameters provided in an embodiment of this application;

[0108] Figure 20 This is a schematic diagram illustrating a fitness change trend provided in an embodiment of this application;

[0109] Figure 21 This is a flowchart of another task scheduling method provided in the embodiments of this application;

[0110] Figure 22 This is a schematic diagram of the structure of a task scheduling device provided in an embodiment of this application;

[0111] Figure 23 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application;

[0112] Figure 24 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation

[0113] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0114] It is understood that the terms "first," "second," etc., used in this application may be used to describe various concepts herein, but unless otherwise stated, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of this application, a first equilibrium parameter may be referred to as a second equilibrium parameter, and similarly, a second equilibrium parameter may be referred to as a first equilibrium parameter.

[0115] "At least one" refers to one or more tasks. For example, at least one task can be one task, two tasks, three tasks, or any integer number of tasks greater than or equal to one. "Multiple" refers to two or more tasks. For example, multiple tasks can be two tasks, three tasks, or any integer number of tasks greater than or equal to two. "Each" refers to each of the at least one tasks. For example, each task refers to each of the multiple tasks. If the multiple tasks are three tasks, then each task refers to each of the three tasks.

[0116] It should be noted that the information (including but not limited to user equipment information, user personal information, etc.), data (including but not limited to data used for analysis, data stored, data displayed, etc.) and signals (including but not limited to signals transmitted between user terminals and other devices) involved in this application have all been fully authorized by the user or relevant parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0117] For example, the task clusters and task links involved in this application are all fully authorized by the users or relevant parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0118] For ease of understanding, the concepts involved in the embodiments of this application are explained below.

[0119] 1. Task scheduling: This refers to the management of tasks, including starting, terminating, and rerunning tasks by judging their preconditions. In this embodiment, the execution conditions of a task include: all tasks on which the task depends have been completed and the earliest start time has been reached.

[0120] 2. Task Instances: These refer to the specific tasks generated in each execution cycle. The default generation time is the earliest time at the task level. Hourly tasks are generated at 0:00 AM every hour, daily tasks are generated at 0:00 AM every day, and monthly tasks are generated at 0:00 AM on the 1st of each month.

[0121] 3. Parent-Child Dependency: This refers to the upstream and downstream dependencies between tasks. Taking a task as an example, its parent task is its upstream task, and the task itself is a child task of its upstream task (i.e., a child task of its parent task). The child task is its downstream task, and the task itself is the parent task of its downstream task (i.e., a parent task of its child task). Therefore, a task depends on its parent task and is depended upon by its child tasks. The execution condition for a task includes the completion of all tasks it depends on. A task can have multiple parent tasks and multiple child tasks simultaneously.

[0122] 4. Delay Execution Duration: This refers to the set time length. When the earliest start time of the task is reached, the start time of the task will be delayed according to the set delay execution duration. For example, if the delay duration is set to 30 minutes for a daily task, the start time of the daily task will be 00:30.

[0123] 5. SLA (Service Level Agreement) tasks: These refer to tasks related to providing data to external parties. They are categorized into four priority levels: S, A, B, and C, with each task corresponding to its respective priority level.

[0124] 6. Leaf tasks: Different tasks have a dependency relationship during execution. The upstream task is the root task, and the downstream task is the leaf task.

[0125] 7. NP (Non-deterministic Polynomial) problems: These are decision problems that are solvable in non-deterministic polynomial time. Specifically, if a decision problem has a non-deterministic algorithm whose verification phase can be completed in polynomial time, then the problem is an NP problem. In other words, NP problems are those where the correctness of a given solution can be verified in polynomial time, but a solution cannot necessarily be found in polynomial time.

[0126] For example, in Sudoku: solving a Sudoku puzzle takes a long time, requiring constant reasoning and trial and error. However, if a Sudoku solution is known, it's possible to check if each row, column, and 3x3 grid conforms to the rules. This checking process is relatively fast, taking place in polynomial time. Therefore, Sudoku is an NP problem.

[0127] For example, consider multiple-choice questions in an exam: if an exam consists entirely of multiple-choice questions, it would take a long time to complete them. However, if one answer is known, checking the answer against the question is much faster; you only need to check the options. The time spent checking the answer doesn't significantly increase with the number of questions, which is why it can be verified in polynomial time. Therefore, multiple-choice questions in an exam are an NP problem.

[0128] In this embodiment of the application, determining the execution time period of multiple tasks in the task cluster is an NP problem.

[0129] 8. Genetic Algorithm: This is a computational model that simulates the biological evolutionary process based on natural selection and genetic mechanisms, as described in Darwin's theory of evolution. It is also a method for searching for optimal solutions by simulating natural evolution. This algorithm uses mathematical methods and computer simulation to transform the problem-solving process into processes similar to the crossover and mutation of chromosomes and genes in biological evolution. When solving complex combinatorial optimization problems, it can usually obtain better optimization results faster than some conventional optimization algorithms.

[0130] The computational process of a genetic algorithm mainly includes initialization, iterative computation, and termination condition determination. A genetic algorithm is an adaptive search algorithm derived from the genetic and evolutionary mechanisms of nature. By simulating the crossover, mutation, and natural selection processes of gene sequences, it searches for the optimal solution and possesses strong global search capabilities.

[0131] In task scheduling scenarios, the allocation order of task chains is transformed into a gene sequence. In the algorithm, "crossover" and "mutation" correspond to the swapping of positions of different leaf tasks, while "natural selection" corresponds to the scheduling score of the allocation order. After multiple iterations, the allocation order with the optimal scheduling score is finally selected. The steps of the genetic algorithm are described in detail below.

[0132] (1) Initialization: In the initial stage, an initial population needs to be generated. Each individual in the population represents a possible solution. Usually, the initial population is obtained by random generation, and the population size and encoding method are set according to the specific requirements of the problem.

[0133] Determine the encoding method: Based on the characteristics of the problem, select an appropriate encoding method to represent the solution to the problem as chromosomes. Common encoding methods include binary encoding and real number encoding.

[0134] Set the population size: Determine the number of individuals in the initial population. This is generally chosen based on the complexity of the problem and the available computing resources, and is usually between tens and hundreds.

[0135] Generate the initial population: Randomly generate a certain number of individuals as the initial population. These individuals are distributed in the genetic space and serve as the starting point for the search.

[0136] (2) Calculate fitness: Fitness measures an individual's performance in solving a problem. To measure the fitness of each individual in the population, a fitness value needs to be assigned to each individual. The higher the fitness value, the closer the individual is to the optimal solution.

[0137] Define a fitness function: Based on the goal of the problem, design a fitness function to measure the degree of adaptation of each individual to the problem environment.

[0138] Calculating individual fitness: For each individual in the population, its fitness value is calculated by substituting it into the fitness function, providing a basis for subsequent selection operations. In the task scheduling scenario of this application, individual fitness refers to the scheduling score of the allocation order.

[0139] (3) Selection: Selection is performed based on the fitness value of each individual. Individuals with better fitness values ​​have a higher probability of being selected. Through selection, superior individuals have the opportunity to pass on their genetic information to the next generation. Common selection methods include roulette wheel selection and tournament selection.

[0140] Determining the selection strategy: Common selection strategies include roulette wheel selection and tournament selection. Roulette wheel selection determines the probability of an individual being selected based on its fitness as a proportion of the total fitness; tournament selection randomly selects a certain number of individuals from the population, choosing the individual with the highest fitness.

[0141] Perform the selection operation: According to the selection strategy, select a certain number of individuals from the current population as parent individuals to generate the next generation.

[0142] (4) Crossover: Crossover is the core of genetic algorithms, simulating the genetic recombination process in nature. Through crossover, two parent individuals can generate new offspring. Crossover can explore new solutions in the solution space. Commonly used crossover operations include single-point crossover and multi-point crossover.

[0143] Set the crossover probability: The crossover probability determines the likelihood of two individuals performing a crossover operation, and is generally set between 0.6 and 0.9.

[0144] Crossover selection: For individuals using binary encoding or other linear encoding, one or more crossover points are randomly selected.

[0145] Perform crossover operation: According to the crossover probability, the selected parent individuals undergo gene exchange at the crossover point to generate new individuals, namely offspring individuals.

[0146] (5) Mutation Operation: To maintain population diversity and prevent the algorithm from getting trapped in local optima, mutation operations are required on individuals. Mutation operations simulate gene mutation phenomena in nature and can perform random searches in the solution space. Commonly used mutation operations include bit reversal mutation, exchange mutation, and inversion mutation.

[0147] Set the mutation probability: The mutation probability is usually set to a small value.

[0148] Determine the mutation location: For each individual, determine whether to perform a mutation operation randomly based on the mutation probability. If a mutation is performed, randomly select the location of the mutated gene.

[0149] Perform mutation operations: Mutate the gene at a selected location, such as changing 0 to 1 or 1 to 0 in binary encoding, or making a small perturbation to the gene value in real number encoding.

[0150] (6) Generate a new population: Replace some or all of the individuals in the original population with the new individuals generated after selection, crossover and mutation operations to form a new population.

[0151] (7) Iteration Stopping Condition Judgment: The genetic algorithm needs to set an iteration stopping condition to determine whether the algorithm has ended. The iteration stopping condition can be reaching the preset maximum number of iterations, finding a suitable solution, or the fitness value of the population reaching stability, etc. After the iteration stopping condition is met, the genetic algorithm ends and outputs the best individual in the current population as the optimal solution.

[0152] Set iteration stopping conditions: Iteration stopping conditions include reaching a predetermined number of iterations, the fitness value reaching a certain threshold, and the fitness value not showing significant improvement for several consecutive generations.

[0153] Determine if the iteration stopping condition is met: If it is met, the genetic algorithm stops and outputs the individual with the highest fitness in the current population as the optimal solution; if it is not met, the iterative calculation continues.

[0154] The task scheduling method provided in this application can be used in computer devices. Optionally, the computer device is a terminal or a server. This application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, online media, and assisted driving.

[0155] Figure 1 This is a schematic diagram of a computer system provided in an embodiment of this application. See also... Figure 1 The computer system includes a terminal 101 and a server 102. The terminal 101 and the server 102 are connected via a wireless or wired network.

[0156] Terminal 101 has a client installed and running, which can be a social application client, online payment client, online shopping client, game client, medical service client, app store client, video client, etc. When terminal 101 runs the client, the client's user interface is displayed on the terminal 101 screen.

[0157] Optionally, terminal 101 may refer to one of a number of terminals, including: smartphones, tablets, laptops, desktop computers, smart speakers, smartwatches, smart voice interaction devices, smart home appliances, in-vehicle terminals, aircraft, VR (Virtual Reality) devices, AR (Augmented Reality) devices, etc., but not limited to these.

[0158] Those skilled in the art will understand that the number of terminals described above can be more or less. For example, there may be only one terminal, or there may be six, eight, or more terminals. This application does not limit the number of terminals or the type of device.

[0159] Figure 1 Only one terminal is shown in the diagram, but in different embodiments, multiple other terminals 103 can access the server 102. Optionally, one or more terminals 103 may also be terminals corresponding to developers, on which a client development and editing platform is installed. Developers can edit and update the client on the terminal 103 and transmit the updated client installation package to the server 102 via wired or wireless network. Terminal 101 can download the client installation package from the server 102 to update the client.

[0160] Terminal 101 and other terminals 103 are connected to server 102 via wired or wireless networks.

[0161] Server 102 includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. Server 102 is used to provide backend services to clients. Optionally, server 102 undertakes the primary computing work, and terminal 101 undertakes the secondary computing work; or, server 102 undertakes the secondary computing work, and terminal 101 undertakes the primary computing work; or, server 102 and terminal 101 collaborate on computing using a distributed computing architecture.

[0162] In this embodiment, terminal 101 sends a task scheduling request for a task cluster to server 102. Server 102 receives the task scheduling request and, using the task scheduling method provided in this embodiment, determines the target allocation result for the task cluster. The target allocation result includes the execution time periods allocated to each of the multiple tasks in the task cluster. Based on the target allocation result, the server schedules the multiple tasks in the task cluster. Alternatively, after determining the target allocation result for the task cluster, server 102 sends the target allocation result to terminal 101. Terminal 101 receives and displays the target allocation result. The user can check whether the target allocation result is correct. After confirming that the target allocation result is correct, terminal 101 can subsequently request server 102 to schedule the multiple tasks in the task cluster according to the target allocation result.

[0163] It should be noted that the above implementation environment is only an example. The method provided in this application embodiment can also be executed by terminal 101 or server 102 alone, or by terminal 101 and server 102 together, or by other computer devices. This application embodiment does not limit this.

[0164] Figure 2This is a flowchart of a task scheduling method provided in an embodiment of this application. This embodiment is executed by a computer device. See also... Figure 2 The method includes:

[0165] 201. The computer equipment determines a task cluster, which includes multiple task links. Each task link includes multiple tasks with dependencies. The execution conditions for each task include that all the tasks it depends on have been completed.

[0166] In this embodiment, the task cluster includes multiple task chains, and each task chain includes multiple tasks with dependencies. Tasks in different task chains may have overlapping parts.

[0167] The execution conditions of a task include that all tasks it depends on have been completed. The number of tasks a task depends on can be one or more, and the tasks it depends on refer to its upstream tasks.

[0168] For example, a task chain includes task A, task B, and task C. Task C directly depends on task B, and task B directly depends on task A. Then, task C indirectly depends on task A. The execution condition for task C is that both task A and task B have been completed, and the execution condition for task B is that task A has been completed.

[0169] 202. The computer device, according to each of the multiple allocation orders, allocates execution time periods for tasks in each task link in turn, based on the execution time periods of the currently allocated tasks and the dependencies between the multiple tasks in each task link, to obtain the allocation result under each allocation order. The allocation result includes the execution time period of each task in the multiple task links.

[0170] Computer devices determine various allocation orders, which refer to the order in which multiple task chains are allocated. In one allocation order, execution time slots are sequentially assigned to multiple tasks within a task chain, resulting in the allocation outcome under that order.

[0171] For example, if a task cluster includes task link A, task link B, and task link C, then these three task links can be allocated in the following possible orders.

[0172] Allocation order 1: Task link A, Task link B, and Task link C.

[0173] Allocation order 2: Task link A, Task link C and Task link B.

[0174] Allocation order 3: Task link B, Task link A, and Task link C.

[0175] Allocation order 4: Task link B, Task link C, and Task link A.

[0176] Allocation order 5: Task link C, Task link A, and Task link B.

[0177] Allocation order 6: Task link C, Task link B, and Task link A.

[0178] When allocating execution time slots for multiple tasks within a task chain, it's necessary to consider the already allocated execution time slots of the tasks in the task chain and the dependencies between them. Different allocation orders will affect the final allocation result; that is, different allocation orders will yield different allocation results. Taking allocation order 1 as an example, when allocating execution time slots for task chain B, the already allocated execution time slots for tasks in task chain A must be considered. Similarly, when allocating execution time slots for task chain C, the already allocated execution time slots for tasks in both task chains A and B must be considered.

[0179] 203. Among the allocation results of computer equipment under multiple allocation orders, determine the target allocation result that meets the scheduling conditions.

[0180] After determining the allocation results under multiple allocation orders, the computer equipment filters out the allocation results that meet the scheduling conditions from the multiple allocation results and takes the allocation results that meet the scheduling conditions as the target allocation result.

[0181] The scheduling conditions can be flexibly set according to actual needs. For example, the scheduling conditions can be set according to the utilization of processing resources, the execution completion time of task clusters, and other dimensions.

[0182] 204. The computer equipment schedules multiple tasks in the task cluster according to the target allocation results.

[0183] The target allocation result includes the execution time of each task in the task cluster. For each task in the task cluster, the task is executed during the execution time indicated by the target allocation result.

[0184] The method provided in this application embodiment includes a task cluster comprising multiple task links, each task link comprising multiple tasks with dependencies. When scheduling the task cluster, processing is performed on a task link basis, allocating execution time slots for multiple tasks within a single task link each time, and allocating multiple task links sequentially according to the allocation order. The allocation process for each task link considers the execution time slots of the allocated tasks and the dependencies between the multiple tasks within the task link to ensure reasonable allocation. Since the allocation of task links requires consideration of the execution time slots of the allocated tasks, different allocation orders for multiple task links will result in different final allocation results. Therefore, multiple different allocation results can be determined according to various allocation orders, and then a target allocation result that meets the scheduling conditions can be selected from these multiple allocation results. This facilitates the selection of a more balanced allocation result for the execution time slots of the task cluster, thereby improving the overall utilization of processing resources.

[0185] Figure 3 This is a flowchart of a task scheduling method provided in an embodiment of this application. This embodiment is executed by a computer device. See also... Figure 3 The method includes:

[0186] 301. The computer equipment determines a task cluster, which includes multiple task chains. Each task chain includes multiple tasks with dependencies. The execution conditions for each task include that all the tasks it depends on have been completed.

[0187] In one possible implementation, the task chain includes a leaf task and at least one non-leaf task that the leaf task depends on, the at least one non-leaf task includes at least one root task, the leaf task has no child tasks, the root task has no parent task, and the non-leaf task is a task that has child tasks.

[0188] Any subtask depends on its parent task. If any subtask's parent task also has its own parent task, then the subtask depends not only on its parent task but also on the parent task's parent task. Alternatively, any subtask depends on its parent task and the task that its parent task depends on.

[0189] In this embodiment, each task link in the task cluster includes only one leaf task. This means that the task links in this application are divided according to the leaf tasks in the task cluster. Each leaf task and all the non-leaf tasks that the leaf task depends on constitute a task link. Each link can be viewed as a tree structure, where the number of root tasks in the tree structure can be one or more, and the number of leaf tasks in the tree structure is one.

[0190] Figure 4 This is a schematic diagram of a task cluster provided in an embodiment of this application, such as... Figure 4 As shown, the leaf tasks in this task cluster include task D, task H, task G, task J, and task M. Therefore, this task cluster includes the following multiple task chains.

[0191] Task Link 1: Task D, Task B, Task A.

[0192] Task Link 2: Task H, Task E, Task F, Task B, Task A, Task C, Task I.

[0193] Task Link 3: Task G, Task C, Task A, Task I.

[0194] Task Link 4: Task J, Task I.

[0195] Task Link 5: Task M, Task L, Task K.

[0196] In this implementation, the task chain includes a leaf task and at least one non-leaf task that the leaf task depends on. This structure makes the dependencies between tasks clearer, and the execution order can be reasonably arranged according to the hierarchical relationship of tasks during task scheduling. This provides a clearer basis for task scheduling, ensuring that no task is missed or incorrectly scheduled, which helps to improve the accuracy and efficiency of task scheduling.

[0197] In one possible implementation, such as Figure 5 As shown, the leaf task is determined as follows: A task A is randomly selected from the task cluster. It is then checked whether task A has any subtasks. If task A has no subtasks, it is added to the leaf task list. If task A has subtasks, any subtask B of task A is selected, and its subtasks are checked. This process continues until all subtasks of task A have been traversed. At this point, the process for task A ends. Other tasks are randomly selected from the task cluster again until all tasks in the cluster have been traversed. The process then ends, and the leaf task list is output.

[0198] In one possible implementation, for each leaf task in the task cluster, a priority level and a latest execution time are set for each leaf task. The priority level of a leaf task can be equivalent to the priority level of the task chain to which it belongs, and the latest execution time of a leaf task can be equal to the latest execution time of the task chain to which it belongs.

[0199] The priority levels and latest execution times of leaf tasks are shown in Table 1 below.

[0200] Table 1

[0201] Task ID Task Name Priority level Latest execution end time 100012345 Leaf Quest 1 S 03:00 100012346 Leaf Mission 2 C 08:00 100012347 Leaf Mission 3 A 02:00 100012348 Leaf Mission 4 S 07:00 100012349 Leaf Quest 5 A 06:00 100012350 Leaf Quest 6 D 11:00 100012351 Leaf Quest 7 B 06:00 …… …… …… ……

[0202] The priority level reflects the importance of the leaf task; the more important the leaf task, the higher its priority level. As shown in Table 1, the priority levels from highest to lowest are: S, A, B, C, and D.

[0203] In one possible implementation, the computer device obtains a whitelist, which includes at least one leaf task. For each leaf task in the whitelist, all tasks in the task chain containing that leaf task are marked as whitelisted. For each task in the whitelist (including the leaf task in the whitelist and all tasks in the task chain containing that leaf task), the earliest start time of that task is used as its preset start time. Subsequent executions of the task begin at this preset start time without delay. The time period from the preset start time of the task's execution duration is then considered the preset execution period of the task. Therefore, subsequent logical calculations are not required to determine the optimal execution period for the task. The whitelist is shown in Table 2 below.

[0204] Table 2

[0205] Task ID Task Name 100012345 Leaf Quest 1 100012346 Leaf Mission 2 100012347 Leaf Mission 3 100012348 Leaf Mission 4 …… ……

[0206] In one possible implementation, in addition to a whitelist, the computer device can also obtain a delay list, which records the delay duration of at least one task. For a task in the delay list, the computer device adds the earliest start time of the task to the delay duration to obtain the preset execution time of the task. Subsequently, the task is executed starting at the preset execution time without delaying the start time. Therefore, the time period from the preset start time of the task to the execution duration of the task is the preset execution period of the task. Thus, it is not necessary to determine the optimal execution period of the task through logical calculations.

[0207] In one possible implementation, the computer device obtains the execution information of each task in the task cluster. The execution information of the task includes at least one of the following: the earliest start time of the task, the earliest end time of the task, the execution duration, the number of CPUs used by the task, the amount of memory used by the task, the upstream dependent tasks of the task, the list of downstream dependent tasks of the task, the priority level of the task, and the latest end time of the task.

[0208] In this context, upstream dependent tasks include all tasks that the current task depends on. Downstream dependent tasks include all tasks that depend on the current task.

[0209] 302. For each of the multiple allocation orders, the computer device performs the following operations on each of the multiple task chains in sequence according to the allocation order: based on the earliest start time of multiple tasks in the task chain, the latest end time of multiple tasks, the execution duration of each task, the execution time of the currently allocated tasks, and the dependencies between multiple tasks, it allocates execution time periods to multiple tasks to obtain the allocation result under the allocation order.

[0210] The allocation results include the execution time of each task in multiple task chains.

[0211] The allocation result under the allocation order includes the allocation sub-results of multiple task chains. Taking one allocation order as an example, each task chain in the multiple task chains is traversed sequentially according to this allocation order. Taking the currently traversed task chain as an example, the computer device allocates execution time periods to the multiple tasks in the task chain based on the earliest start time, the latest end time, the execution duration of each task, the execution time period of the currently allocated tasks, and the dependencies between the multiple tasks, thus obtaining the allocation sub-result of the task chain. In this way, the allocation sub-results of multiple task chains can be determined, and the allocation sub-results of multiple allocation chains constitute the allocation result under this allocation order.

[0212] Using the above method, the allocation result can be determined for each of the various allocation orders.

[0213] This implementation considers the earliest start time, latest finish time, individual execution duration, and dependencies between multiple tasks, ensuring that each task is allocated within a reasonable timeframe. This guarantees that all dependent tasks are completed before a task begins execution, avoiding unnecessary delays. Furthermore, by considering the execution periods of currently allocated tasks, it prevents excessive concentration or dispersion of tasks across different execution periods, improving the balance of task scheduling and thus increasing the utilization of processing resources.

[0214] In one possible implementation, when allocating execution time slots for tasks, it's also necessary to consider whether the task has a preset execution time slot. Taking one allocation order as an example, each task link in multiple task chains is traversed sequentially according to this order. Taking the currently traversed task chain as an example, for each task in this task chain, if the task does not have a preset execution time slot, an execution time slot is allocated to the task based on the currently allocated task's execution time slot and the dependencies between the multiple tasks in the task chain. If the task has a preset execution time slot, the task's preset execution time slot is determined as the task's execution time slot. Following this method, the execution time slot of each task in the task chain can be determined, and the execution time slots of the multiple tasks in the task chain can be determined as the allocation sub-result of the task chain.

[0215] For example, tasks belonging to the whitelist have preset execution periods. For instance, for any task belonging to the whitelist, the computer device determines the earliest start time of the task as its preset start time, adds the preset start time to the task's execution duration to obtain its preset end time, and uses the time period between the preset start time and the preset end time as the task's preset execution period. Therefore, the computer device does not need to use step 302 to determine the execution period of tasks belonging to the whitelist; it can simply allocate the preset execution period to the task's execution period.

[0216] For example, tasks belonging to the delay list have preset execution periods. For instance, for any task in the delay list, the delay duration is recorded in the list. The computer device adds the earliest start time of the task to the delay duration to obtain the preset start time, and adds the preset start time to the execution duration to obtain the preset end time. The time period from the preset start time to the preset end time is taken as the preset execution period of the task. Therefore, the computer device does not need to use step 302 to determine the execution period of tasks belonging to the delay list; it can simply allocate the preset execution period as the execution period of the task.

[0217] For example, if any task is neither on the whitelist nor on the delay list, it is determined that the task has no preset execution time period. Then, the computer device, in step 302, allocates an execution time period to the task based on the currently allocated task execution time periods and task dependencies.

[0218] In this implementation, if a task does not have a preset execution time period, its execution time will be allocated reasonably based on the already assigned task execution time periods and the dependencies between multiple tasks in the task chain. This ensures efficient on-demand task scheduling and reduces resource conflicts. If a task has a preset execution time period, that period will be used directly, guaranteeing the controllability of certain specific tasks. Therefore, this approach combines the advantages of flexible scheduling and fixed time periods, improving the flexibility and controllability of scheduling.

[0219] 303. The computer equipment determines the scheduling score for each allocation result, and among multiple allocation results, determines the target allocation result whose scheduling score satisfies the scheduling conditions.

[0220] The scheduling score of the allocation result is used to reflect the effectiveness of scheduling the task cluster according to the allocation result.

[0221] For example, the higher the scheduling score of the allocation result, the better the scheduling effect of the allocation result. Therefore, among multiple allocation results, the computer device will choose the allocation result with the highest scheduling score as the target allocation result.

[0222] For example, the higher the scheduling score of an allocation result, the worse the scheduling effect of the allocation result. Therefore, among multiple allocation results, the computer device will choose the allocation result with the lowest scheduling score as the target allocation result.

[0223] In one possible implementation, for each allocation result, the computer device determines the scheduling score of the allocation result based on at least one of a third balancing parameter or a timeout parameter. The third balancing parameter reflects the degree of distribution balance among the tasks in the task cluster after allocation according to the allocation result. The timeout parameter reflects the number of tasks that cannot be completed before the latest execution end time.

[0224] Optionally, the computer equipment combines the third equilibrium parameter of the allocation result and the timeout parameter of the allocation result to obtain the scheduling score of the allocation result.

[0225] For example, if the scheduling score is positively correlated with the third equilibrium parameter and the timeout parameter, then the higher the scheduling score, the worse the scheduling effect, and the lower the scheduling score, the better the scheduling effect.

[0226] For example, if the scheduling score is negatively correlated with the third equilibrium parameter and the timeout parameter, then the higher the scheduling score, the better the scheduling effect, and the lower the scheduling score, the worse the scheduling effect.

[0227] For example, since there are differences in the standards of different indicators, the third equilibrium parameter and the timeout parameter are first normalized to obtain the normalized third equilibrium parameter and the normalized timeout parameter. The normalized third equilibrium parameter and the normalized timeout parameter are then weighted and fused to obtain the scheduling score.

[0228] For example, the third balancing parameters include CPU balancing parameters and memory balancing parameters. The CPU balancing parameter reflects the degree of balance in the number of CPUs used by multiple tasks in the task cluster after allocation according to the allocation results. The memory balancing parameter reflects the degree of balance in the number of memory used by multiple tasks in the task cluster after allocation according to the allocation results. The timeout parameters include a first timeout parameter and a second timeout parameter. The first timeout parameter reflects the number of tasks whose allocated execution time period is shorter than the actual execution time. The second timeout parameter reflects the number of tasks whose allocated execution time period is equal to 0.

[0229] The CPU balancing parameter corresponds to a first weight value, the memory balancing parameter corresponds to a second weight value, the first timeout parameter corresponds to a third weight value, and the second timeout parameter corresponds to a fourth weight value. The computer device uses these first, second, third, and fourth weight values ​​to perform a weighted sum of the normalized CPU balancing parameter, normalized memory balancing parameter, normalized first timeout parameter, and normalized second timeout parameter to obtain the scheduling score.

[0230] For example, the first weight value, the second weight value, the third weight value, and the fourth weight value are 0.1, 0.2, 0.3, and 0.4, respectively.

[0231] In this implementation, a scheduling score is generated by fusing the timeout parameter with a third equilibrium parameter, thus comprehensively considering both the balance of resource allocation and the on-time completion of tasks. By filtering the target allocation results that meet the scheduling conditions based on the scheduling score, task scheduling can not only balance resource usage but also effectively avoid task delays, ensuring that tasks can be completed within the predetermined time frame, thereby improving the accuracy and feasibility of task scheduling.

[0232] Optionally, the third balancing parameter is determined as follows: the computer device determines the third balancing parameter for each allocation result based on multiple execution periods indicated by each allocation result. For example, the computer device determines resource usage information under the multiple execution periods indicated by the allocation result, whereby the resource usage information under the execution period represents the amount of processing resources required to execute the task during the execution period; based on the resource usage information under the multiple execution periods, the third balancing parameter for the allocation result is determined.

[0233] For example, the third balancing parameter includes CPU balancing parameter and memory balancing parameter. The CPU balancing parameter is used to reflect the degree of balancing of the number of CPUs occupied by multiple tasks in the task cluster after allocation according to the allocation result. The memory balancing parameter is used to reflect the degree of balancing of the number of memory occupied by multiple tasks in the task cluster after allocation according to the allocation result.

[0234] For example, the CPU balancing parameter is the standard deviation of the number of CPUs used in each execution period. Similarly, the memory balancing parameter is the standard deviation of the amount of memory used in each execution period.

[0235] In this implementation, by analyzing multiple execution periods indicated by each allocation result, a third equilibrium parameter is calculated. This parameter determines the degree of allocation balance among multiple tasks in the task cluster under different allocation results, and then filters out the target allocation result that meets the scheduling conditions based on the third equilibrium parameter. Therefore, this selection method is beneficial for choosing a more suitable allocation result from multiple allocation results, avoiding resource waste or over-concentration, and improving the scheduling effect of the task cluster.

[0236] Furthermore, by calculating the equilibrium parameters for each allocation outcome using resource usage information, it is possible to reflect the resource requirements of different allocation options. By evaluating the resource requirements of each allocation outcome, it is possible to avoid uneven use of processing resources when allocating tasks, effectively select the allocation outcome that best meets the resource equilibrium conditions, and improve the overall utilization rate of processing resources.

[0237] Optionally, the timeout parameter is determined as follows: the computer device determines the timeout parameter for each allocation result based on multiple execution periods indicated by each allocation result.

[0238] For example, the computer device determines the number of timeout tasks corresponding to each of the multiple execution periods indicated by the allocation result. The number of timeout tasks corresponding to the priority refers to the number of tasks that cannot be completed before the latest execution end time among the tasks belonging to the priority. Based on the weights corresponding to the multiple priorities, the number of timeout tasks corresponding to the multiple priorities is weighted and fused to obtain the timeout parameter. The weights corresponding to the priorities are positively correlated with the priorities.

[0239] For example, the timeout parameters include a first timeout parameter and a second timeout parameter. The first timeout parameter is used to reflect the number of tasks whose allocated execution period is less than the execution duration, and the second timeout parameter is used to reflect the number of tasks whose allocated execution period is equal to 0.

[0240] For example, priority levels, in descending order, include: S, A, B, and C. The weight corresponding to level S can be 2 to the power of 4, level A to the power of 2 to the power of 3, level B to the power of 2 to the power of 2 to the power of 2, and level C to the power of 2.

[0241] In this implementation, the number of timeout tasks corresponding to multiple priorities is weighted and merged according to their respective weights to obtain the timeout parameter. This makes the number of timeouts of higher priorities have a greater impact on the final timeout parameter, so higher priority tasks can receive more attention, thereby ensuring that high priority tasks can be completed on time, guaranteeing the execution efficiency of high priority tasks, and improving the rationality of task scheduling.

[0242] In this embodiment, the evaluation of task scheduling effectiveness focuses on key indicators such as CPU usage, memory usage, and the number of abnormally assigned tasks. Combined with actual business scenarios, different statistical weights are assigned to different indicators to construct a scientific indicator model. This model can not only accurately quantify the actual effect of task scheduling, but also provide decision-making basis for continuous optimization of task scheduling strategies based on data feedback, effectively improving the reliability and adaptability of the entire task scheduling system.

[0243] In one possible implementation, the computer device determines scheduling comparison information of the target allocation result and displays the target allocation result and the scheduling comparison information. The scheduling comparison information reflects the difference between not scheduling the task cluster and scheduling the task cluster according to the target allocation result. By viewing the target allocation result and the scheduling comparison information, the user can determine whether the target allocation result is reasonable and correct.

[0244] For example, the scheduling comparison information includes an execution time comparison table, which includes the original start time of the task and the start time after scheduling. This execution time comparison table is shown in Table 3 below.

[0245] Table 3

[0246]

[0247] As shown in Table 3, after scheduling according to the target allocation results, the start time of tasks in the task cluster is significantly advanced, which is beneficial to improving the execution efficiency of the task cluster.

[0248] For example, the scheduling comparison information includes a comparison chart of the distribution of the number of tasks, as shown in the example chart. Figure 6 As shown, from Figure 6As can be seen, after scheduling according to the target allocation results, the number of tasks executed in each execution period is relatively balanced, the time distribution of the number of tasks shifts to later periods, and the number of tasks executed in the early stages decreases.

[0249] For example, the scheduling comparison information includes a comparison chart of CPU usage distribution and a comparison chart of memory usage distribution. The CPU usage distribution comparison chart is as follows: Figure 7 As shown in the comparison chart of the distribution of memory usage, Figure 8 As shown. From Figure 7 and Figure 8 As can be seen, after scheduling according to the target allocation results, the distribution of CPU usage and memory usage in the task cluster has achieved "peak shaving and valley filling", and the distribution of CPU usage and memory usage is more balanced, which is conducive to improving the utilization of processing resources (CPU and memory).

[0250] For example, the scheduling comparison information includes a comparison chart of task scheduling metrics, such as... Figure 9 As shown, task scheduling metrics include the number of minutes before task completion and the task achievement rate. From Figure 9 As can be seen, after scheduling according to the target allocation results, the number of minutes before task completion and the task achievement rate both improved.

[0251] 304. The computer equipment schedules multiple tasks in the task cluster according to the target allocation results.

[0252] The target allocation result includes the execution time period of each task in the task cluster. After confirming that the target allocation result is correct, for each task in the task cluster, the task is executed during the execution time period indicated by the target allocation result.

[0253] For example, the target allocation results can be updated periodically. For instance, if the update cycle for the target allocation results is one week, then the target allocation results of the task cluster will be redefined every week.

[0254] The method provided in this application embodiment includes a task cluster comprising multiple task links, each task link comprising multiple tasks with dependencies. When scheduling the task cluster, processing is performed on a task link basis, allocating execution time slots for multiple tasks within a single task link each time, and allocating multiple task links sequentially according to the allocation order. The allocation process for each task link considers the execution time slots of the allocated tasks and the dependencies between the multiple tasks within the task link to ensure reasonable allocation. Since the allocation of task links requires consideration of the execution time slots of the allocated tasks, different allocation orders for multiple task links will result in different final allocation results. Therefore, multiple different allocation results can be determined according to various allocation orders, and then a target allocation result that meets the scheduling conditions can be selected from these multiple allocation results. This facilitates the selection of a more balanced allocation result for the execution time slots of the task cluster, thereby improving the overall utilization of processing resources.

[0255] When allocating tasks sequentially according to a certain order to determine the allocation result of each task link, the allocation process for any given task link includes two methods, as follows: Figure 10 Implementation examples and Figure 14 The embodiments illustrate the two methods respectively.

[0256] Figure 10 This is a flowchart of a task scheduling method provided in an embodiment of this application. This embodiment is executed by a computer device. See also... Figure 10 The method includes:

[0257] 1001. A computer device determines the traversal order of M tasks based on the dependencies between them in a task chain, so that when arranged in traversal order, the i-th task does not depend on any task after the i-th task.

[0258] Where M is an integer greater than 1, and i is a positive integer not greater than M. In this embodiment, the traversal order of the M tasks refers to the order in which the M tasks are assigned.

[0259] After sorting the M tasks in traversal order, the i-th task does not depend on any task after it. This can be understood as the i-th task not depending on tasks from (i+1)-M. However, the i-th task may or may not depend on the (i-1)-th task. For example, if the (i-1)-th task is the parent task of the i-th task, then the i-th task depends on the (i-1)-th task. Another example is if the (i-1)-th task and the i-th task are different subtasks of the (i-2)-th task, then the i-th task depends on the (i-2)-th task but not on the (i-1)-th task.

[0260] Figure 11 This is a schematic diagram of a traversal order provided in an embodiment of this application, such as... Figure 11 As shown, the task cluster includes task link 1 (task D, task B, task A) and task link 3 (task G, task C, task A, task I). The traversal order of task link 1 is task A, task B, and task D. The traversal order of task link 3 is task A, task I, task C, and task G.

[0261] In one possible implementation, the traversal order of the M tasks in the task chain is determined as follows: First, identify the leaf tasks in the task chain. Then, determine the parent task of each leaf task and designate it as the currently processed task. Next, check if the currently processed task has a parent task. If it does, continue to designate that parent task as the currently processed task until the currently processed task no longer has a parent task. In this case, the currently processed task becomes the first task in the traversal order. Then, check if the first task has subtasks. If it does, add the subtasks of the first task as the currently processed task and add the currently processed task sequentially after the first task. This process continues until the currently processed task no longer has subtasks, indicating that the currently processed task is a leaf task, and this leaf task becomes the last task in the traversal order.

[0262] 1002. For the i-th task currently being traversed, the computer device determines the optional execution time period for the i-th task.

[0263] Taking the i-th task as an example, the computer device determines the earliest start time and the latest end time of the i-th task, and uses the time period between the earliest start time and the latest end time of the i-th task as the optional execution time period of the i-th task.

[0264] In one possible implementation, the computer device determines the total execution time of tasks i+1 to M based on the individual execution times of tasks i+1 to M. The latest execution time of task i is obtained by subtracting the total execution time from the latest completion time of the M tasks. When i equals 1, the time interval between the earliest start time of the M tasks and the latest completion time of task i is determined as the optional execution time interval of task i. When i is greater than 1, the time interval between the end time of the execution time interval of task i-1 and the latest completion time of task i is determined as the optional execution time interval of task i.

[0265] Where i equals 1, the earliest start time of the M tasks is the earliest start time of the i-th task. Where i does not equal 1, the end time of the execution period of the (i-1)-th task is the earliest start time of the i-th task.

[0266] In this implementation, the optional execution period of a task is determined based on the end execution time of its predecessor task and the start execution time of its successor task. This ensures the time coordination between multiple tasks with dependencies, which helps to avoid waste of resources or conflict in task execution.

[0267] In one possible implementation, for the i-th task currently being traversed, the computer device determines the total execution time of tasks i+1 to M based on the execution time of each of the (i+1)-th tasks; the latest execution time of the i-th task is obtained by subtracting the total execution time from the latest execution time of the M tasks.

[0268] When i equals 1, the time period between the earliest start time of the M tasks and the latest end time of the i-th task is determined as the optional execution time period of the i-th task.

[0269] When i is greater than 1, among the first to the (i-1)th tasks, determine at least one parent task of the i-th task, take the latest end execution time of the at least one parent task of the i-th task as the earliest end execution time of the i-th task, and take the time period between the earliest start execution time of the i-th task and the latest end execution time of the i-th task as the optional execution time period of the i-th task.

[0270] 1003. The computer device determines the execution time of the i-th task based on the execution time of the currently assigned tasks within the optional execution time of the i-th task.

[0271] The computer device determines the execution time of the i-th task based on the execution time of the currently assigned tasks and the execution duration of the i-th task within the optional execution time of the i-th task.

[0272] For example, if the duration of the optional execution period of the i-th task is greater than the execution duration of the i-th task, then an execution period with a duration equal to that execution duration can be extracted from the optional execution period of the i-th task and used as the execution period of the i-th task.

[0273] For example, if the duration of the optional execution period of the i-th task is not greater than the execution duration of the i-th task, then the optional execution period is directly used as the execution period of the i-th task.

[0274] In one possible implementation, the computer device determines multiple candidate execution periods for the i-th task within the selectable execution periods of the i-th task; based on the execution periods of the assigned tasks and each candidate execution period, it determines a first equilibrium parameter corresponding to each candidate execution period, the first equilibrium parameter being used to reflect the degree of allocation balance of all currently assigned tasks after allocation according to the candidate execution periods; among the multiple candidate execution periods, the execution periods that satisfy the equilibrium condition of the first equilibrium parameter are selected.

[0275] For example, if the duration of the optional execution period of the i-th task is greater than the execution duration of the i-th task, then multiple candidate execution periods can be extracted from the optional execution period of the i-th task, and the duration of each candidate execution period is equal to the execution duration of the i-th task.

[0276] For example, the smaller the first equilibrium parameter, the higher the degree of allocation balance among all currently assigned tasks after allocation according to candidate execution periods. The larger the first equilibrium parameter, the lower the degree of allocation balance among all currently assigned tasks after allocation according to candidate execution periods. Therefore, after determining the first equilibrium parameter corresponding to each candidate execution period, the computer device determines the candidate execution period with the smallest first equilibrium parameter as the execution period that satisfies the equilibrium condition.

[0277] In this implementation, multiple candidate execution periods are identified from the available execution periods of the task, and a balancing parameter is calculated for each candidate period. This method identifies the execution period that best meets the balancing criteria, preventing excessive concentration or idleness of execution periods and ensuring that resources are allocated rationally during task execution.

[0278] In one possible implementation, the first equilibrium parameter is determined as follows: For each candidate execution period, the first equilibrium parameter corresponding to the candidate execution period is determined based on the resource occupancy information of each execution period of the assigned task and the resource occupancy information of the candidate execution period.

[0279] Among them, the resource usage information during the execution period indicates the amount of processing resources required to execute the task during the execution period.

[0280] For example, the first balancing parameter includes a CPU balancing parameter and a memory balancing parameter. The CPU balancing parameter is used to reflect the degree of balancing of the number of CPUs occupied by all currently allocated tasks after allocation according to the candidate execution time period. The memory balancing parameter is used to reflect the degree of balancing of the number of memory occupied by all currently allocated tasks after allocation according to the candidate execution time period.

[0281] For example, the CPU balancing parameter is the standard deviation of the number of CPUs used in each execution period. Similarly, the memory balancing parameter is the standard deviation of the amount of memory used in each execution period.

[0282] Figure 12 This is a schematic diagram of another task scheduling method provided in an embodiment of this application, such as... Figure 12 As shown, the task chain includes task T1, task T2, and task T3. The earliest start time for this task chain is time point 0, and the latest end time is time point 10. The execution durations of tasks T1, T2, and T3 are 3 hours, 2 hours, and 1 hour, respectively.

[0283] First, task T1 is assigned. The available execution periods for task T1 are time points 0 to 7, and the execution duration of task T1 is 3 hours. Therefore, the candidate execution periods for task T1 include time points 0 to 3, 2 to 4, 3 to 5, 4 to 6, and 5 to 7. From these candidate execution periods, the one that satisfies the balance condition is selected as the execution period for task T1.

[0284] After allocating task T1, task T2 is then allocated. The possible execution periods for task T2 are time points 4 to 9, and the execution duration of task T2 is 2 hours. Therefore, the candidate execution periods for task T2 include time points 4 to 6, 5 to 7, 6 to 8, and 7 to 9. From these candidate execution periods, the one that satisfies the balance condition is selected as the execution period for task T2.

[0285] After assigning task T2, task T3 is assigned in the same way, and will not be described in detail here.

[0286] In this embodiment, since there may be overlapping tasks among multiple task links, taking task link 1 and task link 2 as examples, task link 1 is allocated first, and then task link 2 is allocated. Task link 1 and task link 2 include the overlapping task A. Therefore, when allocating task link 2, for task A, since task A has already been allocated an execution time slot during the allocation process of task link 1, task A is not allocated again during the allocation process of task link 2; the already allocated execution time slot for task A can be directly obtained.

[0287] 1004. The computer device determines the execution time of M tasks in the task chain as the allocation sub-result of the task chain.

[0288] According to steps 1002 and 1003 above, the execution time period of each task in the task chain can be determined, and the execution time periods of the M tasks in the task chain are determined as the allocation sub-result of the task chain.

[0289] Figure 13 This is a flowchart of a task scheduling method provided in an embodiment of this application, such as... Figure 13 As shown, the allocation logic for each task chain uses a stack-like structure. First, it checks if there are any unassigned leaf tasks. If so, it selects a leaf task according to the allocation order and checks if it belongs to the whitelist. If so, it marks the task chain containing the leaf task as whitelisted. Next, it checks if the leaf task has an unassigned parent task. If it does, it retrieves the list of unassigned parent tasks, selects a parent task from the list, and checks if that parent task has an unassigned parent task, continuing until the current task has no parent task. Then, it assigns the current task, retrieves its available execution time slots, and checks if it belongs to the whitelist. If the current task is whitelisted, it allocates its execution time slot according to the preset execution time slot to ensure the task completes as early as possible without delay. If the current task is not whitelisted, it iterates through all candidate execution time slots for the current task, determines the best candidate execution time slot, and assigns it to the current task. After allocating an execution time slot for the task, it updates the task and resource status and returns the task's end execution time. Next, it checks if the current task has any subtasks. If a subtask exists, it returns to the logic of checking if that subtask has any unassigned parent tasks. If the current task has no subtasks, it returns to the logic of checking if there are any unassigned leaf tasks. If there are no unassigned leaf tasks, it means that execution time slots have been allocated to all tasks in the task cluster, so the allocation result is output.

[0290] In this embodiment of the application, in the task scheduling scenario, a stack-like data structure is used. First, based on the dependencies between tasks, the tasks are temporarily sorted from bottom to top. Then, the tasks that have been initially sorted are allocated sequentially from top to bottom. A precise secondary sort is performed based on factors such as CPU usage and memory usage. Through this bidirectional sorting mechanism, the current task allocation scheme is accurately realized, which greatly optimizes the process and efficiency of task processing.

[0291] The method provided in this application first determines the traversal order of tasks based on their dependencies, thus performing an initial sorting to ensure that the task allocation process is not affected by subsequent tasks and avoids conflicts between tasks. Then, based on the execution time periods of the allocated tasks, the execution time periods of the tasks are precisely selected from the available execution time periods, thus performing a secondary sorting to ensure a balanced task allocation. Therefore, this scheduling method not only ensures that tasks are executed in an orderly manner according to their dependencies but also improves the balance of task scheduling and avoids the waste of idle processing resources.

[0292] Figure 14 This is a flowchart of a task scheduling method provided in an embodiment of this application. This embodiment is executed by a computer device. See also... Figure 14 The method includes:

[0293] 1401. Based on the earliest start time of multiple tasks, the latest end time of multiple tasks, the execution duration of each task, and the dependencies between multiple tasks, computer equipment determines multiple candidate allocation results, which represent the execution time periods of each task.

[0294] In one possible implementation, the number of tasks in the task chain is M, where M is an integer greater than 1. The computer device determines the traversal order of the M tasks based on their dependencies, such that, after traversal, the i-th task does not depend on any task following it, where i is a positive integer not greater than M. For the currently traversed i-th task, the device determines its optional execution time slots, and within these slots, selects the one that has not yet been chosen as the execution time slot for the i-th task.

[0295] After traversing the M tasks once, one candidate allocation result for the task chain is obtained. Then, after traversing the M tasks multiple times, multiple candidate allocation results for the task chain are obtained. Since the execution time periods of the M tasks selected in each traversal are different, the resulting candidate allocation results will differ.

[0296] In this implementation, the traversal order of tasks is first determined based on their dependencies, thus performing an initial sorting to ensure that the task allocation process is not affected by subsequent tasks and avoids conflicts between tasks. Then, the execution time of each task is selected from its available execution time slots, resulting in a secondary sort. This approach generates multiple candidate allocation sub-results through multiple traversals, providing various possible allocation schemes for task scheduling. This not only improves the flexibility of task scheduling but also allows for the selection of the allocation sub-result that best meets the balance condition among different schemes, which is beneficial for improving the overall utilization of processing resources and task execution efficiency.

[0297] 1402. The computer device determines a second equilibrium parameter for each candidate allocation sub-result based on the execution time of the assigned tasks and the execution time indicated by each candidate allocation sub-result. The second equilibrium parameter is used to reflect the degree of allocation balance of all currently assigned tasks after allocation according to the candidate allocation sub-result.

[0298] In one possible implementation, the second equilibrium parameter is determined as follows: For each candidate allocation result, the second equilibrium parameter of the candidate allocation result is determined based on the resource occupancy information of each execution period of the allocated task and the resource occupancy information of each execution period corresponding to the candidate allocation result.

[0299] Among them, the resource usage information during the execution period indicates the amount of processing resources required to execute the task during the execution period.

[0300] For example, the second balancing parameters include CPU balancing parameters and memory balancing parameters. The CPU balancing parameters are used to reflect the degree of balancing of the number of CPUs occupied by all currently allocated tasks after allocation according to the candidate allocator results. The memory balancing parameters are used to reflect the degree of balancing of the number of memory occupied by all currently allocated tasks after allocation according to the candidate allocator results.

[0301] For example, the CPU balancing parameter is the standard deviation of the number of CPUs used in each execution period. Similarly, the memory balancing parameter is the standard deviation of the amount of memory used in each execution period.

[0302] In this implementation, by using resource occupancy information, the equilibrium parameters for each candidate allocation sub-outcome are calculated, reflecting the resource requirements of selecting different candidate allocation sub-outcomes. By evaluating the resource requirements of each candidate allocation sub-outcome, it is ensured that uneven use of processing resources is avoided when allocating tasks, and the allocation sub-outcome that best meets the resource equilibrium conditions is effectively selected, which is conducive to improving the overall utilization rate of processing resources.

[0303] 1403. The computer equipment selects the allocation result whose second equilibrium parameter satisfies the equilibrium condition from multiple candidate allocation results.

[0304] In one possible implementation, a smaller second equilibrium parameter indicates a higher degree of allocation balance among all currently assigned tasks after allocation according to the candidate allocator results. Conversely, a larger second equilibrium parameter indicates a lower degree of allocation balance among all currently assigned tasks after allocation according to the candidate allocator results. Therefore, after determining the second equilibrium parameter for each candidate allocator result, the computer device identifies the candidate allocator result with the smallest second equilibrium parameter as the allocator result that satisfies the equilibrium condition.

[0305] The method provided in this application determines multiple candidate allocation sub-results of the task chain. By calculating the second equilibrium parameter of the multiple candidate allocation sub-results, the degree of allocation equilibrium of the multiple candidate allocation sub-results is evaluated. Then, the allocation sub-results that meet the equilibrium conditions are selected according to the second equilibrium parameter, which can avoid resource conflicts and idleness between tasks and is conducive to improving the overall utilization rate of processing resources.

[0306] In this application embodiment, although the allocation result under any allocation order can be determined by adopting the above-described embodiments, in reality, different allocation orders have a great impact on whether the allocation result is reasonable.

[0307] For example, Figure 15 This is a schematic diagram of a task scheduling result provided in an embodiment of this application, such as... Figure 15 As shown, task link 1 includes task T1, and task link 2 includes task T2. Under allocation order 1, task T1 is allocated first, then task T2. Therefore, task T1 is initially allocated an execution period from time point 0 to time point 2, and then task T2 is also allocated an execution period from time point 0 to time point 2. Under allocation order 2, task T2 is allocated first, then task T1. Therefore, task T2 is initially allocated an execution period from time point 0 to time point 2, and then task T1 is allocated an execution period from time point 2 to time point 4. From... Figure 15 It can be seen that the degree of balance of the allocation result of allocation order 1 is lower than that of allocation order 2, and the allocation result of allocation order 2 is better than that of allocation order 1.

[0308] For example, Figure 16 This is a schematic diagram of a task scheduling result provided in an embodiment of this application, such as... Figure 16 As shown, task link 1 includes tasks T1 and T0, and task link 2 includes tasks T2 and T0. Under allocation order 1, the task link containing task T1 is allocated first, followed by the task link containing task T2. Therefore, task T0 is initially allocated an execution period from time point 2 to time point 4, then task T1 is allocated an execution period from time point 4 to time point 6, and finally task T2 is allocated an execution period from time point 4 to time point 6. Under allocation order 2, the task link containing task T2 is allocated first, followed by the task link containing task T1. Therefore, task T0 is initially allocated an execution period from time point 0 to time point 2, then task T2 is allocated an execution period from time point 2 to time point 4, and finally task T1 is allocated an execution period from time point 4 to time point 6. From... Figure 16It can be seen that the degree of balance of the allocation results of allocation order 1 is not much different from that of allocation order 2. However, allocation order 1 will cause the execution completion time of task T2 to exceed time point 4, resulting in a delay in task data output, while allocation order 2 can avoid this problem.

[0309] The above analysis shows that the task allocation order has a significant impact on scheduling performance. To obtain better allocation results, it is necessary to exhaustively search all possible allocation orders. For scenarios with a small number of tasks, exhaustive search is feasible. However, when the number of tasks is large, with the task cluster exceeding 2000 tasks and the number of leaf tasks exceeding 100, the computational load becomes enormous, classifying this problem as an NP-hard problem.

[0310] To address the NP-complete problem, this application employs a genetic algorithm to search for a more efficient allocation order. Specifically, following the genetic algorithm, step 302 described above is executed to determine the allocation result for each of the various allocation orders. See the detailed process below. Figure 17 The example shown.

[0311] Figure 17 This is a flowchart of a task scheduling method provided in an embodiment of this application. This embodiment is executed by a computer device. See also... Figure 17 The method includes:

[0312] 1701. The computer equipment defines a task cluster, which includes multiple task chains, and each task chain includes multiple tasks with dependencies.

[0313] In one possible implementation, the computer device determines the genetic algorithm parameters, which can be a list of parameters as shown in Table 4 below.

[0314] Table 4

[0315] Parameter list Parameter value (default) Number of individuals 1000 Number of iterations 120 Crossover probability 0.9 Number of combinations where crossover occurs 300 Mutation probability 0.4 Number of combinations that mutate 20 …… ……

[0316] Here, the number of individuals represents the number of solutions in the genetic algorithm's population. A larger number of individuals may increase the search space, but it also increases the computational burden. The number of iterations represents the number of times the genetic algorithm updates the population. The crossover probability represents the probability that individuals in the population will cross over. The number of combinations where crossover occurs represents the number of task links requiring crossover among individuals that have crossed over. The mutation probability represents the probability that individuals in the population will mutate. The number of combinations where mutation occurs represents the number of task links requiring mutation among individuals that have mutated.

[0317] 1702. The computer equipment determines the set of allocation orders, which includes N randomly determined allocation orders, where N is an integer greater than 1.

[0318] In this context, the allocation order set is equivalent to the population of the genetic algorithm, and the N allocation orders in the allocation order set are equal to the N individuals in the population of the genetic algorithm.

[0319] For example, N equals 1000.

[0320] 1703. The computer device performs the following iterative process: According to each allocation order in the allocation order set, in multiple task links, based on the execution time of the currently allocated task and the dependency relationship between multiple tasks in each task link, the execution time of each task link is allocated, and the allocation result under each allocation order in the allocation order set is obtained. If the iteration stopping condition is not met, the N allocation orders in the allocation order set are randomly transformed to obtain the transformed allocation order set. If the iteration stopping condition is met, the iteration process is stopped.

[0321] Each iteration proceeds as follows: Obtain the latest allocation order set. Using the methods described in the above embodiments, determine the allocation results under the N allocation orders in the allocation order set. Determine if the iteration stopping condition is met. If the iteration stopping condition is not met, randomly transform the N allocation orders in the allocation order set to obtain a transformed allocation order set, which becomes the latest allocation order set. If the iteration stopping condition is met, stop the iteration process. Subsequently, select the target allocation result from the allocation results under the N allocation orders in this allocation order set.

[0322] In one possible implementation, the N allocation orders in the allocation order set are randomly transformed to obtain the transformed allocation order set, which includes at least one of the following.

[0323] The first method: If the first allocation order and the second allocation order in N allocation orders satisfy the crossover condition, perform a crossover operation on the first allocation order and the second allocation order to obtain the transformed first allocation order and the transformed second allocation order. Add the transformed first allocation order and the transformed second allocation order to the transformed allocation order set.

[0324] Interleaving refers to the process of performing an interleaving operation on two allocation sequences when the two sequences meet the interleaving condition. This operation swaps some of the task orders in the two sequences, creating two new allocation sequences. This combines the advantages of both allocation sequences, generating new possibilities and expanding the range of allocation sequences.

[0325] In one possible implementation, the computer device uses a roulette wheel selection method or a tournament selection method to determine a first allocation order and a second allocation order from N allocation orders. Based on the crossover probability in the genetic algorithm parameters, it is determined whether the first and second allocation orders satisfy the crossover condition. For example, if the crossover probability is equal to 0.9, then the first and second allocation orders have a 90% probability of satisfying the crossover condition and a 10% probability of not satisfying the crossover condition.

[0326] If the first and second allocation orders satisfy the crossover condition, a crossover operation is performed on the first and second allocation orders based on the number of crossover combinations in the genetic algorithm parameters, resulting in transformed first and second allocation orders. For example, each allocation order includes allocation orders for 2000 task links, with 300 crossover combinations. Then, 300 task links are randomly selected from the 2000 task links, and their order in the first allocation order is interchanged with that in the second allocation order, resulting in transformed first and second allocation orders.

[0327] The second method is to perform a mutation operation on the third allocation order in the N allocation orders if the mutation condition is met, and then add the transformed third allocation order to the set of transformed allocation orders.

[0328] The mutation operation refers to performing a mutation operation on the allocation order when the allocation order meets the mutation condition, randomly changing the order of some tasks in the allocation order to form a new allocation order. This helps to avoid getting trapped in local optima, thereby increasing the chance of finding the global optimum.

[0329] In one possible implementation, the computer device uses a roulette wheel selection method or a tournament selection method to determine a third allocation order from N allocation orders. Based on the mutation probability in the genetic algorithm parameters, it is determined whether the third allocation order satisfies the mutation condition. For example, if the mutation probability is equal to 0.4, then the third allocation order has a 40% probability of satisfying the mutation condition and a 60% probability of not satisfying the mutation condition.

[0330] If the third allocation order satisfies the mutation condition, a mutation operation is performed on the third allocation order based on the number of combinations that mutate in the genetic algorithm parameters to obtain the transformed third allocation order. For example, each allocation order includes the allocation order of 2000 task links, and the number of combinations that cross over is 20. Then, 20 consecutive task links are randomly selected from the 2000 task links in the third allocation order, and the order of these 20 task links is randomly changed to obtain the transformed third allocation order.

[0331] The third approach: If the fourth allocation order among the N allocation orders satisfies the retention condition, add the fourth allocation order to the transformed allocation order set.

[0332] The retention operation refers to directly retaining the allocation order without modification when the allocation order meets the retention condition. This preserves the better allocation order and prevents the loss of better allocation orders during iteration.

[0333] In one possible implementation, the fourth allocation order satisfies the retention conditions in at least one of the following cases:

[0334] (1) Arrange the N allocation orders in the current allocation order set in ascending order of scheduling score. The fourth allocation order belongs to the first preset number of allocation orders. Among them, the higher the scheduling score, the lower the scheduling effect. The lower the scheduling score, the better the scheduling effect.

[0335] (2) The scheduling score corresponding to the fourth allocation order is within the preset value range.

[0336] (3) During the process of selecting the allocation order to perform the crossover operation, the fourth allocation order is selected but the fourth allocation order does not meet the crossover condition.

[0337] (4) During the process of selecting the allocation order to perform the mutation operation, the fourth allocation order is selected but the fourth allocation order does not meet the mutation conditions.

[0338] In this implementation, crossover, mutation, and retention operations ensure that different allocation orders can be fully explored and new allocation order sets are generated. These transformation operations introduce randomness and flexibility, making the scheduling process more adaptable and facilitating the rapid finding of more suitable scheduling schemes under complex task dependencies, thereby improving the efficiency of task scheduling.

[0339] In one possible implementation, the iteration stopping condition includes any of the following:

[0340] (1) Among the N allocation orders in the current allocation order set, there exists a target allocation result that satisfies the scheduling conditions.

[0341] For example, in each iteration, after determining the allocation results corresponding to the N allocation orders in the current allocation order set, the scheduling score of each allocation result is determined. If there is an allocation result whose scheduling score satisfies the scheduling condition among the current multiple allocation results, the iteration process is stopped, and the allocation result whose scheduling score satisfies the scheduling condition is taken as the target allocation result.

[0342] (2) The current iteration count has reached the preset number.

[0343] Figure 18 This is a flowchart illustrating task scheduling based on a genetic algorithm, as provided in an embodiment of this application. Figure 18 As shown, the genetic algorithm parameters are input, an initial allocation order set is created, the scheduling score for each allocation order in the set is calculated, the allocation order with the best scheduling score is recorded, and it is determined whether the iteration stopping condition is met. If the stopping condition is met, the allocation order with the best scheduling score is output. If the stopping condition is not met, the allocation order with the best scheduling score is retained, two allocation orders are selected for crossover operation, and one allocation order is selected for mutation operation, adding the transformed allocation order to the transformed allocation order set. It is then determined whether the transformed allocation order set is full. If it is full, the scheduling score for each allocation order in the transformed allocation order set is calculated. If it is not full, the allocation order is randomly transformed again to generate a new allocation order.

[0344] In this implementation, by setting an iteration stopping condition, the scheduling process is ensured to complete within a reasonable time and find a result that meets the scheduling requirements. This not only guarantees the effectiveness of the scheduling process but also avoids excessive consumption of computing resources, thereby improving efficiency.

[0345] 1704. After the computer device stops the iteration process, it determines the target allocation result that satisfies the scheduling conditions from the allocation results corresponding to the N allocation orders in the current allocation order set.

[0346] In one possible implementation, the computer device determines scheduling comparison information of the target allocation result and displays the target allocation result and the scheduling comparison information. The scheduling comparison information reflects the difference between not scheduling the task cluster and scheduling the task cluster according to the target allocation result. By viewing the target allocation result and the scheduling comparison information, the user can determine whether the target allocation result is reasonable and correct.

[0347] For example, the scheduling comparison information includes the execution time comparison table shown in Table 3 above. Figure 6 The comparison chart showing the distribution of task quantity is shown. Figure 7 The comparison chart showing the distribution of CPU usage is shown below. Figure 8 The comparison chart showing the distribution of memory usage is shown. Figure 9 The chart shows a comparison of task scheduling metrics.

[0348] For example, the scheduling comparison information also includes genetic algorithm parameters, as illustrated in the diagram below. Figure 19As shown, the parameters of the genetic algorithm include the number of allocation orders in the allocation order set, the crossover probability, the number of combinations where crossover occurs, the mutation probability, the number of combinations where mutation occurs, the maximum number of iterations, the number of items retained by the elite strategy, and the number of iterations in which the optimal allocation order appears.

[0349] For example, the scheduling comparison information also includes a fitness change trend map, a schematic diagram of which is shown below. Figure 20 As shown, for example, in this embodiment of the application, the fitness of an individual refers to the scheduling score corresponding to the allocation order; the lower the scheduling score, the better the scheduling effect. From Figure 20 As can be seen, the scheduling score decreases as the number of iterations increases, which means that the scheduling effect of the determined allocation result is getting better and better.

[0350] 1705. The computer equipment schedules multiple tasks in the task cluster according to the target allocation results.

[0351] In terms of core algorithms, this patent employs a computational optimization framework based on genetic algorithms, focusing on efficient search for complex task combinatorial problems within limited computing resources. Leveraging the genetic strategy algorithm design, this patent successfully achieves rapid solutions to combinatorial problems that were previously difficult to handle under traditional computing models, significantly reducing computation time to the hour level, substantially improving solution efficiency, alleviating the computational load on the server cluster, enabling refined management of system resource consumption, and ultimately improving overall resource utilization.

[0352] The method provided in this application uses a genetic algorithm to determine the target allocation result. First, N allocation orders are randomly determined. Then, through an iterative process, the set of allocation orders is continuously changed until the iteration stopping condition is met. This iterative process can quickly search different allocation orders, thereby finding the allocation result corresponding to a more suitable allocation order, significantly improving the solution efficiency for finding a suitable allocation result and alleviating the computational load.

[0353] Figure 21 This is a flowchart of another task scheduling method provided in the embodiments of this application, such as... Figure 21 As shown, leaf tasks are first marked, with the user specifying their priority level and latest execution time. Then, leaf tasks are added to a whitelist, passing in genetic algorithm parameters (default values ​​are used if no parameters are passed). The backend server performs task scheduling calculations based on the genetic algorithm parameters and outputs the allocation results. The server then checks the allocation results for rationality. If the allocation results are rational, the execution time periods of tasks in the task cluster are updated in batches based on the allocation results. If the allocation results are unreasonable, the genetic algorithm can be reset for further processing.

[0354] Figure 22 This is a schematic diagram of the structure of a task scheduling device provided in an embodiment of this application. See also... Figure 22 The device includes:

[0355] The first determining module 2201 is used to determine a task cluster, which includes multiple task links. Each task link includes multiple tasks with dependencies. The execution conditions of each task include that all the tasks that the task depends on have been completed.

[0356] The allocation module 2202 is used to allocate execution time periods for tasks in multiple task chains according to each of the multiple allocation orders, based on the execution time periods of the currently allocated tasks and the dependencies between multiple tasks in each task chain, to obtain the allocation result under each allocation order. The allocation result includes the execution time period of each task in multiple task chains.

[0357] The second determining module 2203 is used to determine the target allocation result that meets the scheduling conditions among the allocation results under multiple allocation orders;

[0358] The task scheduling module 2204 is used to schedule multiple tasks in the task cluster according to the target allocation results.

[0359] The task scheduling device provided in this application embodiment includes a task cluster comprising multiple task links, each task link comprising multiple tasks with dependencies. When scheduling the task cluster, processing is performed on a task link basis, allocating execution time slots for multiple tasks within a single task link each time, and allocating multiple task links sequentially according to the allocation order. The allocation process for each task link considers the execution time slots of the allocated tasks and the dependencies between the multiple tasks within the task link to ensure reasonable allocation. Since the allocation of task links requires consideration of the execution time slots of the allocated tasks, different allocation orders for multiple task links will result in different final allocation results. Therefore, multiple different allocation results can be determined according to various allocation orders, and then a target allocation result that meets the scheduling conditions can be selected from these multiple allocation results. This facilitates the selection of a more balanced allocation result for the execution time slots of the task cluster, thereby improving the overall utilization rate of processing resources.

[0360] Optionally, the allocation result under the allocation order includes the allocation sub-results of each of the multiple task chains; the allocation module 2202 is used for:

[0361] For each allocation order, perform the following operations sequentially on each of the multiple task chains, following the allocation order:

[0362] Based on the earliest start time, latest end time, execution duration, and dependencies between tasks in the task chain, execution time periods are assigned to multiple tasks, resulting in the task chain allocation sub-results under the allocation order.

[0363] Optionally, the task chain includes M tasks, where M is an integer greater than 1; the allocation module 2202 is used for:

[0364] Based on the dependencies between M tasks, determine the traversal order of the M tasks so that, after arranging them in the traversal order, the i-th task does not depend on any task after the i-th task, where i is a positive integer not greater than M.

[0365] For the i-th task being traversed, determine the optional execution time period for the i-th task. Within the optional execution time period for the i-th task, determine the execution time period for the i-th task based on the execution time periods of the currently assigned tasks.

[0366] The execution time periods of the M tasks in the task chain are determined as the allocation sub-results of the task chain.

[0367] Optionally, the allocation module 2202 is used for:

[0368] Based on the execution time of each of the (i+1)th to the Mth tasks, determine the total execution time of the (i+1)th to the Mth tasks;

[0369] Subtract the total execution time from the latest execution time of the M tasks to obtain the latest execution time of the i-th task.

[0370] When i equals 1, the time period between the earliest start time of the M tasks and the latest end time of the i-th task is determined as the optional execution time period of the i-th task;

[0371] When i is greater than 1, the time period between the end time of the execution period of the (i-1)th task and the latest end time of the execution of the ith task is determined as the optional execution period of the ith task.

[0372] Optionally, the allocation module 2202 is used for:

[0373] In the optional execution time periods of the i-th task, determine multiple candidate execution time periods for the i-th task;

[0374] Based on the execution time period of the assigned tasks and each candidate execution time period, a first equilibrium parameter is determined for each candidate execution time period. The first equilibrium parameter is used to reflect the degree of allocation balance of all currently assigned tasks after allocation according to the candidate execution time period.

[0375] Among multiple candidate execution periods, the execution period that satisfies the first equilibrium parameter is selected.

[0376] Optionally, the allocation module 2202 is used for:

[0377] For each candidate execution period, the first equilibrium parameter corresponding to the candidate execution period is determined based on the resource usage information of each execution period of the assigned tasks and the resource usage information of the candidate execution period.

[0378] Among them, the resource usage information during the execution period indicates the amount of processing resources required to execute the task during the execution period.

[0379] Optionally, the allocation module 2202 is used for:

[0380] Based on the earliest start time of multiple tasks, the latest end time of multiple tasks, the execution duration of each task, and the dependencies between multiple tasks, multiple candidate allocation sub-results are determined, and the candidate allocation sub-results represent the execution time periods of each task.

[0381] Based on the execution time of the assigned tasks and the execution time indicated by each candidate allocation result, a second balance parameter is determined for each candidate allocation result. The second balance parameter is used to reflect the degree of allocation balance of all currently assigned tasks after allocation according to the candidate allocation result.

[0382] Among multiple candidate allocator results, the allocator result that satisfies the equilibrium condition for the second equilibrium parameter is selected.

[0383] Optionally, the number of tasks in the task chain is M, where M is an integer greater than 1; the allocation module 2202 is used for:

[0384] Based on the dependencies between M tasks, determine the traversal order of the M tasks so that, after arranging them in the traversal order, the i-th task does not depend on any task after the i-th task, where i is a positive integer not greater than M.

[0385] For the i-th task being traversed, determine the possible execution time periods for the i-th task, and among the possible execution time periods for the i-th task, determine the execution time period for the i-th task that has not yet been selected;

[0386] After traversing the M tasks once, a candidate allocation result for the task chain is obtained.

[0387] Optionally, the allocation module 2202 is used for:

[0388] For each candidate allocation sub-result, the second equilibrium parameter of the candidate allocation sub-result is determined based on the resource usage information of the allocated tasks in each execution period and the resource usage information of the candidate allocation sub-result in each execution period.

[0389] Among them, the resource usage information during the execution period indicates the amount of processing resources required to execute the task during the execution period.

[0390] Optionally, the allocation result under the allocation order includes the allocation sub-results of each of the multiple task chains; the allocation module 2202 is used for:

[0391] For each allocation order, perform the following operations sequentially on each of the multiple task chains, following the allocation order:

[0392] For each task in the task chain, if no preset execution time period is set for the task, an execution time period is assigned to the task based on the execution time period of the currently assigned task and the dependency relationship between multiple tasks in the task chain. If a preset execution time period is set for the task, the preset execution time period of the task is determined as the execution time period of the task.

[0393] The execution time periods of multiple tasks in a task chain are determined as the allocation sub-results of the task chain.

[0394] Optionally, the task chain includes a leaf task and at least one non-leaf task that the leaf task depends on. The at least one non-leaf task includes at least one root task. The leaf task has no child tasks, the root task has no parent task, and any child task depends on the parent task of the child task.

[0395] Optionally, the second determining module 2203 is used for:

[0396] Based on the multiple execution periods indicated by each allocation result, a third equilibrium parameter is determined for each allocation result. The third equilibrium parameter is used to reflect the degree of allocation balance among multiple tasks in the task cluster after allocation according to the allocation result.

[0397] Based on the third equilibrium parameter of each allocation result, the target allocation result that satisfies the scheduling conditions is determined.

[0398] Optionally, the second determining module 2203 is used for:

[0399] For each allocation result, determine the resource usage information for multiple execution periods indicated by the allocation result. The resource usage information for each execution period represents the amount of processing resources required to execute the task during that execution period.

[0400] Based on resource usage information across multiple execution periods, a third equilibrium parameter is determined for the allocation result.

[0401] Optionally, the second determining module 2203 is further configured to:

[0402] Based on the multiple execution periods indicated by each allocation result, a timeout parameter is determined for each allocation result. The timeout parameter is used to reflect the number of tasks that cannot be completed before the latest execution end time.

[0403] The second determining module 2203 is used for:

[0404] For each allocation result, the third equilibrium parameter and the timeout parameter of the allocation result are combined to obtain the scheduling score of the allocation result;

[0405] Among multiple allocation results, determine the target allocation result that satisfies the scheduling conditions.

[0406] Optionally, each of the multiple task chains has its own priority; the second determining module 2203 is used for:

[0407] Based on the multiple execution periods indicated by the allocation results, the number of timed-out tasks corresponding to each of the multiple priorities is determined. The number of timed-out tasks corresponding to a priority refers to the number of tasks that cannot be completed before the latest execution end time among the tasks belonging to that priority.

[0408] Based on the weights corresponding to multiple priorities, the number of timeout tasks corresponding to each priority is weighted and fused to obtain the timeout parameter. The weights corresponding to the priorities are positively correlated with the priorities.

[0409] Optionally, the allocation module 2202 is used for:

[0410] Determine the set of allocation orders, which includes N randomly determined allocation orders, where N is an integer greater than 1;

[0411] Perform the following iterative process: According to each allocation order in the allocation order set, in multiple task chains, based on the execution time of the currently allocated task and the dependencies between multiple tasks in each task chain, allocate execution time for each task in the task chain, and obtain the allocation result under each allocation order in the allocation order set; if the iteration stopping condition is not met, randomly transform the N allocation orders in the allocation order set to obtain the transformed allocation order set; if the iteration stopping condition is met, stop the iteration process.

[0412] The second determining module 2203 is used for:

[0413] After stopping the iteration process, determine the target allocation result that satisfies the scheduling conditions from the allocation results corresponding to the N allocation orders in the current allocation order set.

[0414] Optionally, the allocation module 2202 is used for:

[0415] If the first allocation order and the second allocation order in N allocation orders satisfy the crossover condition, perform a crossover operation on the first allocation order and the second allocation order to obtain the transformed first allocation order and the transformed second allocation order. Add the transformed first allocation order and the transformed second allocation order to the set of transformed allocation orders.

[0416] If the third allocation order among N allocation orders satisfies the mutation condition, perform a mutation operation on the third allocation order to obtain the transformed third allocation order, and add the transformed third allocation order to the set of transformed allocation orders.

[0417] If the fourth allocation order among the N allocation orders satisfies the retention condition, the fourth allocation order is added to the transformed allocation order set.

[0418] Optionally, the iteration stopping condition includes any of the following:

[0419] Among the N allocation orders in the current allocation order set, there exists a target allocation result that satisfies the scheduling conditions;

[0420] The current iteration count has reached the preset number.

[0421] It should be noted that the task scheduling device provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the computer device can be divided into different functional modules to complete all or part of the functions described above. In addition, the task scheduling device and the task scheduling method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0422] This application also provides a computer device, which includes a processor and a memory. The memory stores at least one computer program, which is loaded and executed by the processor to perform the operations performed in the task scheduling method of the above embodiments.

[0423] Optionally, the computer device is provided as a terminal. Figure 23 A schematic diagram of the structure of a terminal 2300 provided in an exemplary embodiment of this application is shown.

[0424] Terminal 2300 includes: processor 2301 and memory 2302.

[0425] Processor 2301 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 2301 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). Processor 2301 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 2301 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 2301 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.

[0426] The memory 2302 may include one or more computer-readable storage media, which may be non-transitory. The memory 2302 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 2302 are used to store at least one computer program, which is used by the processor 2301 to implement the task scheduling method provided in the method embodiments of this application.

[0427] In some embodiments, the terminal 2300 may also optionally include: a peripheral device interface 2303 and at least one peripheral device. The processor 2301, memory 2302, and peripheral device interface 2303 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 2303 via a bus, signal line, or circuit board. Optionally, the peripheral device includes at least one of: a radio frequency circuit 2304, a display screen 2305, a camera assembly 2306, an audio circuit 2307, and a power supply 2308.

[0428] Peripheral device interface 2303 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 2301 and memory 2302. In some embodiments, processor 2301, memory 2302 and peripheral device interface 2303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 2301, memory 2302 and peripheral device interface 2303 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.

[0429] The radio frequency (RF) circuit 2304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 2304 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 2304 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 2304 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 2304 can communicate with other devices through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: metropolitan area networks (MANs), various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks (WLANs), and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 2304 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.

[0430] Display screen 2305 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 2305 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 2301 for processing. In this case, display screen 2305 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 2305, disposed on the front panel of terminal 2300; in other embodiments, there may be at least two display screens, disposed on different surfaces of terminal 2300 or in a folded design; in still other embodiments, display screen 2305 may be a flexible display screen, disposed on a curved or folded surface of terminal 2300. Furthermore, display screen 2305 may also be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. The display screen 2305 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0431] The camera assembly 2306 is used to acquire images or videos. Optionally, the camera assembly 2306 includes a front-facing camera and a rear-facing camera. The front-facing camera is disposed on the front panel of the terminal 2300, and the rear-facing camera is disposed on the back of the terminal 2300. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 2306 may also include a flash. The flash may be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cool light flash, which can be used for light compensation at different color temperatures.

[0432] The audio circuit 2307 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 2301 for processing, or input to the radio frequency circuit 2304 to achieve voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located at a different part of the terminal 2300. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from the processor 2301 or the radio frequency circuit 2304 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 2307 may also include a headphone jack.

[0433] Power supply 2308 is used to power the various components in terminal 2300. Power supply 2308 can be AC ​​power, DC power, a disposable battery, or a rechargeable battery. When power supply 2308 includes a rechargeable battery, the rechargeable battery can support wired or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0434] Those skilled in the art will understand that Figure 23 The structure shown does not constitute a limitation on terminal 2300 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.

[0435] Optionally, the computer device is provided as a server. Figure 24 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 2400 can vary significantly due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 2401 and one or more memories 2402. The memories 2402 store at least one computer program, which is loaded and executed by the processor 2401 to implement the methods provided in the above-described method embodiments. Of course, the server may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which will not be elaborated upon here.

[0436] This application also provides a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to implement the operations performed by the task scheduling method of the above embodiments.

[0437] This application also provides a computer program product, including a computer program that is loaded and executed by a processor to perform the operations performed by the task scheduling method of the above embodiments.

[0438] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0439] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present application should be included within the protection scope of the present application.

Claims

1. A task scheduling method, characterized in that, The method includes: A task cluster is defined, the task cluster includes multiple task links, each of the multiple task links includes multiple tasks with dependencies, and the execution condition of each of the multiple tasks includes that all the tasks that the task depends on have been completed. According to each of the multiple allocation orders, in the multiple task links, based on the execution time of the currently allocated task and the dependency relationship between the multiple tasks in each task link, the execution time of the task in each task link is allocated, and the allocation result under each allocation order is obtained. The allocation result includes the execution time of each task in the multiple task links. Among the allocation results under the various allocation orders, determine the target allocation result that satisfies the scheduling conditions; According to the target allocation result, schedule multiple tasks in the task cluster.

2. The method according to claim 1, characterized in that, The allocation result under the allocation order includes the allocation sub-results of each of the multiple task links; according to each of the multiple allocation orders, in the multiple task links, based on the execution time of the currently allocated task and the dependency relationship between the multiple tasks in each task link, the execution time of each task link is allocated to the task, and the allocation result under each allocation order is obtained, including: For each of the allocation orders, the following operations are performed sequentially on each of the plurality of task chains, according to the allocation order: Based on the earliest start time, latest end time, execution duration, and dependencies between tasks in the task chain, execution time periods are allocated to the tasks to obtain the allocation sub-result of the task chain under the allocation order.

3. The method according to claim 2, characterized in that, The task chain includes M tasks, where M is an integer greater than 1. Based on the earliest start time, latest end time, execution duration, and dependencies between the tasks in the task chain, execution time periods are allocated to the tasks, resulting in the allocation sub-result of the task chain under the specified allocation order. This includes: Based on the dependencies between the M tasks, the traversal order of the M tasks is determined so that, after arranging them according to the traversal order, the i-th task does not depend on the tasks after the i-th task, where i is a positive integer not greater than M; For the currently traversed i-th task, determine the optional execution time period of the i-th task, and within the optional execution time period of the i-th task, determine the execution time period of the i-th task based on the execution time period of the currently assigned tasks; The execution time periods of the M tasks in the task chain are determined as the allocation sub-results of the task chain.

4. The method according to claim 3, characterized in that, Determining the optional execution time period for the i-th task includes: Based on the execution time of each of the (i+1)th to the Mth tasks, determine the total execution time of the (i+1)th to the Mth tasks; Subtract the total execution time from the latest execution time of the M tasks to obtain the latest execution time of the i-th task; When i equals 1, the time period between the earliest start time of the M tasks and the latest end time of the i-th task is determined as the optional execution time period of the i-th task; When i is greater than 1, the time period between the end time of the execution period of the (i-1)th task and the latest end time of the execution of the i-th task is determined as the optional execution period of the i-th task.

5. The method according to claim 3, characterized in that, The step of determining the execution time of the i-th task based on the execution time of the currently assigned tasks within the optional execution time of the i-th task includes: Among the selectable execution periods of the i-th task, multiple candidate execution periods for the i-th task are determined; Based on the execution time period of the assigned tasks and each candidate execution time period, a first balance parameter is determined for each candidate execution time period. The first balance parameter is used to reflect the degree of distribution balance of all currently assigned tasks after allocation according to the candidate execution time period. Among the multiple candidate execution periods, the execution periods that satisfy the balance condition of the first balance parameter are selected.

6. The method according to claim 5, characterized in that, The determination of the first equilibrium parameter corresponding to each candidate execution time period based on the execution time period of the assigned tasks and each candidate execution time period includes: For each candidate execution period, a first equilibrium parameter corresponding to the candidate execution period is determined based on the resource occupancy information of each execution period of the assigned tasks and the resource occupancy information of the candidate execution period. The resource usage information during the execution period indicates the amount of processing resources required to execute the task during that execution period.

7. The method according to claim 2, characterized in that, The process involves allocating execution time periods to the multiple tasks based on their earliest start time, latest end time, execution duration, currently assigned execution time periods, and dependencies, thus obtaining the task chain allocation sub-result under the given allocation order. This includes: Based on the earliest start time of the multiple tasks, the latest end time of the multiple tasks, the execution duration of each of the multiple tasks, and the dependencies between the multiple tasks, multiple candidate allocation results are determined, and the candidate allocation results represent the execution time periods of each of the multiple tasks. Based on the execution time of the assigned tasks and the execution time indicated by each candidate allocation result, a second balance parameter is determined for each candidate allocation result. The second balance parameter is used to reflect the degree of allocation balance of all currently assigned tasks after allocation according to the candidate allocation result. Among the various candidate allocation results, the allocation result that satisfies the equilibrium condition for the second equilibrium parameter is selected.

8. The method according to any one of claims 1 to 7, characterized in that, The allocation result under the allocation order includes the allocation sub-results of each of the multiple task links; according to each of the multiple allocation orders, in the multiple task links, based on the execution time of the currently allocated task and the dependency relationship between the multiple tasks in each task link, the execution time of each task link is allocated to the task, and the allocation result under each allocation order is obtained, including: For each of the allocation orders, the following operations are performed sequentially on each of the plurality of task chains, according to the allocation order: For each task in the task chain, if the task does not have a preset execution time period set, an execution time period is assigned to the task based on the execution time period of the currently assigned task and the dependency relationship between multiple tasks in the task chain. If the task has a preset execution time period set, the preset execution time period of the task is determined as the execution time period of the task. The execution time periods of multiple tasks in the task chain are determined as the allocation sub-results of the task chain.

9. The method according to any one of claims 1 to 7, characterized in that, The task chain includes a leaf task and at least one non-leaf task that the leaf task depends on. The at least one non-leaf task includes at least one root task. The leaf task has no child tasks, and the root task has no parent task. Any of the child tasks depends on the parent task of the child task.

10. The method according to any one of claims 1 to 7, characterized in that, Determining the target allocation result that satisfies the scheduling conditions among the allocation results under the multiple allocation orders includes: Based on the multiple execution periods indicated by each allocation result, a third equilibrium parameter is determined for each allocation result. The third equilibrium parameter is used to reflect the degree of allocation balance of multiple tasks in the task cluster after allocation according to the allocation result. Based on the third equilibrium parameter of each allocation result, a target allocation result that satisfies the scheduling conditions is determined.

11. The method according to claim 10, characterized in that, The determination of a third equilibrium parameter for each allocation result based on multiple execution periods indicated by each allocation result includes: For each allocation result, resource occupancy information under multiple execution periods indicated by the allocation result is determined, wherein the resource occupancy information under the execution period represents the amount of processing resources required to execute the task during the execution period; Based on the resource usage information under the multiple execution periods, a third equilibrium parameter is determined for the allocation result.

12. The method according to claim 10, characterized in that, The method further includes: Based on the multiple execution periods indicated by each allocation result, a timeout parameter is determined for each allocation result, the timeout parameter being used to reflect the number of tasks that cannot be completed before the latest execution end time. The determination of the target allocation result that satisfies the scheduling conditions based on the third equilibrium parameter of each allocation result includes: For each of the allocation results, the scheduling score of the allocation result is obtained by fusing the third equilibrium parameter of the allocation result and the timeout parameter of the allocation result. Among multiple allocation results, the target allocation result that satisfies the scheduling conditions is determined.

13. The method according to claim 12, characterized in that, Each of the multiple task chains has its own priority; determining the timeout parameter for each allocation result based on the multiple execution periods indicated by each allocation result includes: Based on the multiple execution periods indicated by the allocation results, the number of timed-out tasks corresponding to each of the multiple priorities is determined. The number of timed-out tasks corresponding to the priority refers to the number of tasks belonging to the priority that cannot be completed before the latest execution end time. Based on the weights corresponding to the multiple priorities, the number of timeout tasks corresponding to the multiple priorities is weighted and fused to obtain the timeout parameter, and the weights corresponding to the priorities are positively correlated with the priorities.

14. The method according to any one of claims 1 to 7, characterized in that, According to each of the multiple allocation orders, in the multiple task chains, based on the execution time of the currently allocated tasks and the dependencies between the multiple tasks in each task chain, execution time periods are allocated to the tasks in each task chain, resulting in the allocation result under each allocation order, including: A set of allocation orders is determined, wherein the set of allocation orders includes N randomly determined allocation orders, where N is an integer greater than 1; The following iterative process is performed: according to each allocation order in the allocation order set, in the plurality of task links, based on the execution time of the currently allocated task and the dependency relationship between the multiple tasks in each task link, an execution time is allocated to the task in each task link, and the allocation result under each allocation order in the allocation order set is obtained; if the iteration stopping condition is not met, the N allocation orders in the allocation order set are randomly transformed to obtain a transformed allocation order set; if the iteration stopping condition is met, the iteration process is stopped. Determining the target allocation result that satisfies the scheduling conditions among the allocation results under the multiple allocation orders includes: After stopping the iteration process, among the allocation results corresponding to the N allocation orders in the current allocation order set, determine the target allocation result that satisfies the scheduling conditions.

15. The method according to claim 14, characterized in that, The step of randomly transforming the N allocation orders in the allocation order set to obtain the transformed allocation order set includes at least one of the following: If the first allocation order and the second allocation order among the N allocation orders satisfy the crossover condition, perform a crossover operation on the first allocation order and the second allocation order to obtain the transformed first allocation order and the transformed second allocation order, and add the transformed first allocation order and the transformed second allocation order to the set of transformed allocation orders; If the third allocation order among the N allocation orders satisfies the mutation condition, a mutation operation is performed on the third allocation order to obtain the transformed third allocation order, and the transformed third allocation order is added to the set of transformed allocation orders. If the fourth allocation order among the N allocation orders satisfies the retention condition, the fourth allocation order is added to the transformed allocation order set.

16. The method according to claim 14, characterized in that, The iteration stopping condition includes any one of the following: Among the N allocation orders in the current allocation order set, there exists a target allocation result that satisfies the scheduling conditions; The current iteration count has reached the preset number.

17. A task scheduling device, characterized in that, The method includes: The first determining module is used to determine a task cluster, the task cluster including multiple task links, each of the multiple task links including multiple tasks with dependencies, and the execution condition of each of the multiple tasks including that all the tasks that the task depends on have been completed. The allocation module is used to allocate execution time periods for tasks in each of the multiple task chains according to each of the multiple allocation orders, based on the execution time periods of the currently allocated tasks and the dependencies between the multiple tasks in each task chain, to obtain the allocation result under each allocation order, wherein the allocation result includes the execution time period of each task in the multiple task chains; The second determining module is used to determine the target allocation result that satisfies the scheduling conditions among the allocation results under the multiple allocation orders; The task scheduling module is used to schedule multiple tasks in the task cluster according to the target allocation result.

18. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one computer program, which is loaded and executed by the processor to perform the operations performed by the task scheduling method as described in any one of claims 1 to 16.

19. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to perform the operations performed by the task scheduling method as described in any one of claims 1 to 16.

20. A computer program product, comprising a computer program, characterized in that, The computer program is loaded and executed by a processor to perform the operations performed by the task scheduling method as described in any one of claims 1 to 16.