Garbage Collection Method, Device, Medium and Computer Equipment of a Storage Device
Through the dynamic priority scoring model and collaborative execution mechanism, the problems of insufficient bandwidth competition and block life management in the existing GC strategy are solved, the garbage collection efficiency and SSD hard disk service life are improved, and the write performance is optimized.
Patent Information
- Application Number
- CN202510737501.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-06-04
AI Technical Summary
Existing GC policies are mostly based on fixed thresholds or periodic triggers, causing GC operations to compete with host write commands for bandwidth, and the I/O throughput drops sharply in high-load scenarios, even lower than the host's minimum performance requirements, and GC tasks are not dynamically allocated in combination with block wear state, resulting in insufficient block life management.
Through the dynamic priority scoring model, the GC task priority is dynamically adjusted, bandwidth occupation is suppressed in high-load scenarios, bandwidth occupation is maximized in low-load scenarios, and GC processors are used to perform GC tasks together to optimize resource utilization.
It improves garbage collection efficiency by 15%-30%, extends the service life of SSD hard disk by 10%, reduces the delay increment to less than 5ms under high load, improves bandwidth occupancy by more than 20%, and ensures that the write performance is always higher than the minimum requirements of the host.
Smart Images

Figure CN120256328B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a garbage collection method, device, medium and computer device for a storage device, and belongs to the technical field of GC recovery methods for NandFlash. Background Art
[0002] Common storage media include various categories such as hard disk drives (HDDs), solid state drives (SSDs), USB flash drives, optical discs, etc. Among them, the core technologies of SSDs are Nand Flash and the main control chip. Nand Flash stores data through floating gate transistors, and compared with traditional HDDs, it has a significant improvement in random read and write speeds and outstanding physical properties (no mechanical components, strong earthquake resistance, low power consumption, no noise). The storage unit of Nand Flash is a floating gate transistor, and its physical characteristics determine the following limitations: Erasure must be performed before writing: The storage unit of Nand Flash can only change from 1 to 0, but the erasure operation will restore the entire block to the all-1 state. Therefore, if data needs to be updated on a page where data has already been written, the entire block needs to be erased first, and then the updated data needs to be rewritten. Minimum operation unit limitation: Writing is in units of pages (for example, 4KB), and erasure is in units of blocks (for example, 64 pages, a total of 256KB). If only 1 page of data needs to be modified, the valid data of the entire block needs to be migrated to a new block, and then the old block needs to be erased, which results in the inability to directly overwrite. Therefore, a large number of invalid data blocks will be generated in the storage module of Nand Flash with continuous write, delete and other operations. In order to reclaim the space occupied by these invalid data and improve storage utilization, garbage collection (GC) operations are required. When moving valid data to a new block, the storage space of the old block needs to be released again after erasing the old block. During the GC operation process, operations such as data migration and erasure are usually involved, and these operations will occupy certain system resources and storage bandwidth, resulting in a significant decrease in write performance. In some application scenarios with high requirements for write performance, such as real-time data recording, high-speed data transmission, etc., this decrease in write performance will seriously affect the overall performance of the system and lead to a decline in user experience.
[0003] Existing GC strategies are mostly triggered based on fixed thresholds (such as when the remaining space is insufficient) or periodically, resulting in competition for bandwidth between GC operations and host write commands, and a sharp drop in I / O throughput in high-load scenarios, even lower than the minimum performance requirements of the host. Summary of the Invention
[0004] Aiming at the deficiencies of the above-mentioned existing technologies, the purpose of the present invention is to provide a garbage collection method, device, medium and computer device for a storage device.
[0005] According to an embodiment of the present invention, a first solution is provided: a garbage collection method for a storage device, including the following steps:
[0006] Cache the write commands issued by the host and the GC operation commands triggered by the system through a cache executor;
[0007] Obtain the real-time bandwidth load of the I / O channel through a load monitoring module, obtain the real-time bandwidth occupancy rate (B_host) and total bandwidth (B_total) of the write command according to the real-time bandwidth load of the I / O channel, and count the invalid data ratio (R_invalid) and block wear ratio (W_ratio) of the data blocks to be recycled in the GC operation command through a flash memory management unit;
[0008] Evaluate the GC operation command through a dynamic priority scoring model according to the invalid data ratio (R_invalid) and block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupancy of the GC operation command in a high-load scenario, and maintain the maximum bandwidth occupancy of the GC operation command in a low-load scenario;
[0009] Calculate the parallel gap execution window and fragmented idle execution window available for the GC operation command according to the real-time bandwidth load of the I / O channel obtained by the load detection module;
[0010] Granularize the high-priority GC task into the smallest operation unit instructions, incorporate the granularized smallest operation unit instructions into the cached write command in the parallel gap execution window through a DMA controller to generate a first instruction, generate a second instruction for the low-priority GC task in the fragmented execution window through a background GC processor, and generate parallel instructions for the first instruction and the second instruction according to the execution order of the cached write command;
[0011] Send and execute the parallel instructions.
[0012] Further, the process of evaluating through the dynamic priority scoring model includes:
[0013] Calculate the invalid data ratio R_invalid of the data block to be recycled as: R_invalid = D_invalid / D_total, where D_invalid is the amount of invalid data in the data block to be recycled, and D_total is the total amount of data in the data block to be recycled;
[0014] Calculate the block wear ratio W_ratio of the data block to be recycled as: W_ratio = W_current / W_max, where W_current is the number of erasures of the current data block, and W_max is the maximum allowable number of erasures of the current data block;
[0015] The process of calculating the priority score by the dynamic priority scoring model includes:
[0016] S_GC = ω_1·R_invalid + ω_2·(1 - W_ratio), where ω_1 and ω_2 are the first weight coefficient and the second weight coefficient respectively;
[0017] When S_GC ≥ S_threshold, evaluate the GC operation command as a high-priority GC task; when S_GC < S_threshold, evaluate the GC operation command as a low-priority GC task, where S_threshold is the dynamic adjustment coefficient.
[0018] Further, the calculation steps of the dynamic adjustment coefficient S_threshold include:
[0019] Obtain the real-time bandwidth load of the I / O channel through the load monitoring module, and calculate the load coefficient for the real-time bandwidth load:
[0020] S_load = α·B_host / B_total + β·ΔT / T_safe + γ·L_GC / L_max, where B_host is the real-time bandwidth occupancy rate, B_total is the total bandwidth, ΔT is the delay increment of the I / O channel, T_safe is the delay safety threshold, L_GC is the queue length of the GC operation commands cached, L_max is the maximum capacity of the queue of the GC operation commands cached, α is the bandwidth calibration coefficient, β is the delay increment calibration coefficient, γ is the GC queue length calibration coefficient, and the three satisfy: α + β + γ = 1;
[0021] When the load coefficient S_load is lower than 0.5, define the real-time bandwidth load of the I / O channel as low load; when the load coefficient S_load is greater than or equal to 0.5, define the real-time bandwidth load of the I / O channel as medium-high load;
[0022] When the I / O channel is in medium-high load, S_threshold = S_base - κ·S_load; when the I / O channel is in low load, S_threshold = S_base, where S_base is the load base threshold and κ is the load sensitivity coefficient.
[0023] Further, the steps for suppressing the bandwidth occupancy of the GC operation command in a high-load scenario include:
[0024] The bandwidth occupancy rate B_GC1 of the high-priority GC task = δ · (B_total - B_host), where δ is the high-bandwidth suppression coefficient and 0 < δ ≤ 1.
[0025] Furthermore, the steps to maintain the maximum bandwidth occupancy of the GC operation command in a low-load scenario include:
[0026] The bandwidth occupancy rate B_GC2 of the low-priority GC task = ε · (B_total - B_host), where ε is 0.8.
[0027] Furthermore, the δ is dynamically adjusted according to the delay increment ΔT:
[0028] When ΔT ≤ T_safe, δ = 0.8; when ΔT > T_safe, δ = 0.3.
[0029] Furthermore, the δ is dynamically adjusted according to the delay increment ΔT and the throughput fluctuation σ:
[0030] When ΔT ≤ 10ms and σ < 5%, δ = 0.8;
[0031] When 10 < ΔT ≤ 20ms or 5% ≤ σ < 10%, δ = 0.5;
[0032] When ΔT > 20ms or σ > 10%, δ = 0.3.
[0033] According to the embodiments of the present invention, using the garbage collection method of the storage device in the first solution provided by the present invention, the second solution is provided as:
[0034] A garbage collection device for a storage device, comprising:
[0035] A cache module for caching the write commands issued by the host and the GC operation commands triggered by the system through a cache executor;
[0036] A load monitoring module for obtaining the real-time bandwidth load of the I / O channel, obtaining the real-time bandwidth occupancy rate (B_host) and the total bandwidth (B_total) of the write commands according to the real-time bandwidth load of the I / O channel, and statistically calculating the invalid data ratio (R_invalid) and the block wear ratio (W_ratio) of the data blocks to be recycled in the GC operation commands through a flash memory management unit;
[0037] The GC operation processing module is used to evaluate GC operation commands through a dynamic priority scoring model according to the invalid data ratio (R_invalid) and the block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupancy of GC operation commands in high-load scenarios, and maintain the maximum bandwidth occupancy of GC operation commands in low-load scenarios;
[0038] The time window calculation module is used to calculate the parallel gap execution window and the fragmented idle execution window available for GC operation commands based on the real-time bandwidth load of the I / O channel obtained by the load detection module;
[0039] The parallel instruction generation module is used to granulate high-priority GC tasks into the smallest operation unit instructions, incorporate the granulated smallest operation unit instructions into the write commands cached in the parallel gap execution window through the DMA controller to generate the first instruction, generate the second instruction for low-priority GC tasks in the fragmented execution window through the background GC processor, and generate parallel instructions for the first instruction and the second instruction according to the execution order of the write commands cached;
[0040] The parallel instruction execution module is used to send and execute the parallel instructions.
[0041] A computer device includes a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor performs the following steps:
[0042] Cache the write commands issued by the host and the GC operation commands triggered by the system through the cache executor;
[0043] Obtain the real-time bandwidth load of the I / O channel through the load monitoring module, obtain the write real-time bandwidth occupancy rate (B_host) and the total bandwidth (B_total) of the write commands according to the real-time bandwidth load of the I / O channel, and count the invalid data ratio (R_invalid) and the block wear ratio (W_ratio) of the data blocks to be recycled in the GC operation commands through the flash memory management unit;
[0044] Evaluate GC operation commands through a dynamic priority scoring model according to the invalid data ratio (R_invalid) and the block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupancy of GC operation commands in high-load scenarios, and maintain the maximum bandwidth occupancy of GC operation commands in low-load scenarios;
[0045] The real-time bandwidth load calculation of the I / O channel obtained by the load detection module can be used for the parallel gap execution window and the fragmented idle execution window of the GC operation command;
[0046] Granularize the high-priority GC tasks into the smallest operation unit instructions. Through the DMA controller, incorporate the granulated smallest operation unit instructions into the write command cached in the parallel gap execution window to generate the first instruction. Through the background GC processor, generate the second instruction for the low-priority GC tasks in the fragmented execution window. Generate parallel instructions for the first instruction and the second instruction according to the execution order of the cached write commands;
[0047] Send and execute the parallel instructions.
[0048] A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor is caused to perform the following steps:
[0049] Cache the write commands issued by the host and the GC operation commands triggered by the system through the cache executor;
[0050] Obtain the real-time bandwidth load of the I / O channel through the load monitoring module. Obtain the write real-time bandwidth occupancy rate (B_host) and the total bandwidth (B_total) of the write command according to the real-time bandwidth load of the I / O channel. Count the invalid data ratio (R_invalid) and the block wear ratio (W_ratio) of the data blocks to be recycled by the GC operation commands through the flash memory management unit;
[0051] Evaluate the GC operation commands through a dynamic priority scoring model according to the invalid data ratio (R_invalid) and the block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupancy of the GC operation commands in high-load scenarios, and maintain the maximum bandwidth occupancy of the GC operation commands in low-load scenarios;
[0052] The real-time bandwidth load calculation of the I / O channel obtained by the load detection module can be used for the parallel gap execution window and the fragmented idle execution window of the GC operation command;
[0053] Granularize the high-priority GC tasks into the smallest operation unit instructions. Through the DMA controller, incorporate the granulated smallest operation unit instructions into the write command cached in the parallel gap execution window to generate the first instruction. Through the background GC processor, generate the second instruction for the low-priority GC tasks in the fragmented execution window. Generate parallel instructions for the first instruction and the second instruction according to the execution order of the cached write commands;
[0054] Send and execute parallel instructions.
[0055] Compared with the prior art, the beneficial effects of the independent claim of the technical solution provided by this application are as follows:
[0056] 1. Evaluate the GC operation commands cached through a dynamic priority scoring model, integrate the proportion of invalid data and the proportion of block wear, scientifically quantify the urgency of GC operation tasks, and preferentially recycle blocks with high benefits or low wear. The so-called high benefits include GC operation tasks with a large amount of space released, effectively improving the space recovery efficiency by 15% - 30% and extending the service life of the SSD hard disk by more than 10%;
[0057] 2. Dynamically adjust the bandwidth occupancy of GC operation commands, suppress the bandwidth occupancy of GC operation commands in high-load scenarios, maximize the GC operation efficiency in low-load scenarios, and ensure that the write performance of write commands is always higher than the minimum requirements of the host;
[0058] 3. High-priority GC tasks perform single-page migration during the execution gap of write commands through the DMA controller, reducing the intervention of the main control chip and reducing the latency increase to within 5ms. Low-priority GC tasks are centrally processed by a dedicated GC processor in the idle execution window to avoid blocking the I / O channel, and the bandwidth occupancy rate is increased by more than 20% through the cooperative execution of software and hardware;
[0059] 4. Monitor and process the real-time bandwidth load of the I / O channel, and cooperatively adjust the execution quantity and bandwidth occupancy rate of high-priority GC tasks, taking into account the processing quantity of high-priority tasks and effectively limiting the high load of resource occupancy of GC tasks. Description of the Drawings
[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0061] Among them:
[0062] Figure 1 It is a flowchart of the garbage collection method of the storage device in an embodiment;
[0063] Figure 2 It is a structural block diagram of the garbage collection device of the storage device in an embodiment;
[0064] Figure 3 It is a structural block diagram of a computer device in an embodiment. Detailed Embodiments
[0065] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope protected by this application.
[0066] Embodiment 1
[0067] The technical problem solved by this embodiment is that existing GC strategies are mostly based on fixed thresholds (such as being triggered when the remaining space is insufficient) or periodic triggers, resulting in competition for bandwidth between GC operations and host write commands, and a sharp drop in I / O throughput in high-load scenarios, even below the minimum performance requirements of the host.
[0068] For example, the conflict between GC operations and write performance: Traditional GC trigger mechanisms (such as fixed thresholds, periodic triggers) cannot dynamically adjust the GC task priority according to the real-time load, resulting in excessive bandwidth occupation by GC at high loads and a sharp increase in write latency;
[0069] Low resource utilization efficiency: Centralized GC operations (such as whole-block migration) occupy continuous I / O channel time, exacerbating write performance fluctuations;
[0070] Insufficient block lifetime management: GC tasks are not dynamically allocated in combination with the block wear state, and frequent erasures of high-wear blocks may cause premature failures.
[0071] Therefore, this embodiment provides a garbage collection method for a storage device, including the steps of:
[0072] S101: Cache the write commands issued by the host and the GC operation commands triggered by the system through a cache executor;
[0073] Obtain the real-time bandwidth load of the I / O channel through a load monitoring module, obtain the real-time write bandwidth occupancy rate (B_host) and total bandwidth (B_total) of the write commands according to the real-time bandwidth load of the I / O channel, and statistically calculate the invalid data ratio (R_invalid) and block wear ratio (W_ratio) of the data blocks to be recycled in the GC operation commands through a flash memory management unit;
[0074] S102: Evaluate the GC operation commands through a dynamic priority scoring model according to the invalid data ratio (R_invalid) and the block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupancy of the GC operation commands in high-load scenarios, and maintain the maximum bandwidth occupancy of the GC operation commands in low-load scenarios;
[0075] S103: Calculate the parallel gap execution window and the fragmented idle execution window for the GC operation commands based on the real-time bandwidth load of the I / O channel obtained by the load detection module;
[0076] S104: Granularize the high-priority GC tasks into the smallest operation unit instructions. Incorporate the granularized smallest operation unit instructions into the write commands cached in the parallel gap execution window through the DMA controller to generate the first instruction. Generate the second instruction for the low-priority GC tasks in the fragmented execution window through the background GC processor. Generate parallel instructions for the first instruction and the second instruction according to the execution order of the cached write commands;
[0077] The working process of the DMA controller (Direct Memory Access Controller) includes: initialization, transfer start, and completion notification.
[0078] S105: Send and execute the parallel instructions.
[0079] Specifically, the process of evaluating through the dynamic priority scoring model includes: calculating the invalid data ratio R_invalid of the data blocks to be recycled as: R_invalid = D_invalid / D_total, where D_invalid is the amount of invalid data in the data blocks to be recycled, and D_total is the total amount of data in the data blocks to be recycled; calculating the block wear ratio W_ratio of the data blocks to be recycled as: W_ratio = W_current / W_max, where W_current is the number of erasure times of the current data block, and W_max is the maximum allowable number of erasure times of the current data block;
[0080] In the SSD calibration test, the flash management unit periodically scans the modules to be recycled, reads the valid page marks in the material block metadata, counts the amount of invalid data and the total amount of data, and updates the invalid pages by counting the L2P table update frequency, once every 10 ms. Record the number of erasure times of each block through the wear leveling controller, and combine it with the maximum number of erasure times provided by the manufacturer (such as 10,000 times).
[0081] The process of the dynamic priority scoring model calculating the priority score includes:
[0082] S_GC = ω_1·R_invalid + ω_2·(1 - W_ratio), where ω_1 and ω_2 are the first weight coefficient and the second weight coefficient respectively; when S_GC ≥ S_threshold, the GC operation command is evaluated as a high-priority GC task, and when S_GC < S_threshold, the GC operation command is evaluated as a low-priority GC task, where S_threshold is a dynamically adjustable coefficient.
[0083] For example, S_GC = 0.6·R_invalid + 0.4·(1 - W_ratio). Through SSD calibration tests, when R_invalid ≥ 0.5 and W_ratio < 0.3, combining the first weight coefficient of 0.6 and the second weight coefficient of 0.4 can increase the space recovery efficiency by 25%.
[0084] Preferably, the dynamically adjustable coefficient S_threshold is 0.7. When S_GC ≥ 0.7, it is marked as a high-priority GC task, and when S_GC < 0.7, it is marked as a low-priority GC task.
[0085] Specifically, the calculation steps of the dynamically adjustable coefficient S_threshold include: obtaining the real-time bandwidth load of the I / O channel through the load monitoring module, and calculating the load coefficient for the real-time bandwidth load:
[0086] S_load = α·B_host / B_total + β·ΔT / T_safe + γ·L_GC / L_max, where B_host is the real-time bandwidth occupancy rate, B_total is the total bandwidth, ΔT is the latency increment of the I / O channel, T_safe is the latency safety threshold, L_GC is the queue length of the cached GC operation commands, L_max is the maximum capacity of the queue of the cached GC operation commands, α is the bandwidth calibration coefficient, β is the latency increment calibration coefficient, γ is the GC queue length calibration coefficient, and the three satisfy: α + β + γ = 1;
[0087] When the load coefficient S_load is lower than 0.5, the real-time bandwidth load of the I / O channel is defined as low load, and when the load coefficient S_load is greater than or equal to 0.5, the real-time bandwidth load of the I / O channel is defined as medium-high load; when the I / O channel is in medium-high load, S_threshold = S_base - κ·S_load, and when the I / O channel is in low load, S_threshold = S_base, where S_base is the load base threshold and κ is the load sensitivity coefficient.
[0088] For example, S_load = 0.5·B_host / B_total + 0.3·ΔT / T_safe + 0.2·L_GC / L_max. In the SSD calibration experiment, when S_load ≥ 0.5, the real-time bandwidth load of the I / O channel is defined as medium-high load, and dynamic threshold adjustment is triggered. When S_load is less than 0.5, the real-time bandwidth load of the I / O channel is defined as low load.
[0089] Specifically, the steps to suppress the bandwidth occupancy of the GC operation command in the high-load scenario include: the bandwidth occupancy rate of the high-priority GC task B_GC1 = δ·(B_total - B_host), where δ is the high-bandwidth suppression coefficient, and 0 < δ ≤ 1.
[0090] The bandwidth suppression logic is that when the high-priority GC task is executing, if the real-time bandwidth load of the I / O channel is high load, the high-bandwidth suppression coefficient is very small. The high-load judgment basis usually includes the increase in the delay increment of the I / O channel. When it exceeds the safety threshold, the high-bandwidth suppression coefficient is adjusted downwards, so that although there are many high-priority GC tasks, the priority execution of the write command must also be ensured. The DMA controller seamlessly switches the write command and the high-priority GC task through the double-buffer mechanism, and the delay increment is controlled within 5 ms.
[0091] Specifically, the steps to maintain the maximum bandwidth occupancy of the GC operation command in the low-load scenario include: the bandwidth occupancy rate of the low-priority GC task B_GC2 = ε·(B_total - B_host), where ε is 0.8.
[0092] The bandwidth acceleration logic is that when the low-priority GC task is executing, if the real-time bandwidth load of the I / O channel is low load, the low-bandwidth suppression coefficient is increased. The low-load judgment basis usually includes the decrease in the delay increment of the I / O channel. The execution efficiency of the low-priority GC task is accelerated through the background GC task processor. For example, when it is detected that the real-time bandwidth occupancy rate B_host ≤ B_total, an asynchronous thread is started to erase the whole block (in units of 256 KB), and the real-time bandwidth utilization rate is increased from 60% to 80%, and there is no write performance fluctuation.
[0093] Specifically, the δ is dynamically adjusted according to the delay increment ΔT: when ΔT ≤ T_safe, δ = 0.8; when ΔT > T_safe, δ = 0.3.
[0094] When considering the throughput fluctuation, the δ is dynamically adjusted according to the delay increment ΔT and the throughput fluctuation σ: when ΔT ≤ 10 ms and σ < 5%, δ = 0.8; when 10 < ΔT ≤ 20 ms or 5% ≤ σ < 10%, δ = 0.5; when ΔT > 20 ms or σ > 10%, δ = 0.3.
[0095] 1. Evaluate the cached GC operation commands through a dynamic priority scoring model, integrating the proportion of invalid data and the block wear ratio, scientifically quantifying the urgency of GC operation tasks, and preferentially recycling high-yield or low-wear blocks. The so-called high yield includes GC operation tasks with a large amount of space released, effectively improving the space recovery efficiency by 15% - 30% and extending the service life of the SSD hard disk by more than 10%;
[0096] 2. Dynamically adjust the bandwidth occupation of GC operation commands, suppress the bandwidth occupation of GC operation commands in high-load scenarios, maximize the GC operation efficiency in low-load scenarios, and ensure that the writing performance of write commands is always higher than the minimum requirements of the host;
[0097] 3. High-priority GC tasks perform single-page migration during the execution gap of write commands through the DMA controller, reducing the intervention of the main control chip and reducing the latency increment to within 5 ms. Low-priority GC tasks are centrally processed by a dedicated GC processor in the idle execution window, avoiding blocking the I / O channel, and improving the bandwidth occupation rate by more than 20% through the collaborative execution of software and hardware;
[0098] 4. Monitor and process the real-time bandwidth load of the I / O channel, and coordinately adjust the execution quantity and bandwidth occupation rate of high-priority GC tasks, taking into account the processing quantity of high-priority tasks and effectively limiting the high load of resource occupation by GC tasks.
[0099] 5. In high-load scenarios, the bandwidth of GC tasks is limited to 0.04B_total, and the number of invalid blocks recycled per hour is increased by 30%. In low-load scenarios, the whole-block erasure speed is increased by 50%, and the standard deviation of block wear balance drops from 15% to 8%.
[0100] Embodiment 2
[0101] As Figure 2 shown, a garbage collection device for a storage device includes:
[0102] A cache module 100 for caching the write commands issued by the host and the GC operation commands triggered by the system through a cache executor;
[0103] A load monitoring module 200 for obtaining the real-time bandwidth load of the I / O channel, obtaining the real-time bandwidth occupation rate (B_host) and total bandwidth (B_total) of the write commands according to the real-time bandwidth load of the I / O channel, and statistically calculating the proportion of invalid data (R_invalid) and block wear ratio (W_ratio) of the data blocks to be recycled by the GC operation commands through the flash memory management unit;
[0104] The GC operation processing module 300 is configured to evaluate GC operation commands through a dynamic priority scoring model according to the invalid data ratio (R_invalid) and the block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupation of GC operation commands in high-load scenarios, and maintain the maximum bandwidth occupation of GC operation commands in low-load scenarios;
[0105] The time window calculation module 400 is configured to calculate a parallel gap execution window and a fragmented idle execution window available for GC operation commands based on the real-time bandwidth load of the I / O channel obtained by the load detection module;
[0106] The parallel instruction generation module 500 is configured to granulate high-priority GC tasks into the smallest operation unit instructions, incorporate the granulated smallest operation unit instructions into the write commands cached in the parallel gap execution window through the DMA controller to generate the first instruction, generate the second instruction for low-priority GC tasks in the fragmented execution window through the background GC processor, and generate parallel instructions from the first instruction and the second instruction according to the execution order of the cached write commands;
[0107] The parallel instruction execution module 600 is configured to send and execute the parallel instructions.
[0108] Embodiment 4
[0109] Figure 3 shows the internal structure diagram of a computer device in an embodiment. The computer device may specifically be a terminal or a server. As Figure 3 shown, the computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the garbage collection method of the storage device. The memory may also store a computer program. When the computer program is executed by the processor, the processor can execute the garbage collection method of the storage device. Those skilled in the art can understand that Figure 3 the structure shown in
[0110] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:
[0111] Cache the write commands issued by the host and the GC operation commands triggered by the system through a cache executor;
[0112] Obtain the real-time bandwidth load of the I / O channel through a load monitoring module, and obtain the real-time bandwidth occupancy rate (B_host) and total bandwidth (B_total) of the write commands according to the real-time bandwidth load of the I / O channel. Statistically calculate the invalid data ratio (R_invalid) and block wear ratio (W_ratio) of the data blocks to be recycled in the GC operation commands through a flash memory management unit;
[0113] Evaluate the GC operation commands through a dynamic priority scoring model according to the invalid data ratio (R_invalid) and block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupancy of the GC operation commands in high-load scenarios, and maintain the maximum bandwidth occupancy of the GC operation commands in low-load scenarios;
[0114] Calculate the parallel gap execution window and fragmented idle execution window available for the GC operation commands according to the real-time bandwidth load of the I / O channel obtained by the load detection module;
[0115] Granularize the high-priority GC tasks into the smallest operation unit instructions, incorporate the granularized smallest operation unit instructions into the cached write commands in the parallel gap execution window through a DMA controller to generate a first instruction, generate a second instruction for the low-priority GC tasks in the fragmented execution window through a background GC processor, and generate parallel instructions for the first instruction and the second instruction according to the execution order of the cached write commands;
[0116] Send and execute the parallel instructions.
[0117] In one embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the processor performs the following steps:
[0118] Cache the write commands issued by the host and the GC operation commands triggered by the system through a cache executor;
[0119] Obtain the real-time bandwidth load of the I / O channel through the load monitoring module, and obtain the real-time bandwidth occupancy rate (B_host) and total bandwidth (B_total) of the write command according to the real-time bandwidth load of the I / O channel. The flash management unit counts the invalid data ratio (R_invalid) and block wear ratio (W_ratio) of the data blocks to be recycled in the GC operation command;
[0120] Evaluate the GC operation command through the dynamic priority scoring model according to the invalid data ratio (R_invalid) and block wear ratio (W_ratio), and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, and suppress the bandwidth occupancy of the GC operation command in high-load scenarios and maintain the maximum bandwidth occupancy of the GC operation command in low-load scenarios;
[0121] Calculate the parallel gap execution window and fragmented idle execution window available for the GC operation command based on the real-time bandwidth load of the I / O channel obtained by the load detection module;
[0122] Granularize the high-priority GC task into the smallest operation unit instructions. The granularized smallest operation unit instructions are incorporated into the cached write command in the parallel gap execution window through the DMA controller to generate the first instruction. The low-priority GC task is generated into the second instruction in the fragmented execution window by the background GC processor. The first instruction and the second instruction are generated into parallel instructions according to the execution order of the cached write command;
[0123] Send and execute the parallel instructions.
[0124] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0125] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0126] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A garbage collection method for a storage device, characterized in that, It includes the following steps: Cache the write commands sent by the host and the GC operation commands triggered by the system through the cache executor; Obtain the real-time bandwidth load of the I / O channel through the load monitoring module, and obtain the real-time bandwidth occupancy rate B_host and the total bandwidth B_total of the write command according to the real-time bandwidth load of the I / O channel. The flash management unit counts the invalid data ratio R_invalid and the block wear ratio W_ratio of the data blocks to be recycled in the GC operation command; Evaluate the GC operation command through the dynamic priority scoring model according to the invalid data ratio R_invalid and the block wear ratio W_ratio, and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, and suppress the bandwidth occupancy of the GC operation command in high-load scenarios and maintain the maximum bandwidth occupancy of the GC operation command in low-load scenarios; Among them, the process of evaluating by the dynamic priority scoring model includes: Calculate the invalid data ratio R_invalid of the data blocks to be recycled as: R_invalid = D_invalid / D_total, where D_invalid is the amount of invalid data of the data blocks to be recycled, and D_total is the total amount of data of the data blocks to be recycled; Calculate the block wear ratio W_ratio of the data blocks to be recycled as: W_ratio = W_current / W_max, where W_current is the number of erase times of the current data block, and W_max is the maximum allowable number of erase times of the current data block; The process of calculating the priority score by the dynamic priority scoring model includes: S_GC = ω_1·R_invalid + ω_2·(1 - W_ratio), where ω_1 and ω_2 are the first weight coefficient and the second weight coefficient respectively; When S_GC ≥ S_threshold, evaluate the GC operation command as a high-priority GC task. When S_GC < S_threshold, evaluate the GC operation command as a low-priority GC task, where S_threshold is the dynamic adjustment coefficient; Calculate the parallel gap execution window and the fragmented idle execution window available for the GC operation command according to the real-time bandwidth load of the I / O channel obtained by the load detection module; The unit instruction granulates the high-priority GC task into the smallest operation unit instruction in the parallel gap, incorporates the granulated smallest operation execution window into the cached write command through the DMA controller to generate the first instruction, and generates the second instruction for the low-priority GC task in the fragmented execution window through the background GC processor, and generates parallel instructions for the first instruction and the second instruction according to the execution order of the cached write command; Send and execute the parallel instructions.
2. The garbage collection method of the storage device according to claim 1, wherein The calculation steps of the dynamic adjustment coefficient S_threshold include: Obtain the real-time bandwidth load of the I / O channel through the load monitoring module, and calculate the load coefficient for the real-time bandwidth load: $S\_load = \alpha \cdot B\_host / B\_total+\beta \cdot \Delta T / T\_safe+\gamma \cdot L\_GC / L\_max$, where $B\_host$ is the real-time bandwidth occupancy rate, $B\_total$ is the total bandwidth, $\Delta T$ is the latency increment of the I / O channel, $T\_safe$ is the latency safety threshold, $L\_GC$ is the queue length of the GC operation commands in the cache, $L\_max$ is the maximum queue capacity of the GC operation commands in the cache, $\alpha$ is the bandwidth calibration coefficient, $\beta$ is the latency increment calibration coefficient, $\gamma$ is the GC queue length calibration coefficient, and the three satisfy: $\alpha+\beta+\gamma = 1$; When the load factor $S\_load$ is lower than 0.5, the real-time bandwidth load of the I / O channel is defined as low load, and when the load factor $S\_load$ is greater than or equal to 0.5, the real-time bandwidth load of the I / O channel is defined as medium-high load; When the I / O channel is in medium-high load, $S\_threshold = S\_base-\kappa \cdot S\_load$, and when the I / O channel is in low load, $S\_threshold = S\_base$, where $S\_base$ is the load base threshold and $\kappa$ is the load sensitivity coefficient.
3. The garbage collection method of the storage device according to claim 2, wherein The steps to suppress the bandwidth occupancy of GC operation commands in high-load scenarios include: The bandwidth occupancy rate $B\_GC1$ of high-priority GC tasks is $B\_GC1=\delta \cdot (B\_total - B\_host)$, where $\delta$ is the high-bandwidth suppression coefficient and $0\lt\delta\leq1$.
4. The garbage collection method of the storage device according to claim 3, wherein The steps to maintain the maximum bandwidth occupancy of GC operation commands in low-load scenarios include: The bandwidth occupancy rate $B\_GC2$ of low-priority GC tasks is $B\_GC2=\varepsilon \cdot (B\_total - B\_host)$, where $\varepsilon$ is 0.
8.
5. The garbage collection method of the storage device according to claim 4, characterized in that, The $\delta$ is dynamically adjusted according to the latency increment $\Delta T$: When $\Delta T\leq T\_safe$, $\delta = 0.8$, and when $\Delta T\gt T\_safe$, $\delta = 0.3$.
6. The garbage collection method of the storage device according to claim 3, wherein The $\delta$ is dynamically adjusted according to the latency increment $\Delta T$ and the throughput fluctuation $\sigma$: When $\Delta T\leq10ms$ and $\sigma\lt5\%$, $\delta = 0.8$; When $10ms\lt\Delta T\leq20ms$ or $5\%\leq\sigma\lt10\%$, $\delta = 0.5$; When $\Delta T\gt20ms$ or $\sigma\gt10\%$, $\delta = 0.3$.
7. A garbage collection device for a storage device, characterized in that, including: A cache module for caching the write commands sent by the host and the GC operation commands triggered by the system through a cache executor; A load monitoring module for obtaining the real-time bandwidth load of the I / O channel, obtaining the write real-time bandwidth occupancy rate $B\_host$ and the total bandwidth $B\_total$ of the write commands according to the real-time bandwidth load of the I / O channel, and statistically calculating the invalid data ratio $R\_invalid$ and the block wear ratio $W\_ratio$ of the data blocks to be recycled of the GC operation commands through a flash memory management unit; The GC operation processing module is used to evaluate the GC operation command through a dynamic priority scoring model according to the invalid data ratio R_invalid and the block wear ratio W_ratio, and output high-priority GC tasks and low-priority GC tasks. The dynamic adjustment coefficient of the dynamic priority scoring model can adjust the number of high-priority GC tasks, suppress the bandwidth occupancy of the GC operation command in high-load scenarios, and maintain the maximum bandwidth occupancy of the GC operation command in low-load scenarios. Among them, the process of evaluating by the dynamic priority scoring model includes: Calculate the invalid data ratio R_invalid of the data block to be recycled as: R_invalid = D_invalid / D_total, where D_invalid is the amount of invalid data of the data block to be recycled, and D_total is the total amount of data of the data block to be recycled; Calculate the block wear ratio W_ratio of the data block to be recycled as: W_ratio = W_current / W_max, where W_current is the number of erasure times of the current data block, and W_max is the maximum allowable number of erasure times of the current data block; The process of the dynamic priority scoring model calculating the priority score includes: S_GC = ω_1·R_invalid + ω_2·(1 - W_ratio), where ω_1 and ω_2 are the first weight coefficient and the second weight coefficient respectively; When S_GC ≥ S_threshold, evaluate the GC operation command as a high-priority GC task. When S_GC < S_threshold, evaluate the GC operation command as a low-priority GC task, where S_threshold is the dynamic adjustment coefficient; The time window calculation module is used to calculate the parallel gap execution window and the fragmented idle execution window available for the GC operation command through the real-time bandwidth load of the I / O channel obtained by the load detection module; The parallel instruction generation module is used to granulate the high-priority GC task into the smallest operation unit instructions, incorporate the granulated smallest operation unit instructions into the write command cached in the parallel gap execution window through the DMA controller and generate the first instruction, generate the second instruction for the low-priority GC task in the fragmented execution window through the background GC processor, and generate parallel instructions for the first instruction and the second instruction according to the execution order of the write command cached; The parallel instruction execution module is used to send and execute the parallel instructions.
8. A computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the processor is caused to execute the steps of the method according to any one of claims 1 to 6.
9. A computer device includes a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor is caused to execute the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for reading flash memory data
CN117215503A
Method and device for realizing garbage collection, computer storage medium and terminal
CN117806985A