A scheduling method based on weight conversion probability and corresponding device
By adopting a scheduling method based on weight conversion probability in distributed storage systems, the problem of low-priority IO cannot be processed for a long time when high-priority IO queues persist, achieving more flexible and efficient IO scheduling, avoiding starvation and improving system performance.
Patent Information
- Application Number
- CN202211089124.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-07
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2042-09-07
AI Technical Summary
In a distributed storage system, when a high-priority IO queue continues to exist, the IO requests in the low-priority IO queue are not processed for a long time, resulting in starvation problems. Moreover, the IO in the priority queue cannot be distinguished and handled in a unified manner according to the FIFO method.
The scheduling method based on the weight conversion probability is adopted, and the weight value of the message queue to be scheduled is summed to determine the target random number, and the queue with the largest weight value is preferred from the message queue as the current scheduling queue. Whether to select the message queue is determined based on the target weight value, random number and first weight value, so as to avoid the low priority IO not being processed for a long time.
It effectively avoids the problem of starvation that low-priority IO cannot be processed for a long time when it persists in a high-priority queue. It also flexibly adjusts the scheduling probability according to the weight value of the IO request, ensuring that high-priority IO is processed in a timely manner and improving system performance.
Smart Images

Figure CN115766612B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of distributed storage, and more specifically, relates to a scheduling method based on weight conversion probability and a corresponding device. Background Art
[0002] In distributed storage, read and write IO (Input / Output) is divided into many types, common types include: client read request, client write request, replica write request, replica write response, recovery read request, recovery write request, data verification read request, etc. Different IO types have different requirements for the response time of IO processing. For example, the priority of client read and write IO requests will be relatively higher, so that the response to the client will be faster, while some internal processing requests, such as internal data verification, are not sensitive to response time, so they will have a relatively low priority, and there will be no impact even if the processing is slower.
[0003] In distributed storage, clients and storage nodes communicate through the network. For each storage service, it is necessary to process IO requests sent by clients and other storage nodes through the network at the same time. IO requests will first enter the IO waiting queue of the storage service, and then be dequeued from the IO waiting queue according to a certain strategy and assigned to the corresponding thread for processing. The order of dequeuing from the IO waiting queue determines the order of IO processing. The IO that is processed first has a shorter response time and better performance; the IO that is dequeued later has relatively lower performance.
[0004] When the IO pressure of the system is relatively high, multiple IO requests will need to be processed at the same time. Which type of IO is processed first will affect the overall performance of the system. At present, the general processing method is to put the IO into two queues with different priorities. The IO in the high-priority queue is processed first. After the high-priority queue is processed, the IO in the low-priority queue is processed.
[0005] The above-mentioned processing method is specifically as follows: different IO types are divided into high priority and low priority, high priority IO is placed in a high priority queue, and low priority IO is placed in a low priority queue; when processing IO requests, messages are first taken out from the high priority queue for processing, and when all messages in the high priority queue are processed, IO in the low priority queue is processed.
[0006] When the IO pressure is relatively high, when there is continuous IO in the high-priority queue, the IO in the low-priority queue will not be processed for a long time, that is, starvation will occur; moreover, the IO in the priority queue cannot be distinguished and can only be processed uniformly in a FIFO (first in, first out) manner. Summary of the invention
[0007] In view of the above defects or improvement needs of the prior art, the present invention provides a scheduling method based on weight conversion probability and a corresponding device, the purpose of which is to adopt a probabilistic scheduling method to avoid the situation where low-priority IO cannot be processed for a long time when the IO pressure is relatively large, thereby solving the technical problem that when there is a continuous IO in the high-priority queue, the IO in the low-priority queue will not be processed for a long time.
[0008] To achieve the above object, according to one aspect of the present invention, a scheduling method based on weight conversion probability is provided, comprising:
[0009] Sum the weight values of the message queues to be scheduled to obtain the target weight value;
[0010] Determine the target random number;
[0011] From the message queues to be scheduled, preferentially select a message queue with the largest weight value as a first message queue, and obtain a first weight value of the first message queue;
[0012] Determine whether to select the first message queue as the current scheduling queue according to the target weight value, the target random number and the first weight value.
[0013] Further, the determining whether to select the first message queue as the current scheduling queue according to the target weight value, the target random number and the first weight value includes:
[0014] Calculating a difference between the target weight value and the first weight value to obtain a second weight value;
[0015] Determining whether the second weight value is not greater than the target random number;
[0016] If the second weight value is not greater than the target random number, the first message queue is selected as the current scheduling queue, and the first message queue is dequeued IO requests in sequence to perform IO read and write operations;
[0017] Furthermore, after determining whether the second weight value is not greater than the target random number, the step further includes:
[0018] If the second weight value is greater than the target random number, the first message queue is not selected, and the first message queue is removed from the message queue to be scheduled;
[0019] From the remaining message queues to be scheduled, preferentially select a message queue with the largest weight value as the first message queue to update the first message queue and update the first weight value;
[0020] Re-summing the weight values of the message queues to be scheduled, and updating the target weight value;
[0021] Execute again “determining whether to select the first message queue as the current scheduling queue according to the target weight value, the target random number and the first weight value”.
[0022] Furthermore, before summing the weight values of the message queues to be scheduled to obtain the target weight value, the step further includes:
[0023] Setting weight values for different types of IO requests and creating message queues based on the weight values;
[0024] An IO request is obtained, a weight value of the IO request is determined according to the type of the IO request, and the IO request is stored in a message queue that matches the weight value.
[0025] Furthermore, the scheduling method further includes:
[0026] Creating a first priority queue and a second priority queue, wherein the second priority queue includes at least one of the message queues, and each message queue has a different weight value;
[0027] Set weight threshold;
[0028] Storing IO requests whose weight values are greater than the weight threshold into the first priority queue;
[0029] The IO requests whose weight values are not greater than the weight threshold are stored in the second priority queue, and the IO requests are stored in the corresponding message queue according to the weight values of the IO requests.
[0030] Furthermore, the scheduling method further includes:
[0031] Prioritize the IO requests in the first priority queue;
[0032] When the first priority queue is empty, determine the message queue to be scheduled from the second priority queue, and perform the step of summing the weight values of the message queues to be scheduled to obtain the target weight value.
[0033] Further, the determining the target random number includes:
[0034] An initial random number is generated, and a modulus operation is performed on a target weight value using the initial random number to obtain the target random number, wherein the value range of the target random number is [0 to the target weight value).
[0035] Furthermore, before summing the weight values of the message queues to be scheduled to obtain the target weight value, the step further includes:
[0036] Before executing the scheduling method each time, determining whether each message queue is empty;
[0037] If the message queue is not empty, the message queue belongs to the message queue to be scheduled;
[0038] If the message queue is empty, the message queue does not belong to the message queue to be scheduled.
[0039] Furthermore, the scheduling method further includes:
[0040] After selecting the current scheduling queue, dequeue the IO request from the queue to determine whether the IO request conflicts with the IO request being processed;
[0041] If there is a conflict, the IO request is temporarily suspended, and the temporarily suspended IO request is processed after the previous conflicting IO request is processed.
[0042] According to another aspect of the present invention, a scheduling device based on weight transition probability is provided, comprising at least one processor and a memory, wherein the at least one processor and the memory are connected via a data bus, and the memory stores instructions that can be executed by the at least one processor, and after being executed by the processor, the instructions are used to complete the scheduling method described in the present application.
[0043] In general, the above technical scheme conceived by the embodiments of the present invention has the following beneficial effects compared with the prior art: the embodiments of the present invention provide a scheduling method based on weight conversion probability and a corresponding device, including: summing the weight values of the message queues to be scheduled to obtain a target weight value; determining a target random number; from the message queues to be scheduled, preferentially selecting the message queue with the largest weight value as the first message queue, and obtaining the first weight value of the first message queue; determining whether to select the first message queue as the current scheduling queue based on the target weight value, the target random number and the first weight value.
[0044] In this application, a probabilistic scheduling method is adopted to avoid the situation where low-priority IO cannot be processed for a long time and starves when the IO pressure is relatively high. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a flowchart of a scheduling method based on weight conversion probability provided by an embodiment of the present invention;
[0046] Figure 2This is a schematic diagram of a data structure of a first priority queue and a second priority queue provided by an embodiment of the present invention;
[0047] Figure 3 This is a schematic diagram of a process of IO request enqueuing provided by an embodiment of the present invention;
[0048] Figure 4 is a flow chart of another scheduling method based on weight conversion probability provided by an embodiment of the present invention;
[0049] Figure 5 It is a structural diagram of a scheduling device based on weight conversion probability provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0051] Embodiment 1:
[0052] See also Figure 1 , this embodiment provides a scheduling method based on weight conversion probability, including:
[0053] Step 101: summing the weight values of the message queues to be scheduled to obtain a target weight value;
[0054] In actual application scenarios, there are multiple types of IO requests in the system, such as client read request, client write request, replica write request, replica write response, recovery read request, recovery write request, data verification read request, etc. The priorities of the above IO requests are different, some are high and some are low.
[0055] In this embodiment, a weight value for describing the priority is defined for each type of IO request, wherein the larger the weight value, the higher the priority of the IO request. The weight values of IO requests of the same type are the same, and the weight values of IO requests of different types may be the same or different.
[0056] Furthermore, a message queue is created, each message queue corresponds to a weight value, and the message queue is used to store IO requests with the same weight value in a FIFO (First Input First Output) mode.
[0057] The range of the weight value is preset, for example, the weight values of all IO requests are within the range of (0, 100).
[0058] It should be noted here that the target weight value changes dynamically. Before each scheduling, it is necessary to determine whether each message queue is empty. If it is empty, its weight will not be included in the calculation of the target weight value.
[0059] Specifically, before executing the scheduling method each time, it is determined whether each message queue is empty; if the message queue is not empty, the message queue belongs to the message queue to be scheduled; if the message queue is empty, the message queue does not belong to the message queue to be scheduled.
[0060] That is, in different scheduling, the target weight value changes dynamically, depending on the weight values of all message queues to be scheduled.
[0061] In addition, in one scheduling, multiple rounds of calculations will be performed. In different rounds of calculations, the queues referred to by the message queues to be scheduled will also change, and the corresponding target weight values will also be different. That is, in each scheduling, the target weight value may also change dynamically. Among them, one scheduling refers to the entire calculation process from the beginning of the calculation to the selection of a message queue.
[0062] Step 102: Determine a target random number;
[0063] Among them, the value range of the target random number is [0~target weight value).
[0064] In an optional embodiment, a random number may be randomly selected from [0 to target weight value) as the target random number.
[0065] In a preferred embodiment, in order to ensure randomness, an initial random number is first generated, the range of which is not agreed upon, and the initial random number is used to perform a remainder operation on the target weight value to obtain the target random number.
[0066] Step 103: From the message queues to be scheduled, preferentially select a message queue with the largest weight value as the first message queue, and obtain a first weight value of the first message queue;
[0067] In this embodiment, weight values are set in advance for different types of IO requests. After receiving an IO request, the weight value of the IO request is determined according to the type of the IO request, and the message queue that matches the IO request is determined according to the weight value of the IO request. IO requests with the same weight value are placed in the same message queue in FIFO mode, and IO requests with different weight values are placed in different message queues.
[0068] Each message queue has a weight value, and the weight value of each message queue is the same as the weight value of the IO request stored in the message queue.
[0069] The first weight value of the first message queue is essentially the weight value of the first message queue. The "first" here has no special limited meaning. It is used for description only to facilitate the expression of different individuals in a category of objects. It should not be interpreted as an order or other aspects with special limited meanings.
[0070] Among them, in one scheduling, multiple rounds of calculation will be carried out. In different rounds of calculation, the queue referred to by the message queue to be scheduled will also change.
[0071] For example, in a certain scheduling, the message queues to be scheduled include message queues q(i), q(j), and q(k). During the first calculation, message queue q(k) is used as the first message queue. The result of the first calculation is: if the first message queue is not selected, message queue q(k) is removed from the message queues to be scheduled. During the first calculation, the message queues to be scheduled only include message queues q(i) and q(j). That is, in one scheduling, the message queues to be scheduled are continuously updated in different rounds of calculation.
[0072] It should be noted that in a scheduling, although the target weight value will change dynamically, the target random number will not change. When the target random number is determined by the modulo method, the modulo operation is only performed based on the target weight value corresponding to the first calculation, and will not be updated with the target weight value.
[0073] Step 104: Determine whether to select the first message queue as the current scheduling queue according to the target weight value, the target random number and the first weight value.
[0074] In a specific embodiment, first, the difference between the target weight value and the first weight value is calculated to obtain a second weight value; it is determined whether the second weight value is not greater than the target random number; if the second weight value is not greater than the target random number, the first message queue is selected as the current scheduling queue, and the first message queue is dequeued IO requests in sequence to perform IO read and write operations.
[0075] If the second weight value is greater than the target random number, the first message queue is not selected, and the first message queue is removed from the message queue to be scheduled, that is, in this round of scheduling, the message queue to be scheduled is also continuously updated.
[0076] Then, from the remaining message queues to be scheduled, the message queue with the largest weight value is preferentially selected as the first message queue to update the first message queue and the first weight value; the weight values of the message queues to be scheduled are re-summed to update the target weight value; and "determining whether to select the first message queue as the current scheduling queue according to the target weight value, the target random number and the first weight value" is executed again. During the re-execution process, since the target weight value and the first weight value have been updated, the second weight value will also be updated accordingly. Then, based on the relationship between the updated second weight value and the target random number, it is determined whether to select the updated first message queue, until a message queue is selected as the scheduling queue.
[0077] In actual application scenarios, in order to avoid IO request conflicts, after selecting the current scheduling queue, the IO request is dequeued from the queue to determine whether the IO request conflicts with the IO request being processed; if there is a conflict, the IO request is temporarily suspended, and the temporarily suspended IO request is processed after the previous conflicting IO request is processed.
[0078] In this embodiment, the scheduling probability can be set based on the weight value of the IO request, and the weight corresponding to the IO request is matched with the scheduling probability, and IO scheduling is performed according to different probabilities. The higher the weight corresponding to the IO request, the greater the scheduling probability, and the easier it is to be selected; the lower the weight corresponding to the IO request, the smaller the scheduling probability, and the less likely it is to be selected. The method of probabilistic scheduling can avoid the situation where low-priority IO cannot be processed for a long time and starves when the IO pressure is relatively high;
[0079] Furthermore, by customizing the weight values of different types of IO requests, the scheduling probability of IO requests can be flexibly adjusted; during the data recovery process, through the probabilistic scheduling method, when there are a large number of internal IOs and client IOs at the same time, the client IOs with relatively higher priorities can be processed first, which can reduce the IO response time and improve performance.
[0080] Embodiment 2:
[0081] Based on the above embodiment 1, in order to ensure that higher priority IO requests can be scheduled first, this embodiment provides another scheduling method, combining Figure 2-3 , specifically including:
[0082] In this embodiment, a first priority queue and a second priority queue are also created, wherein the first priority queue contains only one message queue, and the second priority queue contains at least one message queue, and each message queue has a different corresponding weight value.
[0083] The first priority queue is used to store IO requests whose weight values are greater than the set weight threshold. That is, the message queue in the first priority queue stores IO requests with different weight values. The first priority queue has absolute priority. When the first priority queue is not empty, the IO requests in the first priority queue are preferentially scheduled.
[0084] The second priority queue is used to store IO requests whose weight values are not greater than the set weight threshold. In the second priority queue, each message queue stores IO requests with the same weight value. The weight value corresponding to each message queue is converted into a scheduling probability. Among them, the weight value corresponds to the scheduling probability. The higher the weight of the IO request, the greater the scheduling probability, and the easier it is to be selected. The lower the weight of the IO request, the smaller the scheduling probability. Although the weight of some IO requests is small, the IO request still has a certain probability of being scheduled and will not be completely unschedulable, which can avoid the situation where IO requests with low weight values are never processed.
[0085] For scenarios with particularly high priorities, a weight threshold m is set, where 0 < m < the maximum weight value. m can be set according to the actual situation. For example, the maximum weight value = 100 and m = 75. The IO requests with weight values greater than the weight threshold are stored in the first priority queue. The IO requests with weight values not greater than the weight threshold are stored in the second priority queue, and the IO requests are stored in the corresponding message queues according to the weight values of the IO requests.
[0086] Specifically, after receiving an IO request, the weight value of the IO request is determined according to the type of the IO request. The message queue matching the IO request is determined according to the weight value of the IO request. The IO requests with the same weight value are put into the same message queue in the FIFO mode, and the IO requests with different weight values are put into different message queues.
[0087] The above mainly describes how to store IO requests. Next, how to schedule IO requests will be specifically described.
[0088] In this embodiment, first, it is judged whether the first priority queue is empty. If the first priority queue is not empty, the IO requests in the first priority queue are preferentially processed. If the first priority queue is empty, the message queue to be scheduled is determined from the second priority queue, and the step of summing the weight values of the message queue to be scheduled to obtain the target weight value is executed.
[0089] Among them, the messages in the second priority queue are scheduled probabilistically according to the scheduling method of Embodiment 1.
[0090] The probability scheduling method is adopted. When the weight value of the IO request is greater than the weight threshold m, the absolute priority method is adopted and it will be dequeued from the first priority queue. This is equivalent to the high priority scheduling method in the traditional IO request scheduling. When the weight value of the IO request is less than the threshold m, the probability scheduling method is adopted. This method can solve the problem that the IO requests in the second priority queue will not be processed for a long time and starve to death. At the same time, for IO requests with multiple different weight values, the corresponding probability scheduling can also be performed according to the weight value. The larger the weight value, the higher the priority, and the higher the probability of being processed first. The smaller the weight value, the lower the priority, and the lower the probability of being processed first.
[0091] Among them, the weight threshold m and the weight value of each IO request can be flexibly set within a certain range. It is generally recommended to set the value of threshold m to be larger to ensure that only a small number of IO requests with high priority can enter the second priority queue, and most IO requests still enter the ordinary queue for probabilistic scheduling.
[0092] Embodiment 3:
[0093] Combine the following Figure 4 , using a specific example to illustrate how to perform a scheduling method based on weight conversion probability, the scheduling method includes:
[0094] Step 201: Determine whether the first priority queue is empty;
[0095] In this embodiment, it is first determined whether the first priority queue is empty. If the first priority queue is not empty, step 202a is executed; if the first priority queue is empty, step 202b is executed.
[0096] Step 202a: Dequeue from the first priority queue;
[0097] When the first priority queue is not empty, the IO requests in the first priority queue are preferentially scheduled, and then step 207 is executed.
[0098] Step 202b: Determine the target random number prio;
[0099] In this embodiment, first determine the message queue that is not empty in the second priority queue. The aforementioned non-empty message queue is the message queue to be scheduled corresponding to this scheduling. The sum of the weights of the message queues to be scheduled is calculated to obtain the target weight value, and the target random number prio is determined according to the target weight value.
[0100] Assume that, in this scheduling, in the second priority queue, three message queues are not empty, specifically message queues q(i), q(j), q(k), where i, j, k represent weight values of the message queues.
[0101] Calculate the sum of the weights of the message queues q(i), q(j), and q(k) to be scheduled and obtain the target weight value total_prio:
[0102] total_prio=i+j+k
[0103] It should be noted here that the target weight value total_prio changes dynamically. Before each scheduling, it is necessary to determine whether each message queue in the second priority queue is empty. If it is empty, its weight is not included in the calculation of total_prio.
[0104] In addition, in a scheduling, the target weight value total_prio also changes dynamically. If a message queue is not selected, the weight value of the unselected message queue is not included in the calculation of the target weight.
[0105] Among them, one scheduling refers to the entire process from starting calculation to selecting a message queue.
[0106] Generate an initial random number rand(), and use this initial random number to take the modulus of the target weight value total_prio. After taking the modulus, you will get a target random number prio in the range of [0~total_prio):
[0107] prio = rand() % total_prio
[0108] In each scheduling, the target random number prio does not change. When the target random number is determined by the modulo method, the modulo operation is only performed based on the target weight value corresponding to the first calculation, and will not be updated with the target weight value.
[0109] Step 203: Determine a target weight value total_prio and a first weight value current_prio;
[0110] Step 204: Calculate a second weight value tp according to the target weight value total_prio and the first weight value current_prio;
[0111] The target weight value total_prio is determined in the aforementioned manner, wherein in one scheduling, the target weight value total_prio is updated according to the actual situation.
[0112] Sort the message queues q(i), q(j), and q(k) according to the weight values. First, calculate the message queue with the largest weight value (the first message queue in Embodiment 1), and determine the first weight value current_prio of this first message queue. The first weight value current_prio is essentially the weight value of the first message queue.
[0113] Among them, each message queue has a weight value, and the weight value of each message queue is the same as the weight value of the IO requests stored in this message queue.
[0114] Then, calculate the difference between the target weight value total_prio and the first weight value current_prio to obtain the second weight value tp:
[0115] tp = total_prio – current_prio
[0116] Step 205: Determine whether the second weight value tp is not greater than the target random number prio;
[0117] Determine whether this message queue dequeues from the second priority queue. The calculation method is as follows:
[0118] If tp <= prio, it means this message queue is selected, and execute Step 206. If tp > prio, it means the message queue is not selected, return to execute Step 203, update the target weight value, the first message queue, and the first weight value to continue to judge the next message queue;
[0119] The judgment method for the next message queue is still the above method. Update the second weight value tp according to the updated target weight value and the updated first weight value, and determine whether this message queue dequeues from the second priority queue;
[0120] tp = tp – current_prio
[0121] The judgment method is the same as above. If tp <= prio, it means this message queue is selected. If tp > prio, it means the message queue is not selected, return to execute Step 203, and continue to judge the next queue until a message queue is selected;
[0122] Step 206: Select the current message queue;
[0123] After selecting the current message queue, execute Step 207.
[0124] Step 207: Perform IO read and write processing.
[0125] Calculate all the message queues in the second priority queue in the foregoing manner, select one message queue, dequeue the IO requests from this message queue in sequence, and process them;
[0126] Therefore, according to the scheduling method of this embodiment, the dequeue probability of each message queue matches its own weight value, which can not only ensure that the IO requests with lower weight values are not starved, but also ensure that the IO requests with higher weight values can still be scheduled with a high probability, and try not to disrupt the scheduling priority of the IO requests.
[0127] To better elaborate the foregoing solution, the following is an example for illustration:
[0128] Example 1:
[0129] Suppose i = 10, j = 30, k = 60;
[0130] In this scheduling, when calculating for the first time, the target weight value total_prio = i + j + k = 100, and the initial random number rand() = 80;
[0131] Then, the target random number prio = rand() % total_prio = 80 % 100 = 80;
[0132] The first message queue is q(k), the first weight value current_prio = 60, then the second weight value tp = total_prio - current_prio = 40;
[0133] Since tp = 40, prio = 80, then tp < prio, which meets the selection condition, so the message queue q(k) is selected, and the IO requests in the message queue q(k) are dequeued for processing.
[0134] Example 2:
[0135] Suppose i = 20, j = 30, k = 40;
[0136] In this scheduling, when calculating for the first time, the target weight value total_prio = i + j + k = 90, and the initial random number rand() = 10;
[0137] Then, the target random number prio = rand() % total_prio = 10 % 90 = 10;
[0138] The first message queue is q(k), the first weight value current_prio = 40, then the second weight value tp = total_prio - current_prio = 50;
[0139] Since tp = 50 and prio = 10, then tp > prio, so q(k) is not selected in this calculation;
[0140] Update the target weight value total_prio = i + j = 20 + 30 = 50;
[0141] Update the first message queue to q(j), and update the first weight value current_prio = 30;
[0142] Update the target weight value tp = total_prio - current_prio = 50 - 30 = 20;
[0143] Since tp = 20 and prio = 10, then tp > prio, so q(j) is not selected in this calculation;
[0144] Update the target weight value total_prio = i = 20;
[0145] Continue to update the first message queue to q(i), and update the first weight value current_prio = 20;
[0146] Update the target weight value tp = total_prio - current_prio = 20 - 20 = 0;
[0147] Since tp = 0 and prio = 10, then tp < prio, so q(i) is selected.
[0148] According to the above calculation method, when there are messages to be processed in q(i), q(j), and q(k), there will be a probability of being scheduled from queue q(i) for processing, a probability of being scheduled from queue q(j) for processing, a probability of being scheduled from queue q(k) for processing, where sum is the sum of the weights of q(i), q(j), and q(k). The larger the weight value is set, the higher the probability of being selected from the queue each time, and the lower the weight value is set, the lower the probability of being selected from the queue. However, for low-priority queues, there is still a chance to be selected, but the probability is relatively low.
[0149] The foregoing Example 1 and Example 2 correspond to different scheduling situations and are used to assist in understanding the solution of this embodiment. The following explains why the scheduling method according to this embodiment can ensure that the scheduling probability corresponds to the weight value of the IO request.
[0150] Based on the above example 1, for the three queues q(i), q(j), and q(k), the weight value of q(i) is i=10, the weight value of q(j) is j=30, and the weight value of q(k) is k=60. The probability of leaving the queue of each queue is determined by the weight value. It can be seen that the probability of leaving the queue of q(i) is 10%, the probability of leaving the queue of q(j) is 30%, and the probability of leaving the queue of q(k) is 60%.
[0151] According to the scheduling method of this embodiment, in the process of determining whether to select q(k), since tp=total_prio-current_prio=40, the target random number is [0~100). If q(k) is to be selected, it only needs to satisfy that the target random number is an integer in [40~100). Then the probability that the target random number is an integer in [40~100) is 60%.
[0152] In the process of determining whether to select q(j), the target random number must be an integer in [0-40) before jumping to the program for calculating whether q(k) meets the dequeue condition. Since tp=tp-current_prio=10, if q(k) is to be selected, it only needs to be an integer in [10-40). The probability that the target random number is an integer in [10-40) is 30%.
[0153] In the process of determining whether to select q(i), the target random number must be an integer in [0 to 10) before jumping to the program that calculates whether q(i) meets the dequeue condition. Since tp = tp – current_prio = 0, if q(i) is to be selected, it only needs to be an integer in [0 to 10). The probability that the target random number is an integer in [0 to 10) is 10%.
[0154] Therefore, the scheduling method of this embodiment can ensure that the scheduling probability corresponds to the weight value of the IO request.
[0155] The scheduling method of this embodiment has at least the following advantages:
[0156] The probabilistic scheduling method can avoid the situation where low-priority IO cannot be processed for a long time and starves when the IO pressure is relatively high;
[0157] For multiple IO types with different weight values in the normal priority queue (second priority queue), scheduling can be performed according to the priority level. The higher the priority level, the higher the probability of being scheduled first. Compared with the traditional first-in-first-out method, the solution of this embodiment can achieve more fine-grained distinction.
[0158] By customizing the weight values of different types of IO requests, the scheduling probability of IO requests can be flexibly adjusted;
[0159] During the data recovery process, through the probabilistic scheduling method, when there are a large number of internal IOs and client IOs at the same time, it can be ensured that the client IOs with relatively higher priorities are processed first, which can reduce the IO response time and improve performance.
[0160] Embodiment 4:
[0161] Based on the scheduling method based on weight conversion probability provided in the above-mentioned embodiments 1 to 3, the present invention also provides a scheduling device based on weight conversion probability that can be used to implement the above-mentioned method, such as Figure 5 , which is a schematic diagram of the device architecture of an embodiment of the present invention. The scheduling device based on weighted conversion probability of this embodiment includes one or more processors 21 and a memory 22. Figure 5 A processor 21 is taken as an example.
[0162] The processor 21 and the memory 22 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.
[0163] The memory 22, as a non-volatile computer-readable storage medium of a scheduling method based on weight conversion probability, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as the scheduling method based on weight conversion probability in Example 1. The processor 21 executes various functional applications and data processing of the scheduling device based on weight conversion probability by running the non-volatile software programs, instructions and modules stored in the memory 22, that is, implements the scheduling method based on weight conversion probability of Examples 1 to 3.
[0164] The memory 22 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 22 may optionally include a memory remotely arranged relative to the processor 21, and these remote memories may be connected to the processor 21 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0165] The program instructions / modules are stored in the memory 22, and when executed by the one or more processors 21, the scheduling method based on weighted conversion probability in the above embodiment is executed, for example, the above described Figure 1 The steps shown.
[0166] A person skilled in the art may understand that all or part of the steps in the various methods of the embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0167] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A scheduling method based on weight conversion probability, characterized in that: include: Sum the weight values of the message queues to be scheduled to obtain the target weight value; Determine the target random number; From the message queues to be scheduled, preferentially select a message queue with the largest weight value as a first message queue, and obtain a first weight value of the first message queue; Determining whether to select the first message queue as the current scheduling queue according to the target weight value, the target random number and the first weight value includes: calculating the difference between the target weight value and the first weight value to obtain a second weight value; determining whether the second weight value is not greater than the target random number; If the second weight value is not greater than the target random number, the first message queue is selected as the current scheduling queue, and the first message queue is dequeued IO requests in sequence to perform IO read and write operations.
2. The scheduling method according to claim 1, characterized in that: After determining whether the second weight value is not greater than the target random number, the following step further includes: If the second weight value is greater than the target random number, the first message queue is not selected, and the first message queue is removed from the message queue to be scheduled; From the remaining message queues to be scheduled, preferentially select a message queue with the largest weight value as the first message queue to update the first message queue and update the first weight value; Re-summing the weight values of the message queues to be scheduled, and updating the target weight value; Execute again "determining whether to select the first message queue as the current scheduling queue according to the target weight value, the target random number and the first weight value".
3. The scheduling method according to claim 1, characterized in that: The step of summing the weight values of the message queues to be scheduled to obtain the target weight value also includes: Setting weight values for different types of IO requests and creating message queues based on the weight values; An IO request is obtained, a weight value of the IO request is determined according to the type of the IO request, and the IO request is stored in a message queue that matches the weight value.
4. The scheduling method according to claim 3, characterized in that: The scheduling method further includes: Creating a first priority queue and a second priority queue, wherein the second priority queue includes at least one of the message queues, and each message queue has a different weight value; Set weight threshold; Storing IO requests whose weight values are greater than the weight threshold into the first priority queue; The IO requests whose weight values are not greater than the weight threshold are stored in the second priority queue, and the IO requests are stored in the corresponding message queue according to the weight values of the IO requests.
5. The scheduling method according to claim 4, characterized in that: The scheduling method further includes: Prioritize the IO requests in the first priority queue; When the first priority queue is empty, determine the message queue to be scheduled from the second priority queue, and perform the step of summing the weight values of the message queues to be scheduled to obtain the target weight value.
6. The scheduling method according to any one of claims 1 to 5, characterized in that: Determining the target random number comprises: An initial random number is generated, and a modulus operation is performed on a target weight value using the initial random number to obtain the target random number, wherein the value range of the target random number is [0 to the target weight value).
7. The scheduling method according to any one of claims 1 to 5, characterized in that: The step of summing the weight values of the message queues to be scheduled to obtain the target weight value also includes: Before executing the scheduling method each time, determining whether each message queue is empty; If the message queue is not empty, the message queue belongs to the message queue to be scheduled; If the message queue is empty, the message queue does not belong to the message queue to be scheduled.
8. The scheduling method according to any one of claims 1 to 5, characterized in that: The scheduling method further includes: After selecting the current scheduling queue, dequeue the IO request from the queue to determine whether the IO request conflicts with the IO request being processed; If there is a conflict, the IO request is temporarily suspended, and the temporarily suspended IO request is processed after the previous conflicting IO request is processed.
9. A scheduling device based on weight conversion probability, characterized in that: It includes at least one processor and a memory, wherein the at least one processor and the memory are connected via a data bus, and the memory stores instructions that can be executed by the at least one processor, and after the instructions are executed by the processor, they are used to complete the scheduling method described in any one of claims 1-8.
Citation Information
Patent Citations
Task selection data processing method, device and equipment and storage medium
CN111930486A
Queue scheduling method and system, equipment and medium
CN113590030A