Method for accelerating block device and terminal

By acquiring block device performance data in real time and combining it with user IO rate, the dirty data flushing rate is adjusted, which solves the user experience problem caused by unstable IO of block devices in cloud desktop scenarios and achieves efficient dirty data flushing without affecting normal IO read and write.

CN115525222BActive Publication Date: 2026-01-16FUJIAN CENTM INFORMATION
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211046804.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-30
Publication Date
2026-01-16
Estimated Expiration
2042-08-30

AI Technical Summary

Technical Problem

The existing block device acceleration function has an unreasonable control over the dirty data flushing rate when IO is unstable in cloud desktop scenarios, which affects the user experience.

Method used

By acquiring real-time performance data of block devices, it is determined whether their performance is sufficient. If it is sufficient, the flush rate is increased; otherwise, it is determined whether the hard disk garbage collection mechanism is collecting a large amount of data. If so, the flush step is exited; otherwise, the rate is reduced and the maximum flush rate is calculated in combination with the user IO rate.

Benefits of technology

Without affecting normal user I/O read and write operations, a high-rate dirty data flushing is achieved, reducing user I/O latency, improving user experience, and avoiding the unreasonable control of dirty data flushing rate in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115525222B_ABST
    Figure CN115525222B_ABST
Patent Text Reader

Abstract

The application discloses a kind of acceleration method and terminal of block device, when dirty data is flushed to block device, the performance data of device is obtained, so that the performance of block device is judged based on the performance data, for the block device of sufficient performance, it can improve its flush rate, for the block device of lower performance, it needs to judge whether there is a large amount of garbage collection, if so, exit dirty data flush, otherwise, reduce the rate of block device and calculate its maximum flush rate.Therefore, compared with the traditional dirty data threshold control flush and flush rate, the application can realize the flush of dirty data at any time during the idle period of disk without affecting user experience, and the flush rate is no longer based on dirty data as a standard, which can flush dirty data at a higher rate, and the control of dirty data flush rate is more free and reasonable;At the same time, when the hard disk device does a lot of garbage collection, the function of normal exit dirty data flush can reduce user IO delay and improve user experience.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of block device, in particular to a block device acceleration method and terminal. BACKGROUND

[0002] Due to the dirty data backwash of the existing block device acceleration function, generally a dirty data is used as a threshold to control, when reaching the threshold, the backwash rate is adjusted according to the PID algorithm to backwash the dirty data.

[0003] The main problem of this method is that the backwash rate is controlled according to the PID algorithm of the dirty data, which means that the more the dirty data exceeds the threshold, the faster the backwash rate. However, in the cloud desktop scenario, the IO (input / output) is usually unstable, and a large amount of IO usually lasts for a period of time, such as copying a large file by the user. If the general algorithm is used, it is possible to backwash a large amount of dirty data at the same time of copying the large file, which seriously affects the user experience. SUMMARY

[0004] The technical problem to be solved by the present application is to provide a block device acceleration method and terminal, which can backwash dirty data at a high rate without affecting the normal reading and writing of IO.

[0005] In order to solve the above technical problems, the technical scheme adopted by the present application is:

[0006] A block device acceleration method, comprising the steps of:

[0007] When the hard disk backwashes the dirty data to the block device, the performance data of the block device is acquired in real time, and whether the performance of the block device is sufficient is judged according to the performance data of the block device. If yes, the block device rate is increased;

[0008] Otherwise, whether the garbage collection mechanism in the hard disk is recycling a large amount of data is judged. If yes, the step of backwashing the dirty data from the hard disk to the block device is exited. Otherwise, the block device rate is reduced, and the maximum backwash rate of the block device is calculated in combination with the user IO rate in the hard disk and the block device rate.

[0009] In order to solve the above technical problems, another technical scheme adopted by the present application is:

[0010] A block device acceleration terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, when the processor executes the computer program, the following steps are realized:

