An IO scheduling method, computer program product, device and computer medium
By dividing IO into queues and generating target priorities, the latency and priority issues in existing IO scheduling algorithms are resolved, achieving efficient and stable IO processing.
Patent Information
- Application Number
- CN202510919987.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2045-07-04
AI Technical Summary
In actual applications, existing IO scheduling algorithms cannot distinguish the priorities of different IO requests, resulting in delayed execution of high-priority requests. Priority scheduling algorithms may also experience priority inversion, resulting in increased IO latency.
By dividing the queues for I/O to be processed into the first and second queues, a target priority is generated based on the I/O waiting time and initial priority. Then, the queues are sorted and scheduled in descending order according to the target priority, ensuring that I/O with high latency and low priority is processed first.
Effectively reduce IO latency, take priority into consideration, improve IO processing performance, ensure timely processing of high-priority IO, and avoid long-term accumulation.
Smart Images

Figure CN120406865B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and more specifically, to an IO scheduling method, a computer program product, a device, and a computer medium. Background Art
[0002] In storage systems, I / O (input / output) scheduling algorithms impact system performance and efficiency. I / O scheduling algorithms are primarily categorized into two main categories: First Come First Service (FCFS) and Priority Scheduling. However, these algorithms have limitations in practical applications. For example, the FCFS algorithm cannot distinguish the priorities of different I / O requests, potentially delaying the execution of high-priority I / O requests. While priority scheduling algorithms can schedule I / O requests based on their priority, they can lead to priority inversion in practice, where high-priority I / O requests are blocked by lower-priority ones.
[0003] In summary, how to reduce IO latency is an urgent problem to be solved by those skilled in the art. Summary of the Invention
[0004] The present invention aims to provide an IO scheduling method that can, to a certain extent, solve the technical problem of how to reduce IO latency. The present invention also provides an IO scheduling method, a computer program product, an electronic device, and a computer-readable storage medium.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] In a first aspect, an IO scheduling method is provided, comprising:
[0007] Get pending IO;
[0008] Dividing the to-be-processed IO into queues to obtain a first queue and a second queue;
[0009] Determine the IO start time and initial IO priority of the first queue;
[0010] Determine the IO waiting time of the first queue based on the current time and the IO start time of the first queue;
[0011] Generate an IO target priority of the first queue according to a relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority;
[0012] Sort the IOs of the first queue according to the IO target priority from large to small to obtain a third queue;
[0013] I / O scheduling is performed in the order of the third queue first and the second queue second.
[0014] On the other hand, the queues to be processed are divided into a first queue and a second queue, including:
[0015] Determine the granularity of dividing IO receiving objects;
[0016] Determining a target receiving object for receiving the to-be-processed IO according to the division granularity;
[0017] The target receiving object is used as a queue division granularity to divide the to-be-processed IO into queues to obtain a first queue and a second queue.
[0018] On the other hand, the queues to be processed are divided into first and second queues using the target receiving object as the queue division granularity, including:
[0019] Among the pending IOs, n IOs corresponding to the target receiving object with the earliest start time are divided into a first queue, where n is a positive integer equal to or greater than 1;
[0020] Among the to-be-processed IOs, other IOs corresponding to the target receiving object except the first queue are divided into the second queue.
[0021] On the other hand, the queues to be processed are divided into first and second queues using the target receiving object as the queue division granularity, including:
[0022] Determine, in the to-be-processed IOs, an IO set corresponding to each of the target receiving objects;
[0023] Generate an average latency of IO in the IO set;
[0024] Sort the IO sets in descending order of average latency to obtain an IO set sorting result;
[0025] The first half of the IO sets in the IO set sorting result is used as the first queue;
[0026] The IO sets in the second half of the IO set sorting result are used as the second queue.
[0027] On the other hand, the queues to be processed are divided into first and second queues using the target receiving object as the queue division granularity, including:
[0028] Determine, in the to-be-processed IOs, an IO set corresponding to each of the target receiving objects;
[0029] Generate an average latency of IO in the IO set;
[0030] Sort the IO sets in descending order of average latency to obtain an IO set sorting result;
[0031] The first half of the IO sets in the IO set sorting result are used as the first candidate sets;
[0032] The IO sets in the second half of the IO set sorting result are used as the second candidate sets;
[0033] Assign h IOs with the earliest start time in the first candidate set and k IOs with the earliest start time in the second candidate set to a first queue, where k is a positive integer greater than or equal to 1, and h is a positive integer greater than k;
[0034] In the IO set sorting result, other IOs except the first queue are divided into the second queue.
[0035] On the other hand, get pending IO, including:
[0036] Check whether the target queue is empty. The target queue is used to store the currently running IO;
[0037] In response to the target queue being empty, obtaining the submission queue consisting of the latest submitted IOs;
[0038] Add the IO in the submission queue to the target queue in descending order of IO initial priority;
[0039] Process the IO in the target queue. After the processing is completed, the remaining IO in the target queue is treated as pending IO.
[0040] On the other hand, get pending IO, including:
[0041] Check whether the target queue is empty. The target queue is used to store the currently running IO;
[0042] In response to the existence of IO in the target queue, obtain the submission queue consisting of the latest submitted IO;
[0043] Add the IO in the submission queue to the tail of the target queue in descending order of IO initial priority;
[0044] Traverse the submission queue to get the first candidate IO;
[0045] Get the second candidate IO remaining after processing the IO in the target queue in the historical record;
[0046] The first candidate IO and the second candidate IO are merged to obtain an IO to be processed.
[0047] In another aspect, the IO scheduling in the order of the third queue first and the second queue second further comprises:
[0048] detecting whether the IO scheduling is ended;
[0049] in response to continuing the IO scheduling, returning to perform the steps of obtaining the submission queue composed of the latest submitted IO and the following steps.
[0050] In another aspect, determining the IO waiting duration of the first queue according to the current time and the IO start time of the first queue comprises:
[0051] generating a difference value between the current time and the IO start time of the first queue;
[0052] quantifying the difference value to obtain a first quantization result;
[0053] taking the first quantization result as the IO waiting duration of the first queue.
[0054] In another aspect, generating the IO target priority of the first queue according to the relationship that the target priority is positively related to the IO waiting duration and negatively related to the IO initial priority comprises:
[0055] quantifying the IO initial priority of the first queue to obtain a second quantization result;
[0056] generating the IO target priority of the first queue according to the relationship that the target priority is positively related to the IO waiting duration and negatively related to the second quantization result.
[0057] In another aspect, generating the IO target priority of the first queue according to the relationship that the target priority is positively related to the IO waiting duration and negatively related to the second quantization result comprises:
[0058] generating the IO target priority of the first queue according to the relationship that the target priority is positively related to the IO waiting duration and negatively related to the second quantization result according to a target priority generation formula;
[0059] the target priority generation formula comprises:
[0060] P=a*T / p+b;
[0061] wherein, P represents the IO target priority of the first queue; T represents the IO waiting duration; p represents the second quantization result; a and b both represent compensation coefficients.
[0062] In another aspect, the IO scheduling in the order of the third queue first and the second queue second comprises:
[0063] The IO of the second queue is placed behind the IO of the third queue to obtain a latest target queue, and the target queue is used to store the currently running IO.
[0064] The IO is scheduled according to the target queue.
[0065] In a second aspect, a computer program product is provided, comprising computer programs / instructions, which, when executed by a processor, implement the steps of the IO scheduling method according to any one of the above.
[0066] In a third aspect, an electronic device is provided, comprising:
[0067] a memory, configured to store a computer program;
[0068] a processor, configured to implement the steps of the IO scheduling method according to any one of the above when the computer program is executed.
[0069] In a fourth aspect, a computer readable storage medium is provided, wherein the computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the steps of the IO scheduling method according to any one of the above.
[0070] The IO scheduling method provided by the application comprises the following steps: obtaining to-be-processed IO; performing queue division on the to-be-processed IO to obtain a first queue and a second queue; determining an IO start time and an IO initial priority of the first queue; determining an IO waiting time length of the first queue according to a current time and the IO start time of the first queue; generating an IO target priority of the first queue according to a relationship that the IO target priority is positively correlated with the IO waiting time length and is negatively correlated with the IO initial priority; performing IO sorting on the first queue in a descending order of the IO target priority to obtain a third queue; and performing IO scheduling in an order of the third queue first and then the second queue. The application has the following beneficial effects: the to-be-processed IO is divided into the first queue and the second queue, thereby preliminarily dividing the to-be-processed IO by means of the queue, and the IO of the corresponding queue can be processed flexibly according to requirements subsequently; the IO waiting time length can be generated according to the current time and the IO start time of the first queue, thereby quantifying the IO time delay; the IO target priority of the first queue is generated according to the relationship that the IO target priority is positively correlated with the IO waiting time length and is negatively correlated with the IO initial priority, so that the larger the IO target priority, the larger the IO time delay and the smaller the initial priority; finally, the first queue is sorted in the descending order of the IO target priority to obtain the third queue, and the IO is scheduled in the order of the third queue first and then the second queue, so that the IO with a large time delay and a low initial priority can be scheduled preferentially, the IO time delay is reduced while the priority is taken into account, and the IO processing performance is better. The computer program product, the electronic device and the computer readable storage medium provided by the application also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0072] Figure 1 A flowchart of an IO scheduling method provided by an embodiment of the present invention;
[0073] Figure 2 Flowchart for IO scheduling for storage;
[0074] Figure 3 This is a schematic diagram of the initial IO scheduling;
[0075] Figure 4 This is a schematic diagram of multiple IO scheduling;
[0076] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present invention;
[0077] Figure 6 This is another structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0078] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0079] See also Figure 1 , Figure 1 A flowchart of an IO scheduling method provided by an embodiment of the present invention.
[0080] An IO scheduling method provided by an embodiment of the present invention may include the following steps:
[0081] Step S101: Obtain IO to be processed.
[0082] In actual applications, the IO that needs to be processed currently can be obtained as the pending IO according to the application scenario. The pending IO can be a newly received IO that needs to be processed or an IO that has not been processed before, etc. The present invention does not make specific limitations here.
[0083] In an exemplary embodiment, during the process of obtaining pending IO, if IO processing is performed for the first time, there is no previously unprocessed IO. At this time, the pending IO can be determined based only on the newly received IO that needs to be processed, that is, it can be detected whether the target queue is empty, and the target queue is used to store the currently running IO; in response to the target queue being empty, a submission queue consisting of the latest submitted IO is obtained; the IO in the submission queue is added to the target queue in order from high to low initial priority of the IO, that is, in order from small to large numerical values of the IO initial priority; the IO in the target queue is processed, and after the processing is completed, the remaining IO in the target queue is treated as pending IO.
[0084] In an exemplary embodiment, in the process of obtaining pending IO, if IO processing has been performed before, there are IOs that have not been processed before and there are newly received IOs, so the pending IO needs to be determined based on the newly received IO that needs to be processed and the IO that has not been processed before, that is, it can be detected whether the target queue is empty, and the target queue is used to store the currently running IO; in response to the existence of IO in the target queue, a submission queue composed of the latest submitted IO is obtained; the IO in the submission queue is added to the tail of the target queue in order from high to low initial priority of the IO; the submission queue is traversed to obtain a first candidate IO; the second candidate IO remaining after the IO in the target queue is processed according to the historical record is obtained; the first candidate IO and the second candidate IO are merged to obtain the pending IO.
[0085] In an exemplary embodiment, after IO scheduling is performed in the order of the third queue first and then the second queue, if IO scheduling continues, it is further possible to detect whether IO scheduling is terminated. In response to the IO scheduling continuing, the process returns to execute the steps of obtaining the submission queue consisting of the latest submitted IO and subsequent steps, so as to comprehensively determine the pending IO for IO scheduling based on the currently newly received IO that needs to be processed and the previously unprocessed IO.
[0086] Step S102: Divide the IO to be processed into queues to obtain a first queue and a second queue.
[0087] In actual applications, after obtaining the pending IO that needs to be processed currently, the pending IO can be divided into queues to obtain a first queue and a second queue, so that the first queue and the second queue can be used to process the IO subsequently.
[0088] In an exemplary embodiment, in the process of dividing the queues for processing IO to obtain the first queue and the second queue, the queue division can be performed according to the IO processing requirements. For example, the queue division can be performed according to the receiving objects of the IO to be processed, that is, the division granularity of the IO receiving objects can be determined. This division granularity is used to determine the division unit of the IO receiving objects. For example, if the division granularity is a block in the storage, the IO receiving objects are blocks one by one. Correspondingly, if the division granularity is a page in the storage, the IO receiving objects are pages one by one. According to the division granularity, the target receiving object for receiving the IO to be processed is determined. The queue division of the IO to be processed is performed with the target receiving object as the queue division granularity to obtain the first queue and the second queue.
[0089] In an exemplary embodiment, queues are divided for pending IOs using the target receiving object as the queue division granularity. In the process of obtaining the first and second queues, the n IOs corresponding to the target receiving object with the earliest start time among the pending IOs can be divided into the first queue, where n is a positive integer equal to or greater than 1; and the remaining IOs corresponding to the target receiving object other than the first queue among the pending IOs can be divided into the second queue. Since the IOs with the earliest start time represent the IOs with the highest latency, this embodiment is equivalent to dividing the n IOs with the highest latency within each target receiving object into the first queue and the remaining IOs into the second queue. In this way, the IOs with the highest latency within each target receiving object can be prioritized, avoiding the long-term accumulation of IOs within a single target receiving object and ensuring the stability of IO processing.
[0090] In an exemplary embodiment, queues are divided based on the target receiving object as the granularity for queue division. In the process of obtaining the first and second queues, queue division can be performed on all IOs in a single target receiving object using the target receiving object as the granularity. Specifically, the IO set corresponding to each target receiving object can be determined in the pending IOs; the average latency of the IOs in the IO set can be generated; the IO sets can be sorted in descending order of average latency to obtain an IO set sorting result; the IO sets in the first half of the IO set sorting result can be used as the first queue; and the IO sets in the second half of the IO set sorting result can be used as the second queue. In this way, if the average latency of the IO set corresponding to a single target receiving object is higher, the IO set of this target receiving object will be positioned higher in the IO set sorting result, making it more likely to be assigned to the first queue for priority processing. This allows all IOs in the target receiving object with the highest average latency to be prioritized, thus preventing the long-term accumulation of all IOs in a single target receiving object, which could lead to a continuous decline in the IO processing progress of this target receiving object. In other words, the target receiving object with a long-term IO stack can be cleared in a timely manner, ensuring that the target receiving object can continuously and stably process IOs.
[0091] In an exemplary embodiment, the queue division granularity is used to divide the IO to be processed into queues. In the process of obtaining the first queue and the second queue, the queue division can be performed based on the single IO delay and the overall IO delay in the target receiving object. That is, the IO set corresponding to each target receiving object can be determined in the IO to be processed; the average delay of the IO in the IO set is generated; the IO sets are sorted in descending order according to the average delay to obtain the IO set sorting result; the IO sets in the first half of the IO set sorting result are used as the first candidate set; the IO sets in the second half of the IO set sorting result are used as the second candidate set; the h IOs with the earliest start time in the first candidate set and the k IOs with the earliest start time in the second candidate set are divided into the first queue, k is a positive integer greater than or equal to 1, and h is a positive integer greater than k, for example, if k is 1, then h is 2, and so on; in the IO set sorting result, other IOs except the first queue are divided into the second queue. In this way, the first candidate set is the IO in the target receiving object with higher average latency in the IO set sorting result, and the second candidate set is the IO in the target receiving object with lower average latency in the IO set sorting result. Subsequently, if the h IOs with the earliest start time in the first candidate set and the k IOs with the earliest start time in the second candidate set are divided into the first queue, since k is a positive integer greater than or equal to 1 and h is a positive integer greater than k, more IOs with higher IO latency will be placed in the first queue for priority processing. In this way, the IO with the highest latency in each target receiving object will be prioritized, and the target receiving object with higher overall latency will have more IOs prioritized. On the basis of reducing the IO latency of a single target receiving object, the target receiving object with higher latency can be restored more quickly, the IO latency between target receiving objects can be unified, and the stability of IO processing between target receiving objects can be guaranteed.
[0092] Step S103: Determine the IO start time and IO initial priority of the first queue.
[0093] Step S104: Determine the IO waiting time of the first queue according to the current time and the IO start time of the first queue.
[0094] Step S105: Generate the IO target priority of the first queue according to the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority.
[0095] Step S106: sorting the IOs of the first queue in descending order of IO target priority to obtain a third queue.
[0096] Step S107: IO scheduling is performed in the order of the third queue first and the second queue second.
[0097] In practical applications, after the queues for I / O to be processed are divided into the first and second queues, the I / O scheduling can be determined based on the first and second queues to reduce I / O latency. In this process, the I / O start time and initial I / O priority of the first queue can be determined first. The I / O start time refers to the time when I / O starts to be processed. The I / O start time can be flexibly determined based on the application scenario, and the smaller the value of the initial I / O priority, the higher the initial I / O priority. Secondly, the I / O waiting time of the first queue is determined based on the current time and the I / O start time of the first queue. The I / O waiting time is used to represent the I / O latency, so that the I / O waiting time, or I / O waiting latency, can be incorporated into the I / O scheduling process in the future. Furthermore, based on the relationship that the target priority is positively correlated with the IO wait time and negatively correlated with the IO initial priority, the IO target priority of the first queue is generated. In this way, the longer the IO wait time and the smaller the IO initial priority, the higher the IO target priority. Then, the IOs of the first queue are sorted in descending order according to the IO target priority. If a third queue is obtained, the IO with a larger IO target priority is positioned closer in the third queue and is more likely to be processed first, thereby achieving positive sorting of IO with the help of IO latency and IO initial priority. Finally, if IO scheduling is performed in the order of the third queue first and then the second queue, IO with a larger IO latency and a higher IO initial priority can be scheduled first.
[0098] In an exemplary embodiment, in the process of determining the IO waiting time of the first queue based on the current time and the IO start time of the first queue, the difference between the current time and the IO start time of the first queue can be generated; the difference is quantized to obtain a first quantization result, and this quantization is equivalent to converting the difference into a result that can represent the priority. For example, the increase in the IO delay after the priority increases by one level can be determined, and then the difference is quantized according to this increase to obtain a first quantization result, etc.; the first quantization result is used as the IO waiting time of the first queue. In other words, the first quantization result needs to be applied to characterize the IO waiting time so that the first quantization result can be subsequently applied to perform IO scheduling.
[0099] In an exemplary embodiment, based on the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority, in the process of generating the IO target priority of the first queue, the IO initial priority of the first queue also needs to be quantified to obtain a second quantization result, so as to determine the IO target priority in conjunction with the first quantization result; that is, the IO target priority of the first queue needs to be generated based on the target priority and the IO waiting time, that is, based on the relationship that the target priority is positively correlated with the first quantization result and negatively correlated with the second quantization result.
[0100] In an exemplary embodiment, in the process of generating the IO target priority of the first queue, according to the relationship that the target priority is positively correlated with the IO wait time and negatively correlated with the second quantization result, the IO target priority of the first queue can be generated according to the target priority generation formula. According to the relationship that the target priority is positively correlated with the IO wait time and negatively correlated with the second quantization result, the IO target priority of the first queue can be generated; the target priority generation formula includes: P=a*T / p+b; wherein P represents the IO target priority of the first queue; T represents the IO wait time; p represents the second quantization result; a and b both represent compensation coefficients. In specific application scenarios, the values of a and b can be flexibly determined according to actual needs. For example, a can be 1 and b can be 0. In this case, the target priority generation formula is P=T / p.
[0101] In an exemplary embodiment, during the process of performing IO scheduling in the order of the third queue first and then the second queue, the IO of the second queue can be placed after the IO of the third queue to obtain the latest target queue, which is used to store the currently running IO; IO scheduling is performed according to the target queue, so that the IO can be systematically scheduled with the help of the target queue.
[0102] The present invention provides an IO scheduling method, which includes obtaining pending IO; dividing the pending IO into queues to obtain a first queue and a second queue; determining an IO start time of the first queue and an IO initial priority; determining an IO waiting time of the first queue based on the current time and the IO start time of the first queue; generating an IO target priority for the first queue based on a relationship in which the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority; sorting the IOs of the first queue in descending order of the IO target priority to obtain a third queue; and performing IO scheduling in the order of the third queue first and then the second queue. The beneficial effects of the present invention are as follows: first, the to-be-processed IO is divided into a first queue and a second queue, thereby realizing a preliminary division of the to-be-processed IO with the help of queues, and subsequently the IO of the corresponding queue can be flexibly processed according to demand; and the IO waiting time can be generated according to the current time and the IO start time of the first queue, thereby realizing the quantification of the IO latency, and then the IO target priority of the first queue is generated according to the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority. In this way, the greater the IO target priority, the greater the IO latency and the smaller the initial priority. Finally, the IO of the first queue is sorted in descending order of the IO target priority to obtain the third queue and perform IO scheduling in the order of the third queue first and then the second queue. In this way, IO with large latency and low initial priority can be scheduled first, while reducing IO latency and taking priority into account, and achieving better IO processing performance.
[0103] In order to facilitate the understanding of the IO scheduling solution provided by the present invention, the IO scheduling process is now described in conjunction with the blocks in the storage. The corresponding IO scheduling process can be as follows: Figure 2 As shown, the following process is included:
[0104] For the business virtual machines on the upper storage layer, the virtual machines are divided into levels according to the business they run. For example, the three priorities are high, medium, and low, and the three levels are marked with numbers 1, 2, and 3 respectively;
[0105] Set up two IO queues: the target queue listcur stores the currently running IO, and the submission queue listnew stores the IO submitted from the upper layer to the storage engine in this round;
[0106] When processing the first round of IO, the listcur queue is empty. The data in the listnew queue is divided into three queues pri1, pri2, and pri3 according to the priority. The start time of each IO is recorded. pri1, pri2, and pri3 represent the IO queues of priority levels 1, 2, and 3 respectively.
[0107] Add pri1, pri2, and pri3 to listcur in sequence, such as Figure 3 As shown, Figure 3 IO1, IO2, and IO3 represent the three IOs listed in the example. We traverse listcur, submit the IO to the disk, and record the information of the unfinished IO, including the target storage block (blockcur), the position of the IO in the current listcur, the IO start time (timestart), and the priority (priority). We also get listinfo that records the IO information.
[0108] For the second and subsequent rounds of IO, add listnew to the end of listcur, traverse listnew, record the target storage block, IO position in listcur, IO start time and priority, and put the information into listinfo;
[0109] Traverse listinfo, for example, pick out the first IO of blockcur and put it into the first queue listfirst, and put the remaining IO into the second queue listend in turn;
[0110] Calculate the IO quantified waiting time timewait in listfirst based on timestart and current time timenow;
[0111] Compare timewait with the initial priority priority to obtain the parameter representing the IO priority in listfirst, that is, to obtain the target priority timepri, that is, timepri = (timenow - timestart) / priority;
[0112] According to timepri, rearrange the IO in listfirst from large to small to get the third queue list1first, and put the IO in listend into the rearranged queue to get a new listcur, such as Figure 4 As shown;
[0113] Traverse the IO in listcur. After this round, repeat the steps for the second and subsequent rounds of IO, adding listnew to the end of listcur and the following steps.
[0114] The present invention also provides an electronic device, a computer-readable storage medium, and a computer program product, all of which have the corresponding effects of the IO scheduling method provided in the embodiment of the present invention. Figure 5 , Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present invention.
[0115] An embodiment of the present invention provides an electronic device, including a memory 201 and a processor 202. The memory 201 stores a computer program, and when the processor 202 executes the computer program, the steps of the IO scheduling method described in any of the above embodiments are implemented.
[0116] See also Figure 6 Another electronic device provided by an embodiment of the present invention may further include: an input port 203 connected to the processor 202 for transmitting commands inputted from the outside to the processor 202; a display unit 204 connected to the processor 202 for displaying the processing results of the processor 202 to the outside world; and a communication module 205 connected to the processor 202 for enabling communication between the electronic device and the outside world. The display unit 204 may be a display panel, a laser scanning display, or the like; the communication methods used by the communication module 205 include, but are not limited to, Mobile High-Definition Link (MHL), Universal Serial Bus (USB), High-Definition Multimedia Interface (HDMI), wireless connections such as Wireless Fidelity (WiFi), Bluetooth communication technology, Bluetooth Low Energy communication technology, and communication technology based on IEEE802.11s.
[0117] An embodiment of the present invention 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 the IO scheduling method described in any of the above embodiments are implemented.
[0118] The computer-readable storage medium involved in the present invention includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs (Compact Disc Read-Only Memory), or any other form of storage medium known in the technical field.
[0119] An embodiment of the present invention provides a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, the following steps are implemented:
[0120] Get pending IO;
[0121] Divide the queues for the IO to be processed into the first queue and the second queue;
[0122] Determine the IO start time and initial IO priority of the first queue;
[0123] Determine the IO waiting time of the first queue based on the current time and the IO start time of the first queue;
[0124] The IO target priority of the first queue is generated based on the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority;
[0125] Sort the IOs of the first queue in descending order of IO target priority to obtain the third queue;
[0126] I / O scheduling is performed in the order of the third queue first and the second queue second.
[0127] A computer program product provided by an embodiment of the present invention can guide a processor to obtain pending I / O; divide the pending I / O into queues to obtain a first queue and a second queue; determine an I / O start time of the first queue and an initial I / O priority; determine an I / O waiting time of the first queue based on the current time and the I / O start time of the first queue; generate an I / O target priority for the first queue based on a relationship in which the target priority is positively correlated with the I / O waiting time and negatively correlated with the initial I / O priority; sort the I / O of the first queue in descending order of the I / O target priority to obtain a third queue; and schedule I / O in the order of the third queue first and then the second queue. The beneficial effects of the present invention are as follows: the processor, with the help of the computer program / instructions in the computer program product, first divides the to-be-processed IO into a first queue and a second queue, thereby achieving a preliminary division of the to-be-processed IO with the help of the queues, and subsequently flexibly processing the IO of the corresponding queues according to demand; and can generate the IO waiting time according to the current time and the IO start time of the first queue, thereby quantifying the IO latency; and then, based on the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority, generates the IO target priority of the first queue. In this way, the greater the IO target priority, the greater the IO latency and the smaller the initial priority. Finally, the IO of the first queue is sorted in descending order of the IO target priority to obtain a third queue. If IO scheduling is performed in the order of the third queue first and then the second queue, IO with a large latency and a low initial priority can be scheduled first, thereby reducing the IO latency while taking into account the priority, and achieving better IO processing performance.
[0128] For descriptions of the relevant portions of the computer program product, electronic device, and computer-readable storage medium provided in the embodiments of the present invention, please refer to the detailed description of the corresponding portions in the IO scheduling method provided in the embodiments of the present invention, and will not be repeated here. In addition, portions of the above-mentioned technical solutions provided in the embodiments of the present invention that are consistent with the implementation principles of corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.
[0129] It should also be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," 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. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0130] The foregoing description of the disclosed embodiments enables a person skilled in the art to make or use the application. Numerous modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein can be applied to other embodiments without the use of the inventive faculty. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An IO scheduling method, characterized in that: include: Get pending IO; Dividing the to-be-processed IO into queues to obtain a first queue and a second queue; Determine the IO start time and initial IO priority of the first queue; Determine the IO waiting time of the first queue based on the current time and the IO start time of the first queue; Generate an IO target priority of the first queue according to a relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority; Sort the IOs of the first queue according to the IO target priority from large to small to obtain a third queue; I / O scheduling is performed in the order of the third queue first and the second queue second; The IO waiting time of the first queue is determined according to the current time and the IO start time of the first queue, including: Generate the difference between the current time and the IO start time of the first queue; quantizing the difference to obtain a first quantization result; Using the first quantization result as the IO waiting time of the first queue; The IO target priority of the first queue is generated according to the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the IO initial priority, including: quantizing the initial IO priority of the first queue to obtain a second quantization result; The IO target priority of the first queue is generated according to the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the second quantization result.
2. The IO scheduling method according to claim 1, wherein: The to-be-processed IO is divided into queues to obtain a first queue and a second queue, including: Determine the granularity of dividing IO receiving objects; Determining a target receiving object for receiving the to-be-processed IO according to the division granularity; The target receiving object is used as a queue division granularity to divide the to-be-processed IO into queues to obtain a first queue and a second queue.
3. The IO scheduling method according to claim 2, characterized in that: The target receiving object is used as the queue division granularity to divide the to-be-processed IO into queues to obtain a first queue and a second queue, including: Among the pending IOs, n IOs corresponding to the target receiving object with the earliest start time are divided into a first queue, where n is a positive integer equal to or greater than 1; Among the to-be-processed IOs, other IOs corresponding to the target receiving object except the first queue are divided into the second queue.
4. The IO scheduling method according to claim 2, wherein: The target receiving object is used as the queue division granularity to divide the to-be-processed IO into queues to obtain a first queue and a second queue, including: Determine, in the to-be-processed IOs, an IO set corresponding to each of the target receiving objects; Generate an average latency of IO in the IO set; Sort the IO sets in descending order of average latency to obtain an IO set sorting result; The first half of the IO sets in the IO set sorting result is used as the first queue; The IO sets in the second half of the IO set sorting result are used as the second queue.
5. The IO scheduling method according to claim 2, wherein: The target receiving object is used as the queue division granularity to divide the to-be-processed IO into queues to obtain a first queue and a second queue, including: Determine, in the to-be-processed IOs, an IO set corresponding to each of the target receiving objects; Generate an average latency of IO in the IO set; Sort the IO sets in descending order of average latency to obtain an IO set sorting result; The first half of the IO sets in the IO set sorting result are used as the first candidate sets; The IO sets in the second half of the IO set sorting result are used as the second candidate sets; Assign h IOs with the earliest start time in the first candidate set and k IOs with the earliest start time in the second candidate set to a first queue, where k is a positive integer greater than or equal to 1, and h is a positive integer greater than k; In the IO set sorting result, other IOs except the first queue are divided into the second queue.
6. The IO scheduling method according to claim 1, characterized in that: Get pending IO, including: Check whether the target queue is empty. The target queue is used to store the currently running IO; In response to the target queue being empty, obtaining the submission queue consisting of the latest submitted IOs; Add the IO in the submission queue to the target queue in descending order of IO initial priority; Process the IO in the target queue. After the processing is completed, the remaining IO in the target queue is treated as pending IO.
7. The IO scheduling method according to claim 1, wherein: Get pending IO, including: Check whether the target queue is empty. The target queue is used to store the currently running IO; In response to the existence of IO in the target queue, obtain the submission queue consisting of the latest submitted IO; Add the IO in the submission queue to the tail of the target queue in descending order of IO initial priority; Traverse the submission queue to get the first candidate IO; Get the second candidate IO remaining after processing the IO in the target queue in the historical record; The first candidate IO and the second candidate IO are merged to obtain an IO to be processed.
8. The IO scheduling method according to claim 7, characterized in that: After I / O scheduling is performed in the order of the third queue first and the second queue, it also includes: Check whether IO scheduling is completed; In response to continuing the IO scheduling, the process returns to the step of obtaining the submission queue consisting of the latest submitted IO and subsequent steps.
9. The IO scheduling method according to claim 1, wherein: Generating the IO target priority of the first queue according to the relationship that the target priority is positively correlated with the IO waiting time and negatively correlated with the second quantization result includes: Generate an IO target priority for the first queue according to a target priority generation formula based on a relationship in which the target priority is positively correlated with the IO wait time and negatively correlated with the second quantization result; The target priority generation formula includes: P=a*T / p+b; Wherein, P represents the IO target priority of the first queue; T represents the IO waiting time; p represents the second quantization result; a and b both represent compensation coefficients.
10. The IO scheduling method according to claim 1, wherein: I / O scheduling is performed in the order of the third queue first and the second queue later, including: Place the IO of the second queue after the IO of the third queue to get the latest target queue, which is used to store the currently running IO; Perform IO scheduling according to the target queue.
11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the IO scheduling method according to any one of claims 1 to 10 are implemented.
12. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the IO scheduling method according to any one of claims 1 to 10 when executing the computer program.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the IO scheduling method according to any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Task processing method and system based on multistage queues
CN114860395A