Solid state disk garbage collection process control method, device and electronic equipment
By detecting the available flash memory capacity, calculating urgency and busyness values, predicting transmission duration, and flexibly determining the sleep time of the garbage collection process, the problem of premature wake-up of the garbage collection process in traditional solid-state drives is solved, thus improving operating efficiency.
Patent Information
- Application Number
- CN202511056024.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-30
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-07-30
AI Technical Summary
Traditional solid-state drives (SSDs) often wake up prematurely before data transmission is complete due to their garbage collection process hibernation control method. This can cause conflicts with data transmission and affect flash memory performance and controller resources.
By detecting the available flash memory capacity, calculating the urgency and busyness of the data stream, and predicting the transmission completion time, the sleep time of the garbage collection process can be flexibly determined, replacing the fixed-time sleep method.
It enables flexible and controllable hibernation of the garbage collection process, avoids premature wake-up, reduces resource waste, and improves the operating efficiency of solid-state drives.
Smart Images

Figure CN120560863B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a garbage collection process control method and device for a solid state disk and an electronic device. BACKGROUND
[0002] The garbage collection process is a key core technology of flash memory management in a solid state disk. Since the flash memory of the solid state disk needs to be erased before writing, when data is updated, the old data in the flash memory will become invalid. The garbage collection process identifies and recycles these invalid data to release the storage capacity of the flash memory. However, the garbage collection process has a significant impact on the performance of the flash memory. It will occupy the bandwidth and controller resources of the flash memory, increase the delay of data stream transmission, and excessively occupy the flash memory. Therefore, how to reasonably arrange the sleep of the garbage collection process to avoid conflicts with data stream transmission is particularly important.
[0003] In related technologies, the traditional garbage collection process sleep control of the solid state disk submits the data stream to the controller of the fixed disk at the host end, and then the controller sleeps the garbage collection process according to a fixed time. When the fixed time is reached, the garbage collection process is automatically awakened to perform data recycling of the flash memory. However, in related technologies, the garbage collection process is awakened automatically when the fixed time is reached after the controller sleeps the garbage collection process according to the fixed time. This method is prone to the problem of premature awakening of the garbage collection process before the data stream transmission is completed. SUMMARY
[0004] The present application provides a garbage collection process control method and device for a solid state disk and an electronic device to at least solve the problem that the garbage collection process is awakened prematurely before the data stream transmission is completed in related technologies by the controller sleeping the garbage collection process according to a fixed time and automatically awakening the garbage collection process when the fixed time is reached.
[0005] The present application provides a garbage collection process control method for a solid state disk, comprising:
[0006] When it is detected that the host end starts to transmit any data stream, the available capacity of the flash memory of the solid state disk is checked;
[0007] According to the available capacity, it is determined whether the solid state disk meets the sleep condition of the garbage collection process;
[0008] If it is determined that the solid state disk meets the sleep condition, the urgency value of the data stream is calculated according to the sleep condition and the available capacity;
[0009] The transmission prediction time length of the completion of the data stream transmission is predicted;
[0010] extract a preset number of historical data streams from the flash memory, and determine a busy degree value of the solid state disk according to each historical data stream;
[0011] determine a sleep time of the garbage collection process according to the urgency degree value, the busy degree value and the transmission prediction time length;
[0012] control the garbage collection process to sleep according to the sleep time.
[0013] The application further provides a solid state disk garbage collection process control device, comprising:
[0014] a detection module, configured to check an available capacity of a flash memory of the solid state disk when detecting that the host starts to transmit any data stream;
[0015] a judgment module, configured to judge whether the solid state disk meets a sleep condition of the garbage collection process according to the available capacity;
[0016] a calculation module, configured to calculate an urgency degree value of the data stream according to the sleep condition and the available capacity if it is judged that the solid state disk meets the sleep condition;
[0017] a prediction module, configured to predict a transmission prediction time length of the data stream in which transmission is completed;
[0018] a first determination module, configured to extract a preset number of historical data streams from the flash memory, and determine a busy degree value of the solid state disk according to each historical data stream;
[0019] a second determination module, configured to determine a sleep time of the garbage collection process according to the urgency degree value, the busy degree value and the transmission prediction time length;
[0020] a sleep module, configured to control the garbage collection process to sleep according to the sleep time.
[0021] The application further provides an electronic device, comprising a memory configured to store a computer program and a processor configured to execute the computer program to realize the steps of the solid state disk garbage collection process control method.
[0022] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to realize the steps of the solid state disk garbage collection process control method.
[0023] The solid-state drive (SSD) garbage collection process control method, apparatus, and electronic device provided in this application, when detecting the start of any data stream transmission on the host side, checks the available capacity of the SSD's flash memory; based on the available capacity, determines whether the SSD meets the hibernation conditions for the garbage collection process; if the SSD meets the hibernation conditions, calculates the urgency value of the data stream based on the hibernation conditions and available capacity; predicts the transmission prediction time for the data stream to complete; extracts a preset number of historical data streams from the flash memory, and determines the SSD's busyness value based on each historical data stream; determines the hibernation time of the garbage collection process based on the urgency value, busyness value, and transmission prediction time; and controls the garbage collection process to hibernate based on the hibernation time. By determining the urgency parameter of the data stream, the busyness value of the SSD, and the predicted transmission time value of the data stream, the hibernation time of the garbage collection mechanism is generated, replacing the fixed-time hibernation method of the garbage collection process. This makes the hibernation of the garbage collection process flexible and controllable, and avoids the garbage collection process from waking up prematurely before the data stream transmission is completed. Attached Figure Description
[0024] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 A schematic diagram illustrating an application scenario of the solid-state drive garbage collection process control method provided in this embodiment of the application;
[0026] Figure 2 A flowchart illustrating the garbage collection process control method for solid-state drives provided in this application embodiment. Figure 1 ;
[0027] Figure 3 A flowchart illustrating the garbage collection process control method for solid-state drives provided in this application embodiment. Figure 2 ;
[0028] Figure 4 This is a schematic diagram of the structure of the solid-state drive garbage collection process control device provided in the embodiments of this application;
[0029] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0030] With reference to the drawings and the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0031] It should be noted that, in the description of the present application, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second" and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0032] The garbage collection process is a key core technology of flash memory management in a solid state disk. Since the flash memory of the solid state disk needs to be erased before writing, when the data is updated, the old data in the flash memory will become invalid, and the garbage collection process releases the storage capacity of the flash memory by identifying and recycling these invalid data. However, the garbage collection process has a significant impact on the performance of the flash memory, which will occupy the bandwidth and controller resources of the flash memory, increase the delay of data stream transmission, and excessively occupy the flash memory. Therefore, how to reasonably arrange the sleep of the garbage collection process to avoid conflicts with data stream transmission is particularly important. In related technologies, the sleep control of the garbage collection process of the traditional solid state disk is that after the host end submits the data stream to the controller of the fixed disk, the controller sleeps the garbage collection process according to a fixed time, and automatically wakes up the garbage collection process to perform data recycling of the flash memory when the fixed time is reached. However, in related technologies, the garbage collection process is easily awakened in advance before the data stream transmission is completed by the controller sleeping the garbage collection process according to a fixed time and automatically waking up the garbage collection process when the fixed time is reached.
[0033] To solve the above technical problems, the present application embodiment proposes the following technical concept: the inventor considers that when the host starts to transmit any data stream, the available capacity of the flash memory, if the available capacity is determined to satisfy the sleep condition of the garbage collection process of the solid state disk, the sleep condition and the available capacity are used to calculate the urgency value of the data stream, and the transmission prediction time length of the transmission completion of the data stream is predicted; and the busy degree value of the solid state disk is determined based on the extraction of each historical data stream from the flash memory; the sleep time of the garbage collection process is determined according to the urgency value, the busy degree value and the transmission prediction time length, which is used to sleep the garbage collection process. By determining the urgency parameter of the data stream, the busy degree value of the solid state disk and the transmission time prediction value of the data stream, the sleep time of the garbage collection mechanism is generated, which replaces the fixed time sleep mode of the garbage collection process, so that the sleep of the garbage collection process is flexible and controllable, and the garbage collection process is avoided to wake up in advance before the data stream transmission is completed.
[0034] In order to make the person skilled in the art better understand the present application scheme, the present application will be further described in detail below in combination with the drawings and specific embodiments.
[0035] In combination with the specific application environment architecture or specific hardware architecture on which the solid state disk garbage collection process control method depends, the specific application environment architecture or specific hardware architecture is described here. Reference Figure 1 , Figure 1 The application scenario of the solid state disk garbage collection process control method provided by the present application embodiment is shown in the figure.
[0036] As Figure 1 shown, the application scenario of the solid state disk garbage collection process control method includes a host end 101 and a solid state disk 102.
[0037] The host end 101 can be a single host or a cluster composed of multiple hosts.
[0038] The solid state disk 102 at least includes an electronic device 1021 and a flash memory 1022.
[0039] Among them, the electronic device 1021 can be a controller in the solid state disk 102, or other devices in the solid state disk 102.
[0040] The electronic device 1021 checks the available capacity of the flash memory 1022 of the solid state disk 102 when detecting that the host end 101 starts to transmit any data stream; judges whether the solid state disk 102 satisfies the dormancy condition of the garbage collection process according to the available capacity; if it is judged that the solid state disk 102 satisfies the dormancy condition, calculates the urgency value of the data stream according to the dormancy condition and the available capacity; predicts the transmission prediction time length of the transmission completion of the data stream; extracts a preset number of historical data streams from the flash memory 1022, and determines the busy degree value of the solid state disk 102 according to each historical data stream; determines the dormancy time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction time length; and controls the garbage collection process to be dormant according to the dormancy time.
[0041] Figure 2 The flowchart of the garbage collection process control method of the solid state disk provided by the embodiment of the application Figure 1 As shown in Figure 2 The embodiment of the application provides a garbage collection process control method of a solid state disk, and the method is described in detail as follows.
[0042] S201: When detecting that the host end starts to transmit any data stream, check the available capacity of the flash memory of the solid state disk.
[0043] Exemplarily, the available capacity is C1.
[0044] In addition, before step S201, steps a-c are further included.
[0045] Step a: receive the start flag of the data stream sent by the host end.
[0046] In the embodiment, the start flag can be state bit information or other flag information.
[0047] Step b: generate a receiving response message according to the start flag.
[0048] Step c: send the receiving response message to the host end, so that the host end starts to transmit the data stream.
[0049] S202: Judge whether the solid state disk satisfies the dormancy condition of the garbage collection process according to the available capacity.
[0050] In the embodiment, the dormancy condition can be a preset available capacity range of the flash memory, or a calibrated capacity of the flash memory.
[0051] Exemplarily, the preset capacity range is [1.5G, 300G].
[0052] In addition, when the capacity of the flash memory is less than 1.5G, the solid state disk needs to clean up enough available capacity in the shortest possible time, so it does not need to hibernate the garbage collection process; when the capacity of the flash memory is greater than 300G, the solid state disk has enough available capacity, and it also does not need to hibernate the garbage collection process.
[0053] S203: If it is determined that the solid state disk meets the hibernation condition, the urgency value of the data stream is calculated according to the hibernation condition and the available capacity.
[0054] In this embodiment, the hibernation condition is a preset available capacity range of the flash memory; accordingly, step S203 specifically includes:
[0055] S2031: Determine the target capacity from the preset available capacity range.
[0056] For example, the target capacity is determined to be 300G from the preset capacity range [1.5G, 300G].
[0057] S2032: Calculate the urgency value of the data stream according to the target capacity and the available capacity.
[0058] In this embodiment, the calculation formula for calculating the urgency value of the data stream according to the target capacity and the available capacity is:
[0059]
[0060] In the formula, is the urgency value of the data stream; is the available capacity.
[0061] S204: Predict the transmission prediction time length of the transmission completion of the data stream.
[0062] Specifically, step S204 specifically includes:
[0063] S2041: Obtain the header file of the data stream, and determine the data amount of the data stream according to the header file.
[0064] S2042: Determine whether the data amount is less than the data amount of a preset data block.
[0065] In this embodiment, the data amount of the preset data block can be any of 4k, 6k or 8k, or other data amount.
[0066] S2043: If it is determined that the data amount is not less than the data amount of the preset data block, the data stream is divided into one or more data blocks.
[0067] In this embodiment, the data amount of the data stream is a multiple of the data amount of the preset data block.
[0068] S2044: Determine the single transmission prediction duration of the data block.
[0069] For example, the single transmission prediction duration of the data block is T1.
[0070] S2045: Determine the total number of data blocks, and predict the transmission prediction duration of the transmission completion of the data stream according to the single transmission prediction duration and the total number.
[0071] For example, the total number of data blocks is N.
[0072] In this embodiment, the calculation formula of predicting the transmission prediction duration of the transmission completion of the data stream according to the single transmission prediction duration and the total number is:
[0073] T=N×T1
[0074] In the formula, T is the transmission prediction duration.
[0075] In addition, the single transmission prediction duration is stored in the flash memory.
[0076] S2046: If it is determined that the data amount is less than the data amount of the preset data block, predict the transmission prediction duration of the transmission completion of the data stream according to the data amount.
[0077] S205: Extract a preset number of historical data streams from the flash memory, and determine the busy degree value of the solid state disk according to each historical data stream.
[0078] For example, the busy degree value of the solid state disk is B.
[0079] S206: Determine the sleep time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction duration.
[0080] In this embodiment, the calculation formula of determining the sleep time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction duration is:
[0081] Tgc=A×B×T
[0082] In the formula, Tgc is the sleep time of the garbage collection process.
[0083] S207: Control the garbage collection process to sleep according to the sleep time.
[0084] In summary, the solid state disk garbage collection process control method provided in the embodiment can check the available capacity of the flash memory of the solid state disk when it is detected that the host starts to transmit any data stream, determine whether the solid state disk meets the hibernation condition of the garbage collection process according to the available capacity, calculate the urgency value of the data stream according to the hibernation condition and the available capacity if it is determined that the solid state disk meets the hibernation condition, extract a preset number of historical data streams from the flash memory and determine the busy degree value of the solid state disk according to each historical data stream, determine the hibernation time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction time of the data stream, and control the hibernation of the garbage collection process according to the hibernation time. By determining the urgency parameter of the data stream, the busy degree value of the solid state disk and the transmission time prediction value of the data stream, the hibernation time of the garbage collection mechanism is generated, which replaces the fixed time hibernation mode of the garbage collection process, makes the hibernation of the garbage collection process flexible and controllable, and avoids the premature wake-up of the garbage collection process before the data stream transmission is completed.
[0085] In addition, the solid state disk garbage collection process control method provided in the embodiment can determine the urgency parameter of the data stream, the busy degree value of the solid state disk and the transmission time prediction value of the data stream, and then generate the hibernation time of the garbage collection mechanism, which replaces the fixed time hibernation mode of the garbage collection process, makes the hibernation of the garbage collection process flexible and controllable, avoids the idle time between the hibernation of the garbage collection process and the data stream transmission, reduces the resource waste of the time window, and improves the running efficiency of the solid state disk.
[0086] Figure 3 The flowchart of the solid state disk garbage collection process control method provided in the embodiment Figure 2 In the embodiment of the present application, in Figure 2 Based on the provided embodiment, the specific implementation method of power consumption adjustment corresponding to each device is described in detail. As Figure 3 The solid state disk garbage collection process control method includes:
[0087] S301: determine the transmission time of each historical data stream and the time interval between each historical data stream.
[0088] Specifically, step S301 specifically includes:
[0089] S3011: obtain the start time stamp and the stop time stamp corresponding to each historical data stream from the flash memory.
[0090] S3012: determine the transmission time of each historical data stream and the time interval between each historical data stream according to each start time stamp and each stop time stamp.
[0091] S302: Determine the busy degree value of the solid state disk according to each transmission duration and each time interval.
[0092] Specifically, step S302 specifically includes:
[0093] S3021: Determine the corresponding average transmission duration according to each transmission duration.
[0094] Exemplarily, the determination of the corresponding average transmission duration according to each transmission duration is B1.
[0095] S3022: Determine the corresponding average time interval according to each time interval.
[0096] Exemplarily, the determination of the corresponding average time interval according to each time interval is B2.
[0097] S3023: Determine the initial busy degree value of the solid state disk according to the average transmission duration and the average time interval.
[0098] In the embodiment, the calculation formula of determining the initial busy degree value of the solid state disk according to the average transmission duration and the average time interval is:
[0099]
[0100] In the formula, is the initial busy degree value, and B3∈(0, 1).
[0101] When the data stream transmission is relatively idle, the time interval corresponding to the data stream transmission is large enough, and the value of B3 tends to 1. When the data stream transmission is relatively busy, the time interval corresponding to the data stream transmission is small enough, and the value of B3 tends to 0.
[0102] S3024: Set the corresponding indentation parameter according to the initial busy degree value.
[0103] Exemplarily, the setting of the corresponding indentation parameter according to the initial busy degree value is α.
[0104] S3025: Determine the busy degree value according to the initial busy degree value and the indentation parameter.
[0105] In the embodiment, the calculation formula of determining the busy degree value according to the initial busy degree value and the indentation parameter is:
[0106] B=α×(1+B3)
[0107] In the formula, B is the busy degree value.
[0108] Exemplarily, when α is 1, the value range of B is (1, 2).
[0109] Further, after step S3025, steps d-f are further included:
[0110] Step d: determining the start timestamp and the end timestamp corresponding to the data stream after determining that the data stream transmission is completed.
[0111] Step e: determining the transmission duration of the data stream and the time interval with the previous data stream according to the start timestamp and the end timestamp.
[0112] Step f: storing the transmission duration and the time interval into the flash memory.
[0113] As can be seen, the solid state disk garbage collection process control method provided by the embodiment determines the transmission duration of each historical data stream and the time interval between each historical data stream, and determines the busy degree value of the solid state disk according to each transmission duration and each time interval, so that the determination of the busy degree value of the solid state disk is more accurate, and the accuracy of the sleep time of the garbage collection mechanism is improved.
[0114] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment.
[0115] Figure 4 The structure diagram of the solid state disk garbage collection process control device provided by the embodiment of the application is shown in the figure. Figure 4 As shown, the embodiment of the application further provides a solid state disk garbage collection process control device, which comprises a detection module 401, a judgment module 402, a calculation module 403, a prediction module 404, a first determination module 405, a second determination module 406 and a sleep module 407.
[0116] The detection module 401 is used to check the available capacity of the flash memory of the solid state disk when it is detected that the host starts to transmit any data stream.
[0117] The judgment module 402 is used to determine whether the solid state disk meets the sleep condition of the garbage collection process according to the available capacity.
[0118] The calculation module 403 is used to calculate the urgency degree value of the data stream according to the sleep condition and the available capacity if it is determined that the solid state disk meets the sleep condition.
[0119] The prediction module 404 is used to predict the transmission prediction duration of the transmission completion of the data stream.
[0120] The first determination module 405 is used to extract a preset number of historical data streams from the flash memory, and determine the busy degree value of the solid state disk according to each historical data stream.
[0121] The second determining module 406 is configured to determine a sleep time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction time length.
[0122] The sleep module 407 is configured to control the garbage collection process to sleep according to the sleep time.
[0123] In a possible implementation, the prediction module 404 specifically includes:
[0124] The acquisition unit is configured to acquire a header file of the data stream, and determine a data amount of the data stream according to the header file;
[0125] The judging unit is configured to judge whether the data amount is less than a data amount of a preset data block;
[0126] The dividing unit is configured to divide the data stream into one or more data blocks if it is determined that the data amount is not less than the data amount of the preset data block;
[0127] The determining unit is configured to determine a single transmission prediction time length of the data block;
[0128] The first prediction unit is configured to determine a total number of the data blocks, and predict a transmission prediction time length of the data stream for transmission completion according to the single transmission prediction time length and the total number;
[0129] The second prediction unit is configured to predict the transmission prediction time length of the data stream for transmission completion according to the data amount if it is determined that the data amount is less than the data amount of the preset data block.
[0130] In a possible implementation, the first determining module 405 specifically includes:
[0131] The first determining unit is configured to determine transmission time lengths corresponding to the historical data streams, and time intervals between the historical data streams;
[0132] The second determining unit is configured to determine a busy degree value of the solid state disk according to the transmission time lengths and the time intervals.
[0133] In a possible implementation, the first determining unit specifically includes:
[0134] The acquisition unit is configured to acquire, from the flash memory, start time stamps and stop time stamps corresponding to the historical data streams;
[0135] The determining unit is configured to determine the transmission time lengths corresponding to the historical data streams, and the time intervals between the historical data streams according to the start time stamps and the stop time stamps;
[0136] Correspondingly, the second determining unit specifically includes:
[0137] The first determining unit is configured to determine a corresponding average transmission duration according to each transmission duration;
[0138] The second determining unit is configured to determine a corresponding average time interval according to each time interval;
[0139] The third determining unit is configured to determine an initial busy degree value of the solid state disk according to the average transmission duration and the average time interval;
[0140] The setting unit is configured to set a corresponding indentation parameter according to the initial busy degree value;
[0141] The fourth determining unit is configured to determine a busy degree value according to the initial busy degree value and the indentation parameter.
[0142] In a possible implementation, the apparatus further includes:
[0143] The third determining module is configured to determine a start time stamp and an end time stamp corresponding to the data stream after determining that the data stream transmission is completed;
[0144] The fourth determining module is configured to determine a transmission duration of the data stream and a time interval with a previous data stream according to the start time stamp and the end time stamp;
[0145] The storage module is configured to store the transmission duration and the time interval to the flash memory.
[0146] In a possible implementation, the hibernation condition is a preset available capacity range of the flash memory; accordingly, the computing module 403 specifically includes:
[0147] The determining unit is configured to determine a target capacity from the preset available capacity range;
[0148] The computing unit is configured to calculate a urgency degree value of the data stream according to the target capacity and the available capacity.
[0149] In a possible implementation, the apparatus further includes:
[0150] The receiving module is configured to receive a start flag of the data stream sent by the host end;
[0151] The generating module is configured to generate a receiving response message according to the start flag;
[0152] The sending module is configured to send the receiving response message to the host end, so that the host end starts to transmit the data stream.
[0153] The description of the features in the embodiments of the solid state disk garbage collection process control apparatus can refer to the related description of the embodiments of the solid state disk garbage collection process control method, which will not be repeated here.
[0154] Figure 5 A structural schematic diagram of an electronic device is provided in the present application. As shown in the figure, the electronic device provided in the present embodiment comprises at least one processor 501 and a memory 502. Optionally, the electronic device further comprises a communication component 503. The processor 501, the memory 502 and the communication component 503 are connected through a bus. Figure 5
[0155] In the implementation process, the at least one processor 501 executes the computer execution instructions stored in the memory 502, so that the at least one processor 501 executes the above-mentioned solid state disk garbage collection process control method embodiment.
[0156] The specific implementation process of the processor 501 can refer to the above-mentioned method embodiments, which have similar implementation principles and technical effects, and will not be described here in detail.
[0157] In the above-mentioned embodiments, it should be understood that the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC) and the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor and the like. The steps of the method disclosed in the application can be directly embodied as the execution of the hardware processor, or executed by the combination of hardware and software modules in the processor.
[0158] The memory can contain a random access memory (RAM), and can also include a non-volatile memory (NVM), for example, at least one disk memory.
[0159] The bus can be an industry standard architecture (ISA) bus, a peripheral component (PCI) bus or an extended industry standard architecture (EISA) bus and the like. The bus can be divided into an address bus, a data bus, a control bus and the like. For the convenience of representation, the bus in the drawings of the present application does not limit to only one bus or one type of bus.
[0160] The embodiment of the present application further provides a computer readable storage medium, which stores a computer program, wherein the computer program is arranged to execute the steps in the method for controlling a garbage collection process of a solid state disk.
[0161] In an example embodiment, the computer readable storage medium can include, but is not limited to, a U disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and the like.
[0162] The embodiment of the present application further provides a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps in the method for controlling a garbage collection process of a solid state disk.
[0163] The embodiment of the present application further provides another computer program product, which comprises a non-volatile computer readable storage medium, and the non-volatile computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in the method for controlling a garbage collection process of a solid state disk.
[0164] The skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0165] The above describes in detail the method for controlling a garbage collection process of a solid state disk, the device and the electronic equipment provided by the present application. The principle and implementation of the present application are described by applying specific examples. The above description of the examples is only used to help understand the method of the present application and its core idea. It should be pointed out that for those skilled in the art, without departing from the principle of the present application, some improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims
1. A method for controlling the garbage collection process of a solid-state drive, characterized in that, The application comprises: Upon detecting that the host starts to transmit any data stream, checking the available capacity of the flash memory of the solid state disk; According to the available capacity, judging whether the solid state disk meets the dormancy condition of the garbage collection process; If it is judged that the solid state disk meets the dormancy condition, determining the target capacity according to the dormancy condition, and calculating the urgency value of the data stream according to the target capacity and the available capacity; Predicting the transmission prediction time length of the transmission completion of the data stream; Extracting a preset number of historical data streams from the flash memory, determining the initial busy degree value of each historical data stream, setting the indentation parameter corresponding to the initial busy degree value, and determining the busy degree value of the solid state disk according to the initial busy degree value and the indentation parameter; According to the urgency value, the busy degree value and the transmission prediction time length, determining the dormancy time of the garbage collection process; Controlling the garbage collection process to be dormant according to the dormancy time; The calculation formula for calculating the urgency value of the data stream according to the target capacity and the available capacity is: In the formula, is the urgency value of the data stream; is the available capacity, applicable when the preset capacity range of the flash memory is [1.5G, 300G]; The calculation formula for determining the busy degree value according to the initial busy degree value and the indentation parameter is: B = α × (1 + B3) where B is the busy level value; and a is the backoff parameter. B0is the initial busy level value, B3∈(0, 1). The calculation formula for determining the dormancy time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction time length is: Tgc = A × B × T In the formula, Tgc is the dormancy time of the garbage collection process, and T is the transmission prediction time length.
2. The garbage collection process control method of a solid state drive according to claim 1, wherein, The prediction of the transmission prediction time length of the transmission completion of the data stream comprises: Obtaining the header file of the data stream, and determining the data amount of the data stream according to the header file; Judging whether the data amount is less than the data amount of a preset data block; If it is judged that the data amount is not less than the data amount of the preset data block, the data stream is divided into one or more data blocks; Determining the single transmission prediction time length of the data block; Determining the total number of data blocks, and predicting the transmission prediction time length of the transmission completion of the data stream according to the single transmission prediction time length and the total number; If it is judged that the data amount is less than the data amount of the preset data block, the transmission prediction time length of the transmission completion of the data stream is predicted according to the data amount.
3. The method of claim 1, wherein the method further comprises: The determination of the busy degree value of the solid state disk according to each historical data stream comprises: Determining the transmission time length corresponding to each historical data stream, and the time interval between each historical data stream; According to each transmission time length and each time interval, the busy degree value of the solid state disk is determined.
4. The garbage collection process control method of a solid state drive according to claim 3, wherein, The determination of the transmission time length corresponding to each historical data stream, and the time interval between each historical data stream comprises: From the flash memory, the starting time stamp and the stop time stamp corresponding to each historical data stream are obtained; According to each starting time stamp and each stop time stamp, the transmission time length corresponding to each historical data stream, and the time interval between each historical data stream are determined; Accordingly, the determination of the busy degree value of the solid state disk according to each transmission time length and each time interval comprises: According to the average transmission time length corresponding to each transmission time length; According to the average time interval corresponding to each time interval; determine an initial busy degree value of the solid state disk according to the average transmission duration and the average time interval; set a corresponding indentation parameter according to the initial busy degree value; determine a busy degree value according to the initial busy degree value and the indentation parameter.
5. The garbage collection process control method of a solid state drive according to claim 4, wherein, After the busy degree value is determined according to the initial busy degree value and the indentation parameter, the method further comprises: after determining that the data stream transmission is completed, determining a start timestamp and an end timestamp corresponding to the data stream; determining a transmission duration of the data stream and a time interval with a previous data stream according to the start timestamp and the end timestamp; storing the transmission duration and the time interval to the flash memory.
6. The garbage collection process control method of a solid state drive according to claim 1, wherein, The sleep condition is a preset available capacity range of the flash memory. Accordingly, the calculation of the urgency value of the data stream according to the sleep condition and the available capacity comprises: determining a target capacity from the preset available capacity range; calculating the urgency value of the data stream according to the target capacity and the available capacity.
7. The method according to any one of claims 1 to 6, wherein Before checking the available capacity of the flash memory of the solid state disk, the method further comprises: receiving a start flag of the data stream sent by the host end; generating a receiving response message according to the start flag; sending the receiving response message to the host end to make the host end start transmitting the data stream.
8. A garbage collection process control device for a solid-state drive, characterized in that, The method comprises: a detection module configured to check the available capacity of the flash memory of the solid state disk when detecting that the host end starts transmitting any data stream; a judgment module configured to determine whether the solid state disk satisfies a sleep condition of a garbage collection process according to the available capacity; a calculation module configured to, if it is determined that the solid state disk satisfies the sleep condition, determine a corresponding target capacity according to the sleep condition, and calculate an urgency value of the data stream according to the target capacity and the available capacity; a prediction module configured to predict a transmission prediction duration of the transmission completion of the data stream; a first determination module configured to extract a preset number of historical data streams from the flash memory, determine an initial busy degree value corresponding to each historical data stream, set an indentation parameter corresponding to the initial busy degree value, and determine a busy degree value of the solid state disk according to the initial busy degree value and the indentation parameter; a second determination module configured to determine a sleep time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction duration; a sleep module configured to control the garbage collection process to sleep according to the sleep time. The calculation formula of the urgency value of the data stream according to the target capacity and the available capacity is: In the formula, is the urgency value of the data stream; is the available capacity, which is applicable when the preset capacity range of the flash memory is [1.5G, 300G]; The calculation formula of the busy degree value according to the initial busy degree value and the indentation parameter is: B = α × (1 + B3) where B is the busy level value; and a is the backoff parameter. B0is the initial busy level value, B3∈(0, 1). The calculation formula of the sleep time of the garbage collection process according to the urgency value, the busy degree value and the transmission prediction duration is: Tgc = A × B × T In the formula, Tgc is the sleep time of the garbage collection process, and T is the transmission prediction duration.
9. An electronic device, comprising: The method comprises: a memory configured to store a computer program. A processor is configured to implement the steps of the garbage collection process control method of the solid state drive according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer program is stored in the computer readable storage medium and configured to implement the steps of the garbage collection process control method of the solid state drive according to any one of claims 1 to 7 when executed by the processor.
Citation Information
Patent Citations
Flow control method and device of solid state disk (SSD), storage medium and equipment
CN116126253A