[0011] When the hard disk flushes dirty data to the block device, the performance data of the block device is acquired in real time, and whether the performance of the block device is sufficient is judged according to the performance data of the block device, if yes, the block device rate is increased;

[0012] Otherwise, whether the garbage collection mechanism in the hard disk is recycling a large amount of data is judged, if yes, the step of flushing dirty data from the hard disk to the block device is exited, otherwise, the block device rate is decreased, and the maximum flush rate of the block device is calculated in combination with the user IO rate in the hard disk and the block device rate.

[0013] The beneficial effects of the present application are that when the hard disk flushes dirty data to the block device, the device performance data is acquired, so that the performance of the block device is judged based on the performance data, for the block device with sufficient performance, the flush rate thereof can be increased, and for the block device with lower performance, whether there is a large amount of garbage collection is judged, if yes, the dirty data flush is exited, otherwise, the block device rate is decreased and the maximum flush rate thereof is calculated. Therefore, compared with the conventional dirty data threshold control flush and flush rate, the present application can realize the dirty data flush at any time during the disk idle period without affecting the user experience, and the flush rate is no longer based on the dirty data, so that the dirty data can be flushed at a larger rate, and the dirty data flush rate control is more free and reasonable; at the same time, when the hard disk device performs a large amount of garbage collection, the function of normally exiting the dirty data flush is realized, so that the user IO delay is reduced and the user experience is improved. BRIEF DESCRIPTION OF DRAWINGS

[0014] Figure 1 A flow chart of a block device acceleration method according to an embodiment of the present application;

[0015] Figure 2 A schematic diagram of a block device acceleration terminal according to an embodiment of the present application;

[0016] Figure 3 A specific step flow chart of a block device acceleration method according to an embodiment of the present application;

[0017] Figure 4 A disk performance calculation flow chart of a block device acceleration method according to an embodiment of the present application;

[0018] REFERENCE NUMERALS:

[0019] 1, a block device acceleration terminal; 2, a memory; 3, a processor. DETAILED DESCRIPTION

[0020] To explain the technical content, purposes and effects of the present application in detail, the following will be described in combination with the embodiments and the drawings.

[0021] Please refer to Figure 1The embodiment of the present application provides a block device acceleration method, comprising the steps of:

[0022] When the hard disk flushes dirty data to the block device, the performance data of the block device is acquired in real time, and whether the performance of the block device is sufficient is judged according to the performance data of the block device; if yes, the block device rate is increased.

[0023] Otherwise, whether the garbage collection mechanism in the hard disk is recycling a large amount of data is judged; if yes, the step of flushing dirty data from the hard disk to the block device is exited; otherwise, the block device rate is reduced, and the maximum flush rate of the block device is calculated in combination with the user IO rate in the hard disk and the block device rate.

[0024] From the above description, it can be known that the present application has the beneficial effects that when the hard disk flushes dirty data to the block device, the device performance data is acquired, so that the performance of the block device is judged based on the performance data; for the block device with sufficient performance, the flush rate thereof can be increased; for the block device with lower performance, whether there is a large amount of garbage collection is judged; if yes, the dirty data flush is exited; otherwise, the block device rate is reduced and the maximum flush rate thereof is calculated. Therefore, compared with the conventional dirty data threshold control flush and flush rate, the present application can realize the dirty data flush at any time during the disk idle period without affecting the user experience, and the flush rate is no longer based on the dirty data, so that the dirty data flush rate control is more free and reasonable; at the same time, when the hard disk device performs a large amount of garbage collection, the function of normally exiting the dirty data flush is realized, so that the user IO delay is reduced and the user experience is improved.

[0025] Further, before judging whether the performance of the block device is sufficient according to the performance data of the block device, the following steps are included:

[0026] The performance data of the block device includes IO delay time and queue average depth.

[0027] If the IO delay time exceeds 3ms or the queue average depth is greater than or equal to 3, the step of flushing dirty data from the hard disk to the block device is exited.

