A garbage collection method, an electronic device, and a storage medium
By employing a method of alternating programming and source block marking, the write amplification problem caused by cache limitations during garbage collection in QLC storage devices is resolved, thereby improving storage performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ARTMEM TECHNOLOGY CO LTD
- Filing Date
- 2025-12-12
- Publication Date
- 2026-06-09
Smart Images

Figure CN121300715B_ABST
Abstract
Description
Technical Field
[0001] This application relates to, but is not limited to, the field of storage technology, and particularly to a waste recycling method, electronic device, and storage medium. Background Technology
[0002] In related technologies, when performing garbage collection, Quad-Level Cell (QLC) storage devices need to reprogram the valid data of the source block into the NAND flash memory, and then release the source block by reprogramming the invalid data back into the source block.
[0003] During the reprogramming of valid data into NAND flash memory, the valid data is first scanned and stored in a cache to assist in the reprogramming process. However, cache space is limited, and it is possible that the valid data cannot be completely stored in the cache. This would prevent the valid data from being completely reprogrammed into the NAND flash memory. To prevent this from happening, the source block needs to be retained to provide a basis for reprogramming. This means that the source block cannot be released immediately during the reprogramming process. Therefore, during the release of the source block, an additional data migration and writing step is performed to release the source block. This phenomenon is called write amplification, which seriously affects the performance of QLC memory devices. Summary of the Invention
[0004] This application provides a garbage collection method, electronic device, and storage medium that can reduce the performance degradation of QLC storage devices caused by write amplification.
[0005] On the one hand, embodiments of this application provide a waste recycling method, including:
[0006] Identify multiple source blocks to be recycled and the corresponding destination blocks for each source block;
[0007] Multiple source blocks are used to perform alternating programming on multiple target blocks, and the source blocks that have participated in the first programming are marked.
[0008] In response to one or more of the marked source blocks satisfying a preset condition, the source blocks that satisfy the preset condition are released.
[0009] In one embodiment, the step of performing secondary alternating programming on multiple target blocks based on multiple source blocks, and marking the source blocks that have participated in the first programming, includes:
[0010] In response to performing data migration of the first source block among a plurality of source blocks, the destination block corresponding to the first source block is programmed for the first time according to the first source block, and the first source block is marked;
[0011] Based on the next source block of the first source block, the target block corresponding to the next source block of the first source block is programmed for the first time, and the next source block of the first source block is marked;
[0012] Based on the first source block, the target block corresponding to the first source block is programmed a second time.
[0013] In one embodiment, the step of performing a first programming on the target block corresponding to the first source block based on the first source block includes:
[0014] Identify multiple unprocessed first word lines in the first source block;
[0015] The first programming of multiple first word lines is performed in the destination block corresponding to the first source block.
[0016] In one embodiment, the step of performing a first programming on the target block corresponding to the next source block of the first source block, based on the next source block of the first source block, includes:
[0017] Identify multiple unprocessed second word lines in the next source block of the first source block;
[0018] The first programming of multiple second word lines is performed in the destination block corresponding to the next source block after the first source block.
[0019] In one embodiment, the step of performing secondary alternating programming on multiple target blocks based on multiple source blocks, and marking the source blocks that have participated in the first programming, includes:
[0020] In response to the first source block being marked as not being the first source block, the destination block corresponding to the second source block is programmed a second time according to the second source block, wherein the second source block is the previous source block of the first source block;
[0021] The target block corresponding to the third source block is programmed for the first time according to the third source block, and the third source block is marked, wherein the third source block is the next source block after the first source block;
[0022] The target block corresponding to the first source block is programmed a second time based on the first source block.
[0023] In one embodiment, the first programming of the target block corresponding to the third source block based on the third source block includes:
[0024] Identify multiple unprocessed third word lines in the third source block;
[0025] The first programming of multiple third word lines is performed in the destination block corresponding to the third source block.
[0026] In one embodiment, releasing the source blocks that satisfy the preset conditions in response to one or more of the marked source blocks satisfying a preset condition includes:
[0027] In response to performing a mapping snapshot, one or more target source blocks that have not participated in a second programming are identified among the tagged source blocks;
[0028] Release the identified target source block.
[0029] In one embodiment, releasing the source blocks that satisfy the preset conditions in response to one or more of the marked source blocks satisfying a preset condition includes:
[0030] In response to the fact that the number of marked source blocks is not less than a preset threshold, the target block corresponding to the previous source block of the latest marked source block is programmed a second time according to the previous source block of the latest marked source block;
[0031] Based on the latest tagged source block, the target block corresponding to the latest tagged source block is programmed a second time;
[0032] Release all the source blocks that have been marked.
[0033] On the other hand, embodiments of this application also provide an electronic device, including: at least one processor; at least one memory for storing at least one program; and implementing the garbage collection method as described above when at least one of the programs is executed by at least one of the processors.
[0034] On the other hand, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions, characterized in that the computer-executable instructions are used to execute the garbage collection method as described above.
[0035] On the other hand, embodiments of this application also provide a computer program product, including a computer program or computer instructions, the computer program or computer instructions being stored in a computer-readable storage medium, a processor of an electronic device reading the computer program or computer instructions from the computer-readable storage medium, and the processor executing the computer program or computer instructions to cause the electronic device to perform the garbage collection method as described above.
[0036] This application provides a garbage collection method, electronic device, and storage medium. The method includes determining a plurality of source blocks to be collected and a corresponding destination block for each source block; performing secondary alternating programming on the plurality of destination blocks according to the plurality of source blocks, and marking the source blocks that have participated in the first programming; and releasing the source blocks that meet the preset conditions in response to one or more of the marked source blocks. By using secondary alternating programming and marking the source blocks that have participated in the first programming, the plurality of source blocks can interleave their respective valid data into the destination blocks, thereby delaying the release of each source block and enabling the source block release steps to be executed uniformly. Compared to garbage collection of each source block one by one in the original way, secondary alternating programming can reduce additional data migration and writing steps, effectively suppress write amplification, and thus improve the performance of QLC storage devices. Attached Figure Description
[0037] Figure 1 This is a schematic flowchart of a waste recycling method provided in an embodiment of this application;
[0038] Figure 2 yes Figure 1 The flow of a sub-step embodiment of step 120;
[0039] Figure 3 yes Figure 1 The process of another sub-step embodiment of step 120;
[0040] Figure 4 yes Figure 1 A flowchart illustrating an embodiment of a sub-step of step 130;
[0041] Figure 5 yes Figure 1 A flowchart illustrating another sub-step embodiment of step 130;
[0042] Figure 6 This is a schematic diagram illustrating an implementation method of the waste recycling method provided in this application.
[0043] Figure 7 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0045] It should be noted that although the flowchart shows a logical order, in some cases, the steps shown or described may be executed in a different order than that shown in the flowchart. In the description of the embodiments of this application, "multiple" (or more than) means two or more, "greater than," "less than," and "exceeding" are understood to exclude the number itself, while "above," "below," and "within" are understood to include the number itself. If "first," "second," etc., are described, they are only used to distinguish technical features and should not be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated or the order of the technical features indicated. Furthermore, in the description of the embodiments of this application, the various values mentioned (such as first value, second value, etc.) can be flexibly represented as a single numeric code or an enumerated type value.
[0046] In related technologies, when performing garbage collection, Quad-Level Cell (QLC) storage devices need to reprogram the valid data of the source block into the NAND flash memory, and then release the source block by reprogramming the invalid data back into the source block.
[0047] During the reprogramming of valid data into NAND flash memory, the valid data is first scanned and stored in a cache to assist in the reprogramming process. However, cache space is limited, and it is possible that the valid data cannot be completely stored in the cache. This would prevent the valid data from being completely reprogrammed into the NAND flash memory. To prevent this from happening, the source block needs to be retained to provide a basis for reprogramming. This means that the source block cannot be released immediately during the reprogramming process. Therefore, during the release of the source block, an additional data migration and writing step is performed to release the source block. This phenomenon is called write amplification, which seriously affects the performance of QLC memory devices.
[0048] To mitigate the performance degradation of QLC storage devices caused by write amplification, embodiments of this application provide a garbage collection method, an electronic device, a computer-readable storage medium, and a computer program product. Specifically, the method first identifies multiple source blocks to be garbage collected and corresponding destination blocks. Then, it performs secondary alternating programming on the multiple source blocks and marks source blocks that have already participated in the first programming. Next, in response to one or more marked source blocks meeting preset conditions, the source blocks meeting the preset conditions are released. By using secondary alternating programming and marking source blocks that have already participated in the first programming, multiple source blocks can interleave their valid data into the destination blocks, thereby delaying the release of each source block and allowing the source block release steps to be executed uniformly. Compared to garbage collection of each source block one by one in the original manner, secondary alternating programming reduces additional data migration and writing steps, effectively suppressing write amplification and thus improving the performance of the QLC storage device.
[0049] See Figure 1 , Figure 1 The flowchart of a waste recycling method provided by an embodiment of this application is illustrated. One embodiment of this application provides a waste recycling method, which may include the following steps.
[0050] Step 110: Identify multiple source blocks to be reclaimed and the corresponding destination blocks for each source block;
[0051] Step 120: Perform secondary alternating programming on multiple source blocks based on multiple source blocks, and mark the source blocks that have participated in the first programming;
[0052] Step 130: In response to one or more source blocks among the marked source blocks meeting the preset conditions, release the source blocks that meet the preset conditions.
[0053] In one embodiment, the source block to be reclaimed refers to a data block containing valid data to be transferred.
[0054] In one embodiment, the destination block refers to the data block into which the valid data to be transferred from the source block is to be transferred. The destination block may contain other data or may be completely blank; no specific limitation is made here. Furthermore, multiple source blocks may correspond to the same destination block or different destination blocks; no specific limitation is made here.
[0055] In one embodiment, double-alternating programming refers to alternatingly programming valid data from different source blocks to their respective destination blocks once, until all valid data from all source blocks have been programmed twice to their respective destination blocks.
[0056] In one embodiment, marking source blocks that have participated in the first programming can be achieved by using a record table. After each source block has participated in the first programming, its ID and other identification information are recorded in the table.
[0057] In one embodiment, marking source blocks that have participated in the first programming can be achieved by adding marking data to the metadata of the source block. After each source block has participated in the first programming, marking data is added to the metadata of the source block.
[0058] In one embodiment, during the process of performing secondary alternating programming on multiple target blocks based on multiple source blocks and marking the source blocks that have participated in the first programming, specifically, the first programming can be performed on each source block to its corresponding target block one by one and the source blocks that have participated in the first programming can be marked. Then, the second programming can be performed on each source block to its corresponding target block one by one.
[0059] For example, suppose there are three source blocks A, B, and C, and these three source blocks happen to correspond to the destination block D. Then, first, the first programming is performed from A to D and A is marked. Next, the first programming is performed from B to D and B is marked. Then, the first programming is performed from C to D and C is marked. After that, the second programming begins from A to D. Then, the second programming is performed from B to D. Finally, the second programming is performed from C to D.
[0060] It should be noted that the second-level alternation programming is for block-level alternation programming, so word-line programming also needs to follow the restrictions of the second-level alternation programming.
[0061] In one embodiment, after first performing a first programming operation on each source block to its corresponding destination block and marking the source blocks that have participated in the first programming operation, and then performing a second programming operation on each source block to its corresponding destination block, specifically, the word lines to be processed in each source block can be determined first, then the first programming operation on multiple word lines to be processed is performed on the destination block corresponding to each source block, and the source blocks that have participated in the first programming operation are marked, and then the second programming operation on multiple word lines to be processed is performed on the destination block corresponding to each source block.
[0062] By performing the first programming on each word line to be processed, the second programming of the word lines can be postponed, allowing for a unified release of multiple source blocks at the end, effectively suppressing write amplification. Furthermore, this first programming operation, compared to the secondary programming of word lines in existing technologies, allows sufficient stabilization time for the word lines in the target block that have already undergone the first programming, thus effectively reducing data errors.
[0063] In one embodiment, releasing source blocks that meet preset conditions means using padding data to overwrite the data of each source block that meets the preset conditions, so that each source block that meets the preset conditions becomes a free block.
[0064] See Figure 2 , Figure 2 It shows Figure 1 The process of a sub-step embodiment of step 120. In one embodiment, step 120 may include the following sub-steps.
[0065] Step 210: In response to performing data migration of the first source block among multiple source blocks, perform the first programming on the destination block corresponding to the first source block based on the first source block, and mark the first source block;
[0066] Step 220: Based on the next source block of the first source block, perform the first programming on the target block corresponding to the next source block of the first source block, and mark the next source block of the first source block;
[0067] Step 230: Perform a second programming on the target block corresponding to the first source block based on the first source block.
[0068] In one embodiment, performing data migration of the first source block among multiple source blocks refers to the situation where the first source block entering the secondary alternating programming process among multiple source blocks to be recycled is about to write valid data from the first source block to its corresponding destination block.
[0069] In one embodiment, performing the first programming on the destination block corresponding to the first source block based on the first source block and marking the first source block refers to the operation of programming the valid data in the first source block into a specific area of the destination block corresponding to the first source block and marking the first source block.
[0070] It should be noted that the second-level alternation programming is for block-level alternation programming, so word-line programming also needs to follow the restrictions of the second-level alternation programming.
[0071] In one embodiment, during the initial programming of the target block corresponding to the first source block based on the first source block, several first word lines to be processed in the first source block can be determined first. Then, the initial programming of these first word lines is performed in the target block corresponding to the first source block. Here, a first word line refers to the word line in the first source block that stores valid data. By performing the initial programming of each first word line one by one, the second programming of the first word lines can be postponed, thus enabling a unified release of multiple source blocks at the end, effectively suppressing write amplification. Based on this, the operation of performing the initial programming one by one, compared to the secondary programming of word lines in the prior art, allows sufficient stabilization time for the word lines in the target block that have already undergone the first programming, thereby effectively reducing data errors.
[0072] In one embodiment, during the first programming of the destination block corresponding to the next source block of the first source block based on the next source block of the first source block, specifically, multiple second word lines to be processed in the next source block of the first source block can be determined first. Then, the first programming of the multiple second word lines is performed in the destination block corresponding to the next source block of the first source block. Here, the second word line refers to the word line in the next source block of the first source block that stores the valid data in this source block.
[0073] For example, suppose the first source block contains two first word lines, A and B, and the next source block contains two second word lines, C and E. The destination block corresponding to both source blocks is D. Then, the first programming of first word line A will be performed in D first, followed by the first programming of first word line B in D, then the first programming of second word line C in D, and finally the first programming of second word line E in D.
[0074] In one embodiment, during the second programming of the target block corresponding to the first source block based on the first source block, the process can be as follows: first, read multiple first word lines in the first source block, and then perform the second programming of the multiple first word lines in the first source block one by one in the target block corresponding to the first source block.
[0075] For steps 210 to 220, by performing the first programming on the first source block and then performing the first programming on the next source block corresponding to the destination block, the second programming of multiple source blocks can be postponed. This allows for a unified release of multiple source blocks at the end, effectively suppressing write amplification. Furthermore, performing the first programming operation one by one allows sufficient stabilization time for the destination block, thus effectively reducing data errors.
[0076] See Figure 3 , Figure 3 It shows Figure 1The process of another sub-step embodiment of step 120. In one embodiment, step 120 may include the following sub-steps.
[0077] Step 310: In response to the first source block being marked as not being the first source block, the destination block corresponding to the second source block is programmed a second time according to the second source block, wherein the second source block is the previous source block of the first source block;
[0078] Step 320: Perform the first programming on the target block corresponding to the third source block based on the third source block, and mark the third source block, where the third source block is the next source block after the first source block;
[0079] Step 330: Perform a second programming on the target block corresponding to the first source block based on the first source block.
[0080] In one embodiment, marking a first source block that is not the first source block means that the valid data in the first source block has been programmed to the destination block corresponding to the first source block for the first time and the first source block has been marked.
[0081] In one embodiment, during the second programming of the target block corresponding to the second source block based on the second source block, a plurality of word lines to be processed in the second source block can be read first, and then the second programming of the plurality of word lines to be processed in the second source block can be performed one by one in the target block corresponding to the second source block.
[0082] In one embodiment, during the first programming of the target block corresponding to the third source block based on the third source block, multiple third word lines to be processed in the third source block can be determined first. Then, the first programming of these multiple third word lines is performed in the target block corresponding to the third source block. By performing the first programming of each word line one by one, the second programming of the word lines can be postponed, thereby enabling the unified release of multiple source blocks at the end, effectively suppressing write amplification. Based on this, the operation of performing the first programming one by one, compared to the secondary programming of word lines in the prior art, can reserve sufficient stabilization time for the word lines in the target block that have already undergone the first programming, thereby effectively reducing the possibility of data errors.
[0083] In one embodiment, during the second programming of the target block corresponding to the first source block based on the first source block, multiple word lines to be processed in the first source block can be read first, and then the second programming of the multiple word lines to be processed in the first source block can be performed one by one in the target block corresponding to the first source block.
[0084] For steps 310 to 330, by performing a second programming operation on the first source block and then performing a first programming operation on the target block corresponding to the next source block, the second programming of multiple source blocks can be postponed. This allows for a unified release of multiple source blocks at the end, effectively suppressing write amplification. Furthermore, performing the first programming operation one by one allows sufficient stabilization time for the target block, effectively reducing data errors.
[0085] The following example will illustrate steps 210 to 230 and steps 310 to 330.
[0086] Suppose we have three source blocks A, B, and C, and each of these source blocks corresponds to a destination block D. Then, relative to source block A, source block A is the first source block, and source block B is the next source block after the first source block. Relative to source block B, source block A is the second source block, source block B is the first source block, and source block C is the third source block. The process is as follows: First, program from A to D and mark A. Then, program from B to D and mark B. Next, program from A to D a second time. Then, program from C to D a first time and mark C. Next, program from B to D a second time. Finally, program from C to D a second time.
[0087] The following example will further illustrate steps 210 to 230 and steps 310 to 330.
[0088] Suppose we have three source blocks A, B, C, and D, and these four source blocks all correspond to the destination block E. Then, relative to source block A, source block A is the first source block, and source block B is the next source block after the first source block; relative to source block B, source block A is the second source block, source block B is the first source block, and source block C is the third source block; relative to source block C, source block B is the second source block, source block C is the first source block, and source block D is the third source block. Therefore, the programming process is as follows: First, program from A to E and mark A. Then, program from B to E and mark B. Then, program from A to E a second time. Next, program from C to E a first time and mark C. Then, program from B to E a second time. Then, program from D to E a first time and mark D. Then, program from C to E a second time. Finally, program from D to E a second time.
[0089] See Figure 4 , Figure 4 It shows Figure 1 The process of a sub-step embodiment of step 130. In one embodiment, step 130 may include the following steps.
[0090] Step 410: In response to performing a mapping snapshot, identify one or more target source blocks that have not participated in the second programming among the multiple marked source blocks;
[0091] Step 420: Release the identified target source block.
[0092] In one embodiment, responding to a mapping snapshot refers to the moment when the mapping snapshot process is ready to begin but has not yet started.
[0093] In one embodiment, releasing the determined target source blocks refers to the operation of overwriting each target source block with padding data to make each target source block a free block.
[0094] In one embodiment, during the release of the determined target source block, the target source block can be programmed one by one by first by filling in data, and then programmed a second time by filling in data.
[0095] In one embodiment, during the release of the determined target source blocks, the target source blocks can be programmed alternately in a manner similar to steps 210 to 230 and 310 to 330 by filling in data.
[0096] During the release of the target source block, the target source block is reprogrammed by filling data through a two-stage alternating programming method. Compared with the word line reprogramming in the prior art, this method can reserve enough stabilization time for the word lines in the target source block that have already been programmed for the first time, thereby effectively reducing the possibility of data errors.
[0097] For steps 410 to 420, after the target block is written with valid data from the source block, the mapping table in the QLC storage device is updated to record the storage status of valid data in each storage block. By identifying one or more target source blocks that have not participated in the second programming among the marked source blocks before the mapping snapshot, the source blocks that can be released can be determined. This allows the target source blocks that can be released to be released as much as possible before the mapping snapshot, thereby prompting the mapping table to delete cases where target source blocks no longer need to be recorded to reduce the snapshot size. This reduces the backup storage of useless data during the mapping snapshot process, effectively optimizes the mapping convention, and improves the storage efficiency of the QLC storage device.
[0098] See Figure 5 , Figure 5 The flowchart of a waste recycling method provided in another embodiment of this application is illustrated. In one embodiment, step 130 may further include the following sub-steps.
[0099] Step 510: In response to the fact that the number of marked source blocks is not less than a preset threshold, perform a second programming on the target block corresponding to the previous source block of the latest marked source block.
[0100] Step 520: Based on the latest marked source block, perform a second programming on the destination block corresponding to the latest marked source block;
[0101] Step 530: Release all the marked source blocks.
[0102] In one embodiment, the number of marked source blocks not less than a preset threshold means that the number of source blocks that can be retained in the QLC storage device reaches the limit of the preset threshold, causing the QLC storage device to be unable to reserve enough free data blocks.
[0103] In one embodiment, during the second programming of the target block corresponding to the previous source block of the latest marked source block based on the previous source block of the latest marked source block, specifically, multiple word lines to be processed in the previous source block of the latest marked source block can be read first, and then the second programming of multiple word lines to be processed in the previous source block of the latest marked source block can be performed one by one on the target block corresponding to the previous source block of the latest marked source block.
[0104] In one embodiment, during the second programming of the destination block corresponding to the latest marked source block based on the latest marked source block, specifically, multiple word lines to be processed in the latest marked source block can be read first, and then the second programming of the multiple word lines to be processed in the latest marked source block can be performed one by one in the destination block corresponding to the latest marked source block.
[0105] In one embodiment, releasing all marked source blocks refers to overwriting each marked source block with padding data to make each marked source block a free block.
[0106] In one embodiment, during the process of releasing all marked source blocks, the marked source blocks can be programmed one by one by first by padding data, and then the marked source blocks can be programmed a second time by padding data.
[0107] In one embodiment, during the process of releasing all the marked source blocks, the marked source blocks can be alternately programmed in a manner similar to steps 210 to 230 and 310 to 330 by filling in data.
[0108] During the release of all marked source blocks, secondary programming is performed on all marked source blocks by alternating programming to fill in the data. Compared with word line secondary programming in the prior art, sufficient stabilization time can be reserved for the word lines in all marked source blocks that have been programmed for the first time, thereby effectively reducing the possibility of data errors.
[0109] For steps 510 to 530, before entering the mapping snapshot execution period, a certain number of source blocks will remain due to the secondary alternating programming, which will compress the storage space of the QLC storage device and gradually reduce the number of free blocks. If the number of free blocks decreases to a certain level, it will affect the normal operation of the QLC storage device. Therefore, when the number of marked blocks reaches a certain level, the first programming of new source blocks will no longer be performed, and the current secondary alternating programming process will end. In this way, the QLC storage device can release all the currently marked source blocks in a unified manner to increase the number of free blocks, which helps to reserve enough operating space for the QLC storage device.
[0110] The following example illustrates steps 510 to 530.
[0111] Suppose there are source blocks A and B, where source block B is the next source block after source block A, and the corresponding destination block for both is C. After source block B completes its first programming, it will be marked. If the number of marked source blocks, including source blocks A and B, reaches a threshold, it proves that the QLC storage device cannot currently reserve enough free data blocks. At this time, the QLC storage device will stop the first programming of new source blocks and directly start the second programming of destination block C based on source block A. Finally, it will perform the second programming of destination block C based on source block B to end this two-stage alternating programming process.
[0112] The following is an overall embodiment of a waste recycling method.
[0113] See Figure 6 The storage device performs garbage collection on source block one and has completed scanning the entire block. It then records source block one into the "source block record." When data A and data B in the destination block complete their first programming, the first programming of data in other source blocks must be completed before a second programming of data A and data B can be performed. Only after the second programming is completed can the data be read normally. Therefore, garbage collection is performed on the newly selected source block two, data C and data D are read from source block two, and the first programming is performed. After programming is completed, the second programming of data A and data B in source block one can then be performed. During subsequent mapping snapshots, the "source block record" is checked for pages that need to be read for secondary programming. If no corresponding source block is found, it can be released. When the number of source block records accumulates to the point of insufficient free blocks, padding data is used to release the blocks. This padding data releases all blocks in the "source block record."
[0114] The following examples illustrate the application scenarios of the embodiments of this application.
[0115] It should be noted that the garbage collection method provided in this application embodiment can be applied to cloud database management application scenarios. The following description takes cloud database management application scenarios as an example.
[0116] For example, in cloud databases, various users can modify and manage their cloud data stored in the cloud through their own management terminals. However, cloud databases have a massive data throughput. Therefore, for cloud databases, data changes over a period of time will cause a large amount of data in the NAND flash memory of the storage system that provides hardware services to the cloud database to become data that needs to be reclaimed. If a large amount of NAND flash memory is garbage collected using traditional methods, write amplification will inevitably occur, resulting in a noticeable impact on data services and reducing the user's cloud storage experience.
[0117] To address this, the storage system first identifies multiple source blocks to be reclaimed and their corresponding destination blocks. Then, it performs a second round of alternating programming on the multiple destination blocks based on the source blocks, marking the source blocks that have already participated in the first round of programming. Finally, in response to one or more marked source blocks meeting preset conditions, the source blocks that meet these conditions are released. In this process, by using alternating programming and marking the source blocks that have already participated in the first round of programming, the storage system allows a large number of source blocks to interleave their valid data into the destination blocks. This delays the release of each source block, enabling the source block release steps to be executed uniformly. This effectively suppresses the massive write amplification phenomenon in the storage system and improves the user's cloud storage experience.
[0118] In addition to the embodiments described above, one embodiment of this application also provides an electronic device. See also Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Figure 7 As shown, the electronic device includes a memory 1100 and a processor 1200. The number of memories 1100 and processors 1200 can be one or more. Figure 7 Taking a memory 1100 and a processor 1200 as an example; Figure 7 The memory 1100 and processor 1200 can be connected via a bus or other means. Figure 7 Taking the example of a connection between China and Israel via a bus.
[0119] The memory 1100, as a computer-readable storage medium, can be used to store one or more software programs, computer-executable programs, and modules, such as the programs, instructions, or modules corresponding to the garbage collection method provided in any embodiment of this application. The processor 1200 implements the garbage collection method provided in any embodiment of this application by executing one or more computer programs, instructions, and modules stored in the memory 1100.
[0120] The memory 1100 may primarily include a program storage area and a data storage area, wherein the program storage area may store the operating system and computer programs required for at least one function. Furthermore, the memory 1100 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 1100 may further include memory remotely located relative to the processor 1200, and these remote memories can be connected to the device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0121] In addition to the embodiments described above, one embodiment of this application also provides a computer-readable storage medium storing computer-executable instructions for performing the garbage collection method as described in any of the preceding embodiments.
[0122] Furthermore, one embodiment of this application also provides a computer program product, including a computer program or computer instructions, which are stored in a computer-readable storage medium. A processor of an electronic device reads the computer program or computer instructions from the computer-readable storage medium and executes the computer program or computer instructions, causing the electronic device to perform the garbage collection method as described in any of the preceding embodiments.
[0123] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0124] The above is a detailed description of the preferred embodiments of this application. However, this application is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.
Claims
1. A waste recycling method, characterized in that, include: Identify multiple source blocks to be recycled and the corresponding destination blocks for each source block; Multiple source blocks are used to perform secondary alternating programming on multiple destination blocks, and the source blocks that have participated in the first programming are marked. The secondary alternating programming is used to alternately program the valid data in different source blocks to their respective corresponding destination blocks once, until the valid data in all source blocks have been programmed twice to their respective corresponding destination blocks. In response to performing a mapping snapshot, one or more target source blocks that have not participated in a second programming are identified among the tagged source blocks; Release the identified target source block.
2. The method according to claim 1, characterized in that, The step of performing alternating programming on multiple target blocks based on multiple source blocks, and marking the source blocks that have participated in the first programming, includes: In response to performing data migration of the first source block among a plurality of source blocks, the destination block corresponding to the first source block is programmed for the first time according to the first source block, and the first source block is marked; Based on the next source block of the first source block, the target block corresponding to the next source block of the first source block is programmed for the first time, and the next source block of the first source block is marked; Based on the first source block, the target block corresponding to the first source block is programmed a second time.
3. The method according to claim 2, characterized in that, The first programming of the target block corresponding to the first source block based on the first source block includes: Identify multiple unprocessed first word lines in the first source block; The first programming of multiple first word lines is performed in the destination block corresponding to the first source block.
4. The method according to claim 2, characterized in that, The step of performing the first programming on the target block corresponding to the next source block of the first source block, based on the next source block of the first source block, includes: Identify multiple unprocessed second word lines in the next source block of the first source block; The first programming of multiple second word lines is performed in the destination block corresponding to the next source block after the first source block.
5. The method according to claim 1, characterized in that, The step of performing alternating programming on multiple target blocks based on multiple source blocks, and marking the source blocks that have participated in the first programming, includes: In response to the first source block being marked as not being the first source block, the destination block corresponding to the second source block is programmed a second time according to the second source block, wherein the second source block is the previous source block of the first source block; The target block corresponding to the third source block is programmed for the first time according to the third source block, and the third source block is marked, wherein the third source block is the next source block after the first source block; The target block corresponding to the first source block is programmed a second time based on the first source block.
6. The method according to claim 5, characterized in that, The first programming of the target block corresponding to the third source block based on the third source block includes: Identify multiple unprocessed third word lines in the third source block; The first programming of multiple third word lines is performed in the destination block corresponding to the third source block.
7. The method according to claim 1, characterized in that, The method further includes: In response to the fact that the number of marked source blocks is not less than a preset threshold, the target block corresponding to the previous source block of the latest marked source block is programmed a second time according to the previous source block of the latest marked source block; Based on the latest marked source block, the target block corresponding to the latest marked source block is programmed a second time; Release all the marked source blocks.
8. An electronic device, characterized in that, include: At least one processor; At least one memory for storing at least one program; The garbage collection method as described in any one of claims 1 to 7 is implemented when at least one of the programs is executed by at least one of the processors.
9. A computer-readable storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions are used to perform the waste recycling method as described in any one of claims 1 to 7.