User-mode-oriented storage task adaptive scheduling method and system
By constructing a multi-level priority queue and combining a greedy scheduler with a reinforcement learning scheduler, the problem of inefficient resource utilization and unreliable SLA in storage systems under different load conditions is solved, achieving efficient task scheduling and performance improvement.
Patent Information
- Application Number
- CN202511485814.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-02-06
AI Technical Summary
Existing storage systems lack adaptive scheduling strategies under different load conditions, which makes it impossible to guarantee service quality and system performance at the same time. In particular, under medium load, inefficient resource utilization and failure to guarantee SLA are likely to occur.
An adaptive scheduling method for storage tasks oriented towards user space is adopted. By constructing a multi-level priority queue and combining a greedy scheduler with a reinforcement learning scheduler, the scheduling algorithm is dynamically selected. Priority is determined according to task type and execution stage, and the scheduling strategy is switched under light and heavy load conditions to meet the requirements of the Service Level Agreement (SLA).
It achieves the simultaneous guarantee of task execution efficiency and SLA requirements under different load conditions, improves the overall performance and resource utilization of the storage system, solves the problem of slow response of traditional scheduling strategies under dynamic load, and enhances the system's adaptability in complex load environments.
Smart Images

Figure CN121478434A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer storage system task scheduling technology, and more specifically, relates to a user-mode adaptive scheduling method and system for storage tasks. Background Technology
[0002] To meet the concurrent access demands of various complex business operations, modern storage systems widely adopt multi-threaded models, using inter-thread cooperation to complete task scheduling and processing. The core idea is that the operating system's thread scheduler in kernel space uniformly manages various I / O tasks and distributes them to multiple threads for parallel execution, thereby improving overall throughput and resource utilization. Specific implementation methods vary, such as thread pool models, event-driven models, and CPU affinity-based binding scheduling. Different scheduling strategies are suitable for different load types and system architectures, each with its own advantages and limitations.
[0003] Thread scheduling mechanisms essentially map high-level memory requests to low-level computing resource allocation and coordination. In modern computing platforms, the kernel thread scheduler handles tasks such as resource allocation, execution order control, and concurrent access coordination. However, this kernel-based unified scheduling approach has significant limitations: on the one hand, thread context switching and user-mode / kernel-mode switching introduce additional execution overhead; on the other hand, the scheduling behavior at the operating system level often lacks an understanding of application semantics, making it difficult to achieve fine-grained, low-latency scheduling optimization at the task level. Although the operating system supports setting thread priorities or binding CPU cores, these mechanisms are poorly adaptable to dynamic load changes, have high configuration costs, and are not conducive to flexible and efficient task management.
[0004] To address increasingly complex task models and performance requirements, more and more storage systems are attempting to migrate task scheduling logic to user space for execution. This is achieved by introducing lightweight execution units such as coroutines, enabling more controllable runtime behavior. The coroutine model, with its run-to-complete (RTC) execution method, naturally avoids frequent thread switching and context saving, resulting in extremely high execution efficiency. The coroutine scheduler, as its core component, is responsible for resource management, priority control, and scheduling strategy implementation in user space on a task-by-task basis. By introducing intelligent scheduling algorithms, differentiated resource allocation and quality-of-service (QoS) assurance among tasks can be achieved by combining task importance, latency sensitivity, and historical load information.
[0005] However, existing user-oriented task execution frameworks and scheduling mechanisms still have several problems: First, there is a lack of specialized scheduling strategies for the diverse task types in storage systems. Existing task scheduling, which is generally thread-based, lacks awareness of the tasks executed within a thread and relies on inherent operating system strategies. In real-world storage scenarios, task types are complex and diverse, including but not limited to: read, write, and update operations on metadata; read and write operations on user data; and background tasks related to system maintenance, such as polling tasks that listen for IO requests and garbage collection (GC) tasks in append-only scenarios. A single user read or write operation often triggers multiple different tasks, and these different tasks have significantly different requirements for resource sensitivity, response latency, and processing frequency. Simple scheduling strategies cannot adequately address the performance needs of various tasks, easily leading to system bottlenecks or a decline in service quality.
[0006] Second, using the same scheduling strategy under different system loads lacks awareness of the system state and cannot simultaneously guarantee service quality and system performance under complex loads. For example, when the number of tasks is small or system resources are sufficient, a simple greedy strategy can achieve the lowest average latency and meet the Service Level Agreement (SLA). However, if the system pressure increases, such as when the system is under medium load, continuing to use a greedy strategy may lead to the failure to guarantee the SLA and result in inefficient resource utilization. Summary of the Invention
[0007] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention provides a user-mode adaptive scheduling method and system for storage tasks. Its purpose is to solve the problems of existing scheduling technology having fixed strategies under different load conditions, which cannot simultaneously guarantee service quality and system performance, and inefficient resource utilization.
[0008] To achieve the above objectives, the present invention provides a user-mode adaptive scheduling method for storage tasks, comprising: S1. Construct a multi-level priority queue for scheduling the thread executing the coroutine task and bind it to a CPU core; split the user request into different user tasks, and divide the user tasks and background tasks into tasks with different execution stages; S2. Construct a greedy scheduler and a reinforcement learning scheduler. The greedy scheduler is used to determine the priority of tasks in the multi-level priority queue based on task type and execution stage, so as to minimize the average latency of tasks to be scheduled in the multi-level priority queue. The reinforcement learning scheduler is used to learn the estimated execution time of user tasks in each execution stage to determine the priority of tasks in the multi-level priority queue, so that the sum of the execution time and scheduling waiting time of all user tasks included in the current user request does not exceed the preset service level agreement (SLA) time. The task type includes user tasks and background tasks. S3. Calculate the load value Load of the current task, and compare the load value Load with preset upper and lower thresholds. α and β In comparison, if α ≤Load≤ β If the priority p is determined by the reinforcement learning scheduler, then the priority p of the current task in the multi-level priority queue is determined; otherwise, the priority p is determined by the greedy scheduler. S4. According to the priority p, the current task is scheduled as a coroutine to the queue of the priority corresponding to the multi-level priority queue. The thread bound to the CPU core executes the tasks in the multi-level priority queue in order of priority. The next task is taken as the current task, and the process jumps to step S3 until all the requested tasks are scheduled or the system stops working.
[0009] Furthermore, in step S1, the multi-level priority queue is a four-level priority queue, with the priority decreasing sequentially from level 0 to level 3; In S2, determining the priority of a task in the multi-level priority queue based on the task type and task execution stage includes: For user tasks before and after the blocking phase, set their priority to level 1; for user tasks during the blocking phase, set their priority to level 3. For background tasks that affect the operation of the storage system, set their priority to level 0; for other background tasks before the blocking phase, set their priority to level 2; for other background tasks during the blocking phase, set their priority to level 3; for IO request listening tasks and batch IO tasks after the blocking phase, set their priority to level 1; and for idle garbage collection tasks after the blocking phase, set their priority to level 2.
[0010] Further, in step S2, the sum of the execution time and scheduling wait time of all user tasks included in the current user request is:
[0011] In the formula, Request for the current user The execution phases included For the first Task processing latency in each execution phase For the first Task I / O wait time in each execution phase For the first The scheduling waiting time for each stage of the task; and The sum of these values represents the estimated execution time learned by the reinforcement learning scheduler. The calculation method is as follows:
[0012] In the formula, When inserting a current task whose priority is to be determined into a priority queue of the multi-level priority queue, the number of tasks preceding the current task in that priority queue; This indicates the priority level preceding the current task in the priority queue. The estimated execution time for each task.
[0013] Furthermore, the state of the reinforcement learning scheduler for:
[0014] In the formula, Indicates the first priority level in the multi-level priority queue The estimated clearing time for each priority queue. This represents the current task and its execution phase, Len is the current task data length, and SLA is the current task's SLA time. The action of the reinforcement learning scheduler for:
[0015] In the formula, EST is the estimated waiting time; EET is the estimated execution time, used to update the estimated clearing time and calculate the reward; Prio is the priority p determined by the reinforcement learning scheduler. The rewards for the reinforcement learning scheduler include: prediction accuracy rewards. Rewards for achieving SLA :
[0016] In the formula, AST represents the actual scheduling time, and AET represents the actual waiting time. This indicates the absolute value operation; overtime This refers to the portion that has exceeded the time limit, i.e. The difference with SLA, , These are preset parameters.
[0017] Furthermore, it also includes setting a Scanner mechanism for the reinforcement learning scheduler, specifically including: If a task scheduled to a priority queue with priority p causes a task in a queue with a lower priority to exceed its SLA time limit, then when the level 0 queue is empty, the priority of the tasks in the queue with a lower priority to p is recalculated. Specifically, after a task is scheduled to a priority queue with priority p, whether an SLA time limit will exceed its SLA time limit is determined based on the remaining available time of the tasks in the queue with a lower priority to p. The remaining available time is the difference between the task's SLA time and the time already waited. The priority of tasks in queues with a priority lower than p is recalculated, including: if the remaining available time is less than the estimated execution time, the priority of the task is raised to level 0; otherwise, the priority is adjusted according to the urgency and importance of the task.
[0018] Furthermore, in step S3, when a scheduler switch occurs, the priority of tasks in the multi-level priority queue is recalculated based on the switched scheduler; wherein the scheduler is a greedy scheduler or a reinforcement learning scheduler.
[0019] Furthermore, it also includes setting a preset jitter zone Δ, if the load value Load is within... α ±Δ or β Within ±Δ, no scheduler switching will be performed.
[0020] Further, in step S3, the load value of the current task is calculated, including: Collect load statistics data within a certain time window, including the length of each queue in the multi-level priority queue and the request arrival rate; The load statistics are normalized, and the lengths of the normalized queues at each level and the request arrival rates are weighted and summed to obtain the load value.
[0021] The present invention also provides a user-mode adaptive scheduling system for storage tasks, including a computer-readable storage medium and a processor; The computer-readable storage medium is used to store executable instructions; The processor is used to read executable instructions stored in the computer-readable storage medium and execute the user-mode storage task adaptive scheduling method described above.
[0022] The present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that, when the program is executed by a processor, it implements the user-mode adaptive scheduling method for storage tasks as described in any of the preceding claims.
[0023] In summary, the above-described technical solutions conceived in this invention can achieve the following beneficial effects: (1) The present invention adopts an adaptive scheduling strategy switching mechanism based on dual thresholds. Compared with the traditional static scheduling strategy, it can dynamically select the optimal scheduling algorithm according to the system load status. Under light and heavy load conditions, a greedy strategy is adopted to minimize the average latency. Under medium load conditions, a reinforcement learning strategy is adopted to balance SLA guarantee and system throughput, ensuring that the read and write tasks requested by users will not exceed the latency index required by SLA when completed. It effectively solves the problem of fixed strategy and slow response of existing scheduling technology under different load conditions. It can significantly improve the overall performance and resource utilization of the storage system while ensuring task execution efficiency and SLA requirements, and also improve the system's adaptive capability under complex load environments.
[0024] (2) The present invention introduces an optimization design that combines greedy strategy and reinforcement learning in the scheduling algorithm, which effectively solves the problem of invalid scheduling of IO listening tasks in the storage system and the scheduling optimization problem under SLA constraints (ensuring that the SLA is not violated).
[0025] (3) The user-mode task processing framework of the present invention adopts coroutine scheduling in conjunction with CPU core binding technology to schedule the original storage tasks in user mode in the form of coroutines, thereby realizing a lightweight task execution mode that bypasses the traditional kernel thread scheduler, thereby reducing the additional overhead caused by thread context switching and user mode / kernel mode switching.
[0026] (4) Furthermore, by dividing tasks into fine-grained priorities based on task type and execution stage, tasks in execution stages that affect system operation or cannot be merged can be executed first. The actual execution delay of low-priority IO tasks can facilitate IO merging, reduce the additional overhead caused by multiple system calls, and ensure that the thread CPU is always executing effective tasks, thus minimizing the average latency of tasks to be scheduled in the multi-level priority queue. At the same time, the design of the multi-level priority queue supports differentiated task scheduling. Combined with semantic awareness of task types, it does not need to rely on the general scheduling strategy of the operating system, further improving the efficiency and controllability of task processing in the storage system.
[0027] (5) Furthermore, the present invention also sets up a Scanner mechanism for the reinforcement learning scheduler, which can prevent low-priority tasks from starving due to the continuous insertion of high-priority tasks, while ensuring that tasks close to the SLA limit can be processed in a timely manner.
[0028] (6) Furthermore, to avoid the performance overhead caused by frequent switching, the system sets a threshold jitter zone Δ, and the scheduler is switched only when the load value obviously exceeds the limit. When it is determined that the scheduler needs to be switched, the system will resubmit all tasks to the new scheduler for priority calculation, and redistribute the tasks to the corresponding queues according to the new priority.
[0029] In summary, this invention employs a dual-threshold adaptive scheduling strategy switching mechanism. For the static greedy scheduling strategy, it assigns scheduling priorities to different task categories. For the reinforcement learning scheduling strategy, it uses a reinforcement learning model to learn and generate the priority of the current task in a multi-level queue based on the SLA guarantee level. By considering task type and execution stage as parameters of the scheduler, it supports the scheduling of diverse and differentiated tasks in the storage system. Simultaneously, the system can dynamically switch scheduling strategies based on the current load, achieving an adaptive balance between ensuring the SLA of critical tasks and the overall average system latency, thus facilitating efficient system operation under varying loads. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of the user-mode storage task adaptive scheduling method in an embodiment of the present invention; Figure 2 This is an overall flowchart of the user-mode adaptive scheduling method for storage tasks in this embodiment of the invention. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0032] Example 1 The basic idea of this invention is to achieve a more efficient task processing framework by replacing the original kernel thread-based storage task scheduling scheme with a user-mode coroutine scheduling mechanism. Multi-level priority queues are directly managed and CPU core binding is configured during task scheduling, reducing user-mode / kernel-mode switching latency and improving task execution controllability. A dual-threshold adaptive scheduling strategy switching technique is introduced, combining a greedy scheduler and a reinforcement learning scheduler to alleviate the adaptability problem of static scheduling strategies under dynamic load environments, avoiding performance losses caused by rigid scheduling strategies, and improving the system's adaptability and quality of service assurance under complex loads.
[0033] like Figure 1 and Figure 2 As shown, this embodiment of the invention provides a user-mode adaptive scheduling method for storage tasks, including the following steps: S1. Construct a multi-level priority queue for scheduling threads executing coroutine tasks and bind them to CPU cores. Break down user requests into specific user tasks, and define execution stages and priorities for each stage for these user tasks and background system tasks. A static greedy scheduler then directly assigns task priorities based on task type and execution stage. Task types include different user tasks and background tasks.
[0034] S2. After determining the basic scheduling priority of the task in step S1, set the upper and lower thresholds of the scheduling strategy. α and β And construct a greedy scheduler and a reinforcement learning scheduler.
[0035] S3. During storage system operation, the task scheduling system receives task requests (user requests or background requests) from the storage system and monitors the current load status. Based on the current system load status, it uses a dual-threshold judgment algorithm to assign the current task to the appropriate scheduler and assign it a priority. p This priority level is used to determine which priority queue the current task belongs to within the priority queue.
[0036] S4. Based on the scheduling priority of the current task obtained from the scheduler in step S3. p The current task is scheduled to a specific priority queue in the form of a coroutine. The polling core-bound thread with CPU resources executes the task in order of priority and progress, and reschedules the task after it has completed a stage.
[0037] Set the next task as the current task and repeat steps S3-S4 until the system stops working or all requested tasks have been scheduled.
[0038] Preferably, step S1 includes the following sub-steps: (1-1) The system uses CPU core binding technology to bind threads executing coroutine tasks to specific CPU cores, and configures a multi-level priority queue for each core-bound thread to poll tasks. This priority queue is a multi-level queue, and each level of the queue is used to determine the order of tasks within the same level. After the scheduler determines the priority of the current task, the core-bound thread receives the task, inserts it into the corresponding priority queue according to the task priority, and executes the task according to the queue priority order.
[0039] In this embodiment of the invention, a NUMA-aware CPU core-binding strategy is employed. Upon system startup, hardware topology information is first obtained via system calls, identifying the number of NUMA nodes, the number of CPU cores per node, and the memory distribution. Based on the NUMA topology, the system allocates a dedicated group of worker threads to each NUMA node, ensuring memory access locality during task processing. Each worker thread is bound to a specific CPU core at creation via the CPU affinity setting interface provided by the operating system. This core-binding strategy avoids thread migration between different CPU cores, eliminates CPU cache invalidation caused by thread migration, maintains the hotness of instruction and data caches, and significantly improves task execution efficiency.
[0040] (1-2) The user request is split into specific user tasks, and the execution stages are divided for the split specific user tasks and background system tasks. The priority of each stage is statically divided by the greedy idea, which is used to build a greedy scheduler.
[0041] For a greedy scheduler, the core scheduling goal is to ensure that the CPU of a thread is always executing a valid task, reducing the number of scheduling operations. Delaying the actual execution of I / O facilitates I / O merging, further reducing the overhead of multiple system calls. The core idea is to execute non-mergeable task phases with high priority, such as tasks requiring separate CPU parsing and computation, while executing mergeable task phases with low priority, such as the I / O phases of various tasks.
[0042] In this embodiment of the invention, four task queues with different priority levels are constructed, that is, the priority is set to 4 levels: level 0 to level 3, with the priority decreasing sequentially.
[0043] For newly generated user tasks, the priority of user tasks before the blocking phase is set to level 1, the priority of user tasks in the blocking phase is set to level 3, and the priority of user tasks after the blocking phase is set to level 1. For example, for a user's write request, the task can be divided into ① metadata reading task, ② data writing task, and ③ metadata update task. These three user tasks can be divided into two phases according to the execution phase: a data parsing and execution phase and an IO phase (blocking phase). The former has a higher priority than the latter because tasks in the parsing and execution phase often require immediate CPU processing. In this embodiment of the invention, the priority of tasks in this phase is set to level 1, and then the low-priority IO phase begins. For the IO phase, on the one hand, its specific completion time is difficult to predict; on the other hand, such tasks can be combined into one IO execution through special processing (depending on whether the system specifically handles this) to reduce overhead. Therefore, it is set to a low priority; in this embodiment of the invention, its priority is set to level 3.
[0044] Specifically, for read metadata tasks, the main responsibility of this stage is to retrieve the location information of the target data from the distributed metadata index, including logical address mapping of data blocks, replica distribution locations, access permission verification, and other operations. This stage is CPU-intensive, typically involving hash calculations, index lookups, and permission checks, and can complete the calculations quickly and immediately proceed to the next processing stage. Based on its rapid execution, the system assigns an initial high-priority flag (Level 1) to this type of task. For write data tasks, this stage is responsible for writing the user-submitted data to the underlying storage device. The execution mode of this stage exhibits a clear two-stage characteristic: first, CPU operations such as data preprocessing, encoding, verification, and calculation are performed; then, an I / O write operation is initiated and a response is awaited. Due to the asynchronous nature of I / O operations, the task enters an I / O waiting state (blocked stage) after completing CPU processing. At this time, CPU resources can be released for other tasks. The system assigns an initial high priority to this type of task, but a dynamic priority adjustment mechanism is designed so that the task automatically degrades to a low-priority queue when entering the I / O waiting state. For update metadata tasks, this stage is responsible for updating the distributed metadata index based on the data write results, ensuring data consistency and index accuracy. This stage is also a CPU-intensive operation, involving index updates, consistency checks, transaction commits, etc. The system assigns it an initial high priority (level 1).
[0045] For background tasks, those that affect system operation, such as high-water mark GC tasks or fault recovery tasks that must be executed immediately, should be set to the highest priority. In this embodiment, they are set to level 0. In this embodiment, background tasks that affect system operation refer to those that, if not executed immediately, would cause the storage system to be unable to provide storage services. Tasks such as idle GC tasks, IO request monitoring tasks, or special batch IO tasks can still be divided into multiple sub-tasks. Tasks that do not affect system operation before the blocking phase are given a medium priority. In this embodiment, tasks that do not affect system operation before the blocking phase are given a level 2 priority; tasks during the blocking phase are given a level 3 priority; and tasks after the blocking phase are given a level 1 or level 2 priority. Specifically, IO request monitoring tasks and batch IO tasks are given a level 1 priority, and idle GC tasks are given a level 2 priority.
[0046] In this embodiment of the invention, the priority queue adopts a multi-level queue architecture design. The system establishes four task queues with different priority levels. For different scheduling algorithms, the criteria for enqueuing tasks in different priority queues are not entirely the same. In greedy scheduling, tasks enter different queues mainly based on task type and status, while in intelligent scheduling strategies, it depends on the estimated waiting time of the task.
[0047] Each queue maintains an estimated flush duration field (ECT) in real time. This field is calculated by summing the expected execution times of all tasks in the queue. When a new task is added to the queue, the system updates this field; when a task is completed, the system decrements the field value accordingly. This estimated flush duration provides the reinforcement learning scheduler with a basis for evaluating scheduling wait times.
[0048] The priority range and specific numerical values for each stage can be adjusted according to the system. The principle is to assign higher priorities to tasks that the CPU needs to execute immediately, and lower priorities to tasks where delaying or combining execution would yield greater benefits. For greedy strategies, a fixed priority needs to be determined for each stage of the task. For reinforcement learning scheduling strategies, the goal is to learn the priority of a task at a given stage.
[0049] Preferably, step S2 includes the following sub-steps: (2-1) During the system initialization phase, the dual-threshold scheduling controller sets the upper and lower thresholds α and β of the scheduling strategy based on the system configuration and historical load data. In practical applications, these thresholds are determined according to different system configurations and are empirical values. Specifically, the load statistics collected over a certain time window mainly include two core indicators: the length of each task queue in the multi-level priority queue and the request arrival rate. The task queue length reflects the current task backlog of the system and is a direct indicator of the system's load pressure. The request arrival rate reflects the intensity of external request traffic and is an important basis for predicting the future load trend of the system. After normalizing the task queue length and request arrival rate, the system calculates the comprehensive load index, i.e., the load value Load, using a weighted summation method. In this embodiment of the invention, the weight of the task queue length is 0.7, and the weight of the request arrival rate is 0.3 (these weights are only examples and can be changed). The task queue length has a higher weight because it directly reflects the immediate pressure state of the system, while the request arrival rate has a relatively lower weight because it is mainly used for load trend prediction.
[0050] (2-2) After setting the threshold range in (2-1), the system will construct two different scheduler instances: a greedy scheduler and a reinforcement learning scheduler. The greedy scheduler determines the priority p of the current task based on its type and execution stage, and on the static task priority designed above, so as to minimize the average latency of the tasks to be scheduled in the multi-level priority queue. The reinforcement learning scheduler uses a reinforcement learning algorithm to determine the priority parameter p of the current task, so as to guarantee the Service Level Agreement (SLA) as much as possible, that is, to ensure that the sum of the estimated execution time and scheduling wait time of all tasks in a user request containing n execution stages does not exceed the preset SLA.
[0051] This process involves preparing corresponding scheduling strategies for different load states and completing the scheduler's initial configuration. Different types of schedulers have significantly different optimization objectives and algorithmic logic. Taking a greedy scheduler as an example, a typical implementation organizes tasks to be scheduled through a simple multi-level priority queue, aiming for the lowest average latency. In contrast, a reinforcement learning scheduler provides more refined scheduling decisions, ensuring SLAs when the system is under a certain load.
[0052] (2-3) The reinforcement learning-based scheduler includes learning from historical task execution data and parameter adjustment operations during the construction process.
[0053] Reinforcement learning schedulers rely on historical task execution data (task type, execution time, etc.) for model training and parameter optimization. During model training, the scheduler needs to analyze historical task execution patterns, SLA achievement, and other data to perform multiple rounds of iterative optimization. These optimization operations can be completed offline during model building.
[0054] The purpose of a reinforcement learning scheduler is to learn the latency estimate of each stage of the task and control the waiting latency by dynamically determining the priority p of the task through the waiting time, thereby ensuring that the read and write tasks requested by the user will not exceed the latency index required by the SLA when they are completed.
[0055] Therefore, in this embodiment of the invention, the main objective of the reinforcement learning scheduler is to ensure that for a given condition, the scheduler has the following characteristics: User requests at each stage Its execution time Scheduling waiting time and IO wait time Smaller than the preset That is, the following formula:
[0056] in Representing the Task processing latency in each execution phase Representing the The I / O wait time (blocking time) of each execution phase task. Theoretically, two data ( , ) and the length of data involved in the current task The latency of the I / O phase may also be related to the load. load Related. For the first The scheduling waiting time for each stage.
[0057] In this embodiment of the invention, and The sum of these values, derived implicitly from the reinforcement learning scheduler, represents the estimated execution time.
[0058] The scheduling wait time for a stage p can be approximated as the sum of the execution times of all preceding tasks:
[0059] This indicates the number of tasks preceding the current task in a priority queue when the current task, whose priority is yet to be determined, is inserted into a priority queue of a multi-level priority queue. This indicates the priority level preceding the current task in the priority queue. The estimated execution time of each task. Reinforcement learning schedulers can be built based on the Actor-Critic algorithm, modeling the learning of scheduling parameters as a continuous control problem. The following is just one example scheme; for instance, the system constructs two neural networks: the Actor network is responsible for outputting scheduling decisions, and the Critic network is responsible for evaluating state values. The Actor network structure is: 5 neurons in the input layer (corresponding to a 5-dimensional state vector), 32 neurons in the hidden layer, and 3 neurons in the output layer (corresponding to three predicted values). The Critic network structure is: 5 neurons in the input layer, 32 neurons in the hidden layer, and 1 neuron in the output layer (state value).
[0060] Based on the above analysis, in this embodiment of the invention, the reinforcement learning scheduler is designed according to the following state, action, and reward.
[0061] In reinforcement learning strategies, the state includes the following dimensions: the estimated clearing time for each priority queue, the specific task requiring priority and its execution stage, the data length involved in the current task, the SLA time requirement, and the current load status (load value). This constitutes the state space of the reinforcement learning scheduler. for:
[0062] in, Indicates the first i The estimated clearing time for each priority queue. For the current task and its execution phase, The current task data length is specified, and the SLA is the SLA time requirement for the current task.
[0063] The actions include providing the following metrics for the current task: 1. Estimated waiting time; 2. Estimated execution time; 3. Estimated priority, which in this embodiment is level 0 to 3. The estimated execution time will be used to update the estimated clearing time of the priority queue to which the task belongs and to calculate the reward. This is the action space of the reinforcement learning scheduler. for:
[0064] Where EST is the estimated waiting time for scheduling. The estimated execution time, The estimated priority is p.
[0065] Core learning objective: The core task of the reinforcement learning scheduler is to learn the function. This allows the predicted schedulable time, execution time, and priority to maximize long-term cumulative rewards. The function implicitly learns the task's latency parameters under different conditions, achieving the core objective of "determining priority by calculating the schedulable time of a task."
[0066] After each task is completed, the system records the actual waiting time, execution time, final priority, and SLA achievement status, forming training samples. The reward mechanism involves two parts: prediction accuracy reward and SLA achievement reward. The former is calculated based on the actual completion status of the task and the estimated waiting scheduling time, while the SLA achievement reward is calculated based on the SLA achievement status.
[0067] In this embodiment of the invention, the prediction accuracy reward It can be designed as:
[0068] Where AST represents the actual scheduling time and AET represents the actual waiting time. The estimated waiting time for scheduling, The estimated execution time, This indicates the absolute value operation.
[0069] SLA Achievement Rewards It can be designed as:
[0070] in, overtime This refers to the portion that has exceeded the time limit, i.e. and The difference, , These are preset parameters, taken from experience. This is a multiplication operation. The total reward can be the weighted sum of the above items.
[0071] Furthermore, since the priority of tasks at each stage in reinforcement learning strategies is not fixed, the insertion of high-priority tasks can affect the scheduling waiting time of low-priority tasks. Therefore, in this embodiment of the invention, an additional Scanner mechanism is set up for the reinforcement learning scheduler to reschedule tasks in the queue. The main purpose of the Scanner mechanism is to prevent low-priority tasks from starving due to the continuous insertion of high-priority tasks, while ensuring that tasks approaching the SLA limit can be processed in a timely manner.
[0072] When the Scanner is triggered, it processes tasks in the queue according to a specific scanning strategy. First, the Scanner checks the waiting time and expected execution time of each task, and reassesses the urgency of the tasks based on the current system load. For tasks whose waiting times are close to or exceed the expected waiting time, the Scanner calculates their new priority.
[0073] Specifically, after the reinforcement learning scheduler calculates the priority p of the current task, it inserts it into the queue corresponding to priority p. If the insertion of the current task would cause the SLA of tasks in the lower priority queue (queues with priority lower than p) to expire, then when the level 0 queue is empty, the priorities of the tasks in the lower priority queue are rearranged (the clearing time for each task varies). The number of tasks inserted into the queue with priority p determines whether the insertion of the current task would cause the SLA of tasks in the lower priority queue to expire. If the number of inserted tasks exceeds a preset threshold, it is determined that the insertion of the current task would cause the SLA of tasks in the lower priority queue to expire. The preset threshold is determined empirically, and it varies for different lower priority queues, with higher thresholds for lower priority queues.
[0074] If the remaining available time for a task (SLA time minus the waiting time) is less than the expected execution time, the task will be moved to queue level 0. For other tasks, Scanner will adjust their priority appropriately based on their urgency and importance, potentially moving them to a higher priority queue or lowering them to a lower priority queue.
[0075] The Scanner mechanism also implements a smooth priority adjustment strategy to avoid drastic fluctuations in task priorities. When task priorities need to be adjusted, typically only one priority level is adjusted at a time, unless the task is about to violate SLA constraints. This smooth adjustment strategy prevents drastic fluctuations in system resource allocation and maintains system stability. Simultaneously, the Scanner records the results of each scan and the effect of the adjustment; this information can be used as training data for reinforcement learning to optimize the scheduling strategy. Through learning from historical data and updating parameters online, the reinforcement learning scheduler can precisely control task waiting latency to meet SLA requirements, improving the overall system performance while ensuring service quality.
[0076] Preferably, step S3 includes the following sub-steps: (3-1) During operation, the task scheduling system continuously receives task requests from the storage system and simultaneously collects the current storage system status information in real time through the system load monitoring module.
[0077] (3-2) The scheduling module includes load monitoring metrics for task request records: the current load value, used to maintain a quickly measurable load. load. This indicator will be submitted to a dual-threshold judgment algorithm, which will compare the value with preset upper and lower thresholds. α , β Compare; if the current load value is less than α When the system is under light load, the task queue has a small backlog and the request arrival rate is low, so a greedy scheduler is chosen to minimize the average latency; if the load value is greater than... β The system is under heavy load, with a severe backlog of tasks and a high request arrival rate. At this point, a low SLA default rate cannot be guaranteed. A greedy strategy can be used to reduce the default rate (average latency) and ensure that most tasks can be completed. Therefore, a greedy scheduler is also chosen to quickly process the backlog of tasks and prevent a complete SLA collapse. If the load value is... α and β Between these periods, the system is under moderate load, and the task queue and request arrival rate are within a controllable range. A reinforcement learning scheduler is selected, and priority judgment is made in combination with SLA requirements to perform refined SLA optimization scheduling.
[0078] The core of the dual-threshold judgment algorithm is the design of the load assessment function. The system first collects two core metrics: task queue length and request arrival rate. The load assessment function combines these two metrics into a single load value through weighted summation and normalization. In this embodiment, the task queue length has a weight of 0.7, reflecting the current task backlog in the system. The request arrival rate has a weight of 0.3, reflecting the intensity of external request traffic.
[0079] (3-3) After determining the scheduler type using the dual threshold judgment algorithm, the current task type and execution stage are input into the determined scheduler to obtain the priority p. If a scheduler switch occurs, such as when the load pressure changes, and the currently determined scheduler is different from the scheduler determined for the previous task, all tasks in the queue will be rescheduled. At the same time, the current task request along with the task type prompt information will be sent to the selected scheduler. That is, based on the switched scheduler, the priority p of all tasks waiting to be executed in the current multi-level priority queue will be re-determined, and then the current task type and execution stage will be input into the determined scheduler to obtain the priority p.
[0080] To avoid frequent scheduler switching and subsequent performance overhead due to load jitter around the threshold, this embodiment of the invention sets a threshold jitter range Δ. This value is configured by a configuration item (system setting) and is empirically determined. The determined load value is within... β Within ±Δ, and α When the time is within ±Δ, the system will not switch schedulers again.
[0081] The scheduler calculates a specific priority value p for the current task based on its internal algorithm logic, task type, and task execution stage, and returns the result to the task scheduling system. For the greedy scheduler, priority calculation is mainly based on task type and execution stage. This invention designs four priority levels (0-3), with different task types assigned priorities according to the aforementioned allocation rules. For the reinforcement learning scheduler, the priority calculation process is more complex, mainly based on the task's expected execution time and available waiting time, calculated through an Actor network.
[0082] Preferably, step S4 includes the following sub-steps: (4-1) After receiving the task priority p returned by the scheduler in step S3, the task scheduling system creates a corresponding coroutine instance to encapsulate the current task. Each coroutine instance contains task context (including task ID, task type, priority level, creation timestamp, SLA deadline), execution status (including current execution stage, cumulative execution time, waiting time statistics, and whether it is in IO waiting), and scheduling information (including the priority queue to which it belongs, last scheduling time, expected execution time, and actual execution progress).
[0083] (4-2) Based on the task priority p, insert the coroutine task into the task queue of the corresponding priority.
[0084] (4-3) The polling thread bound to a specific CPU core continuously checks the status of each priority queue. When it finds a task to be executed in the queue, the polling thread processes the coroutine tasks in the queue in descending order of priority to ensure that high-priority tasks are executed first.
[0085] (4-4) If the task is executed by the reinforcement learning scheduler, the network parameters of the reinforcement learning scheduler are updated and the scheduler model is optimized, depending on whether online learning is configured. After the task is completed, if online learning or offline learning is required, the actual execution time of each task, SLA achievement, and other feedback information are recorded to form new training samples and stored in the experience replay buffer. A neural network parameter update is triggered after processing N tasks to ensure continuous model optimization without affecting real-time performance. Specifically, experience samples are replayed to the buffer to store historical data of task execution. Each experience sample contains state information (task characteristics, system load, queue status), action information (assigned priority, predicted execution time, predicted waiting time), reward information (SLA achievement, prediction accuracy, system efficiency improvement), and next state information (system state after execution, new load status). After the system processes a certain number of tasks, a model update is triggered, including sampling data from the experience replay buffer, calculating temporal difference error, updating the parameters of the Actor network and Critic network, and periodically saving model checkpoints. This online learning mechanism enables the scheduler to continuously optimize its decision-making strategies and adapt to dynamic changes in system load. Simultaneously, through batch updates and asynchronous processing, it ensures that the learning process does not impact the system's real-time performance.
[0086] Example 2 This invention provides a user-mode adaptive scheduling system for storage tasks, comprising: The first module receives user requests from the storage system, decomposes them into specific tasks at different stages according to the request type using a task splitting algorithm, constructs a multi-level priority queue and configures CPU core binding, and then sends them to the second module.
[0087] The second module is responsible for building and managing the greedy scheduler and the reinforcement learning scheduler, setting the dual threshold intervals α and β, and completing the initial configuration of the scheduler and preparation for offline training.
[0088] The third module receives task requests from the first module during operation, monitors the current system load status through a dual threshold judgment algorithm, selects the appropriate scheduler based on the load and calculates the task priority p, and sends the scheduling decision to the fourth module.
[0089] The fourth module transforms the task priority p provided by the third module into coroutine task allocation behavior. Through a CPU core-binding polling mechanism, tasks are allocated to the corresponding priority queues in the form of coroutines, and the core-binding threads execute the tasks in priority order. At the same time, the reinforcement learning model is updated online, and then the interaction with the third module is repeated until the system stops working or all requested tasks are scheduled.
[0090] For the specific implementation of each module, please refer to the description of the corresponding steps in Embodiment 1 above, which will not be repeated here.
[0091] Example 3 This invention provides a user-mode adaptive scheduling system for storage tasks, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the user-mode adaptive scheduling method for storage tasks in Embodiment 1 above.
[0092] The relevant technical solutions are the same as above, and will not be repeated here.
[0093] Example 4 This invention provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the user-mode adaptive scheduling method for storage tasks described in Embodiment 1 above.
[0094] Specifically, the memory may include high-speed random access memory, as well as non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital (SD) cards, flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.
[0095] The relevant technical solutions are the same as above, and will not be repeated here.
[0096] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A user-mode adaptive scheduling method for storage tasks, characterized in that, include: S1. Construct a multi-level priority queue for scheduling the thread executing the coroutine task and bind it to a CPU core; The user request is broken down into different user tasks, and the user tasks and background tasks are divided into tasks with different execution stages; S2. Construct a greedy scheduler and a reinforcement learning scheduler. The greedy scheduler is used to determine the priority of a task in the multi-level priority queue based on the task type and execution stage, so as to minimize the average latency of the scheduled tasks in the multi-level priority queue. The reinforcement learning scheduler is used to learn the estimated execution time of user tasks at each execution stage to determine the priority of tasks in the multi-level priority queue, so that the sum of the execution time and scheduling waiting time of all user tasks included in the current user request does not exceed the preset service level agreement (SLA) time; wherein, the task type includes the user task and background task; S3. Calculate the load value Load of the current task, and compare the load value Load with preset upper and lower thresholds. α and β In comparison, if α ≤Load≤ β If the priority p is determined by the reinforcement learning scheduler, then the priority p of the current task in the multi-level priority queue is determined; otherwise, the priority p is determined by the greedy scheduler. S4. According to the priority p, the current task is scheduled as a coroutine to the queue of the priority corresponding to the multi-level priority queue. The thread bound to the CPU core executes the tasks in the multi-level priority queue in order of priority. The next task is taken as the current task, and the process jumps to step S3 until all the requested tasks are scheduled or the system stops working.
2. The user-mode adaptive scheduling method for storage tasks according to claim 1, characterized in that, In step S1, the multi-level priority queue is a four-level priority queue, with the priority decreasing sequentially from level 0 to level 3; In S2, determining the priority of a task in the multi-level priority queue based on the task type and task execution stage includes: For user tasks before and after the blocking phase, set their priority to level 1; for user tasks during the blocking phase, set their priority to level 3. For background tasks that affect the operation of the storage system, set their priority to level 0; for other background tasks before the blocking phase, set their priority to level 2; for other background tasks during the blocking phase, set their priority to level 3; for IO request listening tasks and batch IO tasks after the blocking phase, set their priority to level 1; and for idle garbage collection tasks after the blocking phase, set their priority to level 2.
3. The user-mode adaptive scheduling method for storage tasks according to claim 1 or 2, characterized in that, In step S2, the sum of the execution time and scheduling wait time of all user tasks included in the current user request is: In the formula, Request for the current user The execution phases included For the first Task processing latency in each execution phase For the first Task I / O wait time in each execution phase For the first The scheduling waiting time for each stage of the task; and The sum of these values represents the estimated execution time learned by the reinforcement learning scheduler. The calculation method is as follows: In the formula, When inserting a current task whose priority is to be determined into a priority queue of the multi-level priority queue, the number of tasks preceding the current task in that priority queue; This indicates the priority level preceding the current task in the priority queue. The estimated execution time for each task.
4. The user-mode adaptive scheduling method for storage tasks according to claim 3, characterized in that, The state of the reinforcement learning scheduler for: In the formula, Indicates the first priority level in the multi-level priority queue The estimated clearing time for each priority queue. This represents the current task and its execution phase, Len is the current task data length, and SLA is the current task's SLA time. The action of the reinforcement learning scheduler for: In the formula, EST is the estimated waiting time; EET is the estimated execution time, used to update the estimated clearing time and calculate the reward; Prio is the priority p determined by the reinforcement learning scheduler. The rewards for the reinforcement learning scheduler include: prediction accuracy rewards. Rewards for achieving SLA : In the formula, AST represents the actual scheduling time, and AET represents the actual waiting time. This indicates the absolute value operation; overtime This refers to the portion that has exceeded the time limit, i.e. The difference with SLA, , These are preset parameters.
5. The user-mode adaptive scheduling method for storage tasks according to claim 2, characterized in that, It also includes setting up a Scanner mechanism for the reinforcement learning scheduler, specifically including: If a task scheduled to a priority queue with priority p causes a task in a queue with a lower priority to exceed its SLA time limit, then when the level 0 queue is empty, the priority of the tasks in the queue with a lower priority to p is recalculated. Specifically, after a task is scheduled to a priority queue with priority p, whether an SLA time limit will exceed its SLA time limit is determined based on the remaining available time of the tasks in the queue with a lower priority to p. The remaining available time is the difference between the task's SLA time and the time already waited. The priority of tasks in queues with a priority lower than p is recalculated, including: if the remaining available time is less than the estimated execution time, the priority of the task is raised to level 0; otherwise, the priority is adjusted according to the urgency and importance of the task.
6. The user-mode adaptive scheduling method for storage tasks according to claim 1 or 2, characterized in that, In step S3, when a scheduler switch occurs, the priority of tasks in the multi-level priority queue is recalculated based on the switched scheduler; wherein the scheduler is a greedy scheduler or a reinforcement learning scheduler.
7. The user-mode adaptive scheduling method for storage tasks according to claim 6, characterized in that, It also includes setting a preset jitter zone Δ, if the load value Load is in α ±Δ or β Within ±Δ, no scheduler switching will be performed.
8. The user-mode adaptive scheduling method for storage tasks according to claim 1 or 2, characterized in that, In step S3, the load value (Load) of the current task is calculated, including: Collect load statistics data within a certain time window, including the length of each queue in the multi-level priority queue and the request arrival rate; The load statistics are normalized, and the lengths of the normalized queues at each level and the request arrival rates are weighted and summed to obtain the load value.
9. A user-mode adaptive scheduling system for storage tasks, characterized in that, Includes computer-readable storage media and processors; The computer-readable storage medium is used to store executable instructions; The processor is used to read executable instructions stored in the computer-readable storage medium and execute the user-mode storage task adaptive scheduling method according to any one of claims 1-8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the user-mode storage task adaptive scheduling method as described in any one of claims 1-8.
Citation Information
Cited By
An intelligent analysis box computing power scheduling method and system for industrial production line quality inspection
CN122285305A