[0028] From the above description, it can be known that when the IO delay time or the queue average depth exceeds the corresponding threshold, the step of flushing dirty data from the hard disk to the block device is exited, so that the current user IO delay is reduced and the user experience is improved; and the calculation efficiency is improved through the queue depth and the IO delay.

[0029] Further, judging whether the performance of the block device is sufficient according to the performance data of the block device includes:

[0030] If the IO delay time exceeds 800us, it is determined that the performance of the block device is insufficient, otherwise, it is determined that the performance of the block device is sufficient.

[0031] From the above description, it can be seen that the performance of the block device is determined by the IO delay time, which has high determination efficiency and is closer to the performance determination method in the actual scene.

[0032] Further, the combination of the user IO rate in the hard disk and the block device rate to calculate the maximum flush rate of the block device comprises:

[0033] According to the user IO rate, the current user IO rate is estimated.

[0034] According to the current user IO rate and the block device rate, the maximum flush rate v of the block device is calculated. max :

[0035] v max =(v1-v2)*r.

[0036] In the formula, v1 represents the block device rate, v2 represents the current user IO rate, and r represents the flush coefficient.

[0037] From the above description, it can be seen that the dirty data flush rate can be obtained by subtracting the current IO rate from the block device rate according to the formula, that is, the user IO rate and the dirty data flush rate are considered as a whole, avoiding mutual influence caused by the flush rate being too large or the user IO rate changing; the maximum flush rate is obtained by multiplying the dirty data flush rate by the flush coefficient, which can utilize the read-write performance of the hard disk.

[0038] Further, the estimation of the current user IO rate according to the user IO rate comprises:

[0039] The user IO rate of the previous second is multiplied by an estimation proportion to obtain the current user IO rate.

[0040] From the above description, it can be seen that since the user behavior is difficult to estimate, it is not too appropriate to implement a set of complex algorithms to predict the user behavior in the kernel code, therefore, the user IO rate of the previous second is directly multiplied by an estimation proportion as the estimated user IO rate, which has high calculation efficiency and strong practicability.

[0041] Please refer to Figure 2 Another embodiment of the present application provides a block device acceleration terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:

[0042] When the hard disk flushes dirty data to the block device, performance data of the block device is acquired in real time, and whether the performance of the block device is sufficient is judged according to the performance data of the block device, if yes, the block device rate is increased;

[0043] Otherwise, whether a garbage collection mechanism in the hard disk is recycling a large amount of data is judged, if yes, the step of the hard disk flushing dirty data to the block device is exited, otherwise, the block device rate is decreased, and the maximum flush rate of the block device is calculated in combination with the user IO rate in the hard disk and the block device rate.

[0044] From the above description, the beneficial effects of the present application are that when the hard disk flushes dirty data to the block device, the device performance data is acquired, so that the performance of the block device is judged based on the performance data, for the block device with sufficient performance, the flush rate thereof can be increased, and for the block device with lower performance, whether there is a large amount of garbage collection needs to be judged, if yes, the dirty data flush is exited, otherwise, the block device rate is decreased and the maximum flush rate thereof is calculated. Therefore, compared with the traditional dirty data threshold control flush and flush rate, the present application can realize the dirty data flush at any time during the disk idle period without affecting the user experience, and the flush rate is no longer based on the dirty data, so that the dirty data can be flushed at a larger rate, and the dirty data flush rate control is more free and reasonable; at the same time, when the hard disk device performs a large amount of garbage collection, the function of normally exiting the dirty data flush can reduce the user IO delay and improve the user experience.

[0045] Further, before judging whether the performance of the block device is sufficient according to the performance data of the block device, the following steps are included:

[0046] The performance data of the block device includes IO delay time and queue average depth;

[0047] If the IO delay time exceeds 3ms or the queue average depth is greater than or equal to 3, the step of the hard disk flushing dirty data to the block device is exited.

