Task processing method, system, electronic device, medium and product
By separating the high and low priority task queues in the non-unified memory access architecture nodes, prioritizing high priority tasks and pausing when low priority tasks are detected, the problem of untimely task scheduling in the existing technology is solved, and task processing efficiency and system performance are improved.
Patent Information
- Application Number
- CN202510866082.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-06-26
AI Technical Summary
In the prior art, task scheduling strategies cannot efficiently and reasonably handle tasks of different priority levels, resulting in emergency tasks that may not be processed in time, and frequent use of lock mechanisms leads to degradation of system performance.
In the non-unified memory access architecture node, two execution queues are divided into first type tasks (high priority) and second type tasks (low priority) to prioritize the processing of the first type tasks, and pause processing when the second type of task is detected to ensure that high priority tasks are executed first, avoid the situation where multiple cores strive for the same task, and reduce the use of lock mechanisms.
It realizes timely processing of high-priority tasks, improves task processing efficiency and system performance, avoids performance loss of memory access across non-unified memory access architecture nodes, and ensures that low-priority tasks can also be processed in a timely manner.
Smart Images

Figure CN120386607B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of high-performance computing technology, and in particular to a task processing method, system, electronic equipment, medium and product. Background Art
[0002] In various systems such as computer systems and industrial control systems, there are a large number of tasks of different types and priorities that need to be processed. To process these tasks, different task scheduling strategies have been proposed in related technologies, such as single priority queue scheduling strategy and simple round-robin scheduling strategy.
[0003] In a single-priority queue scheduling strategy, all tasks are arranged in a single priority order and scheduled sequentially. However, when an urgent task arises, if a large number of ordinary tasks are already waiting in the queue, the urgent task may have to wait a long time before being scheduled, resulting in an untimely system response. In a simple round-robin scheduling strategy, each task is scheduled sequentially at fixed time intervals. Because this strategy treats urgent tasks and ordinary tasks equally, urgent tasks may not be processed in a timely manner. During the task scheduling process, multiple cores request tasks from the task priority queue. To ensure the correctness of concurrent access and data consistency, tasks are usually locked. However, frequent use of locking mechanisms to coordinate multi-core task allocation can lead to reduced system performance.
[0004] It can be seen that providing an efficient and reasonable task scheduling solution is a technical problem that people in this field urgently need to solve. Summary of the Invention
[0005] The present invention provides a task processing method, system, electronic device, medium and product to at least solve the problem in related technologies that tasks cannot be scheduled efficiently and reasonably.
[0006] The present invention provides a task processing method, which is applied to a non-uniform memory access architecture node, comprising:
[0007] Responding to a task execution request and determining tasks to be executed according to the task execution request;
[0008] If the tasks to be executed include both first-type tasks and second-type tasks, the first-type tasks are sent to the first-type execution queue in the scheduling domain within the node. After the first-type tasks are sent, the second-type tasks are sent to the second-type execution queue in the scheduling domain within the node. The priority of the first-type tasks is higher than the priority of the second-type tasks. The priority of the first-type execution queue is higher than the priority of the second-type execution queue.
[0009] During the process of distributing the second type of tasks, when it is detected that the tasks to be executed include the first type of tasks, the distribution of the second type of tasks is stopped, and the process returns to the step of sending the first type of tasks to the first type execution queue in the scheduling domain within the node;
[0010] The processor core in the node is controlled to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queue.
[0011] The beneficial effects of the present invention are that, firstly, when there are first-type tasks and second-type tasks of different priorities in the tasks to be executed, the first-type tasks, i.e., the tasks with high priority, are preferentially sent to the first-type execution queue in the scheduling domain within the current node, and the processor cores within the current node execute the tasks in the order of priority of the execution queues. Therefore, the first-type tasks in the first-type execution queue are executed preferentially, ensuring that the tasks with high priority can be sent and executed preferentially, and timely processing of the tasks with high priority is achieved. Secondly, compared with the method in which multiple cores actively request tasks from the queue, which requires locking the tasks, in the method provided by the present invention, the tasks obtained by the processor cores in the scheduling domain are sent by the current node, and there is no situation in which multiple cores compete for the same task, so there is no need to lock the tasks, thereby improving the efficiency of task processing. and improves the performance of the system; thirdly, in this method, tasks are issued within the non-uniform memory access architecture node and the processor core in the scheduling domain corresponding to the non-uniform memory access architecture node is used to execute the tasks, thereby avoiding the performance loss of memory access across the non-uniform memory access architecture node; in addition, after the first type of task is issued, the second type of task, that is, the low-priority task, is issued to the second type of execution queue in the scheduling domain within this node, thereby ensuring that the low-priority task can also be processed in a timely manner, and, in the process of distributing the second type of task, when it is detected that the first type of task is included in the tasks to be executed, the distribution of the second type of task is stopped, and the first type of task is continued to be issued to the first type of execution queue in the scheduling domain within this node, thereby further ensuring that the first type of task, that is, the high-priority task, can be processed in a timely manner, thereby improving the efficiency of task processing.
[0012] The present invention also provides a task processing system, the task processing system is located in a non-uniform memory access architecture node, and the task processing system includes a first-level scheduler and a second-level scheduler;
[0013] The first-level scheduler is used to respond to a task execution request and determine the tasks to be executed included in the task execution request; if the tasks to be executed include both first-type tasks and second-type tasks, the first-type tasks are sent to the first-type execution queue in the scheduling domain within the current node, and after the first-type tasks are sent, the second-type tasks are sent to the second-type execution queue in the scheduling domain within the current node; wherein the priority of the first-type tasks is higher than the priority of the second-type tasks; the priority of the first-type execution queue is higher than the priority of the second-type execution queue; in the process of distributing the second-type tasks, when it is detected that the tasks to be executed include the first-type tasks, the second-type tasks are stopped from being distributed, and the process returns to the step of sending the first-type tasks to the first-type execution queue in the scheduling domain within the current node;
[0014] The secondary scheduler is used to control the processor core in the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queue.
[0015] The present invention also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any one of the above-mentioned task processing methods when executing the computer program.
[0016] The present invention also provides a non-volatile storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned task processing methods are implemented.
[0017] The present invention also provides a computer program product, comprising a computer program, which implements the steps of any of the above-mentioned task processing methods when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0019] Figure 1 A schematic diagram of a non-uniform memory access architecture node is provided for an embodiment of the present invention;
[0020] Figure 2 A flowchart of a task processing method provided by an embodiment of the present invention;
[0021] Figure 3 A schematic diagram of a multi-priority task queue module provided by an embodiment of the present invention;
[0022] Figure 4 A flowchart of a task issuing method provided by an embodiment of the present invention;
[0023] Figure 5 A schematic diagram of task distribution provided by an embodiment of the present invention;
[0024] Figure 6 A flowchart of a method for executing a task provided by an embodiment of the present invention;
[0025] Figure 7 An architectural diagram of a node scheduling domain of a non-uniform memory access architecture provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.
[0027] It should be noted that, in the description of the present invention, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. The terms "first," "second," etc., in the present invention are used to distinguish similar objects, and are not used to describe a particular order or precedence.
[0028] In order to enable those skilled in the art to better understand the solutions of the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods. Figure 1 A schematic diagram of a non-uniform memory access architecture node is provided for an embodiment of the present invention, such as Figure 1 As shown, each scheduling domain corresponds to a specific non-uniform memory access (NUMAA) node. It includes a first-level scheduler (for issuing tasks) and a second-level scheduler (for executing tasks). The domain contains multiple executors fixed by central processing unit (CPU) core binding technology. The task processor method provided by the present invention is applied to non-uniform memory access architecture nodes. Non-uniform memory access architecture is a design pattern for multi-core processors. A scheduling domain (Scheduling Domain) is a logical execution unit consisting of a group of CPU cores with the same NUMA node. Figure 2A flowchart of a task processing method provided by an embodiment of the present invention. The task processing method is applied to a non-uniform memory access architecture node. The method includes two processes: task dispatching and task execution. It is worth noting that when there are tasks in the first type execution queue and / or the second type execution queue, the task execution step can be performed. Figure 2 As shown, task issuance corresponds to steps S10 to S12, and task execution corresponds to step S13. Specifically:
[0029] S10: Responding to the task execution request and determining the tasks to be executed included in the task execution request.
[0030] S11: If the tasks to be executed include both first-type tasks and second-type tasks, the first-type tasks are sent to the first-type execution queue in the scheduling domain within the current node. After the first-type tasks are sent, the second-type tasks are sent to the second-type execution queue in the scheduling domain within the current node.
[0031] The priority of the first type of task is higher than that of the second type of task; and the priority of the first type of execution queue is higher than that of the second type of execution queue.
[0032] S12: During the process of distributing the second type of tasks, when it is detected that the tasks to be executed include the first type of tasks, the distribution of the second type of tasks is stopped and the process returns to step S11.
[0033] S13: Control the processor core in the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queues.
[0034] The task execution request may be sent by the user. That is, the non-uniform memory access architecture node receives the task execution request sent by the user. There is no limitation on the task execution request, which is determined according to the actual situation. The tasks to be executed are determined according to the task execution request. The tasks to be executed may include only the first type of tasks, or only the second type of tasks, or both the first type of tasks and the second type of tasks. In the present invention, the priority of the first type of tasks is higher than the priority of the second type of tasks. Assume that the first type of tasks are special-purpose tasks, such as system maintenance tasks, emergency alarm tasks, etc.; the second type of tasks are ordinary tasks, such as data processing tasks, user request tasks, etc. In order to obtain the situation of the first type of tasks and the second type of tasks included in the tasks to be executed, in implementation, the first type of tasks and the second type of tasks can be placed in the queue respectively. If the queue is empty, it means that there is no task; if the queue is not empty, it means that the task exists.
[0035] Specifically, after detecting that the tasks to be executed include both the first type tasks and the second type tasks, and before sending the first type tasks to the first type execution queue in the scheduling domain within the node, the method further includes:
[0036] The first type of tasks are stored in a first type of queue and the second type of tasks are stored in a second type of queue; wherein the priority of the first type of queue is higher than the priority of the second type of queue.
[0037] For example, the first type of queue is called a special-purpose task queue, and the second type of queue is called a general task queue.
[0038] In practice, there may be multiple tasks (first-type tasks and / or second-type tasks). To ensure that each task can be processed, the first-type queue and / or the second-type queue contain multiple queues with different priorities, and tasks within the same queue have different priorities. There is no limit on the number of queues in each type of queue and it is set based on actual conditions.
[0039] There is no limit on the order of setting task priorities, which can be determined based on actual conditions. In order to prioritize tasks with shorter execution times and reduce task waiting time, tasks with shorter execution times can be given higher priorities during implementation. Determining task priorities includes:
[0040] Obtaining the execution time of the task using a model for predicting the execution time of the task;
[0041] Set the priority for each task in order of execution time from shortest to longest;
[0042] The method of obtaining the task execution time by using the model for predicting the task execution time includes:
[0043] Obtain historical task data and extract target features related to task execution time from the historical task data; wherein the target features include task type, task size, number of concurrent tasks and / or hardware resource status;
[0044] The target features corresponding to the historical task data are used as the input of the model, and the actual execution time is used as the output of the model to train the model to obtain a model for predicting the execution time of the task;
[0045] After receiving the task, extract the features of the task;
[0046] Inputting the task features into a model for predicting the execution time of the task;
[0047] The execution time of the task is output by the model used to predict the execution time of the task.
[0048] In implementation, the task execution time prediction includes the following steps:
[0049] ①Data collection and feature extraction:
[0050] Data collection: Collect historical task data, including task characteristics (such as task type, task size, resource requirements, etc.) and actual execution time.
[0051] Feature extraction: Extract features that are highly correlated with task execution time from historical task data, including:
[0052] Task type: Different types of tasks may have different execution time patterns.
[0053] Task size: The computational size of a task directly affects the execution time.
[0054] Resource requirements: including CPU usage, memory usage, disk input / output (I / O), network bandwidth, etc.
[0055] Historical execution time: The execution time of a task in the past can serve as an important reference.
[0056] Number of concurrent tasks: The number of tasks currently being executed in the system.
[0057] Hardware resource status: The current system hardware resource utilization (such as CPU, memory, disk, network, etc.).
[0058] Data preprocessing: Clean and preprocess the data, remove outliers and missing values, and standardize or normalize the data to facilitate model training.
[0059] ② Feature selection and optimization:
[0060] Feature selection: Select the features that have the greatest impact on task execution time prediction from the extracted features. Feature selection can be done using feature importance analysis (such as tree-based feature importance) or correlation analysis.
[0061] Feature optimization: Further optimize the selected features, such as feature combination and feature dimensionality reduction, to improve the predictive performance of the model.
[0062] ③Model selection and training:
[0063] Model selection: Choose an appropriate machine learning model, such as a neural network (such as a Long Short-Term Memory Network (LSTM) or a Transformer), which can handle complex nonlinear relationships.
[0064] Feature Engineering: Construct a feature matrix, taking the features of the task as input and the actual execution time as output.
[0065] Model training: Use historical data to train the model, adjust model parameters through methods such as cross-validation, and optimize model performance.
[0066] ④Model evaluation and optimization:
[0067] Evaluation indicators: Use indicators such as Mean Squared Error (MSE) and Mean Absolute Error (MAE) to evaluate the prediction error of the model.
[0068] Optimization: Optimize the model based on the evaluation results, such as adjusting model parameters, selecting different feature combinations, trying different algorithms, etc.
[0069] ⑤Task execution time prediction:
[0070] Predicted execution time: For tasks that are new to the system, their features are extracted and input into the trained prediction model. The model will then output the predicted execution time for the task.
[0071] Optimize task distribution: Optimize task distribution and scheduling strategies based on predicted execution time, prioritize tasks with short execution times, and reduce task waiting time.
[0072] In this method, the model-based prediction method predicts the execution time of tasks and sets a higher priority for tasks with shorter execution times, thereby preventing these tasks from having to wait for a long time. In practice, other methods can also be used to set task priorities, which are not limited here.
[0073] In addition, to improve task processing efficiency, tasks are sent to the execution queues in the scheduling domain within the node, including:
[0074] Get the predicted task execution time;
[0075] When it is detected that the execution time of a task is greater than the preset time, the task is split into multiple subtasks and the priorities of the subtasks are set;
[0076] Subtasks are dispatched to the execution queue in the scheduling domain within this node according to their priority.
[0077] The preset time can be determined according to the actual situation. In this method, for tasks that take a long time to execute, try to split them into multiple subtasks and execute them in parallel to further improve task processing efficiency.
[0078] After setting the priority, in order to avoid low-priority tasks waiting for a long time, the priority of the low-priority tasks can be further adjusted. Specifically, the task processing method also includes:
[0079] From the start of task delivery in the second type queue to the target time, a target queue whose waiting time for task processing is longer than the preset time is obtained from the second type queue;
[0080] Place the target task in the target queue into the previous queue of the target queue, and use the previous queue of the target queue as the new target queue;
[0081] When it is detected that the target task has not been issued, obtaining the number of tasks in the second type queue that have been issued between the time when the task in the target queue is placed in the queue before the target queue and the new target time;
[0082] If the number of tasks sent reaches the preset value, the process returns to the step of placing the target task in the target queue into the previous queue of the target queue;
[0083] If it is detected that the target task is being issued, the priority of the task in the target queue remains unchanged.
[0084] There is no limit on the preset duration and preset value, which are determined based on actual conditions. For example, if a task in a priority 5 queue in the second type of queue waits for a long time, the priority of the task in the priority 5 queue will be raised to priority 4, that is, the task in the priority 5 queue will be placed in the priority 4 queue; if the task is not executed after 1000 tasks are completed, the priority of the task in the priority 4 queue will be further raised to priority 3, that is, the task in the priority 4 queue will be placed in the priority 3 queue; if the task is not executed after another 500 tasks are completed, the priority of the task in the priority 3 queue will be further raised to priority 2.
[0085] This method takes into account that in real-world applications, task priorities may change based on the system's operating status, resource usage, and real-time user needs. Therefore, we further investigated a dynamic adjustment mechanism for task priorities, enabling the system to dynamically adjust task priorities based on real-time conditions, thereby better adapting to complex and changing task scheduling scenarios. This method also uses a step-by-step approach to adjust the priorities of lower-priority tasks. This ensures that subsequent tasks are not left waiting while also ensuring that higher-priority tasks at the front are prioritized.
[0086] By setting up a first type queue and a second type queue for storing tasks, tasks are placed in the queues in order of priority, so that tasks can be dispatched in order of priority. To improve system performance, in implementation, tasks are dispatched to the processor cores within the non-uniform memory access architecture node for execution.
[0087] Similarly, in order to ensure that tasks with high priority can be executed first, a first type of execution queue and a second type of execution queue are set up in the scheduling domain within this node. If the tasks to be executed only include first type tasks, the first type of tasks will be distributed to the first type of execution queue in the scheduling domain within this node; if the tasks to be executed only include second type tasks, the second type of tasks will be distributed to the second type of execution queue in the scheduling domain within this node. If the tasks to be executed include both first type tasks and second type tasks, the first type of tasks will be sent to the first type of execution queue in the scheduling domain within this node. After the first type of tasks are sent, the second type of tasks will be sent to the second type of execution queue in the scheduling domain within this node. At the same time, the priority of the first type of execution queue is set higher than the priority of the second type of execution queue. In implementation, the first type of execution queue can be called an emergency task queue, and the second type of execution queue can be called a ready queue.
[0088] In order to ensure that tasks can be processed in a timely manner, sending the first type of tasks to the first type of execution queue in the scheduling domain within the current node includes: sending the first type of tasks to the first type of execution queue in the scheduling domain within the current node according to the priority order of the tasks in the first type of queue.
[0089] Sending the second type of tasks to the second type of execution queue in the scheduling domain within the current node includes sending the second type of tasks to the second type of execution queue in the scheduling domain within the current node according to the priority order of the tasks in the second type of queue.
[0090] When the second type queue includes multiple queues with different priorities, in order to automatically switch the second type queue, in implementation, the second type tasks are dispatched to the second type execution queue in the scheduling domain of the local node according to the priority order of the tasks in the second type queue, including:
[0091] Sending the second type tasks in the queue with the highest priority in the second type queues to the second type execution queue in the scheduling domain within the node;
[0092] Obtain the task status of the highest priority queue; wherein the task status of the queue includes at least whether there is a task in the queue and the dispatch status of the task in the queue;
[0093] When it is detected that the task situation in the highest priority queue meets the preset requirements, the next queue of the highest priority queue is used as the new highest priority queue, and the step of sending the second type of tasks in the highest priority queue in the second type of queue is returned to the second type of execution queue in the scheduling domain within this node; wherein the preset requirements are that there are no tasks in the highest priority queue, or the number of tasks sent in the highest priority queue is greater than or equal to the preset number.
[0094] If it is detected that the task status in the current queue does not meet the preset requirements, the second type of tasks in the current queue will be kept from being issued. At this time, the preset requirements are that there are tasks in the current queue and the number of tasks issued is less than the preset number.
[0095] There is no limit on the preset number and it is determined based on actual conditions. In addition, to prevent tasks in low-priority second-type queues from waiting for too long, different queues in the second-type queue will have different preset numbers; the higher the priority of the queue, the larger the preset number.
[0096] Obtaining the number of tasks issued in the second type queue includes obtaining the number of tasks issued recorded in a counter corresponding to each queue in the second type queue. Specifically, a corresponding counter is set for each queue in the second type queue. Each time a task is issued by a queue, the value of the corresponding counter is incremented by 1.
[0097] Figure 3 A schematic diagram of a multi-priority task queue module provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the structure of the multi-priority task queue includes special-purpose queues and ordinary priority queues. Task queues with different numbers represent different priorities. The higher the priority, the higher the priority the task will be scheduled. The special-purpose queue includes three priority queues. The queue with priority 0 contains three tasks, namely Task 1, Task 2, and Task 3; the queue with priority 1 contains one task, Task 4; and the queue with priority 2 contains one task, Task 5. The ordinary priority queue includes multiple task queues. For example, the queue with priority 4 contains two tasks, namely Task 9 and Task 10; the queue with priority 5 is empty, that is, there are 0 tasks. Each queue in the ordinary priority queue has a corresponding counter. The initial value of the counter is 0. Different queues correspond to different counting thresholds (i.e., the preset number described above), and the counting threshold set for the queue with higher priority is greater than the counting threshold of the queue with lower priority. Figure 3 In [1], the counting thresholds set for queues with priorities of 3 to 7 are 600, 500, 400, 300, and 100, respectively. The counting thresholds set for queues with priorities of 7 to N are all 100.
[0098] After using the counter to count, in order to avoid the influence of the previously recorded value on the counting result. In this embodiment, the count value of the counter can be cleared. Specifically, the task processing method also includes: when it is detected that all queues in the second type queue are empty, or the numbers recorded by the counters corresponding to all queues in the second type queue have reached a preset number, or the numbers recorded by the counters corresponding to some queues in the second type queue have reached a preset number, and the queues corresponding to the queues that have not reached the preset number are empty, the counters corresponding to all queues in the second type queue are cleared.
[0099] In order to ensure that the tasks in the second type queue can also be issued in a timely manner, after the first type tasks are issued, the second type tasks are issued to the second type execution queue in the scheduling domain within this node. It is worth noting that in the process of issuing the second type tasks to the second type execution queue in the scheduling domain within this node, first type tasks may also appear in the tasks to be executed. At this time, in order to ensure that the first type tasks can be discovered and processed in a timely manner, in the process of distributing the second type tasks, when it is detected that the tasks to be executed include the first type tasks, the distribution of the second type tasks is stopped, and the process returns to the step of issuing the first type tasks to the first type execution queue in the scheduling domain within this node.
[0100] To better understand the above distribution rules, the following describes them using a specific task as an example. When there are tasks in a special-purpose task queue, they are dispatched to the urgent queues of all processor cores in the scheduling domain, in order of their priority. When there are no tasks in the special-purpose task queue, they are dispatched to the ready queues of all processor cores in the scheduling domain, in order of their priority. Each priority level in the ordinary task queue corresponds to a counter. When there are no tasks in the queue or the counter reaches a set value, tasks are dispatched to other task queues. Each time a task is dispatched from a ordinary task queue, the corresponding counter is incremented, and the special-purpose task queue is rechecked for new tasks. If there are new tasks, tasks in the special-purpose task queue are dispatched to the urgent queue first; if not, tasks in the ordinary task queue continue to be dispatched. When the counters of all ordinary task queues reach the set value, or when the counters of some ordinary task queues reach the set value and the queues that have not reached the set value are empty, the counters of all ordinary task queues are reset.
[0101] The following describes the task dispatching process described above by taking the first type queue as a special-purpose task queue, the second type queue as a common task queue, the first type execution queue as an emergency queue, and the second type execution queue as a ready queue as an example. Figure 4A flowchart of a task delivery method provided by an embodiment of the present invention is shown in FIG. Figure 4 The figure shows the task distribution process, including the processing logic of special-purpose task queues and general task queues, the role of counters, and the specific steps of task distribution. The method includes:
[0102] S14: Check whether there is a task in the special-purpose task queue; if so, proceed to step S15; if not, proceed to step S16;
[0103] S15: Select a task from the special-purpose task queue and put it into the emergency queue corresponding to the processor core;
[0104] S16: Select the highest priority queue in the common task queue;
[0105] S17: Determine whether the current queue satisfies the requirement that there are tasks in the current queue and the corresponding counter has not reached the threshold; if so, proceed to step S18; if not, proceed to step S20;
[0106] S18: Select a task from the common task queue and put it into the ready queue corresponding to the processor core;
[0107] S19: The task queue counter is incremented by 1; and the process returns to step S14;
[0108] S20: Determine whether one of the following conditions is met: all common task queues are empty, or the values recorded by all common task queue counters reach a threshold, or the counters of some common task queues reach a set value and the queues that do not reach the set value are empty; if not, proceed to step S21; if so, proceed to step S22;
[0109] S21: Switch to the next priority queue in the normal task queue;
[0110] S22: Reset the values of the counters of all common task queues to 0; return to step S14.
[0111] To further improve the flexibility and efficiency of task scheduling, the scheduling domain includes multiple processor cores. The execution queues that send tasks to the scheduling domain within this node include:
[0112] Obtain pre-established task delivery strategies;
[0113] According to the task delivery strategy, tasks are delivered to the execution queues corresponding to the processor cores contained in the scheduling domain within this node; wherein the tasks include first-type tasks and second-type tasks; and the execution queues corresponding to the processor cores include first-type execution queues and second-type execution queues.
[0114] Specifically, according to the task delivery strategy, the task is delivered to this node, and the execution queue corresponding to the processor core contained in the scheduling domain includes: obtaining the hardware resources on which the execution task depends; using the processor core in the scheduling domain containing the hardware resources on which the execution task depends as the target processor core; delivering the task to this node, and the execution queue corresponding to the target processor core contained in the scheduling domain.
[0115] This mechanism directs tasks to specific processor cores for execution. For tasks that rely on specific hardware resources, users can direct them to the processor core associated with that resource, improving task execution efficiency. This mechanism is particularly suitable for tasks with strict real-time requirements and explicit hardware resource dependencies, such as real-time audio and video processing. Users can direct these tasks to processor cores close to the audio or video input devices to reduce data transmission latency. Directed delivery allows users to assign tasks to specific processor cores for execution. This feature enhances the flexibility and controllability of task scheduling.
[0116] In addition to selecting a corresponding processor core for a task based on the hardware resources that the task depends on, in this embodiment, tasks are delivered to the local node according to the task delivery policy. The execution queues corresponding to the processor cores included in the scheduling domain include:
[0117] Obtaining the number of tasks in the first type execution queue and the number of tasks in the second type execution queue corresponding to each processor core in the scheduling domain;
[0118] Selecting a processor core with the least number of tasks in the first type execution queue from all processor cores in the scheduling domain, and using the selected processor core with the least number of tasks in the first type execution queue as a first target processor core;
[0119] Selecting a processor core with the least number of tasks in the second type execution queue from all processor cores in the scheduling domain, and using the selected processor core with the least number of tasks in the second type execution queue as a second target processor core;
[0120] The first type of task is sent to the first type of execution queue corresponding to the first target processor core included in the scheduling domain of the current node, and the second type of task is sent to the second type of execution queue corresponding to the second target processor core included in the scheduling domain of the current node.
[0121] When dispatching tasks, this method selects the queue corresponding to the processor core with the fewest tasks based on the number of tasks in the first and second type execution queues of the processor cores. This method considers load balancing when selecting the processor core to execute tasks. This method effectively prevents some processor cores from being overloaded while others remain idle, further improving system resource utilization and overall performance.
[0122] To further ensure load balancing on the processor cores, the task delivery strategy is to deliver a first-type task to the first-type execution queue of each processor core in the scheduling domain in turn, and then stop delivering tasks until there are no first-type tasks in the first-type queue.
[0123] Alternatively, the task delivery strategy is to sequentially deliver a second type task to the second type execution queue of each processor core in the scheduling domain, and stop delivering tasks until no second type task exists in the second type queue.
[0124] In order to facilitate the understanding of the above task distribution method, the following Figure 5 Provide explanation. Figure 5 A schematic diagram of task distribution provided by an embodiment of the present invention. Figure 5 As shown, there are two executors (physical units that actually execute tasks, consisting of bound CPU cores, i.e., processor cores). The scheduling process involves dispatching a task to the queue of each processor core within the scheduling domain in sequence, until no tasks are available in the priority task queues (such as the first and second type queues described above). The multi-priority task queues include queues from priority 0 to priority N. These queues are special-purpose task queues, while queues from priority 3 to priority N are standard task queues.
[0125] Figure 5In the scheduling domain, the task dispatching process is as follows: Task 1 in the priority 0 queue is dispatched to the urgent task queue corresponding to the left executor; Task 2 in the priority 0 queue is dispatched to the urgent task queue corresponding to the right executor; Task 3 in the priority 0 queue is dispatched to the urgent task queue corresponding to the left executor; Task 4 in the priority 1 queue is dispatched to the urgent task queue corresponding to the right executor; Task 5 in the priority 2 queue is dispatched to the urgent task queue corresponding to the left executor. Similarly, Tasks 6 and 8 in the priority 3 queue and Task 10 in the priority 4 queue are dispatched to the ready queue corresponding to the left executor; Task 7 in the priority 3 queue, Task 9 in the priority 4 queue, and Task 11 in the priority 6 queue are dispatched to the ready queue corresponding to the right executor. By dispatching a task to each queue in the scheduling domain, the load balancing of the processor cores is ensured as much as possible.
[0126] The above specifically describes the process of sending tasks to the execution queue of the scheduling domain within the node. The following describes the process of the processor core executing tasks. Similarly, to ensure that high-priority tasks can be executed in a timely manner, in practice, controlling the processor core within the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queues includes:
[0127] If the first-type execution queue and the second-type execution queue corresponding to the processor core in the node contain tasks, the first-type tasks are executed in the order of priority of the tasks in the first-type execution queue; after the first-type tasks are executed, the second-type tasks are executed in the order of priority of the tasks in the second-type execution queue;
[0128] During the execution of the second type of tasks, when it is detected that the first type of execution queue contains the first type of tasks, the execution of the second type of tasks is stopped and the process returns to the step of executing the first type of tasks in sequence according to the priority order of the tasks in the first type of execution queue.
[0129] The processor core executes tasks in the queue according to their priority order. It's worth noting that to improve task execution efficiency, the priority order of tasks in the queue can be adjusted. For example, machine learning algorithms can be used to predict task execution times and optimize task execution priorities based on the predicted results. Assuming a neural network model (such as the Transformer) is used to predict task execution times, the mathematical formula can be expressed as:
[0130] ;
[0131] in, represents the predicted task execution time; represents the parameters of the model, Represents a neural network model; The feature matrix representing the task includes task type, task size, CPU usage, memory usage, disk I / O, network bandwidth, historical execution time, number of concurrent tasks, hardware resource status, etc. Specifically, the feature matrix It can be expressed as:
[0132] ;
[0133] in, represents the number of samples of training data, represents the number of features, Indicates the The first sample Features, represents the characteristics of the first sample, Represents the characteristics of the second sample.
[0134] The training goal of the model is to minimize the error between the predicted value and the actual value, that is:
[0135] ;
[0136] in, Indicates the The actual execution time of each sample, Indicates the The predicted execution time for each sample.
[0137] Select the Transformer model for training. The model structure can be expressed as:
[0138] ;
[0139] Among them, Embedding represents the embedding layer, which maps the input features to a high-dimensional space; Encoder represents the encoder, which is used to extract high-level representations of features; MLP represents the Multi-Layer Perceptron, which is used for final prediction.
[0140] That is, use machine learning algorithms to predict the execution time of tasks and optimize the order of task execution based on the prediction results.
[0141] In addition, the priority of executing the task can be adjusted according to the resources required to execute the task. Before controlling the processor core in the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queue, the method further includes:
[0142] Obtaining resources that tasks in the first type execution queue depend on and obtaining resources that tasks in the second type execution queue depend on;
[0143] If it is detected that in the first type execution queue or the second type execution queue, the resources on which the high-priority task depends are different from the resources on which the low-priority task depends, the priority of the low-priority task is increased to obtain a new task priority order; and the step of controlling the processor core within this node to execute the first type of task in the first type execution queue and the second type of task in the second type execution queue according to the priority order of the execution queue is entered.
[0144] For example, low-priority tasks occupy fewer network resources, while high-priority tasks occupy more memory resources. If the resources required by low-priority tasks do not conflict with those of high-priority tasks, the priority of low-priority tasks can be increased so that low-priority tasks can use network resources.
[0145] In addition to adjusting the priority order of task execution based on task execution time as described above, the method provided in this embodiment takes into account that task execution is often subject to multiple resource constraints, such as CPU, memory, disk I / O, network bandwidth, etc. Therefore, it is possible to consider incorporating multiple resource dimensions into task scheduling, and perform comprehensive scheduling based on the task's demand for different resources and the system's resource usage, further improving the system's resource utilization and task processing efficiency.
[0146] In addition, there may be related tasks in practice. To ensure that the related tasks can be successfully executed, in implementation, the task processing method further includes: if it is detected that there is a related task with the task to be executed by the processor core, and the related task has not been sent to the execution queue corresponding to the processor core, migrating the task to be executed from the execution queue of the processor core back to the first type queue or the second type queue.
[0147] If data for task A is available, and task A+B is also available, but data for task B is missing, task A+B needs to be moved from the urgent queue back to the end of the priority queue. This ensures that task A+B is executed after task B's data is obtained, ensuring successful execution of task A+B.
[0148] When executing a task, each processor core determines the specific task to execute based on the status of tasks in the first and second type execution queues. The specific execution rules are as follows: Each time a task is executed, it first checks whether there are tasks in the first type execution queue. If there are tasks in the first type execution queue, the task in the first type execution queue is executed; if there are no tasks in the first type execution queue, the task in the second type execution queue is executed.
[0149] The following describes a method for each processor core to execute a task by taking the first type execution queue as an urgent queue and the second type execution queue as a ready queue as an example. Figure 6 A flowchart of a method for executing a task provided by an embodiment of the present invention is shown in FIG. Figure 6 As shown, the method includes:
[0150] S23: The current task is completed;
[0151] S24: Check whether there is a task in the emergency queue; if so, proceed to step S25; if not, proceed to step S26;
[0152] S25: Execute the emergency queue task; return to step S23;
[0153] S26: Execute the ready queue task; return to step S23.
[0154] That is, each time the processor core executes a task, it first checks whether there is a task in the urgent queue. If there is a task in the urgent queue, it executes the task in the urgent queue; if there is no task in the urgent queue, it executes the task in the ready queue.
[0155] To help those skilled in the art better understand the task processing method described above, the method is applied to a task processing system and the above process is further described below. An embodiment of the present invention provides a task processing system. The task processing system is located in a non-uniform memory access architecture node and includes a primary scheduler and a secondary scheduler.
[0156] The first-level scheduler is used to respond to task execution requests and determine the tasks to be executed included in the task execution requests; if the tasks to be executed include both first-type tasks and second-type tasks, the first-type tasks are sent to the first-type execution queue in the scheduling domain within the current node, and after the first-type tasks are sent, the second-type tasks are sent to the second-type execution queue in the scheduling domain within the current node; wherein, the priority of the first-type tasks is higher than the priority of the second-type tasks; the priority of the first-type execution queue is higher than the priority of the second-type execution queue; in the process of distributing the second-type tasks, when it is detected that the tasks to be executed include the first-type tasks, the distribution of the second-type tasks is stopped, and the process returns to the step of sending the first-type tasks to the first-type execution queue in the scheduling domain within the current node.
[0157] The secondary scheduler is used to control the processor core in the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queue.
[0158] Figure 7This is an architectural diagram of a node scheduling domain of a non-uniform memory access architecture provided by an embodiment of the present invention. Figure 7 As shown, a non-uniform memory access architecture node includes a primary scheduler and a secondary scheduler. The primary scheduler includes multiple priority task queues, where queues filled with dashed lines represent special-purpose task queues, and unfilled queues represent standard task queues. The secondary scheduler includes emergency queues and ready queues, where queues filled with dashed lines represent emergency queues, and unfilled queues represent ready queues. The primary scheduler manages priority task queues and dispatches tasks, while the secondary scheduler manages execution queues (including emergency queues and ready queues) and executes tasks. When dispatching tasks, the primary scheduler implements targeted delivery, considers load balancing, and sets timers.
[0159] When the task processing system executes the multi-priority task scheduling method, the steps included are as follows:
[0160] 1. During the system initialization phase, the first-level scheduler creates a multi-priority task queue, initializes the special-purpose task queue and the ordinary task queue, and assigns an initial value of 0 to the counter corresponding to the priority of each ordinary task queue.
[0161] Second, when a new task enters the system, it is added to the corresponding queue according to the task type (special-purpose task or ordinary task) and sorted in the queue according to the priority rules.
[0162] 3. The first-level scheduler performs task distribution:
[0163] First, check whether there are tasks in the special-purpose task queue. If so, send the tasks to the emergency queues of each executor under the scheduling domain in descending order of priority.
[0164] If there are no tasks in the special-purpose task queue, check the ordinary task queue. Start distributing tasks from the ordinary task queue with the highest priority. Each time a task is distributed, the corresponding counter is increased by 1. Immediately after distribution, check whether there are new tasks in the special-purpose task queue. If there are new tasks, suspend the distribution of ordinary tasks and give priority to the tasks in the special-purpose task queue. If there are no new tasks, continue to distribute tasks in the ordinary task queue. When an ordinary task queue has no tasks or its counter reaches the set value, it will transfer tasks to the ordinary task queue of the next priority. When the counters of all ordinary task queues reach the set value, or when the counters of some ordinary task queues reach the set value and the queues that have not reached the set value are empty, reset the counters of all ordinary task queues to 0.
[0165] 4. In the executor, after each task is executed, the secondary scheduler checks whether there is a task in the emergency queue. If there is, the emergency queue task is executed; if there is no task in the emergency queue, the ready queue task is executed.
[0166] In addition, the primary scheduler can prioritize tasks based on the predicted execution time, scheduling tasks with shorter execution times first to reduce task waiting time. For example, for two tasks with predicted execution times of T1 and T2, if T1 < T2, task 1 is preferentially distributed to the queue of the executor. Additionally, for tasks with longer execution times, the secondary scheduler can attempt to split them into multiple subtasks for parallel execution. For example, assuming the predicted execution time of a task is T, it can be split into k subtasks, each with a predicted execution time of T / k, thus improving task processing efficiency.
[0167] In the executor, after each task execution, the secondary scheduler checks whether there are tasks in the emergency queue. If there are, it executes the tasks in the emergency queue; if there are no tasks in the emergency queue, it executes the tasks in the ready queue. At the same time, machine learning algorithms are used to predict the execution time of tasks, and the task distribution and scheduling strategies are optimized based on the prediction results. For example, tasks with shorter execution times are preferentially scheduled to reduce task waiting time. Additionally, for tasks with longer execution times, they are attempted to be split into multiple subtasks for parallel execution to further improve task processing efficiency.
[0168] The system's NUMA-aware scheduling domain design has the following advantages:
[0169] Scheduling domain division: Each scheduling domain corresponds to a NUMA node, and the domain contains multiple core-bound executors (each executor is bound to 1 physical CPU core).
[0170] Lock distribution mechanism: Compared with the method where multiple cores actively obtain tasks, in this method, the primary scheduler distributes tasks in units of scheduling domains, and there is no situation where multiple cores request the same task, so there is no need to lock tasks. Additionally, it supports users to direct tasks to be delivered to a specified CPU core for execution, enhancing the flexibility and controllability of task scheduling. This mechanism is particularly suitable for tasks with high real-time requirements and clear dependencies on hardware resources, such as real-time audio and video processing tasks. Users can deliver them to the CPU core close to the audio or video input device to reduce data transmission latency. Additionally, when the load balancing algorithm distributes tasks, based on the number of tasks in the emergency queue and the ready queue in the computing executor, it selects to distribute tasks to the queue corresponding to the executor with the fewest tasks, effectively avoiding the situation where some executors are overloaded while others are idle, and further improving system resource utilization and overall performance.
[0171] Emergency Task Assurance: The secondary scheduler's emergency queue detection mechanism enables response to sudden emergency tasks within 10μs. (Note: When an executor is processing a long-running task, the emergency task must wait for the current task to complete.) Furthermore, machine learning algorithms are used to predict task execution times, optimizing task distribution and scheduling strategies based on these predictions. For example, tasks with shorter execution times are prioritized to reduce task wait times. Furthermore, for tasks with longer execution times, attempts are made to split them into multiple subtasks for parallel execution, further improving task processing efficiency.
[0172] In the task processing method provided by the present invention, by setting up multi-priority task queues, including special-purpose task queues and general task queues, the priority processing rules of different types of tasks are clarified; a two-level scheduling architecture of a primary scheduler and a secondary scheduler is adopted, the primary scheduler is responsible for task distribution, and the secondary scheduler is responsible for task execution. Through reasonable task distribution and execution strategies, effective scheduling of multi-priority tasks can be achieved, while ensuring the priority execution of special-purpose tasks, taking into account the execution efficiency of general tasks, thereby improving the overall resource utilization and task processing capabilities of the system.
[0173] Specifically, this method achieves:
[0174] 1) Ensure priority execution of critical tasks: By setting up special-purpose task queues and clarifying the priority processing rules for special-purpose tasks, it can ensure that critical tasks can be scheduled and executed first after entering the system, improving the response speed and execution efficiency of critical tasks, and meeting the system's real-time requirements for urgent and important tasks.
[0175] 2) Improved system resource utilization: A counter mechanism is set up for common task queues to dynamically adjust task distribution strategies and avoid task backlogs. While taking task priorities into account, it fully utilizes system resources, improves overall task processing efficiency, avoids waste of system resources, and enables the system to maintain efficient operation even when handling a large number of tasks.
[0176] 3) Optimizing the Task Execution Process: The two-level scheduler further refines the task execution logic, ensuring timely response to urgent tasks at the executor level while also rationally scheduling the execution of ready tasks. This two-level scheduling architecture makes task scheduling more flexible and efficient, optimizes the system's task execution process, and improves overall system performance and stability.
[0177] 4) NUMA Optimization and Lock-Free Design: By mapping scheduling domains to NUMA nodes and designing a core-bound executor, we achieve efficient, lock-free task distribution. Field tests show that in a 128-core NUMA system, this solution significantly reduces context switching overhead and task distribution latency compared to traditional locking schemes.
[0178] 5) Support for Targeted Delivery and Load Balancing: By allowing users to dispatch tasks to specific CPU cores for execution, the flexibility and controllability of task scheduling are enhanced. Furthermore, an innovative load balancing algorithm effectively prevents some executors from being overloaded while others remain idle, further improving system resource utilization and overall performance.
[0179] 6) Task execution time prediction and optimization: Use machine learning algorithms to predict task execution time, optimize task distribution and scheduling strategies based on the prediction results, and further improve task processing efficiency.
[0180] In summary, the present invention can effectively solve the problems existing in the prior art through a reasonable task scheduling strategy and a two-level scheduling architecture, improve the resource utilization, task processing capability and overall performance of the system, and has significant innovation and practicality.
[0181] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0182] In addition, an embodiment of the present invention further provides a task processing device, comprising:
[0183] A response and determination module, configured to respond to a task execution request and determine the tasks to be executed included in the task execution request;
[0184] a first dispatching module configured to dispatch the first-type tasks to a first-type execution queue in a scheduling domain within the local node if the tasks to be executed include both first-type tasks and second-type tasks; and after dispatching the first-type tasks, dispatch the second-type tasks to a second-type execution queue in the scheduling domain within the local node; wherein the priority of the first-type tasks is higher than the priority of the second-type tasks; and the priority of the first-type execution queue is higher than the priority of the second-type execution queue;
[0185] The stop distribution module stops distributing the second type of tasks and returns to trigger the first issuing module when detecting that the tasks to be executed include the first type of tasks in the process of distributing the second type of tasks;
[0186] The execution module is used to control the processor core in the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queue.
[0187] In some embodiments, the task processing device further includes:
[0188] The storage module is used to store the first type of tasks in the first type of queue and store the second type of tasks in the second type of queue; wherein the priority of the first type of queue is higher than the priority of the second type of queue.
[0189] In some embodiments, the first type queue and / or the second type queue includes multiple queues with different priorities, and tasks in the same queue have different priorities.
[0190] The first issuing module includes a first issuing submodule, configured to issue the first type of task to the first type of execution queue in the scheduling domain within the node;
[0191] The second sending submodule is used to send the second type of tasks to the second type of execution queue in the scheduling domain within the node.
[0192] The first sending submodule is specifically configured to send the first type of tasks to the first type of execution queue in the scheduling domain within the node according to the priority order of the tasks in the first type of queue.
[0193] The second sending submodule is specifically configured to send the second type of tasks to the second type of execution queue in the scheduling domain within the node according to the priority order of the tasks in the second type of queue.
[0194] In some embodiments, the second type of queue includes multiple queues with different priorities. The second sending submodule specifically includes:
[0195] A third sending submodule is used to send the second type of tasks in the queue with the highest priority in the second type of queues to the second type of execution queue in the scheduling domain within the node;
[0196] A first acquisition module is used to obtain the task status of the queue with the highest priority; wherein the task status of the queue at least includes whether there is a task in the queue and the dispatch status of the task in the queue;
[0197] The first module is used to use the next queue of the highest priority queue as the new highest priority queue when it is detected that the task situation in the highest priority queue meets the preset requirements, and return to trigger the third sending sub-module; wherein the preset requirements are that there is no task in the highest priority queue, or the number of tasks sent in the highest priority queue is greater than or equal to the preset number.
[0198] In some embodiments, different queues in the second type of queue correspond to different preset numbers; and the higher the priority of the queue, the larger the preset number is set.
[0199] The task processing device includes a second acquisition module, which is used to obtain the number of tasks issued in the second type queue.
[0200] The second acquisition module is specifically used to obtain the number of task issuances recorded in the counter corresponding to each queue in the second type queue.
[0201] In some embodiments, the task processing device further includes:
[0202] The clearing module is used to clear the counters corresponding to all queues in the second type queue when it is detected that all queues in the second type queue are empty, or the numbers recorded by the counters corresponding to all queues in the second type queue reach a preset number, or the numbers recorded by the counters corresponding to some queues in the second type queue reach a preset number and the queues that have not reached the preset number are empty.
[0203] In some embodiments, the task processing device includes a first determination module for determining a task priority.
[0204] The first determination module specifically includes:
[0205] a third acquisition module, configured to acquire the execution time of the task using a model for predicting the execution time of the task;
[0206] The setting module is used to set the priority of each task in the order of the execution time from shortest to longest.
[0207] The third acquisition module specifically includes:
[0208] A fourth acquisition module is configured to acquire historical task data and extract target features related to task execution time from the historical task data; wherein the target features include task type, task size, number of concurrent tasks, and / or hardware resource status;
[0209] A training module is used to train the model using the target features corresponding to the historical task data as the input and the actual execution time as the output of the model, so as to obtain a model for predicting the execution time of the task;
[0210] The extraction module is used to extract the features of the task after receiving the task;
[0211] An input module, configured to input the features of a task into a model for predicting the execution time of the task;
[0212] The output module is used to output the execution time of the task through a model used to predict the execution time of the task.
[0213] In some embodiments, the task processing device further includes:
[0214] A fifth acquisition module is configured to acquire, from the second type queue, a target queue whose waiting time for task processing is longer than a preset time period from the start of task dispatch in the second type queue to the target time period;
[0215] The second module is used to place the target task in the target queue into the previous queue of the target queue, and use the previous queue of the target queue as the new target queue;
[0216] a sixth acquisition module, configured to, when detecting that the target task has not been issued, acquire the number of tasks in the second type queue that have been issued between placing the task in the target queue into the previous queue of the target queue and the new target time;
[0217] The trigger module is used to return to trigger the second module if the number of issued items reaches a preset value;
[0218] The holding module is used to keep the priority of the task in the target queue unchanged if it detects that the target task is being issued.
[0219] In some embodiments, the scheduling domain includes multiple processor cores. The task processing device includes: a second sending module. The second sending module is used to send the task to the execution queue in the scheduling domain of the node.
[0220] The second issuing module includes:
[0221] The seventh acquisition module is used to obtain a pre-established task delivery strategy;
[0222] The third sending module is used to send tasks to the execution queues corresponding to the processor cores contained in the scheduling domain within this node according to the task sending strategy; wherein the tasks include first-type tasks and second-type tasks; the execution queues corresponding to the processor cores include first-type execution queues and second-type execution queues.
[0223] In some embodiments, the third sending module includes:
[0224] An eighth acquisition module is used to acquire the hardware resources that the task execution depends on;
[0225] The third module is used to select a processor core in a scheduling domain containing hardware resources on which the task is executed as a target processor core;
[0226] The fourth sending module is used to send the task to the execution queue corresponding to the target processor core included in the scheduling domain in the node.
[0227] In some embodiments, the third sending module includes:
[0228] a ninth acquisition module, configured to acquire the number of tasks in the first type execution queue and the number of tasks in the second type execution queue corresponding to each processor core in the scheduling domain;
[0229] A first selection module is configured to select a processor core having the least number of tasks in a first type execution queue from all processor cores in the scheduling domain, and use the selected processor core having the least number of tasks in the first type execution queue as a first target processor core;
[0230] A second selection and serving module is configured to select a processor core having the least number of tasks in the second type execution queue from all processor cores in the scheduling domain, and use the selected processor core having the least number of tasks in the second type execution queue as a second target processor core;
[0231] The fifth sending module is used to send the first type of task to the first type of execution queue corresponding to the first target processor core included in the scheduling domain within this node, and to send the second type of task to the second type of execution queue corresponding to the second target processor core included in the scheduling domain within this node.
[0232] In some embodiments, the second sending module includes:
[0233] The tenth acquisition module is used to obtain the predicted execution time of the task;
[0234] The splitting module is used to split the task into multiple subtasks and set the priority of the subtasks when it is detected that the execution time of the task is greater than the preset time;
[0235] The sixth issuing module is configured to issue the subtask to the execution queue in the scheduling domain within the node according to the priority of the subtask.
[0236] In some embodiments, the execution module specifically includes:
[0237] an execution module configured to, if both the first-type execution queue and the second-type execution queue corresponding to the processor core in the node contain tasks, execute the first-type tasks in order of priority of the tasks in the first-type execution queue; and after completing the execution of the first-type tasks, execute the second-type tasks in order of priority of the tasks in the second-type execution queue;
[0238] The stop execution module is used to stop executing the second type of task and return to the trigger execution module when detecting that the first type of task is included in the first type of task in the first type of task execution queue during the execution of the second type of task.
[0239] In some embodiments, the task processing device further includes:
[0240] The migration module is used to migrate the to-be-executed task from the execution queue of the processor core back to the first type queue or the second type queue if it is detected that the to-be-executed task of the processor core has an associated task and the associated task has not been sent to the execution queue corresponding to the processor core.
[0241] In some embodiments, the task processing device further includes:
[0242] an eleventh acquisition module, configured to acquire resources on which tasks in the first type execution queue depend and to acquire resources on which tasks in the second type execution queue depend;
[0243] The promotion module is used to promote the priority of the low-priority task to obtain a new task priority order if it is detected that the resources on which the high-priority task depends are different from the resources on which the low-priority task depends in the first type execution queue or the second type execution queue; and trigger the execution module.
[0244] For the description of the features in the embodiment corresponding to the task processing device, please refer to the relevant description of the embodiment corresponding to the task processing method, and no further details will be given here.
[0245] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above-mentioned task processing method embodiments.
[0246] An embodiment of the present invention further provides a non-volatile storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above-mentioned task processing method embodiments when running.
[0247] In an exemplary embodiment, the non-volatile storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0248] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above-mentioned task processing method embodiments are implemented.
[0249] An embodiment of the present invention further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned task processing method embodiments are implemented.
[0250] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0251] The above is a detailed introduction to a task processing method, system, electronic device, medium and product provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, the present invention can also be improved and modified, and these improvements and modifications also fall within the scope of protection of the present invention.
Claims
1. A task processing method, characterized in that: Applicable to non-uniform memory access architecture nodes, the scheduling domain includes multiple processor cores; including: Responding to a task execution request and determining tasks to be executed according to the task execution request; If the tasks to be executed include both first-type tasks and second-type tasks, the first-type tasks are sent to the first-type execution queue corresponding to the processor core included in the scheduling domain of the current node. After the first-type tasks are sent, the second-type tasks are sent to the second-type execution queue corresponding to the processor core included in the scheduling domain of the current node. The priority of the first-type tasks is higher than the priority of the second-type tasks. The priority of the first-type execution queue is higher than the priority of the second-type execution queue. During the process of distributing the second-type tasks, when it is detected that the tasks to be executed include the first-type tasks, distributing the second-type tasks is stopped, and the process returns to the step of distributing the first-type tasks to the first-type execution queue corresponding to the processor core included in the scheduling domain within the local node; Controlling the processor cores in the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queues; Before controlling the processor core in the current node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queues, the method further includes: Obtaining resources that tasks in the first type execution queue depend on and obtaining resources that tasks in the second type execution queue depend on; If it is detected that in the first type of execution queue or the second type of execution queue, the resources on which the high-priority task depends are different from the resources on which the low-priority task depends, the priority of the low-priority task is increased to obtain a new task priority order; and the processor core in the control node enters the step of executing the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queue.
2. The task processing method according to claim 1, characterized in that: After detecting that the tasks to be executed include both the first type tasks and the second type tasks, before sending the first type tasks to the first type execution queue corresponding to the processor core included in the scheduling domain within the local node, the method further includes: The first type of tasks are stored in a first type of queue and the second type of tasks are stored in a second type of queue; wherein the priority of the first type of queue is higher than the priority of the second type of queue.
3. The task processing method according to claim 2, characterized in that: The first type queue and / or the second type queue includes multiple queues with different priorities, and tasks in the same queue have different priorities; When the first type of task is sent to the local node, the first type of execution queue corresponding to the processor core contained in the scheduling domain includes: Sending the first type of tasks to the first type of execution queues corresponding to the processor cores included in the scheduling domain within the local node according to the priority order of the tasks in the first type of queues; The second type of tasks are sent to the local node. The second type of execution queues corresponding to the processor cores included in the scheduling domain include: The second type of tasks are sent to the second type execution queues corresponding to the processor cores included in the scheduling domain in the node according to the priority order of the tasks in the second type of queues.
4. The task processing method according to claim 3, characterized in that: The second type queue includes multiple queues with different priorities. The second type tasks are sent to the local node according to the priority order of the tasks in the second type queue. The second type execution queues corresponding to the processor cores included in the scheduling domain include: Sending the second type of tasks in the second type queue with the highest priority to the second type execution queue corresponding to the processor core included in the scheduling domain in the local node; Obtain the task status of the highest priority queue; wherein the task status of the queue includes at least whether there is a task in the queue and the dispatch status of the task in the queue; When it is detected that the task status in the highest priority queue meets the preset requirements, the next queue of the highest priority queue is used as the new highest priority queue, and the step of sending the second type of tasks in the highest priority queue in the second type of queue to the second type of execution queue corresponding to the processor core included in the scheduling domain within this node is returned; wherein, the preset requirement is that there is no task in the highest priority queue, or the number of tasks sent in the highest priority queue is greater than or equal to the preset number.
5. The task processing method according to claim 4, characterized in that: Different queues in the second type of queue have different corresponding preset numbers; and the higher the priority of the queue, the larger the preset number is set; Obtaining the number of tasks issued in the second type of queue includes: Obtain the number of tasks issued recorded in the counter corresponding to each queue in the second type queue.
6. The task processing method according to claim 5, characterized in that: Also includes: When it is detected that all queues in the second type queue are empty, or the quantities recorded by the counters corresponding to all queues in the second type queue reach the preset quantity, or the quantities recorded by the counters corresponding to some queues in the second type queue reach the preset quantity and the queues corresponding to those that have not reached the preset quantity are empty, the counters corresponding to all queues in the second type queue are cleared.
7. The task processing method according to any one of claims 3 to 6, characterized in that: Prioritizing tasks includes: Obtaining the execution time of the task using a model for predicting the execution time of the task; Set the priority for each task in order of execution time from shortest to longest; The method of obtaining the task execution time by using the model for predicting the task execution time includes: Obtain historical task data and extract target features related to task execution time from the historical task data; wherein the target features include task type, task size, number of concurrent tasks and / or hardware resource status; The target features corresponding to the historical task data are used as the input of the model, and the actual execution time is used as the output of the model to train the model to obtain a model for predicting the execution time of the task; After receiving the task, extract the features of the task; Inputting the characteristics of the task into the model for predicting the execution time of the task; The execution time of the task is outputted by the model for predicting the execution time of the task.
8. The task processing method according to claim 4, characterized in that: Also includes: From the start of task delivery in the second type queue to the target time, a target queue whose waiting time for task processing is longer than a preset time is obtained from the second type queue; Place the target task in the target queue into the previous queue of the target queue, and use the previous queue of the target queue as the new target queue; When it is detected that the target task has not been issued, obtaining the number of tasks in the second type queue that have been issued between the time when the task in the target queue is placed in the queue before the target queue and the new target time; If the number of tasks sent reaches the preset value, the process returns to the step of placing the target task in the target queue into the previous queue of the target queue; If it is detected that the target task is being issued, the priority of the task in the target queue remains unchanged.
9. The task processing method according to claim 7, characterized in that: When tasks are dispatched to this node, the execution queues corresponding to the processor cores included in the scheduling domain include: Obtain pre-established task delivery strategies; The tasks are delivered to the execution queues corresponding to the processor cores included in the scheduling domain within the node according to the task delivery strategy; wherein the tasks include first-type tasks and second-type tasks.
10. The task processing method according to claim 9, characterized in that: The task is sent to the node according to the task sending strategy. The execution queues corresponding to the processor cores included in the scheduling domain include: Obtain the hardware resources required to execute the task; The processor core in the scheduling domain containing the hardware resources on which the task depends is used as the target processor core; The task is sent to the execution queue corresponding to the target processor core included in the scheduling domain in this node.
11. The task processing method according to claim 9, characterized in that: The task is sent to the node according to the task sending strategy. The execution queues corresponding to the processor cores included in the scheduling domain include: Obtaining the number of tasks in the first type execution queue and the number of tasks in the second type execution queue corresponding to each processor core in the scheduling domain; Selecting a processor core with the least number of tasks in the first type execution queue from all processor cores in the scheduling domain, and using the selected processor core with the least number of tasks in the first type execution queue as a first target processor core; Selecting a processor core with the least number of tasks in the second type execution queue from all processor cores in the scheduling domain, and using the selected processor core with the least number of tasks in the second type execution queue as a second target processor core; The first type of task is sent to the first type of execution queue corresponding to the first target processor core included in the scheduling domain of the current node, and the second type of task is sent to the second type of execution queue corresponding to the second target processor core included in the scheduling domain of the current node.
12. The task processing method according to claim 9, characterized in that: The task dispatching strategy is to dispatch a first type task to the first type execution queue of each processor core in the scheduling domain in turn; and stop dispatching until there is no first type task in the first type queue; Alternatively, the task delivery strategy is to sequentially deliver one second type task to the second type execution queue of each processor core in the scheduling domain, and stop delivering tasks until no second type tasks exist in the second type queue.
13. The task processing method according to claim 7, characterized in that: When tasks are dispatched to this node, the execution queues corresponding to the processor cores included in the scheduling domain include: Get the predicted task execution time; When it is detected that the execution time of a task is greater than the preset time, the task is split into multiple subtasks and the priorities of the subtasks are set; Subtasks are dispatched to the execution queues corresponding to the processor cores contained in the scheduling domain within the node according to their priorities.
14. The task processing method according to claim 9, characterized in that: Controlling the processor core in the node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queues includes: If the first type execution queue and the second type execution queue corresponding to the processor core in the node contain tasks, the first type tasks are executed in order of priority of the tasks in the first type execution queue; after the first type tasks are executed, the second type tasks are executed in order of priority of the tasks in the second type execution queue; During the execution of the second type of task, when it is detected that the first type of task is included in the first type of execution queue, the execution of the second type of task is stopped, and the process returns to the step of executing the first type of task in sequence according to the priority order of the tasks in the first type of execution queue.
15. The task processing method according to claim 14, characterized in that: Also includes: If it is detected that the task to be executed by the processor core has an associated task, and the associated task has not been sent to the execution queue corresponding to the processor core, the task to be executed is migrated from the execution queue of the processor core back to the first type queue or the second type queue.
16. A task processing system, characterized in that: The task processing system is located in a non-uniform memory access architecture node, and the scheduling domain includes multiple processor cores; the task processing system includes a first-level scheduler and a second-level scheduler; The first-level scheduler is used to respond to a task execution request and determine the tasks to be executed included in the task execution request; if the tasks to be executed include both first-type tasks and second-type tasks, the first-type tasks are sent to the first-type execution queue corresponding to the processor core included in the scheduling domain within the current node, and after the first-type tasks are sent, the second-type tasks are sent to the second-type execution queue corresponding to the processor core included in the scheduling domain within the current node; wherein the priority of the first-type tasks is higher than the priority of the second-type tasks; the priority of the first-type execution queue is higher than the priority of the second-type execution queue; in the process of distributing the second-type tasks, when it is detected that the tasks to be executed include the first-type tasks, the distribution of the second-type tasks is stopped, and the process returns to the step of sending the first-type tasks to the first-type execution queue corresponding to the processor core included in the scheduling domain within the current node; The secondary scheduler is configured to control the processor cores within the local node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queues; before controlling the processor cores within the local node to execute the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queues, the secondary scheduler further includes: Obtaining resources that tasks in the first type execution queue depend on and obtaining resources that tasks in the second type execution queue depend on; If it is detected that in the first type of execution queue or the second type of execution queue, the resources on which the high-priority task depends are different from the resources on which the low-priority task depends, the priority of the low-priority task is increased to obtain a new task priority order; and the processor core in the control node enters the step of executing the first type of tasks in the first type of execution queue and the second type of tasks in the second type of execution queue according to the priority order of the execution queue.
17. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the task processing method according to any one of claims 1 to 15 when executing the computer program.
18. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a computer program, wherein the computer program implements the steps of the task processing method according to any one of claims 1 to 15 when executed by a processor.
19. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the task processing method according to any one of claims 1 to 15 are implemented.