A memory control method, a storage device, a medium and a computer device
By implementing a real-time monitoring and dynamic adjustment mechanism for garbage collection intensity, the problem of FGGC scheduling strategy being unable to perceive load status has been solved, achieving stable performance and reliability of NAND flash memory under complex loads, and avoiding user-perceptible latency fluctuations and the risk of system crashes.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-25
- Publication Date
- 2026-03-27
AI Technical Summary
In existing technologies, the forward garbage collection (FGGC) scheduling strategy of NAND flash memory cannot perceive the real-time load status, resulting in severe resource contention, affecting system performance and user experience, and lacking performance quantification guarantee mechanisms and risk avoidance for system availability in emergency situations.
By monitoring host write time and the number of free blocks in real time, the garbage collection intensity is dynamically adjusted. Combined with feedforward and feedback factors to form a composite adjustment mechanism, the FGGC resource allocation is precisely controlled to ensure the system's stable performance and availability under complex loads.
Ensuring a baseline performance under complex loads, smoothing performance fluctuations, reducing user-perceptible latency volatility, improving system robustness and reliability, and avoiding the risk of system crashes.
Smart Images

Figure CN121411709B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of storage control, and in particular to a memory control method, a storage device, a medium and a computer device. BACKGROUND
[0002] NAND Flash is a kind of non-volatile storage medium. Due to its physical characteristics, it cannot directly overwrite data, and needs to recycle invalid data blocks through garbage collection (GC) to release free space. The core implementation steps of GC are to select a source block containing valid or invalid data (Source Block), to migrate valid data to a new target block, to erase the source block and mark it as a free block (Free Block). In the GC process, time-consuming operations such as data migration and erasing operations will occupy the resources of NAND channel bandwidth and host controller, seriously affecting the overall performance of the system and user experience.
[0003] As a key mode of garbage collection, foreground garbage collection (FGGC) needs to be executed synchronously in the context of processing host write commands, directly competing for resources with host write, and in serious cases, causing user-perceptible lag. The core reason for this problem is that the traditional FGGC scheduling strategy relies on static time slice allocation or fixed threshold triggering, which cannot perceive the real-time load state and cannot be associated with performance targets. At the same time, the traditional FGGC scheduling strategy also lacks a quantitative guarantee mechanism for performance targets and an emergency system availability risk avoidance scheme.
[0004] Therefore, the existing technology has the fundamental defects of static scheduling mechanism rigidity, performance quantization deficiency and emergency processing scheme blank, and cannot meet the needs of high-performance storage devices for low latency, high reliability and performance stability, and there is an urgent need for a new control scheme to realize precise scheduling of FGGC resources and system availability guarantee. SUMMARY
[0005] Based on the above, the embodiments of the present application provide a memory control method, a storage device, a medium and a computer device, to solve the problems of the existing technology that have the fundamental defects of static scheduling mechanism rigidity, performance quantization deficiency and emergency processing scheme blank, and cannot meet the needs of high-performance storage devices for low latency, high reliability and performance stability.
[0006] According to a first aspect, the embodiments of the present application provide a memory control method, which comprises:
[0007] The host write time without garbage collection is monitored in real time, the maximum allowed time for a single I / O cycle is obtained based on the worst-case performance requirement preset by the system and the data length of a single write, the dynamic time budget allocable to foreground garbage collection is calculated by comparing the host write time with the maximum allowed time, and the theoretical optimal garbage collection intensity coefficient is obtained based on the ratio of the dynamic time budget to the estimated maximum garbage collection time.
[0008] The host write queue depth is monitored in real time to adjust the feedforward factor, and the number of free blocks is monitored in real time to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection.
[0009] The current implemented garbage collection intensity is calculated according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, and the time slice resources of foreground garbage collection are allocated based on the current implemented garbage collection intensity to control the execution intensity of garbage collection.
[0010] In combination with the first aspect, in a first implementation manner of the first aspect, the step of monitoring the host write time without garbage collection in real time comprises:
[0011] The I / O request is intercepted in the write command processing program of the measurement component embedded in the flash translation layer, and the raw time of each host write command from reception to completion is recorded by a timer;
[0012] The N continuous raw times are subjected to sliding window average filtering to obtain a stable host write time without garbage collection, and the host write time is transmitted to the decision controller.
[0013] In combination with the first aspect and the first implementation manner, in a second implementation manner of the first aspect, the step of calculating the dynamic time budget comprises:
[0014] The worst-case performance requirement preset by the system and the data length of a single write are obtained, wherein the worst-case performance requirement preset by the system is the minimum write performance threshold that the storage device must guarantee, and the data length of a single write is the data amount of a single host write command;
[0015] The worst-case time is calculated as the ratio of the data length of a single write to the worst-case performance requirement;
[0016] The write execution time without garbage collection is measured in real time by a timer embedded in the write command processing program of the flash translation layer;
[0017] The dynamic time budget is the difference between the worst-case time and the write execution time, and the dynamic time budget reflects the current remaining performance capacity of the system.
[0018] With reference to the second implementation of the first aspect, in a third implementation of the first aspect, the step of measuring the write execution time without garbage collection comprises:
[0019] Recording the original time consumption of each write I / O from start to end;
[0020] Sliding window average filtering is performed on at least a plurality of continuously measured original time consumption values to eliminate operation fluctuation noise and obtain an average value as the write execution time without garbage collection.
[0021] With reference to the first aspect, in a fourth implementation of the first aspect, the step of calculating the theoretical optimal garbage collection intensity coefficient comprises:
[0022] Calculating the maximum garbage collection time according to the garbage collection block candidate list of the storage device;
[0023] The theoretical execution intensity coefficient is the ratio of the dynamic time budget to the maximum garbage collection time, and the execution intensity coefficient is clamped between [0, 1], wherein the theoretical execution intensity coefficient of 0 indicates stopping executing garbage collection, and the theoretical execution intensity coefficient of 1 indicates maximum intensity executing garbage collection.
[0024] With reference to the fourth implementation of the first aspect, in a fifth implementation of the first aspect, the step of calculating the maximum garbage collection time comprises:
[0025] Maintaining the garbage collection block candidate list through a state monitor to obtain the valid page number and physical distribution of the candidate block;
[0026] Obtaining the page programming time and page read time of the NAND flash memory as timing parameters, the maximum parallel channel number of the controller, and calculating the total data migration time of a single block;
[0027] Determining a parallel factor according to the controller parallel processing;
[0028] The maximum garbage collection time is the ratio of the total data migration time of a single block to the parallel factor.
[0029] With reference to the fifth implementation of the first aspect, in a sixth implementation of the first aspect, the step of calculating the total data migration time of a single block comprises:
[0030] Reading the page programming time and page read time from the NAND flash memory chip data sheet;
[0031] The total data migration time of a single block = valid page number × (page programming time + page read time), and the total data migration time of a single block covers the total time consumption of valid data read and programming.
[0032] With reference to the first aspect, in a seventh implementation of the first aspect, the step of adjusting the currently implemented garbage collection intensity comprises:
[0033] The feed-forward factor is based on the host write queue depth and anticipates load mutations, and the feedback factor is based on free block data and balances space reclamation and performance;
[0034] The current implemented garbage collection strength is the final execution strength coefficient , .
[0035] In combination with the seventh implementation of the first aspect, in the eighth implementation of the first aspect, the feed-forward factor obtaining step comprises:
[0036] Adjusting according to the host write queue depth lookup table:
[0037] When the queue depth < 32, the feed-forward factor = 1.0, and the feed-forward factor = 1.0 indicates normal load, maintaining the garbage collection strength;
[0038] When the queue depth ≥ 32, the feed-forward factor ≤ 0.5, and the feed-forward factor = ≤ 0.5 indicates burst load, and the garbage collection is inhibited in advance to avoid performance cliff.
[0039] In combination with the seventh implementation of the first aspect, in the ninth implementation of the first aspect, the feedback factor obtaining step comprises:
[0040] Adjusting according to the current free block quantity of the storage device lookup table:
[0041] When the free block quantity > 5% of the total block quantity, the feedback factor ≤ 0.8, and the feedback factor ≤ 0.8 indicates that the garbage collection is inhibited to prioritize performance;
[0042] When 3% of the total block quantity ≤ the free block quantity ≤ 5% of the total block quantity, the feedback factor = 1.0, and the feedback factor = 1.0 indicates the baseline garbage collection state;
[0043] When 2% of the total block quantity ≤ the free block quantity < 3% of the total block quantity, the feedback factor ≥ 1.3, and the feedback factor ≥ 1.3 indicates that the garbage collection strength is enhanced to prevent space shortage;
[0044] When the free block quantity < 2% of the total block quantity, the feedback factor ≥ 1.5, and the feedback factor ≥ 1.5 indicates the maximum garbage collection strength;
[0045] The current implemented garbage collection strength is the final execution strength , Clamped between [0, 1], wherein the theoretical execution strength coefficient of 0 indicates stopping executing garbage collection, and the theoretical execution strength coefficient of 1 indicates maximum strength executing garbage collection.
[0046] In combination with the first aspect, in the tenth implementation of the first aspect, the method further comprises a hierarchical processing step:
[0047] When the number of free blocks falls below a preset threshold, which is 2% of the total number of blocks, trigger forced garbage collection and throttle host write, the throttling step includes reporting busy status to the host, or increasing the host write delay, wherein the delay time is based on dynamic time budget adjustment, if the dynamic time budget is negative, the delay time is the absolute value of the negative value to compensate for the performance gap, if the dynamic time budget is non-negative, the delay time takes 30ms as the base value;
[0048] When the dynamic time budget is negative, trigger the suspension of foreground garbage collection operations to protect host write.
[0049] In combination with the first aspect, in an eleventh implementation manner of the first aspect, the method further includes a service degradation step:
[0050] When the measured write performance continuously falls below the worst-case performance requirement preset by the system for 100ms, trigger the service degradation mode;
[0051] Report performance degradation warning to the host;
[0052] Lower the worst-case performance requirement preset by the system by 20% to maintain the basic availability of the system.
[0053] In combination with the first aspect, in a twelfth implementation manner of the first aspect, the step of allocating time slice resources of foreground garbage collection based on the currently implemented garbage collection intensity includes implementing control cycle scheduling through a token bucket mechanism:
[0054] Divide the control cycle into multiple time slices of equal length s;
[0055] Token generation period = time slice length / final execution intensity coefficient, that is, the larger the final execution intensity coefficient, the smaller the token generation period, and the faster the token generation;
[0056] The token bucket capacity is set to 2 to allow temporary garbage collection bursts to avoid frequent start-stop.
[0057] In combination with the first aspect, in a thirteenth implementation manner of the first aspect, the method further includes a wear leveling step:
[0058] When the difference between the maximum P / E cycle and the average P / E cycle of the blocks exceeds 500 times, trigger the wear leveling task;
[0059] When selecting a block for recycling, if the effective page proportion of the candidate blocks differs by ≤5%, select the block with a higher P / E cycle;
[0060] The total background task intensity of the system is set to a reference value of 1.0 to ensure that foreground garbage collection has priority.
[0061] In combination with the first aspect, in a fourteenth implementation form of the first aspect, the method further comprises a thermal management optimization step:
[0062] establishing a thermal management strategy lookup table to map the storage device temperature to a system preset worst-case required performance;
[0063] when T < 70℃, the system preset worst-case required performance is 800MB / s;
[0064] when 70≤T<80℃, the system preset worst-case required performance is 600MB / s;
[0065] when T≥80℃, the system preset worst-case required performance is 400MB / s;
[0066] dynamically adjusting the system preset worst-case required performance according to the temperature to achieve thermal balance between performance and power consumption.
[0067] According to the second aspect, the embodiments of the present application further provide a storage device for applying the memory control method of any one of the first aspect, the storage device comprising:
[0068] a theoretical coefficient calculation module, configured to monitor a host write time consumption in real time when there is no garbage collection, obtain a maximum allowed time consumption of a single I / O cycle based on a system preset worst-case required performance and a single write data length, calculate a dynamic time budget allocatable to foreground garbage collection by the host write time consumption and the maximum allowed time consumption, and obtain a theoretically optimal garbage collection intensity coefficient based on a ratio of the dynamic time budget to an estimated maximum garbage collection time consumption;
[0069] an adjustment parameter calculation module, configured to monitor a host write queue depth in real time to adjust a feedforward factor, and monitor a number of idle blocks in real time to adjust a feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of idle blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection;
[0070] a current coefficient calculation module, configured to calculate a currently implemented garbage collection intensity according to a product of the theoretically optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, and allocate time slice resources of the foreground garbage collection based on the currently implemented garbage collection intensity to control an execution intensity of the garbage collection.
[0071] According to the third aspect, the embodiments of the present application further provide a computer readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the memory control method of any one of the above.
[0072] According to a fourth aspect, the embodiments of the present application further provide an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the steps of the memory control method according to any one of the above aspects when executing the program.
[0073] The memory control method, the storage device, the medium and the computer device provided by the present application can convert the system performance target into an executable resource control method through the quantitative mechanism of dynamic time budget, combine the real-time load to adaptively adjust the resource occupation of foreground garbage collection, avoid the performance fluctuation problem caused by the traditional static scheduling, and make the system still meet the preset worst demand performance stably under a complex write scenario.
[0074] The complex adjustment method of the fast prediction and feedback is formed by foreseeing the host write load mutation through the feedforward factor and balancing the space recovery demand through the feedback factor, so that the FGGC strength can not only inhibit the resource competition during the load peak, but also can preferentially guarantee the recovery efficiency when the space is tight, the robustness of the system to the dynamic load is improved, and the performance bottom line is guaranteed, the performance jitter is smoothed, and the risk of hanging is eliminated under the complex load.
[0075] The dynamic coupling of the complex factor formed by the theoretically optimal garbage collection strength coefficient and the feedforward factor and the feedback factor is realized for the first time in the industry, and the garbage collection resource allocation is changed from experience-driven to data-driven, the invalid resource occupation and excessive intervention are reduced, the storage life is guaranteed, and the user-perceived write delay fluctuation is significantly reduced.
[0076] The time slice resource of the foreground garbage collection is allocated through the currently implemented garbage collection strength to control the execution strength of the garbage collection, the performance degradation of the NAND medium is adaptively adjusted, the reliable performance commitment is maintained, and the data integrity task such as read interference management is seamlessly integrated into the unified dynamic resource scheduling framework, the active protection of the high-risk data is realized on the premise of not significantly affecting the host experience, and the reliability of the product at the end of life is improved. BRIEF DESCRIPTION OF DRAWINGS
[0077] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0078] Figure 1 One of the flowcharts of the memory control method provided by the present application is shown;
[0079] Figure 2Fig. 2 shows a flowchart of a memory control method according to an embodiment of the present application;
[0080] Figure 3 Fig. 3 shows a flowchart of a memory control method according to an embodiment of the present application;
[0081] Figure 4 Fig. 4 shows a flowchart of a memory control method according to an embodiment of the present application;
[0082] Figure 5 Fig. 5 shows a structure diagram of a memory device according to an embodiment of the present application;
[0083] Figure 6 Fig. 6 shows a hardware structure diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0084] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0085] First, the various professional terms appearing in the embodiments will be explained:
[0086] Garbage Collection (GC): refers to a flash memory management mechanism that acquires available free blocks by recycling blocks containing invalid data. GC can be divided into Foreground Garbage Collection (FGGC) and Background GC (BGGC).
[0087] FGGC: refers to a GC operation that is executed synchronously in the context of processing host write commands. FGGC directly increases the delay of host write commands.
[0088] BGGC: refers to a GC operation that is executed asynchronously when the system is idle or under low load, with minimal impact on host performance.
[0089] Worst Needed Performance: refers to the minimum write performance threshold that the system must guarantee, such as 400 MB / s. Below this value, the user experience or system function will be severely affected.
[0090] I / O Latency: refers to the delay of an input / output operation such as a read or write command, which is the time experienced from the host issuing an IO command to receiving the command completion response.
[0091] Write I / O: refers to the time required for a NAND flash to execute a write command without GC interference.
[0092] I / O Length: refers to the I / O data length (I / O Length), which is the amount of data required to be transmitted for a single write command, usually in units of KB or MB, such as 1 MB.
[0093] Execution Time: refers to the core time required to program LENwr data to the NAND flash without GC.
[0094] Theoretical Max Performance: refers to the peak write performance that can be achieved in an ideal state without GC and other overheads, specifically: .
[0095] Burdended Write I / O: refers to a write command that is executed while the host is writing, with FGGC operations interspersed.
[0096] GCTime: refers to the total time spent on garbage collection-related operations (such as valid data relocation) during the processing of a single host write command.
[0097] Burdended Performance: refers to the actual write performance when FGGC occurs, specifically: .
[0098] Worst Case Time: refers to the maximum allowed time for a single I / O to achieve the worst-case demand performance , specifically: , for example .
[0099] GCAggressiveness: refers to the garbage collection aggressiveness , which is a variable between 0 and 1 that dynamically adjusts the strength of GC, : means to stop GC completely, and the corresponding : means to perform GC with the maximum aggressiveness.
[0100] : refers to the theoretically optimal garbage collection aggressiveness, which is calculated according to the current state of the system (free block number, data distribution, etc.), and can meet the performance requirements and GC progress requirements at the same time.
[0101] Write Amplification: refers to the ratio of the actual amount of data written to the flash memory to the amount of data written by the user (host), which is a key indicator of storage efficiency. In theory, the smaller the value of Write Amplification, the better.
[0102] Dynamic Time Scheduling (DTS): refers to a scheduling strategy that dynamically allocates different task execution time slices according to the real-time load and state of the system.
[0103] Flash Translation Layer (FTL): refers to the firmware layer between the host and the flash memory medium. FTL is responsible for core functions such as address mapping, bad block management, and garbage collection.
[0104] Free Block: refers to a physical block that can accept written data.
[0105] Source Block: refers to a physical block that is selected for recycling during the GC process and contains valid and invalid data.
[0106] NAND Flash is a non-volatile storage medium widely used in Secure Digital (SD) cards, embedded MultiMediaCards (eMMC), Universal Flash Storage (UFS), Solid State Drives (SSD), and other storage products. Due to the physical characteristics of NAND Flash, data is not directly overwritten when updating data, but is written to a new physical address.
[0107] In a storage system, as data is continuously written, deleted, and the like, a large amount of invalid data blocks will be generated in the storage medium. In order to improve the storage utilization, the invalid data blocks need to be recycled by GC to release free space. The core implementation step of GC is to select a source block containing valid or invalid data, migrate the valid data to a new target block, erase the source block and mark it as a free block. In the GC process, time-consuming operations such as data migration and erasure operations will be involved. These operations will occupy the NAND channel bandwidth and the resources of the host controller, thereby causing a significant decline in write performance. In some application scenarios with high requirements for write performance, such as real-time data recording, high-speed data transmission, etc., the decline in write performance will seriously affect the overall performance of the system and the user experience.
[0108] As a key mode of GC, FGGC needs to be executed synchronously in the context of processing host write commands. FGGC competes with host writes for limited NAND flash channel bandwidth and controller computing resources, directly competing with host writes for resources, and in severe cases, can cause user-perceptible lag.
[0109] Traditional FGGC scheduling strategies mostly use static time slices or fixed threshold triggers, which cannot perceive real-time write load and performance targets. At the same time, there is also a lack of mechanism to quantify the worst-case write performance as an upper limit on resources, and there is a risk of system hanging due to free block depletion during write flood, thereby posing a risk to system availability in emergency situations. Traditional FGGC scheduling strategies are difficult to continuously guarantee the minimum performance requirements of the system under the complex and variable workloads of mobile terminals, stringent power dissipation requirements, and changes in NAND physical properties.
[0110] For example, although some FGGC scheduling strategies use closed-loop control to adjust the GC rate, they rely on negative loop feedback (such as the difference in the number of free blocks) and lack a feedforward mechanism (which cannot foresee write load mutations). Another part of the FGGC scheduling strategy schedules GC tasks through priority scoring, but does not introduce a time budget model, which cannot quantify performance targets. Another part of the FGGC scheduling strategy adjusts the migration strategy based on multiple factors, but its optimization goal is data protection rather than minimum write performance guarantee, and there is no emergency degradation mechanism.
[0111] In summary, the existing technology has fundamental defects such as rigid static scheduling mechanism, lack of performance quantification, and blank emergency handling scheme, which cannot meet the needs of low latency, high reliability, and smooth performance of high-performance storage devices such as SD, eMMC, UFS, and SSD. A new control scheme is needed to realize precise scheduling of FGGC resources and guarantee system availability.
[0112] Due to the aforementioned technical problems, this invention provides a memory control method that quantifies the abstract performance target of worst-case performance requirements into a time budget for a single I / O cycle. By introducing a combined feedforward and feedback control mechanism, it achieves precise and adaptive adjustment of garbage collection intensity, thereby ensuring a performance floor, smoothing performance fluctuations, and eliminating the risk of system crashes under complex loads. This memory control method can be used in electronic devices, including but not limited to computers and mobile terminals. Figure 1 This is a flowchart illustrating a memory control method according to an embodiment of the present invention, as shown below. Figure 1 As shown, the method may include the following steps:
[0113] S101. Real-time monitoring of host write time without GC, based on the system's preset worst-case performance requirements. and the length of data written in a single operation Obtain the maximum allowed time for a single write cycle, and calculate the dynamic time budget that can be allocated to FGGC by comparing the host write time with the maximum allowed time. Based on dynamic time budget Compared with the estimated maximum waste recycling time The ratio is used to obtain the theoretical optimal waste recycling coefficient. .
[0114] In this embodiment of the invention, the worst-case performance requirement will be... This abstract performance target is quantified into a time budget for a single I / O cycle, that is, the maximum allowable time for a single I / O cycle is quantified. Then, based on the host write time without GC obtained from real-time monitoring and the maximum allowable time, the precise time resources that can be allocated to FGGC operations within each I / O cycle are precisely quantified, i.e., the dynamic time budget. Therefore, dynamic time budgeting It dynamically reflects the current remaining performance capacity of the system.
[0115] More specifically, the host write time during periods without GC can be monitored in real time using the following methods:
[0116] I / O requests are intercepted in the write command handler (WriteCommandHandler) embedded in the measurement component of the FTL. The raw time taken from receiving to completing each host I / O command is recorded by a timer. Then, a sliding window averaging filter (window size = 16) is performed on the N continuously collected raw time data to eliminate the operation fluctuations of the NAND itself, so as to obtain a stable host write time without garbage collection. This host write time is then transmitted to the decision controller.
[0117] The measurement component can be embedded in the processing path of the write command handler, such as the Write_Command_Handler function of FTL, to intercept I / O requests.
[0118] In this embodiment of the invention, the timer uses a high-precision calculator with an accuracy higher than 1 μs.
[0119] In this embodiment of the invention, a dynamic time budget dynamically reflects the current remaining performance capacity of the system. The calculation steps are as follows:
[0120] S201. Obtain the system's preset worst-case performance requirements. and the length of data written in a single operation Among them, the worst performance requirement The unit is MB / s, which represents the length of data written in a single operation. The unit is MB.
[0121] S202, Calculate the worst-case time. Length of data written in a single operation With worst-case performance requirements The ratio. Specifically, the worst-case time. The formula for calculation is:
[0122]
[0123] S203. The write execution time without GC is measured in real time by a timer embedded in the write command handler of the FTL. .
[0124] In this embodiment of the invention, the timer measures the write execution time in real time when there is no garbage collection (GC) in the following manner. :
[0125] Record the raw time of each write I / O from start to finish. Perform a sliding window average filter on the raw time values of at least a preset number (e.g., 16) of consecutive measurements to eliminate NAND operation fluctuation noise and obtain the average value as the write execution time without GC. .
[0126] S204, Dynamic Time Budgeting Worst-case time With write execution time The difference. Specifically, dynamic time budget. The formula for calculation is:
[0127]
[0128] In this embodiment of the invention, the theoretically optimal waste recycling efficiency coefficient The calculation step of the maximum garbage collection time is:
[0129] S301, calculating the maximum garbage collection time according to the victim block candidate table of the storage device The maximum garbage collection time is not a fixed value, and the calculation of the value needs to be based on the victim block candidate table maintained by the state monitor.
[0130] S302, calculating the theoretical execution intensity coefficient The theoretical execution intensity coefficient is the ratio of the dynamic time budget to the maximum garbage collection time , and the execution intensity coefficient is clamped between [0, 1]. Wherein, the theoretical execution intensity coefficient 0 indicates stopping executing GC, and correspondingly, the theoretical execution intensity coefficient 1 indicates executing GC with the maximum intensity. Specifically, the calculation formula of the theoretical best garbage collection intensity coefficient
[0131]
[0132] More specifically, the calculation step of the maximum garbage collection time is:
[0133] S401, maintaining the victim block candidate table through the state monitor, obtaining the number of valid pages and the physical distribution of the candidate block, that is, comprehensively considering the number of valid pages and the physical distribution (across Die / Plane) in the victim block candidate table.
[0134] S402, obtaining the page programming time (for example, 365μs) and the page read time (for example, 40μs) of the NAND flash memory as timing parameters, the maximum parallel channel number of the controller, and calculating the total data migration time of a single block.
[0135] The calculation step of the total data migration time of a single block is:
[0136] The page programming time and the page read time are read from the NAND flash memory chip data manual, and correspondingly, the total data migration time of a single block = the number of valid pages × (the page programming time + the page read time).
[0137] It should be noted that the total data migration time of a single block covers the total time consumption of valid data reading and programming.
[0138] S403, determining the parallel factor according to the controller parallel processing, and the parallel factor is determined based on the actual situation of the controller architecture and the NAND Plane, and the maximum garbage collection time The ratio of the total time of the monolithic data migration to the parallel factor.
[0139] S102, real-time monitoring of the host write queue depth to adjust the feedforward factor, real-time monitoring of the number of free blocks to adjust the feedback factor, the feedforward factor is used to predict load mutation, and the feedback factor is used to balance space recycling and performance.
[0140] In the embodiment of the application, when the write queue depth exceeds the preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than the second threshold, the feedback factor is increased to enhance garbage collection.
[0141] In the embodiment of the application, the feedforward factor is based on the use of a mutation factor , the mutation factor can be used for predictive smoothing.
[0142] The acquisition method of the feedforward factor will be introduced below in combination with Table 1:
[0143] Table 1 Control strategy of feedforward factor value
[0144]
[0145] As can be seen, the feedforward factor will be adjusted according to the host write queue depth (QueueDepth) table:
[0146] When the queue depth is less than 32, the value of the load mutation factor is set to 1, that is , , which is the reference state, and the queue depth less than 32 indicates that the current load is normal, to maintain the intensity of garbage collection; when the queue depth is greater than or equal to 32, the value of the load mutation factor is set to not more than 0.5, that is, the feedforward factor , F lord ≤0.5, and the queue depth greater than or equal to 32 indicates that the current load is a burst load, and by setting the value of the feedforward factor to not more than 0.5, the GC can be predictively suppressed in advance, and the bandwidth can be reserved in advance for the write flood to avoid performance cliff.
[0147] It should be noted that when the write queue depth is greater than or equal to 32, the higher the depth of the write queue depth, the lower the value of the feedforward factor can be set.
[0148] In the embodiment of the application, the feedback factor is based on a space water level factor , and the space water level factor can be used to prioritize space safety.
[0149] The feedback factor acquisition method is introduced below in combination with Table 2: A network switch batch deployment method, device, equipment and medium are disclosed, relating to the technical field of communication, the method comprising: using the master device to send the user's broadcast configuration control message to the network; using the master device to obtain the first unicast configuration control message returned by the slave device; compiling the configuration file of each slave device; generating the second unicast configuration control message corresponding to the slave device according to the configuration file, and using the master device to synchronously send the second unicast configuration control message to the network. The present application deeply integrates the advantages of zero-contact configuration and centralized management, and can realize zero-environment dependence and support incremental configuration of network switch software configuration, greatly improving the batch deployment efficiency of network switch.
[0150] Table 2 Control strategy of feedback factor value
[0151]
[0152] It can be seen that the feedback factor is adjusted according to the current free block number of the storage device, and the specific strategy is to improve the GC intensity when the space is tight, so as to prioritize space safety:
[0153] When the number of free blocks is greater than 5% of the total number of blocks (high water level), the value of the space water level factor is set to not more than 0.8, that is , , which indicates that the GC is actively inhibited to prioritize performance; when the number of free blocks is between 3% and 5% of the total number of blocks (normal water level), the value of the space water level factor is set to 1, that is , , which indicates the baseline state, that is, the baseline GC state; when the number of free blocks is between 2% and 3% of the total number of blocks (warning water level), the value of the space water level factor is set to more than 1.3 (not more than 1.5), that is , , which indicates that the garbage collection intensity is increased to prevent space shortage; when the number of free blocks is less than 2% of the total number of blocks (emergency water level), the value of the space water level factor is set to more than 1.5, that is , , which indicates the maximum garbage collection intensity.
[0154] In the embodiment of the present application, a fixed, lower priority background task can be periodically run (for example, every 100 ms) to scan all blocks, count the number of current free blocks, and evaluate the health status of all blocks: record P / ECycle, read the bit error rate (Bit Error Rate, BER). According to the preset strategy (such as the lowest priority of the effective page ratio), a recycling block candidate list is generated and maintained. In this way, the number of free blocks, the recycling block candidate list and other information can be obtained.
[0155] S103, according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, the current implemented garbage collection intensity is calculated, and the time slice resource of FGGC is allocated based on the current implemented garbage collection intensity to control the execution intensity of GC.
[0156] In this step, the specific values of the feedforward factor and the feedback factor are first determined based on the above table lookup adjustment method, and then the final execution intensity coefficient is calculated according to the theoretical execution intensity coefficient , the feedforward factor and the feedback factor , and the calculated final execution intensity coefficient is taken as the current implemented garbage collection intensity coefficient, that is:
[0157]
[0158] In the embodiment of the present application, the final execution intensity coefficient is calculated by comprehensively considering the theoretical execution intensity coefficient , the feedforward factor and the feedback factor, and the feedforward control and the feedback control are combined to form a composite control of fast prediction and feedback. In this way, the GC intensity can be finely and adaptively adjusted and controlled.
[0159] The memory control method of the present application converts the system performance target into an executable resource control method through the quantitative mechanism of dynamic time budget, combines the real-time load to adaptively adjust the resource occupation of foreground garbage collection, avoids the performance fluctuation problem caused by traditional static scheduling, and makes the system still meet the preset worst demand performance under complex write scenarios;
[0160] The feedforward factor predicts the host write load mutation, and the feedback factor balances the space recycling demand to form a composite adjustment method of fast prediction and feedback. The FGGC intensity can not only suppress resource competition during load peaks, but also can prioritize recycling efficiency when space is tight, improve the robustness of the system to dynamic load, and thus guarantee the performance bottom line, smooth performance jitter and eliminate the risk of hanging under complex load;
[0161] By dynamically coupling the theoretically optimal garbage collection intensity coefficient with the composite factor formed by the aforementioned feedforward and feedback factors, we have taken the lead in the industry to realize the transformation of garbage collection resource allocation from experience-driven to data-driven, reducing ineffective resource occupation and excessive intervention, and significantly reducing user-perceptible write latency fluctuations while ensuring storage lifespan.
[0162] By allocating time slice resources for future garbage collection based on the current garbage collection intensity, the execution intensity of garbage collection is controlled, adapting to the performance degradation of NAND media and maintaining reliable performance commitments. At the same time, data integrity tasks such as read interference management are seamlessly integrated into a unified dynamic resource scheduling framework. This achieves proactive protection of high-risk data without significantly affecting the host experience, thereby improving the reliability of the product at the end of its life.
[0163] In this embodiment of the invention, the method may further include the following steps:
[0164] S104. When the number of free blocks falls below a preset threshold, forced garbage collection is triggered and host writes are throttled. The throttling steps include reporting a busy (BUSY) state to the host or increasing the host write latency. The preset threshold is 2% of the total number of blocks, which means the free block level has fallen below the emergency threshold.
[0165] In this embodiment of the invention, when the number of free blocks falls below a preset threshold, a forced garbage collection (GC) is first triggered, i.e., a forced reset. The device throttling is applied to host writes, at which point it reports a busy state to the host or adds a command latency of, for example, 10-50ms. By triggering forced garbage collection and write throttling, system crashes due to space exhaustion can be completely avoided at the cost of short-term high latency.
[0166] To ensure that forced intervention and write throttling are carried out correctly, when the number of free blocks falls below the preset threshold, a comprehensive judgment should be made based on whether regular GC can alleviate the free block water level.
[0167] More specifically, the delay time is based on a dynamic time budget. Adjustments, such as dynamic time budgets The absolute value of the negative delay time is used to compensate for performance gaps, if dynamic time budget is used. The value is non-negative, and the delay time is taken as 30ms as the base value.
[0168] S105, When dynamic time budget When the value is negative, the FGGC operation is paused to ensure host writes, and a more conservative write execution time is used in the next control cycle. Recalculate dynamic time budget .
[0169] When the calculated write execution time deviates from the actual value by a large margin, the corresponding dynamic time budget may be a negative value, in the embodiment of the present application, when such an abnormal situation occurs, the FGGC operation is paused, i.e., forced to be stopped, so as to ensure the completion of the current write operation.
[0170] The more conservative write execution time mentioned above can be the write execution time calculated in the last control period multiplied by a preset penalty factor, for example, the penalty factor is set as a constant greater than 1 (e.g., 1.5).
[0171] Preferably, a multi-dimensional lookup table can be established, taking [temperature range, P / E cycle range, read disturbance level] as indexes, to store the write execution time scaling factor under different conditions, so as to predict the NAND performance degradation and make the calculation result of the dynamic time budget more consistent with the actual chip capability.
[0172] Through the setting of steps S104 and S105, hierarchical processing is performed to realize hierarchical availability guarantee.
[0173] In the embodiment of the present application, the method can further include the following steps:
[0174] S106, when the measured burden performance continuously remains lower than the worst demand performance preset by the system for a continuous preset time, a degraded service mode is triggered.
[0175] In the embodiment of the present application, the condition for triggering the degraded service mode can also be that the measured burden performance continuously remains lower than the preset proportion (e.g., 90%) of the worst demand performance preset by the system for a continuous preset time.
[0176] In the degraded service mode, a performance degradation warning is reported to the host, and the worst demand performance
[0177] preset by the system is lowered by 20% to maintain the basic availability of the system, for example, from the original 400MB / s to 320MB / s.
[0178] Through the setting of the degraded service mode, the basic functions and responses of the system can be maintained when the hardware capability is limited.
[0179] In view of scheduling I / O tasks in a high-reliability and performance-stable manner, please refer to Figure 2 The method can further include the following steps:
[0180] S501, real-time monitoring of host write time consumption when there is no garbage collection, obtaining the maximum allowed time consumption of a single I / O cycle based on the worst-case performance requirement preset by the system and the length of a single write data, calculating the dynamic time budget that can be allocated to foreground garbage collection by the host write time consumption and the maximum allowed time consumption, and obtaining the theoretical optimal garbage collection intensity coefficient based on the ratio of the dynamic time budget to the estimated maximum garbage collection time consumption. For specific content, please refer to Figure 1 The step S101 is shown.
[0181] S502, real-time monitoring of host write queue depth to adjust the feedforward factor, and real-time monitoring of the number of free blocks to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection. For specific content, please refer to Figure 1 The step S102 is shown.
[0182] S503, calculating the current implemented garbage collection intensity according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, and distributing the time slice resources of foreground garbage collection based on the current implemented garbage collection intensity to control the execution intensity of garbage collection. For specific content, please refer to Figure 1 The step S103 is shown.
[0183] S504, scheduling of the control period is realized through the Token Bucket Mechanism, specifically: dividing the control period into time slices of a preset time slice length, so that a control period can be divided into tiny time slices (Time Slice); the token generation period = the length of the time slice / the final execution intensity coefficient, the larger the final execution intensity coefficient, the smaller the token generation period, and the faster the token generation, so that a certain number of tokens can be added to the bucket at a preset rate; the token bucket capacity is set to 2 to allow short garbage collection bursts to avoid frequent start-stop.
[0184] When a new I / O task needs to be executed, it must obtain a (or multiple) token from the bucket. If there is a token in the bucket: the / O task successfully obtains the token and is immediately executed or scheduled for execution, which ensures that the average rate of task execution does not exceed the rate of token generation; otherwise, if there is no token in the bucket: the task cannot be executed immediately and is delayed, queued or directly discarded. This plays a role in flow control and shaping. Since the control period is divided into time slices of a preset time slice length, and the token bucket mechanism is used to manage the sending speed of new I / O tasks smoothly and controllably in a fixed time interval, both the long-term average speed and the short-term traffic burst are guaranteed. Through the precise scheduling of FGGC time slice resources by the token bucket mechanism, the mixed I / O task scheduling can be guaranteed in the worst case delay. This precise scheduling method can not only be used for FGGC of UFS devices, but also be applied to the scheduling of other high-performance storage devices such as SD, eMMC, SSD, etc., to meet the needs of these devices for low delay, high reliability and smooth performance.
[0185] In the embodiment of the application, by optimizing the scheduling mode, sufficient free blocks are released in time without affecting the user's write experience when triggering FGGC. At the same time, the device has the ability to handle emergency write-in peaks, that is, when the capacity of new data writing exceeds the total amount of the free block pool (FreePool) instantaneously, it still has the ability to handle such emergency situations.
[0186] In the embodiment of the application, the specific duration of the preset time slice length can be set by the user, for example, the preset time slice length is set to 50μs.
[0187] In order to avoid excessive wear and tear of the blocks and maximize the service life, while not squeezing the resources required by FGGC, thereby ensuring the instant response speed of user operations, please refer to Figure 3 The method can further include the following steps:
[0188] S601, real-time monitoring of host write time consumption when there is no garbage collection, obtaining the maximum allowed time consumption of a single I / O cycle based on the worst-case performance requirement and the length of a single write data of the system, calculating the dynamic time budget that can be allocated to foreground garbage collection by the host write time consumption and the maximum allowed time consumption, and obtaining a theoretical best garbage collection intensity coefficient based on the ratio of the dynamic time budget to the estimated maximum garbage collection time consumption. For specific content, please refer to Figure 1 The step S101 is shown.
[0189] S602, real-time monitoring of host write queue depth to adjust the feedforward factor, real-time monitoring of the number of free blocks to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection. For details, please refer to Figure 1 as described in step S102.
[0190] S603, calculating the current implemented garbage collection intensity according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, and distributing time slice resources for prospective garbage collection based on the current implemented garbage collection intensity to control the execution intensity of garbage collection. For details, please refer to Figure 1 as described in step S103.
[0191] S604, triggering a wear leveling (WL) task when the difference between the maximum P / E cycle of a block and the average P / E cycle exceeds 500 times, and more specifically: when selecting a block for recovery, if the effective page proportion of the candidate blocks differs by ≤5%, the block with a higher P / E cycle is selected; the total background task intensity of the system is set to a reference value of 1.0 to ensure that FGGC has priority, and such a setting will not squeeze the resources required by FGGC, thereby ensuring the instant response speed of user operations.
[0192] Through the setting of wear leveling, the FGGC process completes the wear leveling task on the premise of ensuring performance, thereby maximizing the service life, and at the same time, the system will not be constantly doing wear leveling, but will be triggered according to the judgment that the difference between the maximum P / E cycle of a block and the average P / E cycle exceeds 500 times, so that unnecessary operations can be avoided when wear is very uniform, system resources and power consumption are saved, and performance is ensured.
[0193] Unlike the traditional FGGC scheduling strategy of selecting the block with the least valid pages for recovery, in the embodiment of the present application, a batch of candidate blocks with low valid page proportions are first screened. Then, among these candidate blocks, if their valid page proportions are very close (the difference is less than 5%), the cost difference of migrating these blocks is minimal. At this time, instead of simply pursuing the minimum migration amount, the block with a higher P / E cycle, i.e., a higher wear degree, is selected for recovery, so that a block with a high wear degree is recovered, and then new data is written to other blocks with a lower wear degree, so that wear leveling is achieved more evenly and at a lower cost, thereby making the wear degree of all blocks consistent, and achieving deep synergy with the source block.
[0194] In the embodiment of the present application, a read access count is maintained for each block, and when a source block is selected, (effective page ratio x read count) is taken as a comprehensive index, and blocks with high indexes are preferentially reclaimed, so that data with high read interference risk can be migrated in advance while the conventional GC is performed, and the data integrity is improved.
[0195] Referring to Figure 4 The method can further include the following steps:
[0196] S701, real-time monitoring of host write time consumption when there is no garbage collection, obtaining the maximum allowed time consumption of a single I / O cycle based on the worst demand performance preset by the system and the length of single write data, calculating the dynamic time budget that can be allocated to foreground garbage collection by the host write time consumption and the maximum allowed time consumption, and obtaining the theoretical optimal garbage collection intensity coefficient based on the ratio of the dynamic time budget to the estimated maximum garbage collection time consumption. For specific content, please refer to Figure 1 The step S101 is shown.
[0197] S702, real-time monitoring of host write queue depth to adjust the feedforward factor, and real-time monitoring of the number of free blocks to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection. For specific content, please refer to Figure 1 The step S102 is shown.
[0198] S703, calculating the garbage collection intensity currently implemented according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, and distributing the time slice resources of foreground garbage collection based on the garbage collection intensity currently implemented to control the execution intensity of garbage collection. For specific content, please refer to Figure 1 The step S103 is shown.
[0199] S704, establishing a thermal management strategy lookup table, and mapping the storage device temperature to the worst demand performance preset by the system, for example:
[0200] When T<70℃, it indicates that the internal state of the device is normal, and the worst demand performance preset by the system is 800MB / s;
[0201] When 70≤T<80℃, it indicates that the internal state of the device may be performance frequency reduction, and the worst demand performance preset by the system is 600MB / s;
[0202] When T≥80℃, it indicates that the internal state of the device may be a high temperature state, and the worst demand performance preset by the system is 400MB / s;
[0203] In this way, thermal management optimization can be performed, that is, the worst demand performance preset by the system is dynamically adjusted according to the temperature to achieve thermal balance of performance and power consumption.
[0204] The storage device provided by the embodiment of the present application is described below, and the storage device described below can be referred to in combination with the memory control method described above.
[0205] In view of the above technical problems, the storage device provided by the embodiment of the present application quantifies the abstract performance target of the worst-case performance into the time budget of a single I / O cycle, introduces a feedforward and feedback compound control mechanism, and realizes accurate and adaptive adjustment of the garbage collection strength, thereby guaranteeing the performance bottom line, smoothing the performance jitter, and eliminating the risk of hanging under complex loads. Figure 5 The structure diagram of the memory control method according to the embodiment of the present application is shown in FIG. 1, and the device can include: Figure 5
[0206] The theoretical coefficient calculation module 10 is configured to monitor the host write time consumption in real time when there is no garbage collection, obtain the maximum allowed time consumption of a single I / O cycle based on the worst-case performance and the single write data length preset by the system, calculate the dynamic time budget that can be allocated to foreground garbage collection by the host write time consumption and the maximum allowed time consumption, and obtain the theoretical optimal garbage collection strength coefficient based on the ratio of the dynamic time budget to the estimated maximum garbage collection time consumption.
[0207] In the embodiment of the present application, the abstract performance target of the worst-case performance is quantified into the time budget of a single I / O cycle, that is, the maximum allowed time consumption of a single I / O cycle is quantified, and then the host write time consumption obtained in real time when there is no GC and the maximum allowed time consumption are accurately quantified into the accurate time resource that can be allocated to the FGGC operation in each I / O cycle, that is, the dynamic time budget, so the dynamic time budget dynamically reflects the current remaining performance capacity of the system.
[0208] The adjustment parameter calculation module 20 is configured to monitor the host write queue depth in real time to adjust the feedforward factor, and monitor the number of idle blocks in real time to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of idle blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection.
[0209] In the embodiment of the present application, when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of idle blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection.
[0210] The current coefficient calculation module 30 is configured to calculate the currently implemented garbage collection strength according to the product of the theoretical optimal garbage collection strength coefficient, the feedforward factor, and the feedback factor, and allocate the time slice resource of foreground garbage collection based on the currently implemented garbage collection strength to control the execution strength of garbage collection.
[0211] The module first determines the specific values of the feedforward factor and the feedback factor based on the above-mentioned table lookup adjustment mode, and then calculates the final execution intensity coefficient according to the theoretical execution intensity coefficient, the feedforward factor and the feedback factor, and takes the calculated final execution intensity coefficient as the currently implemented garbage collection intensity coefficient.
[0212] In the embodiment of the application, the parameters of the three dimensions of the theoretical execution intensity coefficient, the feedforward factor and the feedback factor are comprehensively considered in the calculation process of the final execution intensity coefficient, and the feedforward control and the feedback control are intersected to form a composite control of rapid prediction and feedback, and through such a way, the GC intensity can be finely and adaptively adjusted and controlled.
[0213] The storage device of the application converts the system performance target into an executable resource control method through the quantitative mechanism of dynamic time budget, combines the real-time load to adaptively adjust the resource occupation of foreground garbage collection, avoids the performance fluctuation problem caused by traditional static scheduling, and enables the system to still stably meet the preset worst demand performance under complex write scenarios;
[0214] Through the feedforward factor to predict the host write load mutation, and combining the feedback factor to balance the space recovery demand, a composite adjustment method of rapid prediction and feedback is formed, so that the FGGC intensity can not only inhibit resource competition during load peaks, but also can prioritize recovery efficiency when space is tight, improve the robustness of the system to dynamic load, and thus guarantee the performance bottom line, smooth performance jitter and eliminate the risk of hanging under complex load;
[0215] Through the dynamic coupling of the composite factor formed by the theoretical optimal garbage collection intensity coefficient and the above-mentioned feedforward factor and feedback factor, the garbage collection resource allocation is first changed from experience-driven to data-driven in the industry, reducing invalid resource occupation and excessive intervention, while ensuring storage life, significantly reducing user-perceptible write delay fluctuations;
[0216] The time slice resources of foreground garbage collection are allocated by the currently implemented garbage collection intensity to control the execution intensity of garbage collection, adapt to the performance degradation of NAND media, maintain a trusted performance commitment, and at the same time, seamlessly integrate data integrity tasks such as read interference management into a unified dynamic resource scheduling framework, without significantly affecting the host experience, actively protecting high-risk data, and improving the reliability of the product at the end of life.
[0217] Figure 6 An example of a schematic diagram of the physical structure of an electronic device is shown in FIG. 1. Figure 6As shown, the electronic device can include a processor 610, a communications interface 620, a memory 630, and a communications bus 640, wherein the processor 610, the communications interface 620, and the memory 630 complete mutual communication through the communications bus 640. The processor 610 can invoke a logic command in the memory 630 to execute a memory control method, the method comprising:
[0218] Real-time monitoring of host write time consumption when there is no garbage collection, obtaining the maximum allowed time consumption of a single I / O cycle based on the worst-case performance requirement preset by the system and the length of a single write data, calculating the dynamic time budget that can be allocated to foreground garbage collection through the host write time consumption and the maximum allowed time consumption, obtaining the theoretical optimal garbage collection intensity coefficient based on the ratio of the dynamic time budget to the estimated maximum garbage collection time consumption;
[0219] Real-time monitoring of the host write queue depth to adjust the feedforward factor, and real-time monitoring of the number of free blocks to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection;
[0220] Calculating the current implemented garbage collection intensity according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor, and the feedback factor, and distributing the time slice resources of foreground garbage collection based on the current implemented garbage collection intensity to control the execution intensity of garbage collection.
[0221] In addition, the logic instructions in the memory 630 described above can be implemented in the form of a software function unit and sold or used as an independent product, which can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0222] In another aspect, the present application also provides a computer program product, which comprises a computer program, the computer program being stored in a non-transitory computer readable storage medium, and the computer program being executable by a processor to enable a computer to perform the memory control method provided by any of the above methods, and the method comprises:
[0223] The host write time consumption when there is no garbage collection is monitored in real time, the maximum allowed time consumption of a single I / O cycle is obtained based on the worst-case performance and the length of single write data preset by the system, the dynamic time budget that can be allocated to foreground garbage collection is calculated by the host write time consumption and the maximum allowed time consumption, and the theoretical optimal garbage collection intensity coefficient is obtained based on the ratio of the dynamic time budget to the estimated maximum garbage collection time consumption;
[0224] The write queue depth of the host is monitored in real time to adjust the feedforward factor, and the number of free blocks is monitored in real time to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection;
[0225] The currently implemented garbage collection intensity is calculated according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, and the time slice resource of foreground garbage collection is allocated based on the currently implemented garbage collection intensity to control the execution intensity of garbage collection.
[0226] In another aspect, the present application also provides a non-transitory computer readable storage medium, which stores a computer program, and the computer program is executable by a processor to implement the memory control method provided by any of the above methods, and the method comprises:
[0227] The host write time consumption when there is no garbage collection is monitored in real time, the maximum allowed time consumption of a single I / O cycle is obtained based on the worst-case performance and the length of single write data preset by the system, the dynamic time budget that can be allocated to foreground garbage collection is calculated by the host write time consumption and the maximum allowed time consumption, and the theoretical optimal garbage collection intensity coefficient is obtained based on the ratio of the dynamic time budget to the estimated maximum garbage collection time consumption;
[0228] The write queue depth of the host is monitored in real time to adjust the feedforward factor, and the number of free blocks is monitored in real time to adjust the feedback factor, wherein when the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection;
[0229] The currently implemented garbage collection intensity is calculated according to the product of the theoretical optimal garbage collection intensity coefficient, the feedforward factor and the feedback factor, and the time slice resource of foreground garbage collection is allocated based on the currently implemented garbage collection intensity to control the execution intensity of garbage collection.
[0230] Those skilled in the art can clearly understand the implementation of the embodiments by means of software and necessary general hardware platforms through the description of the above embodiments, and of course, the embodiments can also be implemented by hardware. Based on such understanding, the above technical solutions can be embodied in the form of a software product, and the computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments.
[0231] Finally, it should be noted that: the above examples are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing examples, or make equivalent replacement for some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A memory control method applied to a memory device, characterized in that, The method includes: Real-time monitoring of host write time when there is no garbage collection; obtaining the maximum allowable time for a single I / O cycle based on the worst-case performance requirement and the length of data written in a single instance; calculating the dynamic time budget that can be allocated to prospective garbage collection by comparing the host write time with the maximum allowable time; obtaining the theoretically optimal garbage collection intensity coefficient based on the ratio of the dynamic time budget to the estimated maximum garbage collection time. The host write queue depth is monitored in real time to adjust the feedforward factor, and the number of free blocks is monitored in real time to adjust the feedback factor. When the write queue depth exceeds a preset first threshold, the feedforward factor is reduced to suppress garbage collection, and when the number of free blocks is less than a second threshold, the feedback factor is increased to enhance garbage collection. The current waste recycling intensity is calculated based on the product of the theoretical optimal waste recycling intensity coefficient, the feedforward factor, and the feedback factor. Time slice resources for future waste recycling are allocated based on the current waste recycling intensity to control the execution intensity of waste recycling. The steps for calculating the theoretically optimal garbage collection intensity coefficient include: calculating the maximum garbage collection time based on the candidate list of garbage collection blocks in the storage device; and calculating the theoretical execution intensity coefficient A. opt It is the ratio of dynamic time budget to maximum waste collection time, and the execution intensity coefficient is clamped between [0,1]. The steps for calculating the maximum garbage collection time include: maintaining a candidate list of garbage collection blocks through a status monitor, obtaining the number of valid pages and their physical distribution in the candidate blocks; obtaining the page programming time and page read time of the NAND flash memory as timing parameters, the maximum number of parallel channels of the controller, and calculating the total data migration time for a single block; and determining the parallel factor based on the parallel processing of the controller. The maximum garbage collection time is the ratio of the total time for migrating a single data block to the parallelism factor; The current steps for adjusting the intensity of garbage collection include: calculating a feedforward factor and a feedback factor. The feedforward factor is based on the host write queue depth and anticipates load fluctuations, while the feedback factor is based on free block data and balances space reclamation with performance. The current waste recycling efforts represent the final implementation intensity coefficient. , .
2. The memory control method according to claim 1, characterized in that, The steps for real-time monitoring of host write time during periods without garbage collection include: I / O requests are intercepted in the write command handler of the measurement component embedded in the flash conversion layer, and the original time taken from receiving to completing each host write command is recorded by a timer; A sliding window averaging filter is applied to the N continuously collected raw timeouts to obtain a stable host write timeout without garbage collection, and this host write timeout is then transmitted to the decision controller.
3. The memory control method according to claim 2, characterized in that: The calculation steps for dynamic time budgeting include: Obtain the system's preset worst-case performance and single write data length. The system's preset worst-case performance is the minimum write performance threshold that the storage device must guarantee, and the single write data length is the amount of data in a single host write command. The worst-case time is calculated as the ratio of the length of data written in a single operation to the worst-case performance requirement. Write execution time without garbage collection is measured in real time by a timer embedded in the write command handler of the flash conversion layer; The dynamic time budget is the difference between the worst-case time and the write execution time, reflecting the system's current remaining performance capacity.
4. The memory control method according to claim 3, characterized in that: The steps for measuring the write execution time without garbage collection include: Record the raw time taken for each write I / O operation from start to finish; A sliding window averaging filter is applied to at least a plurality of continuously measured raw time values to eliminate operational fluctuation noise and obtain an average value as the write execution time without garbage collection.
5. The memory control method according to claim 1, characterized in that: The step of calculating the theoretically optimal waste recycling intensity coefficient further includes: wherein a theoretical execution intensity coefficient of 0 indicates that waste recycling is stopped, and a theoretical execution intensity coefficient of 1 indicates that waste recycling is executed at the maximum intensity.
6. The memory control method according to claim 1, characterized in that: The calculation steps for the total migration time of a single data block include: Read page programming time and page read time from the NAND flash memory chip datasheet; The total time for single-block data migration = number of valid pages × (page programming time + page read time). The total time for single-block data migration includes the total time spent on valid data reading and programming.
7. The memory control method according to claim 1, characterized in that: The steps for obtaining the feedforward factor include: Adjustments based on host write queue depth: When the queue depth is less than 32, the feedforward factor is 1.
0. A feedforward factor of 1.0 indicates normal load and maintains the intensity of garbage collection. When the queue depth is ≥32, the feedforward factor is ≤0.
5. A feedforward factor of ≤0.5 indicates a sudden load and suggests that garbage collection should be suppressed in advance to avoid a performance precipitate.
8. The memory control method according to claim 1, characterized in that: The steps for obtaining feedback factors include: Adjust based on the current number of free blocks in the storage device: The number of free blocks is greater than 5% of the total number of blocks, and the feedback factor is ≤0.
8. A feedback factor ≤0.8 indicates that garbage collection is suppressed in order to prioritize performance. If 3% of the total number of blocks is less than or equal to 5% of the total number of blocks, the feedback factor is 1.
0. A feedback factor of 1.0 indicates the baseline garbage collection status. If 2% of the total number of blocks is less than or equal to 3% of the total number of blocks, the feedback factor is greater than or equal to 1.
3. A feedback factor greater than or equal to 1.3 indicates that efforts to improve waste recycling are being made to prevent insufficient space. The number of free blocks is less than 2% of the total number of blocks, and the feedback factor is greater than or equal to 1.
5. A feedback factor greater than or equal to 1.5 indicates the maximum garbage collection intensity. The current waste recycling efforts represent the final implementation intensity. ,Will The clamp is between [0,1], where a theoretical execution strength coefficient of 0 indicates that garbage collection is stopped, and a theoretical execution strength coefficient of 1 indicates that garbage collection is executed at the maximum intensity.
9. The memory control method according to claim 1, characterized in that, The method further includes a hierarchical processing step: When the number of free blocks falls below a preset threshold, which is 2% of the total number of blocks, forced garbage collection is triggered and host writes are throttled. The throttling steps include reporting a busy state to the host or increasing the host write latency. The latency is adjusted based on a dynamic time budget. If the dynamic time budget is negative, the absolute value of the negative latency is used to compensate for the performance gap. If the dynamic time budget is non-negative, the latency is taken as a base value of 30ms. When the dynamic time budget is negative, the foreground garbage collection operation is paused to ensure host writes.
10. The memory control method according to claim 1, characterized in that, The method also includes a service degradation step: When the measured write performance is consistently lower than the system's preset worst-case performance within 100ms, the service degradation mode is triggered. Report performance degradation warnings to the host computer; The worst-case performance requirement preset by the system will be reduced by 20% to maintain basic system availability.
11. The memory control method according to claim 1, characterized in that, The steps for allocating time slices for prospective waste collection based on the current waste collection intensity include scheduling the control cycle through a token bucket mechanism: The control cycle is divided into multiple time slices of equal length; The token generation cycle = time slice length / final execution strength coefficient. That is, the larger the final execution strength coefficient, the shorter the token generation cycle, and the faster the token is generated. The token bucket capacity is set to 2 to allow short garbage collection bursts to avoid frequent start-stop cycles.
12. The memory control method according to claim 1, characterized in that, The method also includes a wear equalization step: When the difference between the maximum P / E cycle and the average P / E cycle of a block exceeds 500 times, the wear leveling task is triggered. When selecting reclaimed blocks, if the difference in the effective page ratio of candidate blocks is ≤5%, the block with the higher P / E cycle is selected; The overall background task intensity of the system is set to a baseline value of 1.0 to ensure that forward garbage collection is given priority.
13. The memory control method according to claim 1, characterized in that, The method also includes a thermal management optimization step: Establish a thermal management strategy lookup table to map the storage device temperature to the system's preset worst-case performance requirements; When T < 70℃, the system's preset worst-case performance requirement is 800MB / s; When 70≤T<80℃, the system's preset worst-case performance requirement is 600MB / s; When T≥80℃, the system's preset worst-case performance requirement is 400MB / s; The system dynamically adjusts its preset worst-case performance based on temperature to achieve a thermal balance between performance and power consumption.
14. A storage device, characterized in that, For applying the memory control method according to any one of claims 1 to 13, the memory device comprises: The theoretical coefficient calculation module is used to monitor the host write time in real time when there is no garbage collection. Based on the worst-case performance requirement and the length of data written in a single instance, it obtains the maximum allowable time for a single I / O cycle. By calculating the host write time and the maximum allowable time, it calculates the dynamic time budget that can be allocated to the prospective garbage collection. Based on the ratio of the dynamic time budget to the estimated maximum garbage collection time, it obtains the theoretical optimal garbage collection intensity coefficient. The parameter calculation module is used to monitor the host write queue depth in real time to adjust the feedforward factor and monitor the number of free blocks in real time to adjust the feedback factor. When the write queue depth exceeds the preset first threshold, the feedforward factor is reduced to suppress garbage collection. When the number of free blocks is less than the second threshold, the feedback factor is increased to enhance garbage collection. The current coefficient calculation module is used to calculate the current waste recycling intensity based on the product of the theoretical optimal waste recycling intensity coefficient, the feedforward factor, and the feedback factor. Based on the current waste recycling intensity, time slice resources for future waste recycling are allocated to control the execution intensity of waste recycling.
15. A computer-readable storage medium, characterized in that, The device stores a computer program that, when executed by a processor, causes the processor to perform the steps of the method as described in any one of claims 1 to 13.
16. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method as described in any one of claims 1 to 13.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and storage medium
CN119088286A
Memory recovery method and device, electronic equipment and storage medium
CN120233934A