[0048] From the above description, when the IO delay time or the queue average depth exceeds the corresponding threshold, the step of the hard disk flushing dirty data to the block device needs to be exited, which can reduce the current user IO delay and improve the user experience; and the calculation efficiency can be improved by calculating through the queue depth and the IO delay.

[0049] Further, judging whether the performance of the block device is sufficient according to the performance data of the block device includes:

[0050] If the IO delay time exceeds 800us, it is determined that the performance of the block device is insufficient, otherwise, it is determined that the performance of the block device is sufficient.

[0051] From the above description, it can be seen that the performance of the block device is determined by the IO delay time, which is efficient and close to the actual performance determination method in the scene.

[0052] Further, the maximum flush rate of the block device is calculated according to the user IO rate and the block device rate, which comprises:

[0053] The user current IO rate is estimated according to the user IO rate;

[0054] The maximum flush rate v of the block device is calculated according to the user current IO rate and the block device rate max :

[0055] v max =(v1-v2)*r;

[0056] In the formula, v1 represents the block device rate, v2 represents the user current IO rate, and r represents the flush coefficient.

[0057] From the above description, it can be seen that the dirty data flush rate can be obtained by subtracting the current IO rate from the block device rate according to the formula, that is, the user IO rate and the dirty data flush rate are considered as a whole, avoiding the mutual influence caused by the too large flush rate or the change of the user IO rate; The maximum flush rate is obtained by multiplying the dirty data flush rate by the flush coefficient, which can utilize the read-write performance of the hard disk.

[0058] Further, the user current IO rate is estimated according to the user IO rate, which comprises:

[0059] The user current IO rate is obtained by multiplying the user IO rate of the previous second by the estimation proportion.

[0060] From the above description, it can be seen that it is difficult to estimate the user behavior, and it is not suitable to implement a complex algorithm to estimate the user behavior in the kernel code, so the user IO rate of the previous second is directly multiplied by the estimation proportion to obtain the estimated user IO rate, which is efficient and practical.

[0061] The above-mentioned block device acceleration method and terminal of the application are suitable for updating data in a hard disk and a magnetic disk, and when a user copies a large file in the hard disk, the dirty data is flushed to the magnetic disk at a relatively high rate without affecting the normal IO read-write, which will be described in detail through specific embodiments.

[0062] Embodiment one

[0063] Please refer to Figure 1 and Figure 3 , a block device acceleration method, in this embodiment, the block device is a magnetic disk, which comprises the following steps:

[0064] S1, when the hard disk flushes dirty data to the block device, real-time performance data of the block device is acquired, and whether the performance of the block device is sufficient is determined according to the performance data of the block device, if yes, the speed of the block device is increased.

[0065] S11, performance data of the block device is acquired.

[0066] Specifically, original data such as disk queue depth, IOPS (input / output planning system), IO delay, etc. is counted.

[0067] S12, if the IO delay time exceeds 3ms or the queue average depth is greater than or equal to 3, the step of flushing dirty data from the hard disk to the block device is exited.

[0068] Specifically, please refer to Figure 4 if the disk queue average depth is greater than or equal to 3 within one second, the dirty data flushing step is exited, otherwise whether the read-write delay is greater than 3ms is determined, if yes, the dirty data flushing step is exited, if no, the step S13 is executed.

[0069] S13, combined with the PID (proportion-integral-differential) control algorithm, if the IO delay time exceeds 800us, it is determined that the performance of the block device is insufficient, otherwise, it is determined that the performance of the block device is sufficient, and the speed of the block device is increased.

[0070] Specifically, when the delay time is greater than 800us, the delay time and the preset 800us are PID controlled and calculated, the greater the difference between the delay time and 800us, the greater the speed of the block device is reduced; when the delay time is less than 800us, the delay time and the preset 800us are PID controlled and calculated, the greater the difference between the delay time and 800us, the greater the speed of the block device is increased.

