Input and output request scheduling method and device, storage medium and program product
By using ring request queues and dynamic scheduling algorithms in computer systems, the problems of large system call overhead and frequent context switching are solved, and more efficient input and output request processing is achieved.
Patent Information
- Application Number
- CN202510845765.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-08-05
AI Technical Summary
In the prior art, the input and output request processing method has large system call overhead and frequent context switching, resulting in low overall performance.
An efficient ring request queue is used to manage input and output requests, and dynamic scheduling is performed based on the system resource status and requested resource requirements information and priority to ensure fast entrusting and dequeuing operations, and dynamically allocate system resources.
It improves the overall throughput of the system, reduces the system call overhead, avoids frequent context switching, and improves the efficiency of input and output request scheduling.
Smart Images

Figure CN120429089A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to an input and output request scheduling method, device, storage medium, and program product. Background Art
[0002] Input / Output (I / O) operations are crucial components of computer systems. Currently, there are two common methods for processing I / O requests. One approach involves storing multiple received I / O requests in multiple queues and dispatching them to I / O devices. During a single dispatch, I / O requests from higher-priority queues outnumber those from lower-priority queues. Another approach involves setting up multiple queues in the operating system, with each queue corresponding to one or more process groups. Priorities are set based on the importance of the process groups, prioritizing I / O requests from higher-priority process groups to ensure timely processing of I / O requests from critical applications.
[0003] However, improving I / O response speed by prioritizing I / O does not necessarily improve overall I / O response speed and processing capacity. It is ineffective when there are too many I / Os of the same priority. Furthermore, there are problems with high system call overhead and frequent context switching, which affect overall performance. Summary of the Invention
[0004] The present application provides an input / output request scheduling method, device, storage medium and program product to at least solve the problems of high system call overhead, frequent context switching and low input / output request scheduling efficiency in related technologies.
[0005] This application provides an input and output request scheduling method, including: Receive each input and output request to be scheduled and add each input and output request to the ring request queue; Obtaining system resource status, and obtaining resource demand information and priority corresponding to each input and output request in the circular request queue; The input and output requests in the ring request queue are scheduled according to the system resource status, resource demand information and priority corresponding to each input and output request.
[0006] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any one of the above-mentioned input and output request scheduling methods when executing the computer program.
[0007] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above-mentioned input and output request scheduling methods are implemented.
[0008] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned input and output request scheduling methods when executed by a processor.
[0009] This application utilizes an efficient circular request queue to manage input and output requests, ensuring rapid enqueue and dequeue operations for each input and output request. Request scheduling is performed based on the system resource status and the resource demand information and priority corresponding to each input and output request, enabling dynamic allocation of system resources. This allows the system to process multiple input and output requests simultaneously, fully utilizing the system's concurrent processing capabilities. Multiple input and output requests can be properly scheduled, avoiding competition and conflicts for system resources and improving the overall system throughput. Consequently, the technical issues of high system call overhead, frequent context switching, and low input and output request scheduling efficiency can be resolved, achieving the technical effect of reducing system call overhead, avoiding frequent context switching, and improving input and output request scheduling efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0011] Figure 1 A flowchart of an implementation method of an input and output request scheduling method provided in an embodiment of the present application; Figure 2 A flowchart of another method for scheduling input and output requests according to an embodiment of the present application; Figure 3 A structural block diagram of an input and output request scheduling system provided in an embodiment of the present application; Figure 4 A workflow diagram of an input and output request scheduling system provided in an embodiment of the present application; Figure 5 This is a structural block diagram of an input and output request scheduling device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0012] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0013] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0014] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0015] In conjunction with the specific application environment architecture or specific hardware architecture on which the execution of the input and output request scheduling method depends, the specific application environment architecture or specific hardware architecture is described herein.
[0016] An embodiment of the present application provides an input / output request scheduling method, and the method is described in detail in conjunction with the execution flow of the input / output request scheduling method.
[0017] See also Figure 1 , Figure 1 This is a flowchart of an implementation method of an input and output request scheduling method provided in an embodiment of the present application. The method may include the following steps.
[0018] S101: receiving input and output requests to be scheduled, and adding each input and output request to a ring request queue.
[0019] Applications send their pending I / O requests to the I / O Request Processing Center, which then receives them. A pre-built circular request queue is used. Upon receiving each pending I / O request, the I / O Request Processing Center adds it to the queue. By using an efficient circular request queue to manage I / O requests, the queue ensures fast enqueueing and dequeuing of requests.
[0020] The input / output request processing center may be a server, a processor, etc. that is deployed with a scheduling strategy for each input / output request.
[0021] S102: Obtaining the system resource status, and obtaining the resource demand information and priority corresponding to each input and output request in the ring request queue.
[0022] After adding each I / O request to the ring request queue, the system resource status is obtained. The system resource status may include memory usage, central processing unit (CPU) core utilization, disk input / output (I / O) throughput, etc.
[0023] Preset default priorities for different I / O request types. For example, database transaction I / O requests have higher priority than regular file read requests. Obtain resource requirement information and priorities for each I / O request in the circular request queue. Resource requirement information can include requirements for memory resources, CPU resources, and disk I / O.
[0024] S103: Scheduling the input and output requests in the ring request queue according to the system resource status, resource requirement information and priority corresponding to each input and output request.
[0025] After obtaining the system resource status and the resource requirement information and priority level of each I / O request in the ring request queue, asynchronous scheduling is performed on each I / O request in the ring request queue based on the system resource status, resource requirement information, and priority level of each I / O request. For example, when CPU utilization is low but the disk is busy, low-priority requests that rely heavily on disk I / O are weighted down, and high-priority I / O requests that require more CPU resources are prioritized. By dynamically allocating system resources, such as CPU time slices and disk input bandwidth, each I / O request is ensured to be processed promptly.
[0026] This application utilizes an efficient circular request queue to manage input and output requests, ensuring rapid enqueue and dequeue operations for each input and output request. Request scheduling is performed based on the system resource status and the resource demand information and priority corresponding to each input and output request, enabling dynamic allocation of system resources. This allows the system to process multiple input and output requests simultaneously, fully utilizing the system's concurrent processing capabilities. Multiple input and output requests can be properly scheduled, avoiding competition and conflicts for system resources and improving the overall system throughput. Consequently, the technical issues of high system call overhead, frequent context switching, and low input and output request scheduling efficiency can be resolved, achieving the technical effect of reducing system call overhead, avoiding frequent context switching, and improving input and output request scheduling efficiency.
[0027] In a specific embodiment of the present application, scheduling each input and output request in the ring request queue may include the following steps: Step 1: Selecting each fifth input / output request whose data request amount is lower than a preset value from the input / output requests in the ring request queue; Step 2: Merge the fifth input and output requests to obtain a merged input and output request; Step 3: Scheduling the merged input / output requests and other input / output requests in the ring request queue except for the fifth input / output requests.
[0028] For the convenience of description, the above three steps can be combined for explanation.
[0029] The data request volume of each I / O request can be counted, and then the fifth I / O request with a data request volume lower than a preset value can be selected from the I / O requests in the ring request queue. These fifth I / O requests are then merged to obtain a merged I / O request. The merged I / O request and all other I / O requests in the ring request queue, excluding the fifth I / O request, are then scheduled. By merging I / O requests with lower data request volumes, unnecessary system calls and context switches are reduced, reducing overhead, improving I / O request scheduling efficiency, and optimizing the I / O operation process.
[0030] See also Figure 2 , Figure 2 This is a flowchart of another implementation method of an input and output request scheduling method provided in an embodiment of the present application. The method may include the following steps.
[0031] S201: Receive input and output requests to be scheduled.
[0032] An event-driven approach can be used to process input and output requests, avoiding the waste of CPU resources associated with traditional polling. When an input or output event occurs, the system immediately responds and processes the corresponding request. This mechanism enables more efficient use of CPU resources and improves system responsiveness in high-concurrency scenarios.
[0033] S202: Create corresponding data structures for each input and output request.
[0034] After receiving each I / O request to be scheduled, a corresponding data structure is created for each I / O request. The data structure may contain information such as request type (such as read request, write request), data address, data length, priority, etc.
[0035] S203: Perform a validity check on each input and output request based on each data structure.
[0036] After creating the corresponding data structure for each input and output request, we perform a validity check on each input and output request based on the data structure. By writing a validity check function, we can verify the integrity of the request data, the validity of the address, etc.
[0037] In a specific implementation of the present application, step S203 may include the following steps: Step 1: Perform a request data integrity check on each input and output request according to each data structure to obtain a request data integrity check result; Step 2: Perform data address validity check on each input and output request according to each data structure to obtain the data address validity check result; Step 3: Perform a validity check on each input and output request based on the request data integrity check results and data address validity check results corresponding to each input and output request.
[0038] For the convenience of description, the above three steps can be combined for explanation.
[0039] After creating corresponding data structures for each input / output request, a request data integrity check is performed on each input / output request based on each data structure to obtain a request data integrity check result. A data address validity check is then performed on each input / output request based on each data structure to obtain a data address validity check result. Based on the request data integrity check results and data address validity check results corresponding to each input / output request, a validity check is performed on each input / output request. By writing a validity check function to verify the integrity of the request data and the validity of the address, the validity of the request data is guaranteed, the occupation of system resources by illegal input / output requests is avoided, and system resource utilization is improved.
[0040] In a specific embodiment of the present application, performing a data address validity check on each input and output request according to each data structure to obtain a data address validity check result may include the following steps: By checking whether the data address contained in each data structure is within the valid sector range of the disk, the validity check result of the data address corresponding to each input and output request is obtained.
[0041] When checking the validity of each I / O request, the data address contained in each data structure is checked to see if it is within the valid sector range of the disk. This ensures the validity of the data address corresponding to the I / O request.
[0042] S204: Add each input and output request that passes the validity check to the ring request queue.
[0043] After checking the validity of each input / output request based on each data structure, each input / output request that passes the validity check is added to the ring request queue. When adding each input / output request to the ring request queue, the request is added in descending order of priority.
[0044] S205: Obtain the system resource status, and obtain the resource demand information and priority corresponding to each input and output request in the ring request queue.
[0045] S206: Obtaining a preset upper limit of the waiting time and the waiting time corresponding to each input and output request.
[0046] The upper limit of the waiting time for the input and output requests is preset, and the preset upper limit of the waiting time and the waiting time length corresponding to each input and output request are obtained.
[0047] S207: Scheduling each input and output request in the circular request queue according to the system resource status, the upper limit of the waiting time, the resource requirement information corresponding to each input and output request, the priority and the waiting time.
[0048] After obtaining the preset wait time limit and the corresponding wait time for each input / output request, the system schedules each input / output request in the circular request queue based on the system resource status, the wait time limit, the resource requirement information corresponding to each input / output request, the priority, and the wait time. By presetting the wait time limit and then scheduling input / output requests based on the wait time limit, the system avoids excessive wait times for relatively low-priority input / output requests. By adopting a hybrid scheduling algorithm based on priority and wait time, the system improves scheduling efficiency and fairness.
[0049] In a specific implementation of the present application, step S207 may include the following steps: Step 1: Calculate the first scheduling weight corresponding to each input and output request based on the upper limit of the waiting time, the priority corresponding to each input and output request, and the waiting time; Step 2: Adjust each first scheduling weight according to the system resource status and the resource demand information corresponding to each input and output request to obtain a second scheduling weight corresponding to each input and output request; Step 3: Schedule the input and output requests in the ring request queue according to the second scheduling weights.
[0050] For the convenience of description, the above three steps can be combined for explanation.
[0051] After obtaining the preset waiting time upper limit and the waiting time corresponding to each input and output request, the first scheduling weight corresponding to each input and output request is calculated according to the waiting time upper limit, the priority corresponding to each input and output request, and the waiting time. For example, the first scheduling weight corresponding to the input and output request whose waiting time reaches the waiting time upper limit is set to be larger, and the first scheduling weight corresponding to the input and output request with a higher priority is set to be larger. For multiple input and output requests whose waiting time reaches the waiting time upper limit, the first scheduling weight corresponding to the input and output request with a higher priority is larger, and the first scheduling weight corresponding to the input and output request whose waiting time reaches the waiting time upper limit is larger than the input and output request whose waiting time does not reach the waiting time upper limit. For multiple input and output requests whose waiting time does not reach the waiting time upper limit, the first scheduling weight corresponding to the input and output request with a higher priority is larger.
[0052] Each first scheduling weight is adjusted based on the system resource status and the resource demand information corresponding to each input and output request. For example, each first scheduling weight is adjusted based on the scarcity and idleness of each type of system resource to obtain a second scheduling weight corresponding to each input and output request. Each input and output request in the circular request queue is scheduled based on each second scheduling weight. By calculating the first scheduling weight based on the waiting time upper limit, priority, and waiting time, and adjusting each first scheduling weight based on the system resource status to obtain each second scheduling weight, the input and output request is then scheduled based on each second scheduling weight. This fully considers the waiting time of each input and output request and the system resource usage. While ensuring that each input and output request can be polled and executed within a certain period of time, it avoids system crashes due to resource exhaustion, thereby ensuring system stability and reliability.
[0053] In a specific embodiment of the present application, calculating the first scheduling weight corresponding to each input and output request according to the upper limit of the waiting time, the priority corresponding to each input and output request, and the waiting time may include the following steps: Step 1: Determine whether the waiting time has reached the upper limit of the waiting time. If so, proceed to step 2; if not, proceed to step 3; Step 2: Adjust the priority of the input / output request whose waiting time reaches the upper limit of the waiting time to the highest priority, and calculate the first scheduling weight corresponding to each input / output request according to the adjusted priority corresponding to each input / output request; Step 3: Calculate the first scheduling weight corresponding to each input and output request according to the priority corresponding to each input and output request.
[0054] For the convenience of description, the above three steps can be combined for explanation.
[0055] After obtaining the preset upper limit of waiting time and the waiting time corresponding to each input / output request, it is determined whether the waiting time has reached the upper limit of waiting time. If so, the priority of the input / output request whose waiting time has reached the upper limit of waiting time is adjusted to the highest priority, and the first scheduling weight corresponding to each input / output request is calculated based on the adjusted priority of each input / output request. If not, the first scheduling weight corresponding to each input / output request is calculated based on the priority of each input / output request. By setting the priority of the input / output request whose waiting time has reached the upper limit of waiting time to the highest priority, it is ensured that the input / output request whose waiting time has reached the upper limit of waiting time is executed first.
[0056] It can also be set that when there are multiple input and output requests whose waiting time reaches the upper limit of the waiting time, the input and output requests whose waiting time reaches the upper limit of the waiting time will be further prioritized according to the original priority corresponding to the input and output requests whose waiting time reaches the upper limit of the waiting time, so as to ensure that the input and output requests with higher original priority and whose waiting time reaches the upper limit of the waiting time are scheduled earlier.
[0057] In a specific embodiment of the present application, adjusting each first scheduling weight according to the system resource state and the resource demand information corresponding to each input and output request to obtain the second scheduling weight corresponding to each input and output request may include the following steps: Step 1: Determine whether there is a first resource type in a resource-constrained state according to the system resource status. If so, execute step 2; if not, execute step 4; Step 2: Based on the resource demand information and priorities corresponding to each input / output request, select a first input / output request whose demand for the first resource type exceeds a first preset ratio and whose priority is lower than a first preset priority level from each input / output request, and adjust the first scheduling weight corresponding to the first input / output request downward to obtain a second scheduling weight corresponding to the first input / output request; Step 3: Determine the input / output requests other than the first input / output request in the ring request queue as second input / output requests, and determine the first scheduling weight corresponding to each second input / output request as the second scheduling weight corresponding to each second input / output request; Step 4: Determine the first scheduling weight corresponding to each input / output request as the second scheduling weight corresponding to each input / output request.
[0058] For the convenience of description, the above four steps can be combined for explanation.
[0059] After calculating the first scheduling weight corresponding to each input and output request based on the upper limit of the waiting time, the priority level and the waiting time corresponding to each input and output request, it is determined whether there is a first resource type in a resource-scarce state according to the system resource status. If so, it means that the resources of the first resource type in the system are insufficient. According to the resource demand information and priority level corresponding to each input and output request, a first input and output request whose demand for the first resource type exceeds a first preset proportion value and whose priority level is lower than the first preset priority level is selected from each input and output request, and the first scheduling weight corresponding to the first input and output request is lowered to obtain a second scheduling weight corresponding to the first input and output request. The other input and output requests in the circular request queue except the first input and output request are determined as second input and output requests, and the first scheduling weight corresponding to each second input and output request is determined as the second scheduling weight corresponding to each second input and output request. If not, the first scheduling weight corresponding to each input and output request is determined as the second scheduling weight corresponding to each input and output request. By detecting that the first resource type is in a resource-scarce state, the scheduling weight of the first input and output request whose demand for the first resource type exceeds the first preset proportion value and whose priority is lower than the first preset priority level is lowered, thereby avoiding the system crash due to resource exhaustion and further improving the stability and reliability of the system.
[0060] The resource shortage state can be determined based on a preset resource utilization threshold. For example, when the utilization of a certain system resource reaches an upper limit of the resource utilization threshold, it indicates that the system resource is in a resource shortage state.
[0061] In a specific implementation of the present application, determining the first scheduling weight corresponding to each second input / output request as the second scheduling weight corresponding to each second input / output request may include the following steps: Step 1: Determine whether there is a second resource type in an idle state according to the system resource status. If so, execute step 2; if not, do nothing. Step 2: Based on the resource demand information and priorities corresponding to the second input / output requests, select a third input / output request from the second input / output requests, the third input / output request having a demand for the second resource type exceeding a second predetermined ratio and a priority higher than the second predetermined priority level; Step 3: Increase the first scheduling weight corresponding to the third input / output request to obtain a second scheduling weight corresponding to the third input / output request; Step 4: Determine the first scheduling weights corresponding to the second input / output requests except the third input / output request in each second input / output request as the second scheduling weights corresponding to the corresponding second input / output request.
[0062] For the convenience of description, the above four steps can be combined for explanation.
[0063] After determining the other input / output requests in the circular request queue, except for the first input / output request, as second input / output requests, a determination is made based on the system resource status whether any second resource type is in a resource-idle state. If not, it indicates that all types of system resources are well utilized and no processing is performed. If so, based on the resource demand information and priority corresponding to each second input / output request, a third input / output request is selected from each second input / output request, whose demand for the second resource type exceeds a second preset ratio and whose priority is higher than the second preset priority level. The first scheduling weight corresponding to the third input / output request is increased to obtain a second scheduling weight corresponding to the third input / output request. The first scheduling weight corresponding to each second input / output request, except for the third input / output request, is determined as the second scheduling weight corresponding to the corresponding second input / output request. By increasing the scheduling weight of the input / output request that is more dependent on the resource-idle state, the utilization rate of the resource-idle state is improved, and the scheduling efficiency of the input / output request is improved.
[0064] The resource shortage state can also be determined based on a preset resource utilization threshold. For example, when the utilization of a certain system resource is lower than the lower limit of the resource utilization threshold, it indicates that the system resource is in a resource idle state.
[0065] S208: When the scheduling completion input / output request is detected, a scheduling completion notification is returned via a preset scheduling completion notification interface.
[0066] When a scheduled I / O request is detected, a scheduling completion notification is returned via a pre-defined scheduling completion notification interface. Multiple notification interface implementations are available, including callback function registration and semaphore manipulation. When an I / O request is scheduled, processing is performed based on the notification method registered by the application. If the application has registered a callback function, it is directly called and passed the I / O request scheduling result. If a semaphore is used, the corresponding semaphore is released to notify the application of the completion of the I / O request scheduling. By promptly returning a scheduling completion notification to the application after the I / O request is scheduled, timely reporting of the I / O request scheduling progress is achieved. This allows applications to promptly understand the results of the I / O request scheduling, avoiding errors or exceptions caused by untimely information and further improving system stability. The corresponding request in the request queue is also updated to the completed status, facilitating subsequent cleanup and statistics. Statistical information such as operation duration can also be recorded.
[0067] During the data transmission process, the number of data copies is minimized as much as possible. The zero-copy mechanism provided by the operating system is used, such as the file transfer (sendfile) function in the Linux system, to directly transfer data in both directions between the user space and the storage device. Data is directly transferred from the disk cache to the network socket or other target address, reducing the number of data copies between the user space and the kernel space, thereby improving data transmission efficiency. This is especially effective in scenarios that require large amounts of data transmission, such as streaming services.
[0068] In a specific embodiment of the present application, after determining, based on the system resource status, that a first resource type is in a resource-scarce state, the method may further include the following steps: Step 1: selecting, from the input / output requests, a fourth input / output request whose demand for the first resource type exceeds a third predetermined ratio, based on the resource demand information corresponding to each input / output request; Step 2: Lower the priority of the fourth input / output request.
[0069] For the convenience of description, the above two steps can be combined for explanation.
[0070] Based on the resource demand information corresponding to each input / output request, a fourth input / output request whose demand for the first resource type exceeds a third preset ratio is selected from the input / output requests, and its priority is lowered. By lowering the scheduling weight of input / output requests with high resource dependencies in a resource-constrained state, system crashes due to resource exhaustion are avoided, further improving system stability and reliability, and enhancing the system's input / output request processing performance.
[0071] See also Figure 3 , Figure 3 This is a structural diagram of an input and output request scheduling system provided by an embodiment of the present application. Figure 4 , Figure 4 This is a workflow diagram for an input / output request scheduling system provided in an embodiment of the present application. The system may include a request queue management module, an asynchronous scheduling module, an input / output request execution module, a completion notification module, and a resource management module. The responsibilities of each module in input / output request scheduling are as follows.
[0072] Request Queue Management Module: This module is responsible for receiving input and output requests from applications and storing them in an orderly fashion in a request queue. It uses an efficient ring queue data structure to manage the request queue, ensuring rapid enqueue and dequeue operations. Furthermore, this module performs preliminary validity checks on requests to enable more efficient processing by subsequent modules.
[0073] Asynchronous Scheduling Module: This module asynchronously schedules I / O requests in the request queue based on system resource usage and their priority. It dynamically allocates system resources, such as CPU time slices and disk I / O bandwidth, to ensure that every request is processed promptly. This module also utilizes advanced scheduling algorithms, such as a hybrid scheduling algorithm based on task priority and wait time, to improve scheduling efficiency and fairness.
[0074] The I / O request execution module is responsible for actually executing I / O operations, including reading and writing data from and to storage devices. It interacts with the underlying hardware and utilizes device drivers to complete data transfers. This module utilizes an optimized I / O operation process, reducing unnecessary system calls and context switches, and improving I / O execution efficiency.
[0075] Completion Notification Module: When an I / O operation completes, this module promptly sends a completion notification to the application. Depending on the application's needs, this notification may be sent through various methods, such as callbacks or semaphores. Simultaneously, the module updates the status of the corresponding request in the request queue to facilitate subsequent cleanup and statistics.
[0076] Resource Management Module: This module manages and monitors various resources in the system, including memory, CPUs, and disks. It monitors resource usage in real time and takes appropriate measures when resources are insufficient. For example, when memory usage exceeds 80%, it triggers a memory recycling mechanism to swap infrequently used memory pages to disk. When disk I / O bandwidth is insufficient, it dynamically adjusts the scheduling strategy of the asynchronous scheduling module to lower the priority of requests that rely heavily on disk I / O, ensuring system stability and efficiency.
[0077] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0078] An embodiment of the present application also provides an input and output request scheduling device.
[0079] See also Figure 5 , Figure 5 This is a structural block diagram of an input / output request scheduling device provided in an embodiment of the present application. The device may include: A request adding module 51 is used to receive input and output requests to be scheduled and add each input and output request to a ring request queue; The information acquisition module 52 is used to obtain the system resource status and obtain the resource demand information and priority corresponding to each input and output request in the ring request queue; The request scheduling module 53 is used to schedule the input and output requests in the ring request queue according to the system resource status, resource demand information and priority corresponding to each input and output request.
[0080] This application utilizes an efficient circular request queue to manage input and output requests, ensuring rapid enqueue and dequeue operations for each input and output request. Request scheduling is performed based on system resource status, resource demand information corresponding to each input and output request, and priority, enabling dynamic allocation of system resources. This allows the system to process multiple input and output requests simultaneously, fully utilizing the system's concurrent processing capabilities. Multiple input and output requests can be properly scheduled, avoiding competition and conflicts for system resources and improving the overall system throughput. Consequently, the technical issues of high system call overhead, frequent context switching, and low input and output request scheduling efficiency can be resolved, achieving the technical effect of reducing system call overhead, avoiding frequent context switching, and improving input and output request scheduling efficiency.
[0081] In a specific implementation of the present application, the request scheduling module 53 may include: The waiting time acquisition submodule is used to obtain the preset waiting time upper limit and the waiting time corresponding to each input and output request; The first request scheduling submodule is used to schedule each input and output request in the ring request queue according to the system resource status, the upper limit of the waiting time, the resource demand information corresponding to each input and output request, the priority and the waiting time.
[0082] In a specific implementation of the present application, the request scheduling submodule may include: A first scheduling weight calculation unit is used to calculate a first scheduling weight corresponding to each input and output request according to the upper limit of the waiting time, the priority corresponding to each input and output request, and the waiting time; a second scheduling weight obtaining unit, configured to adjust each first scheduling weight according to the system resource state and the resource demand information corresponding to each input and output request, to obtain a second scheduling weight corresponding to each input and output request; The request scheduling unit is used to schedule the input and output requests in the ring request queue according to the second scheduling weights.
[0083] In a specific implementation of the present application, the first scheduling weight calculation unit may include: The first judgment subunit is used to judge whether the waiting time reaches the upper limit of the waiting time; The first scheduling weight calculation subunit is used to adjust the priority of the input and output requests whose waiting time reaches the upper limit of the waiting time to the highest priority if there is a waiting time that reaches the upper limit of the waiting time, and calculate the first scheduling weight corresponding to each input and output request according to the priority corresponding to each input and output request after adjustment; if there is no waiting time that reaches the upper limit of the waiting time, calculate the first scheduling weight corresponding to each input and output request according to the priority corresponding to each input and output request.
[0084] In a specific implementation of the present application, the second scheduling weight obtaining unit may include: The second judging subunit is configured to judge whether there is a first resource type in a resource-scarce state according to the system resource state; The second scheduling weight obtaining subunit is used to, when it is determined according to the system resource status that there is a first resource type in a resource-constrained state, select from each input and output request a first input and output request whose demand for the first resource type exceeds a first preset proportion value and whose priority is lower than a first preset priority level based on the resource demand information and priority corresponding to each input and output request, and lower the first scheduling weight corresponding to the first input and output request to obtain a second scheduling weight corresponding to the first input and output request; determine the other input and output requests in the circular request queue except the first input and output request as the second input and output request, and determine the first scheduling weight corresponding to each second input and output request as the second scheduling weight corresponding to each second input and output request; when it is determined according to the system resource status that there is no first resource type in a resource-constrained state, determine the first scheduling weight corresponding to each input and output request as the second scheduling weight corresponding to each input and output request.
[0085] In a specific embodiment of the present application, a second scheduling weight obtaining subunit is specifically used to determine whether there is a second resource type in a resource-idle state based on the system resource status; if so, based on the resource demand information and priority corresponding to each second input and output request, select a third input and output request from each second input and output request whose demand for the second resource type exceeds a second preset proportion value and whose priority is higher than the second preset priority level; increase the first scheduling weight corresponding to the third input and output request to obtain the second scheduling weight corresponding to the third input and output request; determine the first scheduling weights corresponding to the other second input and output requests in each second input and output request except the third input and output request as the second scheduling weight corresponding to the corresponding second input and output request.
[0086] In a specific embodiment of the present application, the device may further include: a fourth input / output request selection module configured to, after determining, based on the system resource status, that a first resource type is in a resource-constrained state, select, from the input / output requests, a fourth input / output request whose demand for the first resource type exceeds a third preset ratio based on resource demand information corresponding to each input / output request; The priority lowering module is used to lower the priority of the fourth input / output request.
[0087] In a specific embodiment of the present application, the device may further include: A data structure creation module is used to create a corresponding data structure for each input and output request after receiving each input and output request to be scheduled and before adding each input and output request to the circular request queue; A validity check module is used to perform validity checks on each input and output request based on each data structure; The request adding module is specifically used to add each input and output request that passes the legality check to the ring request queue.
[0088] In a specific embodiment of the present application, the legality check module may include: The request data integrity check result obtaining submodule is used to perform a request data integrity check on each input and output request according to each data structure to obtain a request data integrity check result; The data address validity check result obtaining submodule is used to perform data address validity check on each input and output request according to each data structure to obtain the data address validity check result; The legality check submodule is used to perform a legality check on each input and output request based on the request data integrity check result and the data address validity check result corresponding to each input and output request.
[0089] In a specific embodiment of the present application, the data address validity check result obtaining submodule is specifically used to obtain the data address validity check result corresponding to each input and output request by checking whether the data address contained in each data structure is within the valid sector range of the disk.
[0090] In a specific implementation of the present application, the request scheduling module 53 may include: a fifth input / output request selection submodule, configured to select, from the input / output requests in the circular request queue, fifth input / output requests whose data request amount is lower than a preset value; a merged input and output request obtaining submodule, configured to merge the fifth input and output requests to obtain a merged input and output request; The second request scheduling submodule is configured to schedule the merged input / output requests and other input / output requests in the ring request queue except the fifth input / output requests.
[0091] In a specific embodiment of the present application, the device may further include: The notification return module is used to return a scheduling completion notification through a preset scheduling completion notification interface when a scheduling completed input and output request is detected after scheduling each input and output request in the ring request queue.
[0092] For the description of the features in the embodiment corresponding to the input / output request scheduling apparatus, reference can be made to the relevant description of the embodiment corresponding to the input / output request scheduling method, which will not be repeated here.
[0093] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above-mentioned input and output request scheduling method embodiments.
[0094] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned input and output request scheduling method embodiments when running.
[0095] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0096] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above-mentioned input and output request scheduling method embodiments are implemented.
[0097] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps in any of the above-mentioned input and output request scheduling method embodiments.
[0098] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0099] The above describes in detail the input and output request scheduling method, device, storage medium, and program product provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only intended to help understand the method and core concept of the present application. It should be noted that, for those skilled in the art, without departing from the principles of the present application, various improvements and modifications may be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
Claims
1. A method for scheduling input and output requests, characterized in that: include: Receive each input and output request to be scheduled and add each input and output request to the ring request queue; Obtaining system resource status, and obtaining resource demand information and priority corresponding to each input and output request in the circular request queue; The input and output requests in the ring request queue are scheduled according to the system resource status, resource demand information and priority corresponding to each input and output request.
2. The input and output request scheduling method according to claim 1, wherein: Scheduling each input and output request in the ring request queue according to the system resource status, resource requirement information corresponding to each input and output request, and priority, including: Get the preset waiting time limit and the waiting time corresponding to each input and output request; The input and output requests in the circular request queue are scheduled according to the system resource status, the upper limit of the waiting time, the resource demand information corresponding to each input and output request, the priority and the waiting time.
3. The input and output request scheduling method according to claim 2, characterized in that: Scheduling each input and output request in the ring request queue according to the system resource status, the upper limit of the waiting time, the resource requirement information corresponding to each input and output request, the priority, and the waiting time, including: Calculate the first scheduling weight corresponding to each input and output request according to the upper limit of the waiting time, the priority corresponding to each input and output request, and the waiting time; Adjusting each first scheduling weight according to the system resource state and resource demand information corresponding to each input and output request to obtain a second scheduling weight corresponding to each input and output request; The input and output requests in the ring request queue are scheduled according to the second scheduling weights.
4. The input and output request scheduling method according to claim 3, wherein: Calculating first scheduling weights corresponding to the input and output requests according to the upper limit of the waiting time, the priorities and waiting times corresponding to the input and output requests, including: Determine whether the waiting time reaches the upper limit of the waiting time; If so, the priority of the input / output request whose waiting time reaches the upper limit of the waiting time is adjusted to the highest priority, and the first scheduling weight corresponding to each input / output request is calculated according to the priority corresponding to each input / output request after the adjustment; If not, first scheduling weights corresponding to the input and output requests are calculated according to the priorities corresponding to the input and output requests.
5. The input and output request scheduling method according to claim 3 or 4, characterized in that: Adjusting each first scheduling weight according to the system resource state and resource demand information corresponding to each input and output request to obtain a second scheduling weight corresponding to each input and output request, including: Determining whether there is a first resource type in a resource-scarce state according to the system resource state; If so, selecting, from the input / output requests, a first input / output request whose demand for the first resource type exceeds a first preset ratio and whose priority is lower than a first preset priority level, based on the resource demand information and priorities corresponding to the respective input / output requests, and lowering the first scheduling weight corresponding to the first input / output request to obtain a second scheduling weight corresponding to the first input / output request; Determine the other input / output requests in the ring request queue except the first input / output request as second input / output requests, and determine the first scheduling weight corresponding to each second input / output request as the second scheduling weight corresponding to each second input / output request; If not, the first scheduling weight corresponding to each input / output request is determined as the second scheduling weight corresponding to each input / output request.
6. The input and output request scheduling method according to claim 5, characterized in that: Determining the first scheduling weights corresponding to the second input / output requests as the second scheduling weights corresponding to the second input / output requests includes: Determining whether there is a second resource type in a resource idle state according to the system resource state; If so, selecting, from the second input / output requests, a third input / output request whose demand for the second resource type exceeds a second preset ratio and whose priority is higher than the second preset priority level, based on the resource demand information and priority corresponding to each second input / output request; increasing the first scheduling weight corresponding to the third input / output request to obtain a second scheduling weight corresponding to the third input / output request; The first scheduling weights corresponding to the second input / output requests other than the third input / output request in each second input / output request are determined as the second scheduling weights corresponding to the corresponding second input / output request.
7. The input and output request scheduling method according to claim 5, characterized in that: After determining, according to the system resource status, that a first resource type is in a resource-scarce state, the method further includes: selecting, from the input / output requests, a fourth input / output request whose demand for the first resource type exceeds a third preset ratio value, according to the resource demand information corresponding to each input / output request; Lowering the priority of the fourth input / output request.
8. The input and output request scheduling method according to claim 1, wherein: After receiving each input and output request to be scheduled and before adding each input and output request to the ring request queue, the method further includes: Create corresponding data structures for each input and output request; Perform a validity check on each input and output request based on each data structure; Accordingly, each input and output request is added to the ring request queue, including: Each input and output request that passes the validity check is added to the ring request queue.
9. The input and output request scheduling method according to claim 8, characterized in that: Perform a validity check on each input and output request based on each data structure, including: Perform a request data integrity check on each input and output request according to each data structure to obtain a request data integrity check result; Perform data address validity check on each input and output request according to each data structure, and obtain the data address validity check result; Perform a validity check on each input and output request based on the request data integrity check results and data address validity check results corresponding to each input and output request.
10. The input and output request scheduling method according to claim 9, characterized in that: Perform data address validity checks on each input and output request based on each data structure, and obtain data address validity check results, including: By checking whether the data address contained in each data structure is within the valid sector range of the disk, the validity check result of the data address corresponding to each input and output request is obtained.
11. The input and output request scheduling method according to claim 1, wherein: Scheduling each input and output request in the ring request queue includes: Selecting, from the input and output requests in the ring request queue, each fifth input and output request whose data request amount is lower than a preset value; Merging the fifth input and output requests to obtain a merged input and output request; The merged input / output requests and other input / output requests in the ring request queue except the fifth input / output requests are scheduled.
12. The input and output request scheduling method according to claim 1, wherein: After scheduling the input and output requests in the ring request queue, the method further includes: When a scheduling completion input / output request is detected, a scheduling completion notification is returned through a preset scheduling completion notification interface.
13. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the input and output request scheduling method according to any one of claims 1 to 12 when executing the computer program.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the input and output request scheduling method according to any one of claims 1 to 12.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the input and output request scheduling method according to any one of claims 1 to 12 are implemented.