Task execution method and device, computer equipment and readable storage medium
By selecting task queues and tasks in the task execution window based on the number of executed tasks and the expected percentage of task execution, the problem of low-priority tasks being postponed indefinitely in existing technologies is solved, thereby improving the fairness and balance of task execution.
Patent Information
- Application Number
- CN202511513074.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-21
- Publication Date
- 2026-01-23
AI Technical Summary
Existing task scheduling methods strictly determine the execution order according to task priority, which may cause low-priority tasks to be delayed indefinitely when high-priority tasks continue to arrive, and the fairness and response time of the system cannot be guaranteed.
When the number of tasks in the task execution window is lower than the threshold, the target task queue is selected from the candidate task queues based on the number of executed tasks and the expected percentage of task execution in each candidate task queue. Then, tasks are selected and added from the target task queue for execution, taking into account the number of executed tasks and the expected percentage of task execution to improve fairness and balance.
By considering the number of executed tasks in the task queue and the expected percentage of tasks to be executed, the problem of low-priority tasks being postponed indefinitely is solved, improving the fairness and balance of task execution and meeting user expectations.
Smart Images

Figure CN121387482A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer application, in particular to a task execution method and device, computer equipment and readable storage medium. BACKGROUND
[0002] Priority scheduling is a task scheduling method based on task priority. Each job or task is assigned a priority, and the scheduler decides the execution order of each task according to the priority, and high-priority tasks are executed first. This algorithm is widely used in real-time systems, multi-task operating systems and other scenarios. Its working principle is to assign a priority to each task, select the task with the highest priority for execution during scheduling, and continue scheduling the next task after the task is completed.
[0003] However, the existing task scheduling method or task execution method strictly determines the execution order of the task according to the priority of the task, and if high-priority tasks continue to arrive, low-priority tasks may be indefinitely postponed, and the fairness and response time of the system cannot be guaranteed. SUMMARY
[0004] Therefore, it is necessary to provide a task execution method and device, computer equipment and readable storage medium for increasing the fairness of task execution and task response time in view of the above technical problems.
[0005] In a first aspect, the present application provides a task execution method applied to a computer equipment, comprising:
[0006] In the case that the number of tasks being executed in the task execution window is less than the number threshold, a target task queue is selected from each candidate task queue according to the number of executed tasks and the expected task execution proportion of each candidate task queue; wherein the number of executed tasks of each candidate task queue is the number of tasks in the candidate task queue that have been added to the task execution window.
[0007] A target task is selected from the pending tasks in the target task queue, and the target task is added to the task execution window to execute the target task.
[0008] In the embodiments of the present application, in the case that the number of tasks being executed in the task execution window is lower than the number threshold, i.e., in the case that the to-be-processed task needs to be delivered to the task execution window, the target task queue can be selected from the candidate task queues according to the number of executed tasks and the expected task execution proportion of each candidate task queue. The target task is selected from the to-be-processed tasks of the target task queue, and the target task is added to the task execution window for execution. The number of executed tasks of each candidate task queue is the number of tasks in the candidate task queue that have been added to the task execution window. In the present application, the target queue is selected from the candidate task queues by comparing the number of executed tasks and the expected task execution proportion of each candidate queue, so that, compared with the prior art which relies too much on the task priority, the number of executed tasks of each candidate task queue is considered, and the expected task execution proportion of each candidate queue is also considered, so that the task scheduling execution is associated with the user expectation, which not only solves the problem that the low-priority task may be postponed indefinitely, but also improves the fairness and balance of task execution and the user satisfaction.
[0009] In one of the embodiments, selecting the target task queue from the candidate task queues according to the number of executed tasks and the expected task execution proportion of each candidate task queue comprises:
[0010] determining the total number of executed tasks according to the number of executed tasks of each candidate task queue;
[0011] determining the actual execution task proportion of each candidate task queue according to the total number of executed tasks and the number of executed tasks of each candidate task queue;
[0012] selecting the target task queue from the candidate task queues according to the actual execution task proportion and the expected task execution proportion of each candidate task queue.
[0013] In the embodiments of the present application, when the target task queue is selected from the candidate task queues, first, the total number of executed tasks is determined based on the number of executed tasks of each candidate task queue. Then, the actual execution task proportion of each candidate task queue is determined according to the total number of executed tasks and the number of executed tasks of each candidate task queue. Finally, the target task queue is selected from the candidate task queues based on the comparison and analysis of the actual execution task proportion and the expected task execution proportion of each candidate task queue, which improves the fairness of the target task queue determined.
[0014] In one of the embodiments, selecting the target task queue from the candidate task queues according to the number of executed tasks and the expected task execution proportion of each candidate task queue comprises:
[0015] For each candidate task queue, a ratio difference between an actual execution task ratio and an expected task execution ratio of the candidate task queue is determined.
[0016] The candidate task queue with the smallest ratio difference is selected as the target task queue.
[0017] In the embodiments of the present application, by determining the ratio difference between the actual execution task ratio and the expected task execution ratio of the candidate task queue, the deviation between the actual and expected task execution of each candidate task queue can be determined, and the candidate task queue with the smallest ratio difference is preferentially selected as the target task queue, so that the task execution scheduling is more in line with the user's expectation, and the rationality of selecting the target task queue is further improved, thereby improving the fairness and balance of the to-be-processed task scheduling.
[0018] In one of the embodiments, the candidate task queue with the smallest ratio difference is selected as the target task queue, including:
[0019] If the number of candidate task queues with the smallest ratio difference is at least two, the target task queue is selected from the candidate task queues with the smallest ratio difference according to the queue priority of the candidate task queues with the smallest ratio difference.
[0020] In the embodiments of the present application, each candidate task queue also has a corresponding queue priority. In the case where the number of candidate task queues with the smallest ratio difference is at least two, the queue priority also needs to be considered when confirming the target task queue. Based on the queue priority, the balance of task scheduling execution is improved, and the conflict situation when selecting the target task queue is avoided, and the scheduling resources are reasonably allocated according to the queue priority to meet the user's expectation.
[0021] In one of the embodiments, the method further includes:
[0022] The expected execution task ratio of each candidate task queue is determined according to the queue priority of each candidate task queue.
[0023] In the embodiments of the present application, the expected execution task ratio of each candidate task queue is determined based on the queue priority of each candidate task queue. Compared with the prior art in which task execution is too dependent on task priority, resulting in the situation that low-priority tasks may be indefinitely postponed, in the present embodiment, the queue priority of each candidate task queue is reflected in the expected execution task ratio, and the situation that low-priority jobs are starved does not occur, and the fairness and balance of the system are taken into account.
[0024] In one of the embodiments, the method further includes:
[0025] In the case where the number of tasks being executed in the task execution window is lower than the number threshold, the task existence in each initial task queue is determined.
[0026] The task existence condition is that the initial task queue has a pending task.
[0027] In the embodiments of the present application, when the candidate task queue is selected, the initial task queue having a pending task is taken as the candidate task queue, and when the target task queue is determined, the initial task queue not having a pending task can be excluded preferentially, thereby improving the efficiency of determining the target task queue.
[0028] In one of the embodiments, the method further includes:
[0029] In the case of receiving a pending task, the pending task is allocated to an initial task queue matching a task priority of the pending task according to the task priority of the pending task and the queue priority of each initial task queue.
[0030] In the embodiments of the present application, not only each candidate task queue has a corresponding queue priority, but also each pending task has a corresponding task priority, and the scheduling resources of the pending task can be allocated reasonably based on the task priority. Based on the embodiments, the task priorities of the pending tasks in each candidate task queue can be made the same, thereby improving the fairness and balance of the pending tasks with the same task priority in the execution of scheduling. Since the pending tasks with different task priorities are allocated in different candidate task queues, the difference of the pending tasks with different task priorities in the execution of scheduling is also improved.
[0031] In one of the embodiments, the method further includes:
[0032] The system pressure is determined according to an index parameter of a target index of the computer device; wherein the target index includes a performance index and / or a load index;
[0033] In the case that the system pressure exceeds a preset threshold, the queue index of the initial task queue and / or the window index of the task execution window are adjusted; wherein the queue index includes at least one of an expected execution task proportion, a queue length and a task quantity; and the window index includes at least one of a window size, a delayed execution mode and a delayed execution time.
[0034] In the embodiments of the present application, the system pressure is determined according to the index parameter of the target index of the computer device, thereby realizing the quantitative processing of the computer device in the running pressure. In the case that the system pressure exceeds the preset threshold, the queue index of the initial task queue and / or the window index of the task execution window are adjusted, thereby not only realizing the adaptive adjustment of the computer device, automatically optimizing the system resources, guaranteeing the safe and stable operation of the system, but also effectively avoiding the situation of system resource shortage and resource exhaustion.
[0035] In one of the embodiments, the method further includes:
[0036] In a case where the duration between the current time and the last update time reaches the preset duration, adjusting the executed task quantity of each initial task queue.
[0037] In the embodiments of the present application, by configuring the preset duration, in a case where the duration between the current time and the last update time reaches the preset duration, the executed task quantity of each initial task queue is adjusted, which can realize the decay processing of the executed task quantity of each initial task queue, so as to gradually reduce the influence of the historical data on the future task execution scheduling, and make the task scheduling result more suitable for the current system state.
[0038] In a second aspect, the present application further provides a task execution device configured in a computer device, including:
[0039] The selection module is configured to select a target task queue from each candidate task queue according to the executed task quantity and the expected task execution proportion of each candidate task queue in a case where the task quantity of the tasks being executed in the task execution window is lower than the quantity threshold; wherein the executed task quantity of each candidate task queue is the task quantity of the tasks in the candidate task queue that have been added to the task execution window.
[0040] The adding module is configured to select a target task from the to-be-processed tasks of the target task queue, and add the target task to the task execution window to execute the target task.
[0041] In a third aspect, the present application further provides a computer device including a memory and a processor, the memory stores a computer program, and the processor implements the steps in each method embodiment provided in the first aspect when executing the computer program.
[0042] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps in each method embodiment provided in the first aspect.
[0043] In a fifth aspect, the present application further provides a computer program product including a computer program, and the computer program is executed by a processor to implement the steps in each method embodiment provided in the first aspect.
[0044] In the task execution method, the task execution device, the computer device, and the readable storage medium, in a case where the number of tasks being executed in the task execution window is lower than the number threshold, i.e., in a case where it is necessary to deliver the to-be-processed task to the task execution window, a target task queue can be selected from each candidate task queue according to the number of executed tasks and the expected task execution proportion of each candidate task queue. A target task is selected from the to-be-processed tasks of the target task queue, and the target task is added to the task execution window to execute the target task. The number of executed tasks of each candidate task queue is the number of tasks in the candidate task queue that have been added to the task execution window. In this application, the target queue is selected from each candidate task queue by comparing the number of executed tasks and the expected task execution proportion of each candidate queue. Compared with the prior art which relies too much on the task priority, this application not only considers the number of executed tasks of each candidate task queue, but also considers the expected task execution proportion of each candidate queue, so that the task scheduling and execution are associated with the user's expectation, solving the problem that low-priority tasks may be postponed indefinitely for processing, and improving the fairness and balance of task execution and user satisfaction. BRIEF DESCRIPTION OF DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other related drawings can also be obtained without creative labor.
[0046] Figure 1 A schematic diagram of the principle of a computer device;
[0047] Figure 2 A flowchart of a first task execution method provided by some embodiments of the present application;
[0048] Figure 3 A flowchart of determining the actual execution task proportion of each candidate task queue provided by some embodiments of the present application;
[0049] Figure 4 A flowchart of determining a target task queue provided by some embodiments of the present application;
[0050] Figure 5 A flowchart of determining a target task queue provided by some embodiments of the present application;
[0051] Figure 6 A flowchart of determining the expected execution task proportion of each candidate task queue provided by some embodiments of the present application;
[0052] Figure 7 A flowchart of a process for determining a candidate task queue is provided for some embodiments of the present application;
[0053] Figure 8 A flowchart of a process for assigning a to-be-processed task is provided for some embodiments of the present application;
[0054] Figure 9 A flowchart of a second task execution method is provided for some embodiments of the present application;
[0055] Figure 10 A flowchart of a process for adjusting the number of executed tasks of each initial task queue is provided for some embodiments of the present application;
[0056] Figure 11 A flowchart of a third task execution method is provided for some embodiments of the present application;
[0057] Figure 12 A structural block diagram of a task execution apparatus is provided for some embodiments of the present application;
[0058] Figure 13 An internal structural diagram of a computer device is provided for some embodiments of the present application. DETAILED DESCRIPTION
[0059] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0060] Priority scheduling is a task scheduling method based on task priority. Each job or task is assigned a priority, and the scheduler determines the execution order of each task according to the priority, and high-priority tasks are executed first. This algorithm is widely used in real-time systems, multi-task operating systems, etc., and its working principle is to assign a priority to each task, select the task with the highest priority for execution during scheduling, and continue the scheduling of the next task after the task is completed.
[0061] However, the existing task scheduling method or task execution method strictly determines the execution order of the task according to the priority of the task, and if high-priority tasks continuously arrive, low-priority tasks may be indefinitely postponed, and the fairness and response time of the system cannot be guaranteed.
[0062] To solve the above problems, a task execution method of the present application can be applied to Figure 1In the application environment shown, in a case where the number of tasks being executed in the task execution window is lower than the number threshold, a target task queue is selected from each candidate task queue according to the number of executed tasks and the expected task execution proportion of each candidate task queue; the number of executed tasks of each candidate task queue is the number of tasks in the candidate task queue that have been added to the task execution window. A target task is selected from the pending tasks in the target task queue, and the target task is added to the task execution window for execution.
[0063] Based on this, in an exemplary embodiment, as shown in Figure 2 a task execution method is provided, and the method is applied to Figure 1 a computer device as an example for illustration, and specifically includes the following steps:
[0064] S201, in a case where the number of tasks being executed in the task execution window is lower than the number threshold, a target task queue is selected from each candidate task queue according to the number of executed tasks and the expected task execution proportion of each candidate task queue.
[0065] The number of executed tasks of each candidate task queue is the number of tasks in the candidate task queue that have been added to the task execution window. The task execution window refers to a window for executing pending tasks, a task is added to the task execution window to start execution, and exits the window after execution. The task being executed refers to a pending task whose execution state is being executed, and the pending task becomes a task being executed after being delivered to the task execution window. The number of tasks refers to the number of tasks being executed in the task execution window. The number threshold refers to a boundary adjustment that is pre-set to trigger selection of a target task from each candidate task queue. The expected task execution proportion refers to a pre-configured ratio of the number of tasks that the candidate task queue hopes to add to the task execution window to the total number of tasks added to the task execution window by all candidate task queues. The target task queue refers to a task queue that adds tasks to the task execution window.
[0066] Optionally, in this embodiment, the expected task execution proportion of each candidate task queue can be configured according to configuration information.
[0067] Optionally, in this embodiment, the number threshold can be determined according to user-provided demand information; the demand information includes a specific value of the number threshold.
[0068] Optionally, in this embodiment, the number threshold can also be dynamically adjusted according to system pressure; for example, in a case where the system pressure exceeds a first value, the number threshold is the first value.
[0069] Optionally, the quantity threshold in the embodiment can be determined according to the window size of the execution window. Specifically, the maximum window size is taken as the quantity threshold. In the embodiment, the window size determines the maximum number of tasks in parallel of the task execution window, i.e., the number of tasks being executed that are allowed to be executed simultaneously at most. In the embodiment, the maximum number of tasks in parallel of the task execution window is taken as the quantity threshold.
[0070] In one optional embodiment, the optional implementation of selecting the target task queue from the candidate task queues according to the number of executed tasks and the expected task execution proportion of each candidate task queue is that the number of executed tasks and the expected task execution proportion of each candidate task queue are input into an intelligent analysis model, and the target task queue is output by the intelligent analysis model. The intelligent analysis model can be a trained neural network model.
[0071] In another optional embodiment, another optional implementation of selecting the target task queue from the candidate task queues according to the number of executed tasks and the expected task execution proportion of each candidate task queue is that the actual task execution proportion of each candidate task queue is determined according to the number of executed tasks of each candidate task queue. For each candidate task queue, the ratio of the actual task execution proportion to the expected task execution proportion of the candidate task queue is determined, and the candidate task queue with the smallest ratio is taken as the target task queue.
[0072] S202, selecting a target task from the pending tasks of the target task queue and adding the target task to the task execution window to execute the target task.
[0073] The target task refers to a pending task selected from the target task queue and needed to be delivered to the task execution window.
[0074] In one optional embodiment, the pending task with the first sequence in the target task queue is selected as the target task, and the target task is added to the task execution window to execute the target task.
[0075] In another optional embodiment, the target task is selected from the pending tasks of the target task queue according to the task priority of each pending task in the target task queue, and the target task is added to the task execution window to execute the target task. For example, the pending task with the highest task priority in the target task queue is selected as the target task.
[0076] The task execution method can select a target task queue from each candidate task queue according to the executed task quantity of each candidate task queue and the expected task execution proportion, in a case where the number of tasks being executed in the task execution window is less than the quantity threshold, that is, in a case where a to-be-processed task needs to be delivered to the task execution window. A target task is selected from the to-be-processed tasks of the target task queue, and the target task is added to the task execution window to execute the target task. The executed task quantity of each candidate task queue is the number of tasks in the candidate task queue that have been added to the task execution window. In this application, the target queue is selected from each candidate task queue by comparing the executed task quantity of each candidate queue and the expected task execution proportion. Compared with the prior art which relies too much on task priority, this application not only considers the executed task quantity of each candidate task queue, but also considers the expected task execution proportion of each candidate queue, so that the task scheduling and execution is associated with user expectations, solving the problem that low-priority tasks may be postponed indefinitely for processing, and improving the fairness and balance of task execution and user satisfaction.
[0077] On the basis of the above-mentioned embodiments, in one exemplary embodiment, in order to more accurately determine the target task queue and improve the fairness of target task queue selection, as shown in Figure 3 The optional implementation of selecting a target task queue from each candidate task queue according to the executed task quantity of each candidate task queue and the expected task execution proportion includes:
[0078] S301, determining a total executed task quantity according to the executed task quantity of each candidate task queue.
[0079] The total executed task quantity refers to a total value determined based on the executed task quantity of each candidate task queue.
[0080] In one optional embodiment, the sum of the executed task quantities of each candidate task queue is used as the total executed task quantity.
[0081] In another optional embodiment, the candidate task queue in this embodiment refers to a task queue that has to-be-processed tasks. Specifically, the candidate task queue refers to a task queue in the initial task queue that has to-be-processed tasks. In this embodiment, the sum of the executed task quantities of the initial task queue is used as the total executed task quantity.
[0082] S302, determining an actual executed task proportion of each candidate task queue according to the total executed task quantity and the executed task quantity of each candidate task queue.
[0083] The actual executed task proportion refers to the proportion of the executed task quantity in the total executed task quantity.
[0084] In an optional embodiment, for each candidate task queue, a ratio of the number of executed tasks of the candidate task queue to the total number of executed tasks is taken as the actual execution task proportion of the candidate task queue.
[0085] S303, selecting a target task queue from the candidate task queues according to the actual execution task proportions and the expected task execution proportions of the candidate task queues.
[0086] In an optional embodiment, for each candidate task queue, a ratio of the actual task execution proportion to the expected task execution proportion of the candidate task queue is determined as a task execution ratio. The task execution ratios of the candidate task queues are sorted, and the candidate task queue pointed to by the smallest task execution ratio is taken as the target task queue.
[0087] In the embodiments of the present application, when selecting the target task queue from the candidate task queues, first, the total number of executed tasks is determined based on the sum of the numbers of executed tasks of the candidate task queues. Then, the actual execution task proportions of the candidate task queues are determined according to the total number of executed tasks and the numbers of executed tasks of the candidate task queues. Finally, the target task queue is selected from the candidate task queues based on the comparison and analysis of the actual execution task proportions and the expected task execution proportions of the candidate task queues, which improves the fairness of the target task queue confirmed.
[0088] On the basis of the above-mentioned embodiments, in an exemplary embodiment, in order to further improve the accuracy of the selection of the target task queue and make the selected target task queue more in line with the user's expectation, and improve the fairness of the selection of the target task queue, as shown in Figure 4 The optional implementation of selecting the target task queue from the candidate task queues according to the actual execution task proportions and the expected task execution proportions of the candidate task queues includes:
[0089] S401, for each candidate task queue, determining a proportion difference between the actual execution task proportion and the expected task execution proportion of the candidate task queue.
[0090] In an optional embodiment, for each candidate task queue, a difference between the actual execution task proportion and the expected task execution proportion of the candidate task queue is taken as the proportion difference. It should be noted that the proportion difference can be negative, and is not the absolute value of the difference. For example, if the actual execution task proportion is 20% and the expected task execution proportion is 30%, the proportion difference is 20%-30%=-10%.
[0091] S402, taking the candidate task queue with the smallest proportion difference as the target task queue.
[0092] In an optional embodiment, if the number of the candidate task queues with the minimum difference value of the proportion is one, the candidate task queue with the minimum difference value of the proportion is selected as the target task queue.
[0093] In another optional embodiment, if the number of the candidate task queues with the minimum difference value of the proportion is at least two, the target task queue is selected from the candidate task queues with the minimum difference value of the proportion according to the number of tasks in the candidate task queues with the minimum difference value of the proportion. For example, the candidate task queue with the minimum difference value of the proportion and the largest number of tasks is selected as the target task queue.
[0094] In this embodiment, by determining the difference value of the proportion between the actual execution proportion and the expected execution proportion of the candidate task queues, the deviation between the actual and expected execution of the candidate task queues in terms of task execution can be determined. The candidate task queue with the minimum difference value of the proportion is preferentially selected as the target task queue, so that the task execution scheduling is more in line with the user's expectation, and the rationality of the selection of the target task queue is further improved, thereby improving the fairness and balance of the scheduling of the tasks to be processed.
[0095] On the basis of the above-mentioned embodiments, in an example embodiment, in the case where the number of the candidate task queues with the minimum difference value of the proportion is at least two, in order to avoid selection conflicts, the candidate task queue with the minimum difference value of the proportion is selected as the target task queue, including: Figure 5
[0096] S501, if the number of the candidate task queues with the minimum difference value of the proportion is at least two, the target task queue is selected from the candidate task queues with the minimum difference value of the proportion according to the queue priority of the candidate task queues with the minimum difference value of the proportion. Specifically, the candidate task queue with the lowest queue priority is selected from the candidate task queues with the minimum difference value of the proportion as the target task queue. In this embodiment, in the case where the number of the candidate task queues with the minimum difference value of the proportion is at least two, the selection of the target task is more inclined to the candidate task queue with the low priority, the response time of the task with the low priority is increased, and the fairness and balance of the overall task execution scheduling are improved.
[0097] In this embodiment, each candidate task queue also has a corresponding queue priority. In the case where the number of the candidate task queues with the minimum difference value of the proportion is at least two, the queue priority is also considered when the target task queue is confirmed. Based on the queue priority, the balance of the task scheduling and execution is improved, and the conflict in the selection of the target task queue is avoided. The scheduling resources are reasonably allocated according to the queue priority, and the user's expectation is met.
[0098] On the basis of the above embodiments, in an exemplary embodiment, in order to more accurately determine the expected task execution proportion of each candidate task queue, as shown in Figure 6 An optional implementation of a task execution method includes:
[0099] S601, according to the queue priority of each candidate task queue, determine the expected execution task proportion of each candidate task queue.
[0100] In an optional embodiment, the expected execution task proportion of each candidate task queue is determined according to the queue priority of each candidate task queue and the priority list. The priority list records the queue priority of each queue and the expected execution task proportion corresponding to the queue priority. That is, according to the queue priority of each candidate task queue, the expected execution task proportion of each candidate task queue can be determined based on the table lookup method.
[0101] In this embodiment, the expected execution task proportion of each candidate task queue is determined based on the queue priority of each candidate task queue. Compared with the prior art, in which task execution is too dependent on task priority, resulting in the situation that low-priority tasks may be indefinitely postponed, in this embodiment, the queue priority of each candidate task queue is reflected in the expected execution task proportion, and the situation that low-priority jobs are starved does not occur, and the fairness and balance of the system are taken into account. That is, based on this embodiment, the candidate task queue is associated with the queue priority, and the strong dependence on the queue priority when selecting the target task queue is solved, and the queue priority and the expected task execution proportion are associated, and the role of the queue priority in determining the target task queue is weakened.
[0102] On the basis of the above embodiments, in an exemplary embodiment, in order to improve the efficiency of determining the target task queue and reduce the computational burden, as shown in Figure 7 An optional implementation of a task execution method includes:
[0103] S701, in the case where the number of tasks being executed in the task execution window is lower than the number threshold, determine the task existence condition in each initial task queue.
[0104] The initial task queue refers to all task queues in the computer device.
[0105] In an optional embodiment, in the case where the number of tasks being executed in the task execution window is lower than the number threshold, the number of tasks to be processed in each initial task queue is obtained. According to the number of tasks to be processed in each initial task queue, the task existence condition in each initial task queue is determined. For example, if the number of tasks to be processed in the initial task queue is more than one, it is determined that the task existence condition of the initial task queue is that there are tasks to be processed.
[0106] S702, the task existence case is an initial task queue with pending tasks, as a candidate task queue.
[0107] In the embodiments of the present application, when selecting the candidate task queue, the initial task queue with pending tasks is selected as the candidate task queue, and when determining the target task queue, the initial task queue without pending tasks can be excluded in priority, thereby improving the efficiency of determining the target task queue and reducing the calculation burden when determining the target task queue.
[0108] On the basis of the above-mentioned embodiments, in an exemplary embodiment, in order to reflect the task priority of the pending task and associate the task priority with the queue priority of each candidate task queue, as shown in the following table, a task execution method can include: Figure 8
[0109] S801, in the case of receiving a pending task, according to the task priority of the pending task and the queue priority of each initial task queue, the pending task is assigned to the initial task queue matching the task priority.
[0110] The task priority refers to a priority level pre-assigned to the pending task to represent the importance of the pending task.
[0111] In the present embodiment, an optional implementation of determining the task priority of the pending task is to configure the corresponding task priority for the pending task according to the task type of the pending task. For example, if the task type is a game task or a video task, the corresponding task priority is relatively high. If the task type is a normal download task, the corresponding task priority is relatively low.
[0112] In another optional implementation of determining the task priority of the pending task in the present embodiment, the corresponding task priority is configured for the pending task according to the level of the task source of the pending task. For example, the higher the level of the task source, the higher the corresponding task priority. The lower the level of the task source, the lower the corresponding task priority.
[0113] In an optional embodiment, according to the task priority of the pending task and the queue priority of each initial task queue, the pending task is assigned to the initial task queue matching the task priority. The initial task queue with the same task priority as the pending task is selected as the target delivery queue. The pending task is assigned to the end position of the task queue of the target delivery queue. The task priority of the pending task in each initial task queue is the same as the queue priority of the initial task queue.
[0114] In the embodiments of the present application, not only each candidate task queue has a corresponding queue priority, but also each to-be-processed task has a corresponding task priority, and the scheduling resources of the to-be-processed tasks can be reasonably allocated based on the task priority. Based on the embodiments, the task priorities of the to-be-processed tasks in each candidate task queue can be made the same, and the fairness and balance of the to-be-processed tasks with the same task priority in the execution scheduling can be improved. Since the to-be-processed tasks with different task priorities are allocated in different candidate task queues, the difference of the to-be-processed tasks with different task priorities in the execution scheduling can also be improved.
[0115] On the basis of the above embodiments, in an exemplary embodiment, in order to reflect the task priority of the to-be-processed task and associate the task priority with the queue priority of each candidate task queue, as shown in a task execution method, an optional implementation manner includes: Figure 9
[0116] S901, determining the system pressure according to the index parameter of the target index of the computer device.
[0117] The target index includes a performance index and / or a load index. The performance index includes but is not limited to at least one of CPU utilization, memory usage, bandwidth occupancy, disk utilization, storage fragmentation, cache water level, journal recovery rate, and redundancy degradation ratio. The load index includes but is not limited to at least one of the number of tasks in each candidate task queue, the number of tasks in the task execution window and the current window size, and the actual task execution proportion of each candidate task queue.
[0118] In an optional embodiment, the index parameter of the target index of the computer device is input to an intelligent analysis model, and the system pressure is output by the intelligent analysis model. The intelligent analysis model can be a trained neural network model.
[0119] In another alternative embodiment, the index value of each target index is determined according to the index parameter of the target index of the computer device. The total index value is determined according to the index value of each target index. The total index value is taken as the system pressure. In this embodiment, the alternative implementation of determining the index value of each target index according to the index parameter of the target index of the computer device is that, for each target index, the index value of the target parameter is determined according to the index parameter of the target index and the candidate parameter interval corresponding to the target index; each candidate parameter interval corresponds to an index value; the index value corresponding to the candidate parameter interval in which the index parameter of the target index is located is taken as the index value of the target index. In this embodiment, the alternative implementation of determining the total index value according to the index value of each target index is that the index values of the target indexes are fused to obtain the total index value; the fusion processing mode includes any one of the product, the sum and the weighted sum.
[0120] S902, in the case where the system pressure exceeds the preset threshold, adjusting the queue index of the initial task queue and / or the window index of the task execution window.
[0121] The queue index includes at least one of the expected execution task proportion, the queue length and the task quantity; the window index includes at least one of the window size, the delayed execution mode and the delayed execution time.
[0122] In an alternative embodiment, in the case where the system pressure exceeds the preset threshold, the queue index of the initial task queue is adjusted. Alternatively, in the case where the system pressure exceeds the preset threshold, at least one of the expected execution task proportion, the queue length and the task quantity of the initial task queue is adjusted. The queue length refers to the maximum number of tasks to be processed that can be accommodated by the candidate task queue. Alternatively, in this embodiment, the alternative implementation of adjusting the expected execution task proportion of the initial task queue is that, according to the proportion range of the expected execution task proportion, the expected execution task proportion of the initial task queue is adjusted so that the adjusted expected execution task proportion cannot exceed the maximum value of the proportion range. In addition to adjusting the queue index according to the system pressure, it is also determined whether the expected task execution proportion of each initial task queue needs to be adjusted according to the actual task execution proportion of each initial task queue. For example, if the difference between the actual task execution proportion (or the number of executed tasks) of a certain initial task queue and the actual task execution proportion (or the number of executed tasks) of other initial task queues is greater than a preset threshold, the expected task execution proportion of the initial task queue is adjusted according to the proportion range corresponding to the initial task queue to improve the task execution efficiency of the tasks to be processed in the initial task queue, thereby improving the fairness and balance of task execution scheduling.
[0123] In another alternative embodiment, the window index of the task execution window is adjusted when the system pressure exceeds a preset threshold. Optionally, in some embodiments, the preset threshold includes a first threshold and a second threshold. When the system pressure exceeds the first threshold, the window size of the task execution window is reduced, i.e., the number of task parallel executions of the task execution window is reduced. When the system pressure exceeds the second threshold, the window latency of the task execution window is increased, i.e., the delayed execution mode is entered, the window latency is increased, and the system is given recovery time. After the system pressure returns to a normal level, the delayed execution mode is exited.
[0124] In yet another alternative embodiment, the queue index of the initial task queue and the window index of the task execution window are adjusted when the system pressure exceeds a preset threshold. It should be noted that the specific scheme of adjusting the queue index of the initial task queue and the window index of the task execution window is described in detail in the above embodiments, and will not be repeated here.
[0125] In an embodiment, the system pressure is determined according to the index parameter of the target index of the computer device, which realizes the quantitative processing of the computer device in terms of running pressure. When the system pressure exceeds a preset threshold, the queue index of the initial task queue and / or the window index of the task execution window is adjusted, which not only realizes the adaptive adjustment of the computer device, automatically optimizes system resources, and guarantees the safe and stable operation of the system, but also effectively avoids the situation of system resource shortage and resource exhaustion.
[0126] On the basis of the above embodiments, in an exemplary embodiment, in order to reduce the influence of historical data on future task execution scheduling, as shown in Figure 10 An alternative embodiment of a task execution method includes:
[0127] S1001, when the time length between the current time and the last update time reaches a preset time length, the number of executed tasks of each initial task queue is adjusted.
[0128] In an alternative embodiment, a preset update period is configured, and when the current period ends, i.e., when the time length between the current time and the last update time reaches a preset time length, the number of executed tasks of each initial task queue is adjusted.
[0129] In another alternative embodiment, a decay timer is configured in the computer device, and based on the decay timer (e.g., when the timing time length reaches the timing time length), it is determined that the time length between the current time and the last update time reaches a preset time length, and the number of executed tasks of each initial task queue is adjusted.
[0130] In the embodiment, the optional implementation of adjusting the executed task quantity of each initial task queue is to obtain a decay value of each initial task queue. Based on the decay value of each initial task queue, the decay processing (for example, the executed task quantity is subtracted by the decay value) is performed on the executed task quantity of each initial task queue, to obtain the processed executed task quantity of each initial task queue. The decay values of the initial task queues can be the same or different.
[0131] In the embodiment, another optional implementation of adjusting the executed task quantity of each initial task queue is to determine the decay value of each initial task queue according to the queue priority of each initial task queue. For example, the decay value of each initial task queue can be determined according to the queue priority of each initial task queue by using a lookup table method. Based on the decay value of each initial task queue, the decay processing (for example, the executed task quantity is subtracted by the decay value) is performed on the executed task quantity of each initial task queue, to obtain the processed executed task quantity of each initial task queue.
[0132] In the embodiment, by configuring a preset time length, the executed task quantity of each initial task queue is adjusted when the time length between the current time and the last update time reaches the preset time length. The decay processing of the executed task quantity of each initial task queue is performed to gradually reduce the influence of historical data on future task execution scheduling, so that the task scheduling result is more suitable for the current system state.
[0133] Based on the above embodiments, in an exemplary embodiment, as shown in Figure 11 The task execution method can include the following steps:
[0134] S1101, when receiving a to-be-processed task, the to-be-processed task is assigned to an initial task queue matching the task priority according to the task priority of the to-be-processed task and the queue priority of each initial task queue.
[0135] S1102, when the number of tasks being executed in the task execution window is lower than the number threshold, it is determined that there is a task in each initial task queue.
[0136] S1103, the initial task queue with the to-be-processed task is taken as a candidate task queue.
[0137] S1104, the expected execution task proportion of each candidate task queue is determined according to the queue priority of each candidate task queue.
[0138] S1105, the total number of executed tasks is determined according to the executed task quantity of each candidate task queue.
[0139] S1106, determine the actual execution task proportion of each candidate task queue according to the total number of executed tasks and the number of executed tasks of each candidate task queue.
[0140] S1107, for each candidate task queue, determine the proportion difference between the actual execution task proportion and the expected task execution proportion of the candidate task queue.
[0141] S1108, determine the number of candidate task queues with the smallest proportion difference.
[0142] S1109, if the number of candidate task queues with the smallest proportion difference is one, then the candidate task queue with the smallest proportion difference is selected as the target task queue.
[0143] S1110, if the number of candidate task queues with the smallest proportion difference is at least two, then the target task queue is selected from the candidate task queues with the smallest proportion difference according to the queue priority of the candidate task queues with the smallest proportion difference.
[0144] S1111, select a target task from the to-be-processed tasks of the target task queue, and add the target task to the task execution window to execute the target task.
[0145] The embodiment also includes a system adaptive adjustment process, and the specific scheme is as follows:
[0146] According to the index parameter of the target index of the computer device, the system pressure is determined. The target index includes performance index and / or load index.
[0147] In the case where the system pressure exceeds the preset threshold, the queue index of the initial task queue and / or the window index of the task execution window are adjusted. The queue index includes at least one of the expected execution task proportion, the queue length and the task quantity; the window index includes at least one of the window size, the delayed execution mode and the delayed execution time.
[0148] The embodiment also includes a process of attenuating the number of executed tasks of each candidate task queue, and the specific scheme is as follows:
[0149] In the case where the time length between the current time and the last update time reaches the preset time length, the number of executed tasks of each initial task queue is adjusted.
[0150] It should be understood that although each step in the flowchart involved in each embodiment as described above is shown in sequence according to the direction of the arrow, these steps are not necessarily executed in the order indicated by the arrow. Unless explicitly stated herein, there is no strict order limitation for the execution of these steps, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps. It can be understood that the steps in different embodiments can be freely combined as needed, and various non-contradictory schemes formed by the combination are within the scope of protection of the present application.
[0151] Based on the same inventive concept, the embodiments of the present application also provide a task execution device for implementing the above-mentioned task execution method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more task execution device embodiments provided below can refer to the limitations of the task execution method in the above text, which will not be repeated here.
[0152] In one exemplary embodiment, as shown in Figure 12 a task execution device is provided, applied to a computer device, comprising: a selection module 10 and an adding module 20; wherein,
[0153] The selection module 10 is configured to, in a case where the number of tasks being executed in the task execution window is less than a quantity threshold, select a target task queue from each candidate task queue according to the number of executed tasks of each candidate task queue and the expected task execution proportion; wherein the number of executed tasks of each candidate task queue is the number of tasks in the candidate task queue that have been added to the task execution window.
[0154] The adding module 20 is configured to select a target task from the to-be-processed tasks of the target task queue and add the target task to the task execution window to execute the target task, wherein:
[0155] In one embodiment, the selection module 20 is further configured to:
[0156] determine the total number of executed tasks according to the number of executed tasks of each candidate task queue;
[0157] determine the actual execution task proportion of each candidate task queue according to the total number of executed tasks and the number of executed tasks of each candidate task queue;
[0158] According to the actual execution task proportion and the expected task execution proportion of each candidate task queue, a target task queue is selected from the candidate task queues.
[0159] In one of the embodiments, the selection module 20 is further specifically configured to:
[0160] For each candidate task queue, a proportion difference value between the actual execution task proportion and the expected task execution proportion of the candidate task queue is determined.
[0161] The candidate task queue with the minimum proportion difference value is selected as the target task queue.
[0162] In one of the embodiments, the selection module 20 is further specifically configured to:
[0163] If the number of the candidate task queues with the minimum proportion difference value is at least two, the target task queue is selected from the candidate task queues with the minimum proportion difference value according to the queue priorities of the candidate task queues with the minimum proportion difference value.
[0164] In one of the embodiments, the task execution device in the task execution device, Figure 12 In one of the embodiments, the task execution device in the task execution device,
[0165] The first determination module is configured to determine the expected execution task proportion of each candidate task queue according to the queue priorities of the candidate task queues.
[0166] In one of the embodiments, the task execution device in the task execution device, Figure 12 In one of the embodiments, the task execution device in the task execution device,
[0167] The second determination module is configured to determine the task existence in each initial task queue in the case that the number of tasks being executed in the task execution window is lower than the number threshold.
[0168] The third determination module is configured to select the initial task queue with the task existence of the existing to-be-processed task as the candidate task queue.
[0169] In one of the embodiments, the task execution device in the task execution device, Figure 12 In one of the embodiments, the task execution device in the task execution device,
[0170] The distribution module is configured to, in the case that the to-be-processed task is received, distribute the to-be-processed task to the initial task queue matching the task priority according to the task priority of the to-be-processed task and the queue priorities of each initial task queue.
[0171] In one of the embodiments, the task execution device in the task execution device, Figure 12 In one of the embodiments, the task execution device in the task execution device,
[0172] The fourth determining module is used to determine the system pressure based on the indicator parameters of the target indicators of the computer equipment; wherein the target indicators include performance indicators and / or load indicators.
[0173] If the system pressure exceeds a preset threshold, adjust the queue index of the initial task queue and / or the window index of the task execution window; wherein, the queue index includes at least one of the expected execution task percentage, queue length, and number of tasks; the window index includes at least one of the window size, delayed execution mode, and delayed execution time.
[0174] In one embodiment, the upper Figure 12 One of the task execution devices in the invention further includes:
[0175] The adjustment module is used to adjust the number of executed tasks in each initial task queue when the time between the current time and the previous update time reaches a preset duration.
[0176] Each module in the aforementioned task execution device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0177] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 13 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores task queue-related information. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a task execution method.
[0178] Those skilled in the art will understand that Figure 13The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0179] In an exemplary embodiment, a computer device is provided, comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.
[0180] In an embodiment, a computer readable storage medium is provided, storing a computer program, and the computer program implementing the steps in the above method embodiments when executed by a processor.
[0181] In an embodiment, a computer program product is provided, comprising a computer program, and the computer program implementing the steps in the above method embodiments when executed by a processor.
[0182] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.
[0183] The technical features of the above embodiments can be combined in any manner. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not exist contradictions, they should be considered as the scope of the present application.
[0184] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A task execution method characterized by, The method is applied to a computer device, and the method comprises: In a case where a number of tasks being executed in a task execution window is lower than a number threshold, a target task queue is selected from each candidate task queue according to an executed task number and an expected task execution proportion of each candidate task queue; the executed task number of each candidate task queue is a number of tasks in the candidate task queue that have been added to the task execution window; A target task is selected from a to-be-processed task in the target task queue, and the target task is added to the task execution window to execute the target task.
2. The method of claim 1, wherein, The target task queue is selected from each candidate task queue according to the executed task number and the expected task execution proportion of each candidate task queue, and the method comprises: A total number of executed tasks is determined according to the executed task number of each candidate task queue; An actual execution task proportion of each candidate task queue is determined according to the total number of executed tasks and the executed task number of each candidate task queue; The target task queue is selected from each candidate task queue according to the actual execution task proportion and the expected task execution proportion of each candidate task queue.
3. The method of claim 2, wherein, The target task queue is selected from each candidate task queue according to the executed task proportion and the expected task execution proportion of each candidate task queue, and the method comprises: For each candidate task queue, a proportion difference value between the actual execution task proportion and the expected task execution proportion of the candidate task queue is determined; The candidate task queue with the minimum proportion difference value is selected as the target task queue.
4. The method of claim 3, wherein, The candidate task queue with the minimum proportion difference value is selected as the target task queue, and the method comprises: If the number of candidate task queues with the minimum proportion difference value is at least two, a target task queue is selected from the candidate task queues with the minimum proportion difference value according to a queue priority of the candidate task queues with the minimum proportion difference value.
5. The method of claim 1, wherein, The method further comprises: An expected execution task proportion of each candidate task queue is determined according to a queue priority of each candidate task queue.
6. The method of claim 1, wherein, The method further comprises: In a case where a number of tasks being executed in a task execution window is lower than a number threshold, a task existence condition in each initial task queue is determined; An initial task queue with a to-be-processed task in the task existence condition is selected as the candidate task queue.
7. The method of claim 6, wherein, The method further comprises: In a case where a to-be-processed task is received, the to-be-processed task is distributed to an initial task queue matching a task priority of the to-be-processed task according to the task priority and a queue priority of each initial task queue.
8. The method of claim 6, wherein, The method further comprises: A system pressure is determined according to an index parameter of a target index of the computer device; the target index comprises a performance index and / or a load index; In a case where the system pressure exceeds a preset threshold, a queue index of the initial task queue and / or a window index of the task execution window are adjusted; the queue index comprises at least one of an expected execution task proportion, a queue length and a task number; the window index comprises at least one of a window size, a deferred execution mode and a deferred execution time.
9. The method of claim 6, wherein, The method further comprises: In a case where a time length between the current time and the last update time reaches a preset time length, the executed task quantity of each initial task queue is adjusted.
10. A task execution apparatus characterized by comprising: The device is configured in a computer device, and the device comprises: The selection module is configured to, in a case where a task quantity of tasks being executed in a task execution window is lower than a quantity threshold, select a target task queue from each candidate task queue according to an executed task quantity and an expected task execution proportion of each candidate task queue; wherein the executed task quantity of each candidate task queue is a task quantity of tasks in the candidate task queue that have been added to the task execution window. The adding module is configured to select a target task from a to-be-processed task of the target task queue, and add the target task to the task execution window to execute the target task. 11.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-10 when the computer program is executed by the processor. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 9.
12. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 9.