[0071] Further, the maximum flushing speed v of the block device is calculated according to the current IO speed of the user and the speed of the block device max :

[0072] v max =(v1-v2)*r;

[0073] In the formula, v1 represents the speed of the block device, v2 represents the current IO speed of the user, and r represents the flushing coefficient, which is 80% in this embodiment.

[0074] S2, otherwise, whether the garbage collection mechanism in the hard disk is recycling a large amount of data is determined, if yes, the step of flushing dirty data from the hard disk to the block device is exited, otherwise, the speed of the block device is reduced, and the maximum flushing speed of the block device is calculated according to the IO speed of the user in the hard disk and the speed of the block device.

[0075] Specifically, in addition to a few hard disks such as optane persistent memory, ssd (solid state disk) and nvme solid state disk are mostly composed of nand flash (flash) medium, which means that when data is written to a page, it needs to be erased and then written. However, the nand flash erase unit is erased in block (block) units, and there are usually 64 pages in a block. When erasing a block, valid pages need to be copied elsewhere. If the actual disk rate changes little, the performance suddenly decreases seriously, and the IO delay suddenly increases by more than 2ms, most of the time the garbage collection mechanism of the disk device is working, at this time the dirty data can be paused, and when the performance is good, the dirty data can be brushed.

[0076] Among them, the user's current IO rate is estimated according to the user's IO rate, that is, the user's IO rate in the last second is multiplied by the estimated proportion to obtain the user's current IO rate. In this embodiment, the estimated proportion is 120%;

[0077] According to the user's current IO rate and the block device rate, the maximum brushing rate v of the block device is calculated max :

[0078] v max =(v1-v2)*r;

[0079] In the formula, v1 represents the block device rate, v2 represents the user's current IO rate, and r represents the brushing coefficient. In this embodiment, the brushing coefficient is 80%, which can be adjusted according to the actual scene. Mainly considering the influence of read and write IOPS and read and write blocks, and the influence of the garbage collection mechanism.

[0080] In summary, through the block device acceleration method of this embodiment, the traditional dirty data is no longer used as a threshold for control. Through real-time performance data analysis, the dirty data rate is adjusted in time, forming a complete loop control system, which can guarantee that the dirty data is brushed at a relatively large rate without affecting normal IO read and write, and can clean the dirty data on the nvme device as soon as possible. Guaranteeing the subsequent continuous acceleration of the mechanical disk, improving the user's health, so as to fully utilize the idle time period to brush the dirty data, maximize the acceleration function of the acceleration disk; At the same time, avoid the need to manually modify the parameters of the idle brushing function due to the reduction of the performance of the nvme device, the garbage collection mechanism, etc. And this method takes the final user performance data as a reference, which can effectively shield the performance jitter and changes caused by various reasons of the acceleration disk.

[0081] Embodiment two

[0082] Please refer to Figure 2The application provides a terminal 1 for accelerating a block device, comprising a memory 2, a processor 3 and a computer program stored in the memory 2 and capable of running on the processor 3, wherein the processor 3 implements each step of the method for accelerating a block device according to the first embodiment when the computer program is executed.

[0083] In conclusion, the application provides a method and a terminal for accelerating a block device, when dirty data is flushed to the block device, the device performance data is obtained, and the performance of the block device is judged based on the performance data; the flushing rate of the block device with sufficient performance can be improved; and for the block device with lower performance, it is determined whether there is a large amount of garbage collection; if yes, the dirty data flushing is exited; otherwise, the flushing rate of the block device is reduced, and the maximum flushing rate is calculated. Therefore, compared with the conventional method of controlling the flushing and the flushing rate by using the dirty data as a threshold, the application can realize the dirty data flushing at any time during the idle period of the disk without affecting the user experience, and the flushing rate is no longer controlled by the dirty data, so that the dirty data can be flushed at a higher rate, and the control of the dirty data flushing rate is more reasonable and free; meanwhile, the user IO rate and the flushing rate are considered as a whole, so as to avoid the mutual influence caused by the excessively large flushing rate or the change of the user IO rate. The dirty data flushing function can be normally exited when the user performs file copying or a large amount of IO occurs, or the hard disk device performs a large amount of garbage collection, so as to reduce the user IO delay and improve the user experience.

