Task processing method and system, electronic equipment, medium and product
By prioritizing the issuance of high-priority tasks in non-unified memory access architecture nodes and dynamically adjusting the queue, the problem of unreasonable 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
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2045-06-26
AI Technical Summary
In the prior art, task scheduling strategies cannot efficiently and reasonably handle tasks with different priorities, 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, tasks with high priority are issued to the first type of execution queue, and tasks are executed in the order of priority of the execution queue, avoiding multiple cores to fight for the same task, locking mechanism, adjusting priority by predicting the task execution time, and dynamically adjusting the task queue to ensure that high priority tasks are processed in a timely manner.
It realizes efficient and timely processing of tasks with high priority, improves system performance, avoids performance losses of cross-node memory access, and ensures that low priority tasks can also be processed in a timely manner.
Smart Images

Figure CN120386607A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of high-performance computing, and particularly to a task processing method, system, electronic device, 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. In order to process tasks, different task scheduling strategies have been proposed in related technologies, such as a single priority queue scheduling strategy and a simple round-robin scheduling strategy.
[0003] In the single priority queue scheduling strategy, all tasks are arranged in a single priority order and scheduled in sequence. However, when an emergency task appears, if there are already a large number of ordinary tasks waiting to be executed in the queue, the emergency task may need to wait for a long time to be scheduled, resulting in untimely system response; in the simple round-robin scheduling strategy, each task is scheduled at a fixed time interval. Since this strategy treats emergency tasks and ordinary tasks equally, emergency tasks may not be processed in time. And during the task scheduling process, multiple cores obtain tasks from the task priority queue. In order to ensure the correctness of concurrent access and data consistency, it is usually necessary to lock tasks. However, frequent use of the lock mechanism to coordinate multi-core task allocation will lead to a decline in system performance.
[0004] Therefore, it can be seen that providing an efficient and reasonable task scheduling scheme is a technical problem that needs to be solved urgently by those skilled in the art. 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 that tasks cannot be scheduled efficiently and reasonably in related technologies.
[0006] The present invention provides a task processing method, which is applied to a non-uniform memory access architecture node and includes: Responding to a task execution request and determining the to-be-executed tasks included according to the task execution request; If the to-be-executed tasks include both first-type tasks and second-type tasks at the same time, then send the first-type tasks to the first-type execution queue in the scheduling domain within this node, and after sending the first-type tasks, send the second-type tasks to the second-type execution queue in the scheduling domain within this node; wherein, the priority of the first-type tasks is higher than that of the second-type tasks; the priority of the first-type execution queue is higher than that of the second-type execution queue; During the process of distributing the second-type tasks, when it is detected that the to-be-executed tasks include first-type tasks, stop distributing the second-type tasks and return to the step of sending the first-type tasks to the first-type execution queue in the scheduling domain within this node; Control the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue in the priority order of the execution queues.
[0007] The beneficial effects of the present invention are as follows. First, when there are both first-type tasks and second-type tasks with different priorities among the tasks to be executed, the first-type tasks, that is, the tasks with higher priorities, are preferentially sent to the first-type execution queue in the scheduling domain within this node, and the processor cores within this node execute the tasks in the priority order of the execution queues. Therefore, the first-type tasks in the first-type execution queue are preferentially executed, ensuring that the tasks with higher priorities can be preferentially sent and executed, and realizing timely processing of the tasks with higher priorities. Second, compared with the method of multiple cores actively fetching tasks from the queue and needing to lock the tasks, in the method provided by the present invention, the tasks obtained by the processor cores in the scheduling domain are sent by this node, and there is no situation where multiple cores compete for the same task. Therefore, there is no need to lock the tasks, and thus, the task processing efficiency is improved and the system performance is enhanced. Third, in this method, tasks are sent within a non-uniform memory access architecture node and the processor cores in the corresponding scheduling domain of the non-uniform memory access architecture node are used to execute the tasks, avoiding the performance loss of cross-non-uniform memory access architecture node memory access. In addition, after sending the first-type tasks, the second-type tasks, that is, the tasks with lower priorities, are sent to the second-type execution queue in the scheduling domain within this node, ensuring that the tasks with lower priorities can also be processed in a timely manner. Moreover, during the process of distributing the second-type tasks, when it is detected that the tasks to be executed include first-type tasks, the distribution of the second-type tasks is stopped, and the first-type tasks are continuously sent to the first-type execution queue in the scheduling domain within this node, further ensuring that the first-type tasks, that is, the tasks with higher priorities, can be processed in a timely manner and improving the task processing efficiency.
[0008] The present invention also provides a task processing system, which is located in a non-uniform memory access architecture node. 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 to-be-executed tasks included according to the task execution request; if the to-be-executed tasks 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 this node, and after sending the first-type tasks, the second-type tasks are sent to the second-type execution queue in the scheduling domain within this node; wherein, the priority of the first-type tasks is higher than that of the second-type tasks; the priority of the first-type execution queue is higher than that of the second-type execution queue; during the process of distributing the second-type tasks, when it is detected that the to-be-executed tasks include first-type tasks, the distribution of the second-type tasks is stopped, and it returns to the step of sending the first-type tasks to the first-type execution queue in the scheduling domain within this node; The second-level scheduler is used to control the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue in the order of the priority of the execution queues.
[0009] The present invention also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of any one of the above task processing methods when executing the computer program.
[0010] The present invention also provides a non-volatile storage medium, in which a computer program is stored, and wherein the computer program implements the steps of any one of the above task processing methods when executed by a processor.
[0011] The present invention also provides a computer program product, including a computer program, and the computer program implements the steps of any one of the above task processing methods when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0013] Figure 1 It is a schematic diagram of a non-uniform memory access architecture node provided by an embodiment of the present invention; Figure 2 It is a flowchart of a task processing method provided by an embodiment of the present invention; Figure 3 It is a schematic diagram of a multi-priority task queue module provided by an embodiment of the present invention; Figure 4 It is a flowchart of a task sending method provided by an embodiment of the present invention; Figure 5 A schematic diagram of task distribution provided by an embodiment of the present invention; Figure 6 A flowchart of a method for executing tasks provided by an embodiment of the present invention; Figure 7 An architecture diagram of a non-uniform memory access architecture node scheduling domain provided by an embodiment of the present invention. Detailed implementation manners
[0014] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present invention.
[0015] It should be noted that in the description of the present invention, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present invention are used to distinguish similar objects and not to describe a specific order or sequence.
[0016] In order to enable those skilled in the art of the present technology to better understand the solution of the present invention, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners. Figure 1 An embodiment of the present invention provides a schematic diagram of a non-uniform memory access architecture node. As Figure 1 shown, each scheduling domain corresponds to a specific non-uniform memory access (Non-Uniform Memory Access) 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 the 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. The non-uniform memory access architecture is a design pattern of a multi-core processor. A scheduling domain is a logical execution unit composed of a group of CPU cores with the same NUMA nodes. Figure 2 A flowchart of a task processing method provided by an embodiment of the present invention. The task processing method is applied to non-uniform memory access architecture nodes. The method includes two processes: task issuing and task execution. It should be noted that when there are tasks in the first-type execution queue and / or the second-type execution queue, the step of task execution can be performed. AsFigure 2 As shown, the task distribution corresponds to steps S10 to S12, and the task execution corresponds to step S13. Specifically: S10: Respond to a task execution request and determine the to-be-executed tasks included according to the task execution request.
[0017] S11: If the to-be-executed tasks include both first-type tasks and second-type tasks at the same time, then distribute the first-type tasks to the first-type execution queue in the scheduling domain within this node. After finishing distributing the first-type tasks, distribute the second-type tasks to the second-type execution queue in the scheduling domain within this node.
[0018] Among them, the priority of the first-type tasks is higher than that of the second-type tasks; the priority of the first-type execution queue is higher than that of the second-type execution queue.
[0019] S12: During the process of distributing the second-type tasks, when it is detected that the to-be-executed tasks include first-type tasks, stop distributing the second-type tasks and return to step S11.
[0020] S13: Control the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue according to the priority order of the execution queues.
[0021] The task execution request can be sent by a user. That is, a non-uniform memory access architecture node receives a task execution request sent by a user. There is no limitation on the task execution request, which is determined according to the actual situation. Determine the to-be-executed tasks included according to the task execution request. The to-be-executed tasks can include only first-type tasks, or only second-type tasks, or both first-type tasks and second-type tasks at the same time. In the present invention, the priority of the first-type tasks is higher than that of the second-type tasks. Assume that the first-type tasks are special-purpose tasks, such as system maintenance tasks, emergency alarm tasks, etc.; the second-type tasks are ordinary tasks, such as data processing tasks, user request tasks, etc. In order to obtain the situation of the first-type tasks and the second-type tasks included in the to-be-executed tasks, in implementation, the first-type tasks and the second-type tasks can be respectively placed in queues. If the queue is empty, it means there is no task; if the queue is not empty, it means there is a task.
[0022] Specifically, after it is detected that the to-be-executed tasks include both first-type tasks and second-type tasks at the same time, before distributing the first-type tasks to the first-type execution queue in the scheduling domain within this node, it further includes: Store the first-type tasks in the first-type queue and store the second-type tasks in the second-type queue; among them, the priority of the first-type queue is higher than that of the second-type queue. If the first type of queue is called a special-purpose task queue and the second type of queue is called a general task queue.
[0023] In practice, there may be multiple tasks (the first type of task and / or the second type of task). To ensure that each task can be processed, the first type of queue and / or the second type of queue contains multiple queues with different priorities, and the tasks in the same queue have different priorities. There is no limit to the number of queues included in each type of queue, which is set according to the actual situation.
[0024] There is no limit to the order of setting task priorities, which is determined according to the actual situation. To preferentially schedule tasks with short execution times and reduce task waiting times, in implementation, tasks with short execution times can be set with higher priorities. Determining task priorities includes: Obtaining the execution time of a task through a model for predicting the execution time of a task; Setting priorities for each task in ascending order of the execution time of the task; Among them, obtaining the execution time of a task through a model for predicting the execution time of a task includes: Obtaining historical task data and extracting target features related to the task execution time from the historical task data; among them, the target features include task type, task size, number of concurrent tasks, and / or hardware resource status; Using the target features corresponding to the historical task data as the input of the model and the actual execution time as the output of the model to train the model to obtain a model for predicting the execution time of a task; After receiving a task, extracting the features of the task; Inputting the features of the task into the model for predicting the execution time of a task; Outputting the execution time of the task through the model for predicting the execution time of a task.
[0025] In implementation, predicting the task execution time includes the following steps: ① Data collection and feature extraction: Data collection: Collecting historical task data, including task features (such as task type, task size, resource requirements, etc.) and actual execution time.
[0026] Feature extraction: Extracting features with high correlation with the task execution time from the historical task data, specifically including: Task type: Different types of tasks may have different execution time patterns.
[0027] Task size: The computational amount size of a task directly affects the execution time.
[0028] Resource requirements: including CPU usage, memory usage, disk input / output (I / O), network bandwidth, etc.
[0029] Historical execution time: The execution time of the task in the past can be used as an important reference.
[0030] Number of concurrent tasks: The number of tasks currently being executed in the system.
[0031] Hardware resource status: The utilization rate of the hardware resources of the current system (such as CPU, memory, disk, network, etc.).
[0032] Data preprocessing: Clean and preprocess the data, remove outliers and missing values, and standardize or normalize the data for model training.
[0033] ② Feature selection and optimization: Feature selection: Select the features that have the most impact on the prediction of task execution time from the extracted features. Feature importance analysis (such as feature importance based on tree models) or correlation analysis can be used to select features.
[0034] Feature optimization: Further optimize the selected features, such as feature combination, feature dimensionality reduction, etc., to improve the prediction performance of the model.
[0035] ③ Model selection and training: Model selection: Select a suitable machine learning model, such as neural networks (such as Long Short-Term Memory Network (LSTM) or Transformer), which can handle complex non-linear relationships.
[0036] Feature engineering: Construct a feature matrix, with the features of the task as input and the actual execution time as output.
[0037] Model training: Use historical data to train the model, adjust the model parameters through methods such as cross-validation, and optimize the model performance.
[0038] ④ Model evaluation and optimization: Evaluation metrics: Use metrics such as Mean Squared Error (MSE) and Mean Absolute Error (MAE) to evaluate the prediction error of the model.
[0039] Optimization: Optimize the model according to the evaluation results, such as adjusting model parameters, selecting different feature combinations, trying different algorithms, etc.
[0040] ⑤ Task execution time prediction: Predicted execution time: For tasks newly entering the system, extract their features and input them into the trained prediction model, and the model will output the predicted execution time of the task.
[0041] Optimize task distribution: According to the predicted execution time, optimize the task distribution and scheduling strategy, prioritize tasks with short execution times, and reduce task waiting time.
[0042] In this method, the execution time of the task is predicted based on the model prediction method, and a higher priority is set for tasks with short execution times, avoiding tasks with short execution times waiting for a long time. In practice, other methods can also be used to set priorities for tasks, which are not limited here.
[0043] In addition, in order to improve the efficiency of task processing, the execution queue in the scheduling domain within this node to which the task is sent includes: Obtain the predicted execution time of the task; When it is detected that the execution time of the task is greater than the preset time, split the task into multiple subtasks and set the priorities of the subtasks; Send the subtasks to the execution queue in the scheduling domain within this node according to the priorities of the subtasks.
[0044] The preset time can be determined according to the actual situation. In this method, for tasks with long execution times, try to split them into multiple subtasks for parallel execution to further improve the task processing efficiency.
[0045] After setting the priorities, in order to avoid tasks with low priorities waiting for a long time, the priorities of tasks with low priorities can be further adjusted. Specifically, the task processing method further includes: From the start of task sending in the second type of queue to the target moment, obtain the target queue in the second type of queue where the waiting time of the task to be processed is greater than the preset duration; Place the target task in the target queue into the queue before the target queue, and use the queue before the target queue as the new target queue; When it is detected that the target task has not been sent, obtain the number of tasks sent in the second type of queue from the time when the task in the target queue is placed into the queue before the target queue to the new target moment; If the number of sent tasks reaches the preset value, return to the step of placing the target task in the target queue into the queue before the target queue; If it is detected that the target task is sent, keep the priorities of the tasks in the target queue unchanged.
[0046] There are no restrictions on the preset duration and preset value, which are determined according to the actual situation. For example, if a task in the queue with a priority of 5 in the second type of queue has waited for a long time, the priority of this task in the queue with a priority of 5 is increased to a priority of 4, that is, this task in the queue with a priority of 5 is placed in the queue with a priority of 4; if this task has not been executed after waiting for 1000 tasks to be executed, the priority of this task in the queue with a priority of 4 is continued to be increased to a priority of 3, that is, this task in the queue with a priority of 4 is placed in the queue with a priority of 3; if this task has not been executed after waiting for another 500 tasks to be executed, the priority of this task in the queue with a priority of 3 is continued to be increased to a priority of 2.
[0047] In this method, it is considered that in actual applications, the priority of tasks may change according to the running state of the system, resource usage, and the real-time needs of users. Therefore, a dynamic adjustment mechanism for task priorities is further studied, enabling the system to dynamically adjust the priorities of tasks according to real-time situations, so as to better adapt to complex and changeable task scheduling scenarios. And in this method, the priorities of tasks with lower priorities are changed in a step-by-step manner. On the one hand, it ensures that subsequent tasks will not wait indefinitely; on the other hand, it ensures that tasks with higher priorities in the front can be processed first.
[0048] By setting up the first type of queue and the second type of queue for storing tasks, tasks are placed in the queues according to the priority order, enabling tasks to be issued according to the priority order of tasks. To improve the performance of the system, in implementation, tasks are issued to the processor cores within the non-uniform memory access architecture nodes for execution.
[0049] Similarly, to ensure that tasks with higher priorities can be executed first, a first type of execution queue and a second type of execution queue are set in the corresponding scheduling domain within this node. If the tasks to be executed only include the first type of tasks, the first type of tasks are distributed to the first type of execution queue in the scheduling domain within this node; if the tasks to be executed only include the second type of tasks, the second type of tasks are distributed to the second type of execution queue in the scheduling domain within this node. If the tasks to be executed include both the first type of tasks and the second type of tasks, the first type of tasks are issued to the first type of execution queue in the scheduling domain within this node, and after issuing the first type of tasks, the second type of tasks are issued 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 the emergency task queue, and the second type of execution queue can be called the ready queue.
[0050] To ensure that tasks can be processed in a timely manner, distributing the first type of tasks to the first type of execution queue in the scheduling domain within this node includes: distributing the first type of tasks to the first type of execution queue in the scheduling domain within this node in the order of task priorities in the first type of queue.
[0051] Distributing the second type of tasks to the second type of execution queue in the scheduling domain within this node includes: distributing the second type of tasks to the second type of execution queue in the scheduling domain within this node in the order of task priorities in the second type of queue.
[0052] When there are multiple queues with different priorities in the second type of queue, to achieve automatic switching of the second type of queue, in implementation, distributing the second type of tasks to the second type of execution queue in the scheduling domain within this node in the order of task priorities in the second type of queue includes: Distributing the second type of tasks in the queue with the highest priority in the second type of queue to the second type of execution queue in the scheduling domain within this node; Obtaining the task status in the queue with the highest priority; wherein, the task status in the queue includes at least whether there is a task or not in the queue, and the distribution status of the tasks in the queue; When it is detected that the task status in the queue with the highest priority meets the preset requirements, taking the next queue of the queue with the highest priority as the new queue with the highest priority, and returning to the step of distributing the second type of tasks in the queue with the highest priority in the second type of queue to the second type of execution queue in the scheduling domain within this node; wherein, the preset requirements are that there is no task in the queue with the highest priority, or the number of tasks distributed in the queue with the highest priority is greater than or equal to the preset quantity.
[0053] When it is detected that the task status in the current queue does not meet the preset requirements, continue to distribute the second type of tasks in the current queue. At this time, the preset requirements are that there is a task in the current queue, and the number of tasks distributed is less than the preset quantity.
[0054] There is no limit to the preset quantity, which is determined according to the actual situation. In addition, to prevent tasks in queues with lower priorities in the second type of queue from waiting for too long. In implementation, the preset quantities corresponding to different queues in the second type of queue are different; and the higher the priority of the queue, the larger the preset quantity set.
[0055] Obtaining the number of tasks distributed in the second type of queue includes: obtaining the number of tasks distributed recorded in the counters corresponding to each queue in the second type of queue. That is, a corresponding counter is set for each queue in the second type of queue. Each time a task is distributed from a queue, the value of the counter corresponding to the queue is incremented by 1.
[0056] Figure 3A schematic diagram of a multi-priority task queue module provided by an embodiment of the present invention is shown as follows: 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.
[0057] 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.
[0058] 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.
[0059] To better understand the above distribution rules, the following uses a specific task to illustrate the distribution rules. When there are tasks in the special-purpose task queue, the tasks are distributed to the emergency queues of all processor cores under the scheduling domain in sequence according to the priority of the special-purpose task queue; when there are no tasks in the special-purpose task queue, the tasks are distributed to the ready queues of all processor cores under the scheduling domain in sequence according to the priority of the ordinary task queue. Each priority of the ordinary task queue corresponds to a counter. When there are no tasks in the queue or the counter accumulates to the set value, the task distribution is switched to other task queues. For each task distributed from the ordinary task queue, the corresponding counter is incremented by one, and it is re-detected whether there are new tasks in the special-purpose task queue. If there are new tasks, the tasks in the special-purpose task queue are preferentially distributed to the emergency queue; if not, the tasks in the ordinary task queue continue to be distributed. When the counters of all ordinary task queues reach the set value, or 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.
[0060] Taking the first type of queue as the special-purpose task queue, the second type of queue as the ordinary task queue, the first type of execution queue as the emergency queue, and the second type of execution queue as the ready queue as an example, the process of task distribution described above is illustrated. Figure 4 It is a flowchart of a task distribution method provided by an embodiment of the present invention. As Figure 4 shown, it shows the task distribution process, including the processing logic of the special-purpose task queue and the ordinary task queue, the role of the counter, and the specific steps of task distribution. The method includes: S14: Check whether there are tasks in the special-purpose task queue; if so, go to step S15; if not, go to step S16; S15: Select a task from the special-purpose task queue and put it into the corresponding emergency queue of the processor core; S16: Select the highest-priority queue in the ordinary task queue; S17: Determine whether the current queue meets the condition that there are tasks in the current queue and the corresponding counter has not reached the threshold; if so, go to step S18; if not, go to step S20; S18: Select a task from the ordinary task queue and put it into the corresponding ready queue of the processor core; S19: Increment the counter of the task queue by 1; return to step S14; S20: Determine whether one of the following conditions is met: all ordinary task queues are empty, or whether the values recorded by the counters of all ordinary task queues reach the threshold, or the counters of some ordinary task queues reach the set value and the queues that have not reached the set value are empty; if not, go to step S21; if so, go to step S22; S21: Switch to the next priority queue in the normal task queue; S22: Reset the values of the counters of all normal task queues to 0; return to step S14.
[0061] To further improve the flexibility and efficiency of task scheduling. In implementation, the scheduling domain includes multiple processor cores. Sending tasks to the execution queues in the scheduling domain within this node includes: Obtain the pre-established task sending policy; According to the task sending policy, send the task to the execution queue corresponding to the processor core included in the scheduling domain within this node; where the task includes a first type of task and a second type of task; the execution queue corresponding to the processor core includes a first type of execution queue and a second type of execution queue.
[0062] Specifically, sending the task to the execution queue corresponding to the processor core included in the scheduling domain within this node according to the task sending policy includes: obtaining the hardware resources on which the execution task depends; using the processor core within the scheduling domain that includes the hardware resources on which the execution task depends as the target processor core; sending the task to the execution queue corresponding to the target processor core included in the scheduling domain within this node.
[0063] That is, the task is directly delivered to a specified processor core for execution. For some tasks that depend on specific hardware resources, the user can directly deliver them to the processor core associated with the resource, thereby improving the task execution efficiency. 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. The user can deliver them to the processor core close to the audio or video input device to reduce data transmission latency. By means of direct delivery, the user is allowed to publish tasks to a specified processor core for execution. This feature enhances the flexibility and controllability of task scheduling.
[0064] In addition to the above-mentioned selection of the corresponding processor core for the task according to the hardware resources on which the execution task depends, in this embodiment, sending the task to the execution queue corresponding to the processor core included in the scheduling domain within this node according to the task sending policy includes: Obtain the number of tasks in the first type of execution queue and the number of tasks in the second type of execution queue corresponding to each processor core within the scheduling domain; Select the processor core with the least number of tasks in the first type of execution queue from all the processor cores within the scheduling domain, and use the selected processor core with the least number of tasks in the first type of execution queue as the first target processor core; Select the processor core with the smallest number of tasks in the second - type execution queue from all the processor cores within the scheduling domain, and use the selected processor core with the smallest number of tasks in the second - type execution queue as the second target processor core; Dispatch the first - type tasks to the first - type execution queues corresponding to the first target processor cores included in the scheduling domain within this node, and dispatch the second - type tasks to the second - type execution queues corresponding to the second target processor cores included in the scheduling domain within this node.
[0065] When distributing tasks, this method selects to distribute tasks to the corresponding queues of the processor core with the smallest number of tasks according to the number of tasks in the first - type execution queue and the second - type execution queue in the processor core. That is, it selects the processor core for task execution considering load balancing. This method can effectively avoid the situation where some processor cores are overloaded while others are idle, and further improve the system resource utilization rate and overall performance.
[0066] To further ensure load balancing on the processor cores, the task - dispatching policy is to sequentially dispatch one first - type task to the first - type execution queues of each processor core within the scheduling domain; stop dispatching until there are no first - type tasks left in the first - type queues; Or, the task - dispatching policy is to sequentially dispatch one second - type task to the second - type execution queues of each processor core within the scheduling domain; stop dispatching until there are no second - type tasks left in the second - type queues.
[0067] To facilitate the understanding of the above - mentioned task - distribution method, the following is combined with Figure 5 for illustration. Figure 5 This is a schematic diagram of task distribution provided by an embodiment of the present invention. As Figure 5 shown, there are two executors (physical units for actually executing tasks, composed of CPU cores bound to cores, that is, processor cores), and the adopted method is to sequentially dispatch one task to the queues of each processor core within the scheduling domain; stop dispatching until there are no tasks left in the priority task queues (such as the first - type queues and the second - type queues described above). The multi - priority task queues include queues with priorities from 0 to N. Among them, the queues with priorities from 0 to 2 are special - purpose task queues, and the queues with priorities from 3 to N are ordinary task queues.
[0068] Figure 5Among them, the process of task distribution is as follows: Task 1 in the queue with priority 0 is distributed to the emergency task queue corresponding to the left executor, and Task 2 in the queue with priority 0 is distributed to the emergency task queue corresponding to the right executor; Task 3 in the queue with priority 0 is distributed to the emergency task queue corresponding to the left executor; Task 4 in the queue with priority 1 is distributed to the emergency task queue corresponding to the right executor; Task 5 in the queue with priority 2 is distributed to the emergency task queue corresponding to the left executor. In the same way, Task 6 and Task 8 in the queue with priority 3 and Task 10 in the queue with priority 4 are distributed to the ready queue corresponding to the left executor, and Task 7 in the queue with priority 3, Task 9 in the queue with priority 4, and Task 11 in the queue with priority 6 are distributed to the ready queue corresponding to the right executor. By distributing one task to each queue in the scheduling domain respectively, the load balance of the processor cores is ensured as much as possible.
[0069] The process of task distribution to the execution queues in the scheduling domain within this node is specifically described above. Next, the process of the processor core executing tasks will be described. Similarly, in order to ensure that tasks with higher priorities can be executed in a timely manner, in implementation, the processor cores within this node are controlled to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue in the priority order of the execution queues, including: If the first-type execution queue and the second-type execution queue corresponding to the processor core within this node contain tasks, the first-type tasks are executed in sequence according to the priority order of the tasks in the first-type execution queue; after the first-type tasks are executed, the second-type tasks are executed in sequence according to the priority order of the tasks in the second-type execution queue; During the process of executing the second-type tasks, when it is detected that the first-type execution queue contains first-type tasks, the execution of the second-type tasks is stopped, and the process returns to the step of executing the first-type tasks in sequence according to the priority order of the tasks in the first-type execution queue.
[0070] The processor core executes tasks in the priority order of the tasks in the queue. It should be noted that in order to improve the efficiency of task execution, the priority order of the tasks in the queue can be adjusted. For example, machine learning algorithms can be used to predict the execution time of tasks, and the priority of task execution can be optimized according to the prediction results. Suppose a neural network model (such as Transformer) is selected to predict the task execution time, and its mathematical formula can be expressed as: ; Among them, represents the predicted task execution time; represents the parameters of the model, represents the neural network model; The feature matrix representing the task includes task type, task size, CPU usage rate, memory usage rate, disk I / O, network bandwidth, historical execution time, number of concurrent tasks, hardware resource status, etc. Specifically, the feature matrix can be expressed as: ; where, represents the number of samples of the training data, represents the number of features, represents the th feature of the th sample, represents the feature of the first sample,
[0071] The training objective of the model is to minimize the error between the predicted value and the actual value, that is: ; where, represents the actual execution time of the th sample, represents the predicted execution time of the th sample.
[0072] Select the Transformer model for training, and the model structure can be expressed as: ; where, Embedding represents the embedding layer, which maps the input features to a high-dimensional space, Encoder represents the encoder, which is used to extract the high-level representation of the features, and MLP represents the Multi-Layer Perceptron, which is used for the final prediction.
[0073] That is, use machine learning algorithms to predict the execution time of tasks, and optimize the execution order of tasks according to the prediction results.
[0074] In addition, the priority during task execution can also be adjusted according to the resources required for the execution task. Before controlling the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue in the order of the priority of the execution queue, it also includes: Obtain the resources on which the tasks in the first-type execution queue depend and obtain the resources on which the tasks in the second-type execution queue depend; If it is detected that the resources relied on by the task with a higher priority in the first type of execution queue or the second type of execution queue are different from the resources relied on by the task with a lower priority, then the priority of the task with a lower priority is increased to obtain a new task priority order; and it enters the step of controlling the processor cores 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.
[0075] For example, if the task with a lower priority occupies less network resources, the task with a higher priority occupies more memory resources, and the resources required by the task with a lower priority do not conflict with those of the task with a higher priority, then the priority of the task with a lower priority can be increased so that the task with a lower priority can use the network resources.
[0076] In addition to adjusting the priority order when executing tasks based on the execution time of tasks described above, in the method provided in this embodiment, considering that the execution of tasks is often restricted by multiple resources, such as CPU, memory, disk I / O, network bandwidth, etc. Therefore, it is possible to consider incorporating multiple resource dimensions into the consideration scope of task scheduling, and perform comprehensive scheduling according to the requirements of tasks for different resources and the resource usage situation of the system, so as to further improve the resource utilization rate of the system and the task processing efficiency.
[0077] In addition, there may be associated tasks in practice. To ensure the successful execution of associated tasks, in implementation, the task processing method further includes: if it is detected that there are associated tasks for the tasks to be executed by the processor core and the associated tasks have not been sent to the execution queue corresponding to the processor core, then the task to be executed is migrated back to the first type of queue or the second type of queue from the execution queue of the processor core.
[0078] For example, if the data of A is obtained and the task of A + B is also obtained, but the data of B is not available, then the task of A + B needs to be returned from the emergency queue to the end of the priority queue. Ensure that after the task of obtaining B data is executed first, then the task of A + B is executed, ensuring the successful execution of the task of A + B.
[0079] When each processor core executes tasks, it determines the specific tasks to be executed according to the situations of the tasks in the first type of execution queue and the second type of execution queue. The specific execution rules are as follows: when executing each task, first detect whether there are tasks in the first type of execution queue. If there are tasks in the first type of execution queue, then execute the tasks in the first type of execution queue; if there are no tasks in the first type of execution queue, then execute the tasks in the second type of execution queue.
[0080] Taking the first type of execution queue as the emergency queue and the second type of execution queue as the ready queue as an example below, the method for each processor core to execute tasks is described. Figure 6The flowchart of a method for executing tasks provided by an embodiment of the present invention is as follows: Figure 6 As shown, the method includes: S23: The current task is completed; S24: Check whether there is a task in the emergency queue; if yes, go to step S25; if no, go to step S26; S25: Execute the task in the emergency queue; return to step S23; S26: Execute the task in the ready queue; return to step S23.
[0081] That is, when the processor core executes each task, it first detects whether there is a task in the emergency queue. If there is a task in the emergency queue, the task in the emergency queue is executed; if there is no task in the emergency queue, the task in the ready queue is executed.
[0082] To enable those skilled in the art to better understand the task processing method described above, the above method will be applied to a task processing system below to further illustrate the above process. 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 the task processing system includes a first-level scheduler and a second-level scheduler.
[0083] The first-level scheduler is used to respond to a task execution request and determine the to-be-executed tasks included according to the task execution request; if the to-be-executed tasks 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 this 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 this node; wherein, the priority of the first-type tasks is higher than that of the second-type tasks; the priority of the first-type execution queue is higher than that of the second-type execution queue; during the process of distributing the second-type tasks, when it is detected that the to-be-executed tasks include first-type tasks, the distribution of the second-type tasks is stopped, and it returns to the step of sending the first-type tasks to the first-type execution queue in the scheduling domain within this node.
[0084] The second-level scheduler is used to control the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue in the order of the priority of the execution queues.
[0085] Figure 7 The architecture diagram of the scheduling domain of a non-uniform memory access architecture node provided by an embodiment of the present invention is as follows: Figure 7As shown in the figure, the non-uniform memory access architecture node includes a first-level scheduler and a second-level scheduler. The first-level scheduler includes multiple priority task queues. Among them, the queue filled with dotted lines represents the special-purpose task queue, and the unfilled queue represents the ordinary task queue. The second-level scheduler includes an emergency queue and a ready queue. Among them, the queue filled with dotted lines represents the emergency queue, and the unfilled queue represents the ready queue. The first-level scheduler manages the priority task queues and distributes tasks. The second-level scheduler manages the execution queues (including the emergency queue and the ready queue) and executes tasks. When the first-level scheduler distributes tasks, it performs directed delivery, considers load balancing, and sets timers, etc.
[0086] When the task processing system executes the multi-priority task scheduling method, the steps included are as follows: First, in the system initialization stage, the first-level scheduler creates multiple priority task queues, 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.
[0087] 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.
[0088] Third, the first-level scheduler performs task distribution: First, check whether there are tasks in the special-purpose task queue. If there are, the tasks are sequentially sent to the emergency queues of each executor in the scheduling domain in descending order of priority.
[0089] If there are no tasks in the special-purpose task queue, then check the ordinary task queues. Start distributing tasks from the ordinary task queue with the highest priority. For each task distributed, the corresponding counter is incremented 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 processing the tasks in the special-purpose task queue; if there are no new tasks, continue to distribute tasks in the ordinary task queue. When a certain ordinary task queue has no tasks or its counter reaches the set value, switch to the ordinary task queue with the next lower priority to distribute tasks. 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.
[0090] Fourth, in the executor, after each task execution is completed, the second-level scheduler checks whether there are tasks in the emergency queue. If there are, execute the tasks in the emergency queue; if there are no tasks in the emergency queue, execute the tasks in the ready queue.
[0091] 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, then task 1 is preferentially distributed to the executor's queue. In addition, 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, thereby improving task processing efficiency.
[0092] In the executor, after each task is executed, 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. In addition, for tasks with longer execution times, they are attempted to be split into multiple subtasks for parallel execution to further improve task processing efficiency.
[0093] The system adopts a NUMA-aware scheduling domain design with the following advantages: 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).
[0094] 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. In addition, 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. In addition, when the load balancing algorithm distributes tasks, it selects to distribute tasks to the corresponding queue of the executor with the fewest tasks based on the number of tasks in the emergency queue and the ready queue in the computing executor, effectively avoiding the situation where some executors are overloaded while other executors are idle, and further improving system resource utilization and overall performance.
[0095] Emergency task guarantee: Through the emergency queue detection mechanism of the secondary scheduler, sudden emergency tasks can be responded to within 10 μs (note that when the executor is processing long-duration tasks, the emergency task needs to wait for the current task to complete). 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 according to the prediction results. For example, tasks with short execution times are preferentially scheduled to reduce task waiting times. In addition, for tasks with longer execution times, they are attempted to be split into multiple subtasks for parallel execution to further improve task processing efficiency.
[0096] In the task processing method provided by the present invention, by setting up multi-priority task queues, including special-purpose task queues and ordinary task queues, the priority processing rules for 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, the execution efficiency of ordinary tasks is taken into account, and the overall resource utilization rate and task processing capacity of the system are improved.
[0097] Specifically, the following are achieved through this method: 1) Guarantee the 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 preferentially scheduled and executed after entering the system, improve the response speed and execution efficiency of critical tasks, and meet the real-time requirements of the system for emergency and important tasks.
[0098] 2) Improve the system resource utilization rate: A counter mechanism is set for the ordinary task queue, which can dynamically adjust the task distribution strategy to avoid task backlogs. While taking into account task priorities, the system resources are fully utilized, the overall task processing efficiency is improved, the waste of system resources is avoided, and the system can operate efficiently when processing a large number of tasks.
[0099] 3) Optimize the task execution process: The setting of the secondary scheduler further refines the task execution logic, ensuring that emergency tasks can be promptly responded to at the executor level, and at the same time reasonably arranging the execution of ready tasks. This two-level scheduling architecture makes task scheduling more flexible and efficient, optimizes the system task execution process, and improves the overall performance and stability of the system.
[0100] 4) NUMA optimization and lock-free design: Through the correspondence between the scheduling domain and the NUMA node, and the design of the core-bound executor, lock-free and efficient task distribution is achieved. Actual measurements show that in a 128-core NUMA system, this solution significantly reduces the context switching overhead compared with the traditional lock mechanism solution, and the task distribution delay is also significantly reduced.
[0101] 5) Support for directional delivery and load balancing: By allowing users to publish tasks to specified CPU cores for execution, the flexibility and controllability of task scheduling are enhanced. At the same time, an innovative load balancing algorithm can effectively avoid the situation where some executors are overloaded while others are idle, further improving the system resource utilization rate and overall performance.
[0102] 6) Prediction and optimization of task execution time: Use machine learning algorithms to predict the execution time of tasks, and optimize task distribution and scheduling strategies based on the prediction results to further improve task processing efficiency.
[0103] In summary, through a reasonable task scheduling strategy and a two-level scheduling architecture, the present invention can effectively solve the problems existing in the prior art, improve the system's resource utilization rate, task processing ability, and overall performance, and has significant innovation and practicality.
[0104] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method.
[0105] In addition, an embodiment of the present invention also provides a task processing device, including: A response and determination module, configured to respond to a task execution request and determine the to-be-executed tasks included according to the task execution request; A first distribution module, configured to, if the to-be-executed tasks include both first-type tasks and second-type tasks, distribute the first-type tasks to the first-type execution queue in the scheduling domain within this node, and after distributing the first-type tasks, distribute the second-type tasks to the second-type execution queue in the scheduling domain within this node; wherein, the priority of the first-type tasks is higher than that of the second-type tasks; the priority of the first-type execution queue is higher than that of the second-type execution queue; A stop distribution module, configured to, during the process of distributing the second-type tasks, when it is detected that the to-be-executed tasks include first-type tasks, stop distributing the second-type tasks and return to trigger the first distribution module; An execution module, configured to control the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue in the order of the priority of the execution queues.
[0106] In some embodiments, the task processing device further includes: A storage module, configured to store the first-type tasks in the first-type queue and store the second-type tasks in the second-type queue; wherein, the priority of the first-type queue is higher than that of the second-type queue.
[0107] In some embodiments, the first type of queue and / or the second type of queue include multiple queues with different priorities, and the priorities of tasks in the same queue are different.
[0108] The first distribution module includes a first distribution sub-module for distributing the first type of tasks to the first type of execution queue in the scheduling domain within the present node. The second distribution sub-module is used for distributing the second type of tasks to the second type of execution queue in the scheduling domain within the present node.
[0109] The first distribution sub-module is specifically configured to distribute the first type of tasks to the first type of execution queue in the scheduling domain within the present node according to the priority order of tasks in the first type of queue.
[0110] The second distribution sub-module is specifically configured to distribute the second type of tasks to the second type of execution queue in the scheduling domain within the present node according to the priority order of tasks in the second type of queue.
[0111] In some embodiments, the second type of queue includes multiple queues with different priorities. The second distribution sub-module specifically includes: A third distribution sub-module for distributing the second type of tasks in the queue with the highest priority in the second type of queue to the second type of execution queue in the scheduling domain within the present node; A first acquisition module for acquiring the task situation in the queue with the highest priority; wherein, the task situation in the queue at least includes whether there is a task in the queue and the distribution situation of tasks in the queue; A first acting module for, when detecting that the task situation in the queue with the highest priority meets the preset requirements, taking the next queue of the queue with the highest priority as the new queue with the highest priority and returning to trigger the third distribution sub-module; wherein, the preset requirements are that there is no task in the queue with the highest priority, or the number of distributed tasks in the queue with the highest priority is greater than or equal to the preset number.
[0112] In some embodiments, the preset numbers corresponding to different queues in the second type of queue are different; and the higher the priority of the queue, the larger the set preset number.
[0113] The task processing device includes a second acquisition module for acquiring the number of distributed tasks in the second type of queue.
[0114] The second acquisition module is specifically configured to acquire the number of distributed tasks recorded in the counters corresponding to each queue in the second type of queue.
[0115] In some embodiments, the task processing device further includes: A clearing module, configured to clear all the counters corresponding to all the queues in the second type of queue when it is detected that all the queues in the second type of queue are empty, or the quantities recorded by the counters corresponding to all the queues in the second type of queue reach a preset quantity, or the quantities recorded by the counters corresponding to some of the queues in the second type of queue reach the preset quantity and the queues corresponding to the un - reached preset quantity are empty.
[0116] In some embodiments, the task processing device includes a first determination module, configured to determine the task priority.
[0117] The first determination module specifically includes: A third acquisition module, configured to acquire the execution time of a task through a model for predicting the execution time of the task; A setting module, configured to set priorities for each task in ascending order of the execution time of the task.
[0118] Wherein, the third acquisition module specifically includes: A fourth acquisition module, configured to acquire historical task data and extract target features related to the execution time of the task from the historical task data; wherein, the target features include task type, task size, number of concurrent tasks, and / or hardware resource status; A training module, configured to use the target features corresponding to the historical task data as the input of the model and the actual execution time as the output of the model to train the model, so as to obtain a model for predicting the execution time of the task; An extraction module, configured to extract the features of a task after receiving the task; An input module, configured to input the features of the task into the model for predicting the execution time of the task; An output module, configured to output the execution time of the task through the model for predicting the execution time of the task.
[0119] In some embodiments, the task processing device further includes: A fifth acquisition module, configured to acquire, from the start of task distribution in the second type of queue to a target moment, a target queue in the second type of queue whose waiting time for task processing is greater than a preset duration; A second placement module, configured to place the target task in the target queue into the queue before the target queue, and use the queue before the target queue as the new target queue; A sixth acquisition module, configured to acquire the number of tasks distributed in the second type of queue from the time when the task in the target queue is placed into the queue before the target queue to a new target moment when it is detected that the target task has not been distributed; A trigger module, configured to return and trigger the second placement module if the distribution quantity reaches a preset value; A retention module, configured to retain the priority of tasks in a target queue unchanged if it is detected that a target task is issued.
[0120] In some embodiments, a scheduling domain includes multiple processor cores. The task processing device includes: a second issuing module. The second issuing module is configured to issue a task to an execution queue in the scheduling domain within the present node.
[0121] The second issuing module includes: A seventh obtaining module, configured to obtain a pre-established task issuing policy; A third issuing module, configured to issue a task to an execution queue corresponding to a processor core included in the scheduling domain within the present node according to the task issuing policy; wherein, the task includes a first type of task and a second type of task; the execution queue corresponding to the processor core includes a first type of execution queue and a second type of execution queue.
[0122] In some embodiments, the third issuing module includes: An eighth obtaining module, configured to obtain hardware resources on which an execution task depends; A third acting as module, configured to use a processor core within the scheduling domain that includes the hardware resources on which the execution task depends as a target processor core; A fourth issuing module, configured to issue a task to an execution queue corresponding to the target processor core included in the scheduling domain within the present node.
[0123] In some embodiments, the third issuing module includes: A ninth obtaining module, configured to obtain the number of tasks in the first type of execution queue and the number of tasks in the second type of execution queue corresponding to each processor core within the scheduling domain; A first selecting and acting as module, configured to select, from all the processor cores within the scheduling domain, a processor core with the least number of tasks in the first type of execution queue, and use the selected processor core with the least number of tasks in the first type of execution queue as a first target processor core; A second selecting and acting as module, configured to select, from all the processor cores within the scheduling domain, a processor core with the least number of tasks in the second type of execution queue, and use the selected processor core with the least number of tasks in the second type of execution queue as a second target processor core; A fifth issuing module, configured to issue 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 the present node, and issue 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 the present node.
[0124] In some embodiments, the second issuing module includes: A tenth acquisition module, configured to acquire the execution time of the predicted task; A splitting module, configured to split the task into multiple subtasks and set the priorities of the subtasks when it is detected that the execution time of the task is greater than a preset time; A sixth distribution module, configured to distribute the subtasks to the execution queues in the scheduling domain within the node according to the priorities of the subtasks.
[0125] In some embodiments, the execution module specifically includes: An execution module, configured to, if tasks are included in the first-type execution queue and the second-type execution queue corresponding to the processor cores within the node, sequentially execute the first-type tasks in the order of the priorities of the tasks in the first-type execution queue; after executing the first-type tasks, sequentially execute the second-type tasks in the order of the priorities of the tasks in the second-type execution queue; A stop execution module, configured to, during the process of executing the second-type tasks, when it is detected that a first-type task is included in the first-type execution queue, stop executing the second-type tasks and return to trigger the execution module.
[0126] In some embodiments, the task processing device further includes: A migration module, configured to, if it is detected that there are associated tasks for the tasks to be executed by the processor core and the associated tasks are not distributed to the execution queue corresponding to the processor core, migrate the tasks to be executed back from the execution queue of the processor core to the first-type queue or the second-type queue.
[0127] In some embodiments, the task processing device further includes: An eleventh acquisition module, configured to acquire the resources relied on by the tasks in the first-type execution queue and acquire the resources relied on by the tasks in the second-type execution queue; An elevation module, configured to, if it is detected that in the first-type execution queue or the second-type execution queue, the resources relied on by the tasks with higher priorities are different from the resources relied on by the tasks with lower priorities, elevate the priorities of the tasks with lower priorities to obtain a new task priority order; and trigger the execution module.
[0128] For the descriptions of the features in the embodiments corresponding to the task processing device, reference may be made to the relevant descriptions in the embodiments corresponding to the task processing method, which will not be elaborated herein one by one.
[0129] An embodiment of the present invention further provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the embodiments of the above task processing method.
[0130] An embodiment of the present invention also provides a non-volatile storage medium, in which a computer program is stored, and the computer program is configured to execute the steps in any of the above-described task processing method embodiments when running.
[0131] In an exemplary embodiment, the above non-volatile storage medium may include, but is not limited to: various media that can store computer programs such as USB flash drives, read-only memories (ROM for short), random access memories (RAM for short), external hard drives, magnetic disks, or optical discs.
[0132] An embodiment of the present invention also provides a computer program product. The above computer program product includes a computer program, and when the computer program is executed by a processor, the steps in any of the above-described task processing method embodiments are implemented.
[0133] An embodiment of the present invention also provides another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-described task processing method embodiments are implemented.
[0134] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0135] The above has introduced in detail a task processing method, system, electronic device, medium, and product provided by the present invention. Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the protection scope of the present invention.
Claims
1. A task processing method, characterized in that, Applied to a non-uniform memory access architecture node, including: Responding to a task execution request and determining the to-be-executed tasks included according to the task execution request; If the to-be-executed tasks include both first-type tasks and second-type tasks at the same time, then send the first-type tasks to the first-type execution queue in the scheduling domain within this node, and after sending the first-type tasks, send the second-type tasks to the second-type execution queue in the scheduling domain within this 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; During the process of distributing the second-type tasks, when it is detected that the to-be-executed tasks include the first-type tasks, stop distributing the second-type tasks and return to the step of sending the first-type tasks to the first-type execution queue in the scheduling domain within this node; Controlling the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type execution queue according to the priority order of the execution queues.
2. The task processing method according to claim 1, wherein After detecting that the to-be-executed tasks include both first-type tasks and second-type tasks at the same time and before sending the first-type tasks to the first-type execution queue in the scheduling domain within this node, it further includes: Storing the first-type tasks in the first-type queue and storing the second-type tasks in the second-type queue; wherein, the priority of the first-type queue is higher than the priority of the second-type queue.
3. The task processing method according to claim 2, wherein The first-type queue and / or the second-type queue includes multiple queues with different priorities, and the tasks in the same queue have different priorities; Sending the first-type tasks to the first-type execution queue in the scheduling domain within this node includes: Sending the first-type tasks to the first-type execution queue in the scheduling domain within this node according to the task priority order in the first-type queue; Sending the second-type tasks to the second-type execution queue in the scheduling domain within this node includes: Sending the second-type tasks to the second-type execution queue in the scheduling domain within this node according to the task priority order in the second-type queue.
4. The task processing method according to claim 3, characterized in that The second-type queue includes multiple queues with different priorities, and the step of sending the second-type tasks to the second-type execution queue in the scheduling domain within this node according to the task priority order in the second-type queue includes: Sending the second-type tasks in the queue with the highest priority in the second-type queue to the second-type execution queue in the scheduling domain within this node; Obtaining the task situation in the queue with the highest priority; wherein, the task situation in the queue at least includes whether there are tasks in the queue or not, and the sending situation of the tasks in the queue. When it is detected that the task situation in the queue with the highest priority meets the preset requirements, the next queue of the queue with the highest priority is used as the new queue with the highest priority, and the step of distributing the second-type tasks in the queue with the highest priority in the second-type queue to the second-type execution queue in the scheduling domain within the node is returned; wherein, the preset requirements are that there is no task in the queue with the highest priority, or the number of tasks distributed in the queue with the highest priority is greater than or equal to the preset number.
5. The task processing method according to claim 4, characterized in that, The preset numbers corresponding to different queues in the second-type queue are different; and the higher the priority of the queue, the larger the preset number set; Obtaining the number of tasks distributed in the second-type queue includes: Obtaining the number of tasks distributed recorded in the counters corresponding to each queue in the second-type queue.
6. The task processing method according to claim 5, wherein It 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 reach the preset number, or the numbers recorded by the counters corresponding to some queues in the second-type queue reach the preset number, and the queues corresponding to the numbers that do not reach the preset number 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, Determining the task priority includes: Obtaining the execution time of the task through a model for predicting the execution time of the task; Setting priorities for each task in the order of the execution time of the tasks from short to long; Among them, obtaining the execution time of the task through a model for predicting the execution time of the task includes: Obtaining historical task data and extracting target features related to the execution time of the task from the historical task data; wherein, the target features include task type, task size, number of concurrent tasks, and / or hardware resource status; Using the target features corresponding to the historical task data as the input of the model and the actual execution time 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, extracting the features of the task; Inputting the features of the task into the model for predicting the execution time of the task; Outputting the execution time of the task through the model for predicting the execution time of the task.
8. The task processing method according to claim 4, wherein It also includes: From the start of the distribution of tasks in the second-type queue to the target moment, obtaining the target queue in the second-type queue whose waiting time for task processing is greater than the preset time; Placing the target task in the target queue into the queue before the target queue, and using the queue before the target queue as the new target queue; When it is detected that the target task has not been distributed, obtaining the number of tasks distributed in the second-type queue from the time when the task in the target queue is placed in the queue before the target queue to the new target moment; If the number of distributed tasks reaches the preset value, return to the step of placing the target task in the target queue into the queue before the target queue; If it is detected that the target task is distributed, keep the priority of the task in the target queue unchanged.
9. The task processing method according to claim 7, wherein The scheduling domain includes multiple processor cores; Distributing the task to the execution queue in the scheduling domain within the node includes: Obtaining the pre-established task distribution policy; According to the task distribution policy, tasks are distributed to the execution queues corresponding to the processor cores included in the scheduling domain within this node; 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.
10. The task processing method according to claim 9, characterized in that, The distributing tasks to the execution queues corresponding to the processor cores included in the scheduling domain within this node according to the task distribution policy includes: Obtain the hardware resources on which the execution tasks depend. Take the processor cores within the scheduling domain that include the hardware resources on which the execution tasks depend as target processor cores. Distribute the tasks to the execution queues corresponding to the target processor cores included in the scheduling domain within this node.
11. The task processing method according to claim 9, wherein The distributing tasks to the execution queues corresponding to the processor cores included in the scheduling domain within this node according to the task distribution policy includes: Obtain the number of tasks in the first-type execution queues and the number of tasks in the second-type execution queues corresponding to each processor core within the scheduling domain. Select from all the processor cores within the scheduling domain the processor core with the least number of tasks in the first-type execution queue, and take the selected processor core with the least number of tasks in the first-type execution queue as the first target processor core. Select from all the processor cores within the scheduling domain the processor core with the least number of tasks in the second-type execution queue, and take the selected processor core with the least number of tasks in the second-type execution queue as the second target processor core. Distribute the first-type tasks to the first-type execution queue corresponding to the first target processor core included in the scheduling domain within this node, and distribute the second-type tasks to the second-type execution queue corresponding to the second target processor core included in the scheduling domain within this node.
12. The task processing method according to claim 9, wherein The task distribution policy is a policy of sequentially distributing one first-type task to the first-type execution queues of each processor core within the scheduling domain; stopping the distribution until there are no first-type tasks in the first-type queue. Or, the task distribution policy is a policy of sequentially distributing one second-type task to the second-type execution queues of each processor core within the scheduling domain; stopping the distribution until there are no second-type tasks in the second-type queue.
13. The task processing method according to claim 7, wherein The distributing tasks to the execution queues in the scheduling domain within this node includes: Obtain the predicted execution time of the task. In the case where it is detected that the execution time of the task is greater than the preset time, split the task into multiple subtasks and set the priorities of the subtasks. Distribute the subtasks to the execution queues in the scheduling domain within this node according to the priorities of the subtasks.
14. The task processing method according to claim 9, characterized in that, Controlling the processor cores within this node to execute the first-type tasks in the first-type execution queue and the second-type tasks in the second-type 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 cores within this node contain tasks, then sequentially execute the first-type tasks according to the priority order of the tasks in the first-type execution queue; after executing the first-type tasks, sequentially execute the second-type tasks according to the priority order 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 sequentially executing the first type of tasks in the first type of execution queue 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, It further includes: If it is detected that there is an associated task for the task to be executed by the processor core and the associated task has not been issued to the execution queue corresponding to the processor core, the task to be executed is migrated back from the execution queue of the processor core to the first type of queue or the second type of queue.
16. The task processing method according to claim 1, wherein Before controlling the processor cores 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, it further includes: Obtaining the resources upon which the tasks in the first type of execution queue depend and obtaining the resources upon which the tasks in the second type of execution queue depend; If it is detected that in the first type of execution queue or the second type of execution queue, the resources upon which the task with a higher priority depends are different from the resources upon which the task with a lower priority depends, the priority of the task with a lower priority is raised to obtain a new task priority order; and the process enters the step of controlling the processor cores 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.
17. A task processing system, characterized in that, 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; 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 the first type of task and the second type of task, the first type of task is issued to the first type of execution queue in the scheduling domain within the node, and after issuing the first type of task, the second type of task is issued to the second type of execution queue in the scheduling domain within the node; wherein, the priority of the first type of task is higher than the priority of the second type of task; the priority of the first type of execution queue is higher than the priority of the second type of execution queue; during 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 process returns to the step of issuing the first type of task to the first type of execution queue in the scheduling domain within the node; The second-level scheduler is used to control the processor cores 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.
18. An electronic device, characterized in that, It includes: A memory for storing a computer program; A processor for implementing the steps of the task processing method according to any one of claims 1 to 16 when executing the computer program.
19. A non-volatile storage medium, characterized in that, A computer program is stored in the non-volatile storage medium, wherein the computer program implements the steps of the task processing method according to any one of claims 1 to 16 when executed by a processor.
20. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the task processing method according to any one of claims 1 to 16.
Citation Information
Patent Citations
Method for implementing assist nuclear task dynamic PRI scheduling with hardware assistant
CN101414270A
Task processing method and device
CN113327053A
Task processing method and device, electronic equipment and medium
CN116069485A
Task scheduling method and device for distributed storage system
CN117093335A
Task scheduling method, system and equipment for multi-stage feedback queue and medium
CN119179558A
Cited By
Task scheduler for parallel processor chips
CN121143982A