[0084] The above description is only an embodiment of the application, and does not limit the patent range of the application, and any equivalent transformation or direct or indirect application in the related technical field based on the content of the specification and the drawings is also included in the patent protection range of the application.

Claims

1. A method of accelerating a block device, the method comprising: The method comprises the steps of: acquiring performance data of the block device in real time when the hard disk flushes dirty data to the block device, judging whether the performance of the block device is sufficient according to the performance data of the block device, increasing the block device rate if yes; otherwise, judging whether a garbage collection mechanism in the hard disk is recycling a large amount of data, exiting the step of flushing dirty data to the block device if yes, otherwise, decreasing the block device rate, and calculating the maximum flush rate of the block device in combination with a user IO rate in the hard disk and the block device rate; the step of calculating the maximum flush rate of the block device in combination with the user IO rate in the hard disk and the block device rate comprises: multiplying the user IO rate of the previous second by an estimated proportion to obtain a current user IO rate; calculating a maximum scrub rate v of the block device according to a current IO rate of the user and the block device rate max : v max = (v1-v2)*r; in the formula, v1 represents the block device rate, v2 represents the current user IO rate, and r represents a flush coefficient.

2. The method of claim 1, wherein, The step of judging whether the performance of the block device is sufficient according to the performance data of the block device comprises: the performance data of the block device comprises an IO delay time and a queue average depth; if the IO delay time exceeds 3 ms or the queue average depth is greater than or equal to 3, the step of flushing dirty data to the block device is exited.

3. The method of claim 2, wherein, The step of judging whether the performance of the block device is sufficient according to the performance data of the block device comprises: if the IO delay time exceeds 800 μs, it is determined that the performance of the block device is insufficient, otherwise, it is determined that the performance of the block device is sufficient.

4. An acceleration terminal for a block device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor implements the following steps when executing the computer program: acquiring performance data of the block device in real time when the hard disk flushes dirty data to the block device, judging whether the performance of the block device is sufficient according to the performance data of the block device, increasing the block device rate if yes; otherwise, judging whether a garbage collection mechanism in the hard disk is recycling a large amount of data, exiting the step of flushing dirty data to the block device if yes, otherwise, decreasing the block device rate, and calculating the maximum flush rate of the block device in combination with a user IO rate in the hard disk and the block device rate; the step of calculating the maximum flush rate of the block device in combination with the user IO rate in the hard disk and the block device rate comprises: multiplying the user IO rate of the previous second by an estimated proportion to obtain a current user IO rate; calculating a maximum scrub rate v of the block device according to a current IO rate of the user and the block device rate max : v max = (v1-v2)*r; in the formula, v1 represents the block device rate, v2 represents the current user IO rate, and r represents a flush coefficient.

5. The acceleration terminal of a block device according to claim 4, wherein The step of judging whether the performance of the block device is sufficient according to the performance data of the block device comprises: the performance data of the block device comprises an IO delay time and a queue average depth; if the IO delay time exceeds 3 ms or the queue average depth is greater than or equal to 3, the step of flushing dirty data to the block device is exited.

6. The acceleration terminal of a block device according to claim 5, wherein The step of judging whether the performance of the block device is sufficient according to the performance data of the block device comprises: if the IO delay time exceeds 800 μs, it is determined that the performance of the block device is insufficient, otherwise, it is determined that the performance of the block device is sufficient.

Citation Information

Patent Citations

  • Method and device for brushing data, electronic equipment and storage medium

    CN114442935A