Garbage collection method and device, storage medium and program product
By classifying the effective data in flash memory devices according to their popularity levels and separating primary garbage collection and delayed garbage collection operations, the write amplification problem is solved, improving the performance and lifespan of the storage system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIBABA CLOUD COMPUTING CO LTD
- Filing Date
- 2024-11-14
- Publication Date
- 2026-05-15
AI Technical Summary
In existing technologies, write amplification severely impacts storage system performance during garbage collection operations in flash memory devices, making it imperative to reduce write amplification a problem that needs to be addressed.
By classifying the valid data in the storage blocks according to their popularity level, the garbage collection operation is divided into two parts: primary garbage collection and delayed garbage collection. Data with higher popularity level is processed first, while data with lower popularity level is processed later and stored and managed separately.
It effectively reduces write amplification in storage systems, improving system performance and lifespan. Specific effects include a 6.7% to 14.5% reduction in write amplification in certain scenarios.
Smart Images

Figure CN122045075A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer storage technology, and in particular to a waste recycling method, device, storage medium and program product. Background Technology
[0002] Flash memory is a non-volatile storage medium. Zone namespace solid state drives (ZNS SSDs) are an example of applications that utilize flash memory technology. They improve the performance and durability of SSDs by dividing the internal structure of the SSD into multiple zones and implementing optimized data management strategies in these zones.
[0003] In one storage solution, when an SSD executes a write request, it does not directly overwrite existing data. Instead, it first writes the data to a new location and marks the old data as invalid. As the amount of invalid data increases, the SSD needs to perform garbage collection (GC) to free up space. During garbage collection, valid data in the storage zone to be garbage collected is moved to other storage zones, and the data in the storage zone to be garbage collected is erased.
[0004] During garbage collection (GC), migrating valid data generates additional internal write traffic, leading to increased write amplification in the storage system and impacting its performance. Therefore, reducing write amplification is a crucial issue that urgently needs to be addressed. Summary of the Invention
[0005] This application provides a method, apparatus, storage medium, and program product for garbage collection, which reduces write amplification in storage systems.
[0006] This application provides a garbage collection method, comprising: responding to a garbage collection trigger event; determining a first storage block in a target storage medium that requires garbage collection operation, the first storage block including valid data; dividing the valid data in the first storage block into first valid data and second valid data, wherein the popularity level of the first valid data is higher than that of the second valid data; performing a main garbage collection operation on the first valid data in the first storage block to invalidate the first valid data in the first storage block; and performing a delayed garbage collection operation on the second valid data in the accumulated first storage blocks when multiple first storage blocks have accumulated after the main garbage collection operation.
[0007] This application also provides an electronic device, including: a memory and a processor; the memory for storing a computer program; and the processor, coupled to the memory, for executing the computer program to implement the steps in the waste recycling method provided in this application.
[0008] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to implement the steps of the garbage collection method provided in this application.
[0009] This application also provides a computer program product, including a computer program / instructions, which, when executed by a processor, cause the processor to implement the steps in the garbage collection method provided in this application.
[0010] In this embodiment, the valid data in the storage blocks to be reclaimed is divided into popularity levels, and the garbage collection operation is divided into two parts: main garbage collection operation and delayed garbage collection operation. The main garbage collection operation prioritizes the migration of the first valid data with higher popularity level, while the delayed garbage collection operation migrates the second valid data with lower popularity level from the accumulated multiple storage blocks. Garbage collection is performed separately according to data popularity, which can reduce the real-time write amplification of the storage system.
[0011] Furthermore, by delaying garbage collection operations, data with lower frequency levels are migrated to separate storage blocks for unified storage management. Since the stored data has lower frequency, it helps to reduce the probability of these storage blocks being garbage collected, thereby reducing the write amplification problem of these storage blocks and thus reducing the write amplification problem of the entire storage system as a whole. Attached Figure Description
[0012] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0013] Figure 1 A schematic flowchart of a waste recycling method provided for an exemplary embodiment of this application;
[0014] Figure 2 A schematic diagram illustrating the execution of a primary garbage collection operation and a delayed garbage collection operation on a storage block, provided as an exemplary embodiment of this application;
[0015] Figure 3 A schematic diagram illustrating a process for performing a primary garbage collection operation and a delayed garbage collection operation, provided as an exemplary embodiment of this application;
[0016] Figure 4A schematic diagram of the structure of a waste recycling device provided for an exemplary embodiment of this application;
[0017] Figure 5 This is a schematic diagram of the structure of an electronic device provided as an exemplary embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0020] The various models involved in this application (including but not limited to language models or large models) comply with relevant laws and standards.
[0021] To address the aforementioned technical issues, hot and cold data separation is a method to reduce write amplification X1. By storing the first valid data with higher popularity (e.g., hot data) separately, the migration of the first valid data during garbage collection can be reduced, thereby reducing write amplification and improving system performance and lifespan. Besides separating the first valid data (e.g., hot data), another write amplification optimization method X2 is to store the second valid data (e.g., cold data) separately. Storing cold data separately refers to storing the second valid data with lower popularity by delaying garbage collection operations.
[0022] Specifically, in method X2, the garbage collection operation is divided into two parts: a main garbage collection operation and a delayed garbage collection operation, to store the second most valid data separately. The main garbage collection operation prioritizes processing the first most valid data with higher popularity, while the delayed garbage collection operation processes the second most valid data with lower popularity, reducing real-time write amplification. Furthermore, by storing data of different popularity levels separately through the main and delayed garbage collection operations, the first most valid data with higher popularity may become invalid before garbage collection, while the second most valid data with lower popularity is stored separately, reducing the probability of it being garbage collected and thus reducing write amplification overall.
[0023] The write amplification of the storage system is evaluated by constructing test cases. For example, the target storage medium in the test cases has 8TB of storage space, with 20GB used for hot data, 1000GB for frozen data, and the remaining space used for warm data. Warm data is data with a heat level lower than hot data but higher than frozen data. The garbage collection method provided in this application can produce the following effects:
[0024] a) When the effective data on the target storage medium equals 5800GB, the write amplification calculated using method X1 in the distributed storage system is 0.90, and the write amplification calculated using method X2 (which is the method mainly described in the embodiments of this application) is 0.84. The garbage collection method provided in this application can reduce the write amplification by 6.7%.
[0025] b. When the effective data on the target storage medium equals 6600GB, the write amplification of the distributed storage system calculated using method X1 is 1.17, and the write amplification calculated using method X2 is 1.00. The garbage collection method provided in this application can reduce write amplification by 14.5%.
[0026] It's important to note that write amplification is typically a value greater than or equal to 1. However, under certain optimization techniques and scenarios, write amplification can be less than 1. Here are some reasons why the calculated write amplification might be less than 1: data compression, deduplication, and write optimizations performed before writing data to storage blocks. Additionally, the calculation of write amplification varies between different storage systems and depends on the specific circumstances.
[0027] Therefore, adding the second valid data (frozen chunks) to a dedicated second storage block after garbage collection can significantly reduce write amplification. Support for separately storing frozen data needs to be added. The write amplification benefit is related to the proportion of the second valid data; the higher the proportion of the second valid data, the greater the write amplification benefit.
[0028] The following describes in detail a solution provided by an embodiment of this application, with reference to the accompanying drawings.
[0029] Figure 1 This is a schematic flowchart of a waste recycling method provided as an exemplary embodiment of this application. Figure 1 As shown, the method includes:
[0030] 101. In response to a garbage collection trigger event, determine the first storage block in the target storage medium that requires garbage collection operation. The first storage block includes valid data.
[0031] 102. Divide the valid data in the first storage block into first valid data and second valid data, with the popularity level of the first valid data being higher than that of the second valid data;
[0032] 103. Perform a main garbage collection operation on the first valid data in the first storage block to invalidate the first valid data in the first storage block;
[0033] 104. When multiple first storage blocks accumulate after the main garbage collection operation, a delayed garbage collection operation is performed on the second valid data in the multiple accumulated first storage blocks.
[0034] In this embodiment, the target storage medium can be any non-volatile storage medium. Target storage media include various types; for example, based on the different connection methods of the storage cells, target storage media are divided into NOR Flash and NAND Flash, among others. NAND Flash storage cells are relatively small, suitable for high-density integration, and can provide larger storage capacity, therefore they are widely used.
[0035] ZNS SSD is a type of solid-state drive based on NAND Flash. ZNS is a feature in the NVMe 2.0 technical specification. Its core idea is that persistent storage (such as SSDs) provides a zone access interface to replace the block device interface provided by traditional persistent storage (such as SSDs). ZNS introduces the concept of "partitions" on top of NVMe, also known as flash zones or storage blocks. Persistent storage is divided into different types of flash zones (or partitions), each consisting of multiple flash blocks or physical blocks. Flash blocks are sequentially appended storage resources and do not support in-place random updates. Once filled, a flash block enters read-only mode. To update a flash block, a complete data erase operation is required. Compared to traditional block device interface persistent storage (such as SSDs), ZNS simplifies the internal design and implementation of persistent storage. The data layout on the flash zones is implemented by the storage engine. Through the collaborative work of the storage engine and persistent storage, the overall write amplification factor of persistent storage is reduced, thus fully utilizing the characteristics of flash media.
[0036] In this embodiment, the application field of the target storage medium is not limited. For example, the target storage medium can be used in Elastic Block Storage (EBS) systems, which provide persistent and highly reliable block-level random storage for Elastic Compute Service (ECS) cloud servers. Currently, EBS storage systems can use ZNS SSDs to store data. Alternatively, the target storage medium can also be used in large-scale data storage scenarios of object storage systems, such as cloud storage services.
[0037] In this embodiment, the target storage medium is divided into multiple storage blocks. A storage block is a logical region on the target storage medium, and each storage block includes multiple physical blocks. The physical blocks within each storage block are contiguous, and each storage block is managed as a whole. Data is written to storage blocks in the order of the physical blocks, starting from the first physical block and continuing until the storage block is full. In one storage method, when updating data for storage block A, existing data is not directly overwritten. Instead, data is written to a new storage block B, and the corresponding data in the original storage block A is marked as invalid. After all data in storage block A is marked as invalid or garbage collected (GC), it can be rewritten. One implementation of storage blocks can be a zone in a ZNS SSD.
[0038] In this embodiment, the storage block includes valid data and invalid data. Invalid data refers to data that has been marked as invalid, usually due to data update or deletion operations. Invalid data is generally inaccessible to applications or other system components. Valid data refers to data that needs to be retained and can be accessed. Valid data can typically be read normally by applications or other system components; it is usually recently written data or data that has been updated but not yet overwritten. Figure 2 Examples of valid and invalid data are provided, but this is not the only example. Specifically, in... Figure 2 In the example shown, a storage block consists of 10 "squares," each representing a data segment. Figure 2 The illustration uses an example where each data block occupies 10% of the storage block, but it is not limited to this. For details regarding data blocks and data sub-blocks, please refer to the following examples.
[0039] In this embodiment, data in a storage block can be represented by data blocks. Data blocks are the division of large text into data blocks at the application, file system, and distributed storage system levels. The size of a data block is typically variable and can be adjusted according to application needs, while the size of the physical block or storage block is determined by the storage device. A data block can be written to one or more physical blocks. For example, multiple data blocks can be written to a storage block in parallel. After one storage block is full, the next storage block is written, and so on, until all data blocks are written to the storage block. Thus, each storage block includes at least one data sub-block corresponding to multiple data blocks, and the relationship between data blocks and storage blocks is many-to-many. For example, one implementation of a data block can be a chunk, and a data sub-block can be a sub-chunk.
[0040] In this embodiment, a garbage collection trigger event is an event that triggers a garbage collection operation on a target storage medium. A garbage collection trigger event can be a system event, an application event, or a user operation trigger, etc.
[0041] For example, a garbage collection trigger event can be implemented as a system event. A system event could be that the first space utilization rate of the target storage medium is higher than a set space utilization threshold, such as 70%, 75%, or 80%. Alternatively, a system event could be that the utilization rate of a storage block in the target storage medium is lower than a set block utilization threshold, such as 65%, 72%, or 79%.
[0042] For example, garbage collection trigger events are implemented as application events, which can be the application executing set business logic, application startup events, application switching from the background to the foreground events, etc.
[0043] For example, garbage collection trigger events can be implemented as user actions, which can include, but are not limited to, various interaction methods such as touch, gestures, voice, head movements, and eye movements. Touch actions include, but are not limited to, single-click, double-click, long-press, and swipe actions.
[0044] In this embodiment, in response to a garbage collection trigger event, a first storage block in the target storage medium that requires garbage collection is determined. This first storage block includes valid data. The implementation method for determining the first storage block in the target storage medium that requires garbage collection is not limited. An exemplary description follows.
[0045] For example, the storage block with the smallest amount of valid data is selected from the target storage medium as the first storage block to be garbage collected. Another example is selecting candidate storage blocks from the target storage medium whose amount of valid data exceeds a set data size threshold; then, the first storage block to be garbage collected is randomly selected from these candidate blocks.
[0046] The number of first storage blocks can be one or more, without limitation. For example, a garbage collection trigger event is implemented as follows: when the space utilization rate of the target storage medium is greater than a set utilization threshold, each garbage collection trigger event determines one first storage block, performs garbage collection on this first storage block, and continues to determine whether the space utilization rate of the target storage medium meets the set utilization threshold, until the space utilization rate of the target storage medium is less than or equal to the set utilization threshold. Alternatively, when the space utilization rate of the target storage medium is greater than the set utilization threshold, each garbage collection trigger event determines multiple first storage blocks. These multiple first storage blocks are determined based on the space utilization rate of the target storage medium, ensuring that garbage collection on these multiple storage blocks results in the space utilization rate of the target storage medium being less than or equal to the set utilization threshold.
[0047] In this embodiment, the valid data in the first storage block is divided into first valid data and second valid data, with the first valid data having a higher popularity level than the second valid data. The popularity level of data can be determined by the number of garbage collections; the more garbage collections, the higher the popularity level. Alternatively, the popularity level can also be determined by the access frequency; the higher the access frequency, the higher the popularity level. For example, popularity levels can include: hot data, warm data, cold data, and ice data. For instance, hot data refers to data with a very high access frequency, possibly with several read / write operations per second or minute; warm data has a medium access frequency, possibly with several read / write operations per day or week; cold data has a low access frequency, possibly with only one read / write operation every few months or years; and ice data has an extremely low access frequency, possibly with only one read / write operation every few years or even longer.
[0048] The popularity levels of the first and second valid data points are not limited. It is sufficient that the popularity level of the first valid data point is higher than that of the second valid data point. For example, the first valid data point could be hot or warm data, while the second valid data point could be cold or icy data. Another example is that the first valid data point is non-icy data, and the second valid data point is icy data.
[0049] In this embodiment, a main garbage collection operation is performed on the first valid data in the first storage block. The main garbage collection operation refers to the operation of prioritizing garbage collection on the first valid data in the first storage block. The main garbage collection operation may include: (1) migrating or copying the first valid data to other suitable storage blocks. Figure 2 The illustration is given by moving the first valid data to the third storage block G1, but it is not limited to this; (2) the first valid data is marked as invalid data in the first storage block.
[0050] Optionally, if the first storage block does not contain the second valid data, the main garbage collection operation further includes: (3) releasing the first storage block so that the first storage block can be rewritten with data.
[0051] Optionally, for the first storage block after the main garbage collection operation, if the first storage block contains second valid data, the first storage block can be marked as a storage block that needs to undergo delayed garbage collection. In this case, no new data is written to the storage block until the delayed garbage collection operation is completed.
[0052] In this embodiment, as the number of primary garbage collection operations increases, the first storage blocks after primary garbage collection operations can gradually accumulate. When multiple first storage blocks accumulate, delayed garbage collection operations are performed on the second valid data within these accumulated first storage blocks. By delaying garbage collection, the second valid data with lower priority among the accumulated storage blocks is migrated, and garbage collection is performed separately according to data priority to reduce real-time write amplification of the storage system. Specifically, the first storage blocks after primary garbage collection operations can be added to a processing queue, where they are gradually accumulated. For example, the number of accumulated first storage blocks can be 2, 5, or 8, etc.
[0053] Optionally, an implementation of delayed garbage collection for second valid data accumulated in multiple first storage blocks includes: migrating the second valid data from the multiple first storage blocks to at least one second storage block, wherein the at least one second storage block is dedicated to storing the second valid data. By delaying garbage collection, data with lower activity levels is centrally migrated to separate storage blocks for unified storage management. Due to the lower data activity, this reduces the probability of these storage blocks being garbage collected, thereby reducing write amplification issues in these storage blocks and ultimately reducing write amplification issues across the entire storage system.
[0054] The number of first and second storage blocks is not limited. For example, if the number of first storage blocks is 2, the number of second storage blocks can be 1; if the number of first storage blocks is 5, the number of second storage blocks can be 1, 2, 3, or 4, etc. Figure 2 The illustration uses four first storage blocks as an example: storage block E1, storage block E2, storage block E4, and storage block E5. Storage block E3 is the first storage block that did not undergo delayed garbage collection after the main garbage collection operation. Figure 2 The illustration uses an example where the number of second storage blocks is 1 and the second storage block is F1, but it is not limited to this.
[0055] Considering that if the first and second valid data are migrated to the same storage block through garbage collection, a large amount of the second valid data needs to be moved each time garbage collection occurs, even if few read and write operations are performed on the second valid data, resulting in higher write amplification. Therefore, at least one second storage block is dedicated to storing the second valid data, separating the first and second valid data. In subsequent processes, the second valid data has a lower probability of being garbage collected, while the first valid data may become invalid before garbage collection, eliminating the need for garbage collection on the first valid data. This reduces write amplification overall in subsequent processes.
[0056] Delayed garbage collection refers to performing garbage collection operations on the second valid data in multiple first storage blocks after the main garbage collection operation. "Delayed" can be understood as the garbage collection operation on the second valid data in the same storage block being later than the garbage collection operation on the first valid data. Delaying garbage collection on the second valid data can reduce real-time write amplification.
[0057] The delayed garbage collection operation may include: (1) migrating the second valid data in the first storage block after the main garbage collection operation to the second storage block; and (2) releasing the first storage block.
[0058] In this embodiment, valid data in the storage blocks to be reclaimed is classified by popularity level, and the garbage collection operation is divided into two parts: a primary garbage collection operation and a delayed garbage collection operation. The primary garbage collection operation prioritizes migrating the first valid data with a higher popularity level, while the delayed garbage collection operation migrates the second valid data with a lower popularity level from the accumulated storage blocks. This separation of garbage collection based on data popularity reduces real-time write amplification in the storage system. Furthermore, the delayed garbage collection operation centrally migrates data with lower popularity levels to separate storage blocks for unified storage management. Since the stored data has lower popularity, this reduces the probability of these storage blocks being garbage collected, thus reducing write amplification issues in these blocks and consequently reducing the overall write amplification problem of the entire storage system.
[0059] In this embodiment, the implementation of delayed garbage collection is not limited to the case where multiple first storage blocks are accumulated after the main garbage collection operation, and the second valid data in the accumulated multiple first storage blocks is executed.
[0060] In one optional embodiment, a cumulative quantity threshold is set, which can be 2, 5, or 15, etc., and is not limited thereto. If the number of first storage blocks after the main garbage collection operation reaches the cumulative quantity threshold, a delayed garbage collection operation is performed on the second valid data in the first storage blocks up to the cumulative quantity threshold.
[0061] In another optional embodiment, considering that the first storage block after the main garbage collection operation is an accumulating process and the number of accumulated first storage blocks is dynamically changing, reasonable execution trigger conditions are set for the delayed garbage collection operation. Based on these trigger conditions, some or all of the accumulated first storage blocks are selected for delayed garbage collection. After the delayed garbage collection operation, the number of accumulated first storage blocks decreases. If no first storage block that meets the execution trigger conditions is found after the decrease in the number of first storage blocks, accumulation can continue until some or all of the first storage blocks meet the execution trigger conditions, at which point the delayed garbage collection operation is performed.
[0062] Based on this, an implementation method for performing delayed garbage collection on second valid data in the accumulated first storage blocks when multiple first storage blocks are accumulated after the main garbage collection operation includes: accumulating the first storage blocks after the main garbage collection operation to obtain multiple first storage blocks; selecting at least two first storage blocks that meet the execution triggering conditions in batches from the multiple first storage blocks, wherein the at least two first storage blocks are some or all of the multiple first storage blocks; and performing delayed garbage collection on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
[0063] In this context, batch selection means selecting at least two first storage blocks that meet the execution triggering conditions in each batch. Since the first storage blocks after the main garbage collection operation are dynamically changing, in the next batch, at least two first storage blocks can continue to be selected from the accumulated multiple first storage blocks.
[0064] Optionally, the trigger condition is that the difference between the number of first storage blocks released and the number of second storage blocks consumed during the delayed garbage collection operation is greater than or equal to a number K, where K ≥ 1 and is a positive integer. That is, performing the delayed garbage collection operation results in space gain, as free storage blocks can be obtained for subsequent read and write operations, thereby improving the space utilization of the target storage medium.
[0065] Optionally, one implementation of accumulating the first storage block after performing the main garbage collection operation to obtain multiple first storage blocks may be to accumulate the first storage block after performing the main garbage collection operation according to a quantity K, so as to accumulate at least K first storage blocks, so as to facilitate subsequent determination of whether a target block group exists.
[0066] Optionally, an implementation method for selecting at least two first storage blocks that satisfy the execution triggering condition from a plurality of first storage blocks includes: determining whether a target block group exists among the plurality of first storage blocks based on the amount of valid data in the plurality of first storage blocks; wherein the target block group includes at least two currently accumulated first storage blocks, and a first number of second storage blocks required to perform delayed garbage collection operations on the second valid data in the at least two first storage blocks is less than a second number of at least two first storage blocks, for example, the difference between the first number and the second number is greater than or equal to a number K, K≥1, and is a positive integer; if a target block group exists, the first storage blocks in the target block group are selected as the at least two first storage blocks that satisfy the execution triggering condition.
[0067] Optionally, if no target block group exists, the first storage blocks continue to accumulate until a target block group is obtained. The first storage blocks in the target block group are then used as at least two first storage blocks that satisfy the execution triggering condition. This process continuously checks whether the target block group exists among the accumulated first storage blocks to adapt to dynamic changes in the first storage blocks, improving the flexibility of performing delayed garbage collection operations.
[0068] The method for determining whether a target block group exists in multiple first storage blocks based on the amount of valid data in multiple first storage blocks is not limited.
[0069] For example, multiple first storage blocks can be combined to obtain multiple candidate block groups, and any candidate block group includes at least two candidate first storage blocks; for any candidate block group, a first number of second storage blocks required to perform delayed garbage collection operations on the second valid data in the at least two candidate first storage blocks, and a second number of at least two candidate first storage blocks are determined; if the first number is less than the second number, then any candidate block group is taken as the target block group.
[0070] For example, based on the order of the amount of data (including second valid data) in multiple first storage blocks from smallest to largest, two candidate first storage blocks are selected; the first number of storage blocks required after performing delayed garbage collection on these two candidate first storage blocks is predicted; if this first number is less than 2, the two candidate first storage blocks are selected as the two first storage blocks that meet the execution triggering condition. If the first number is equal to 2, a third candidate storage block is selected; the first number of storage blocks required after performing delayed garbage collection on these three candidate first storage blocks is predicted; if this first number is less than 3, the three candidate first storage blocks are selected as the three first storage blocks that meet the execution triggering condition. If the first number is equal to 3, a fourth candidate storage block is selected, and so on, until at least two first storage blocks meet the execution triggering condition, or until the number of selected storage blocks is greater than 15, at which point two candidate first storage blocks are selected again. The main garbage collection operation and the delayed garbage collection operation are two relatively decoupled processes. During the process of determining multiple first storage blocks that meet the execution triggering conditions, the main garbage collection operation can also be continuously executed, and the number of first storage blocks that need to perform delayed garbage collection operations is also continuously increasing. Therefore, candidate first storage blocks can be selected from the increased first storage blocks to determine whether multiple candidate first storage blocks meet the execution triggering conditions.
[0071] It should be noted that the event that triggers the determination of whether multiple first storage blocks meet the execution triggering condition is not limited. For example, it can be a periodic event, such as checking whether multiple first storage blocks meet the execution triggering condition at set intervals, for example, the set interval could be 120s, 60s, or 10s, etc., without limitation. Another example is that the determination of whether multiple first storage blocks meet the execution triggering condition can be made when the number of first storage blocks performing the main garbage collection operation accumulates to a set threshold, where the threshold could be 2, 5, or 15, etc.
[0072] Optionally, if multiple first storage blocks meet the execution triggering conditions, a delayed garbage collection operation can be performed directly, or a delayed execution time can be set, and the delayed garbage collection operation can be performed when the delayed execution time arrives.
[0073] Further optionally, based on the number of at least two first storage blocks, a delayed execution time corresponding to at least two first storage blocks is determined; when the delayed time arrives, a delayed garbage collection operation is performed on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
[0074] Optionally, based on the effective data volume of at least two first storage blocks, predict the first write amplification information corresponding to the delayed garbage collection operation performed on the second effective data in the at least two first storage blocks; if the first write amplification information meets the set write amplification conditions, determine the delayed execution time corresponding to the at least two first storage blocks based on the number of at least two first storage blocks; when the delayed time arrives, perform the delayed garbage collection operation on the second effective data in the at least two first storage blocks to release the at least two first storage blocks. This method can effectively balance the performance and durability of the target storage medium, especially in application scenarios with frequent data writes and deletions. By reasonably arranging the timing of the delayed garbage collection operation, write amplification can be significantly reduced, and the read and write efficiency of the storage system can be improved.
[0075] Optionally, if the first write amplification information corresponding to the delayed garbage collection operation does not meet the set write amplification conditions, it means that directly performing the delayed garbage collection operation may be more advantageous, which can avoid unnecessary data migration and write amplification, thereby protecting the lifespan of the target storage medium and maintaining a high performance level. In this case, there is no need to delay the execution time, and the delayed garbage collection operation is directly performed on the second valid data in at least two first storage blocks to release at least two first storage blocks.
[0076] The implementation method for determining the delayed execution time corresponding to at least two first storage blocks based on the number of at least two first storage blocks is not limited. The more at least two first storage blocks there are, the later the delayed execution time. For example, the delayed execution time for 5 first storage blocks is 5 minutes, and the delayed execution time for 10 first storage blocks is 30 minutes. For example, the delayed execution time for at least two first storage blocks can be determined using a non-linearly increasing function based on the number of at least two first storage blocks. The non-linearly increasing function grows at an increasingly faster rate. The non-linearly increasing function can be an exponential function or a polynomial function, etc.
[0077] The setting of write amplification conditions is not limited. In one optional embodiment, the write amplification condition can be that the first write amplification information is greater than a set write amplification threshold. To prevent real-time write amplification from increasing further, in this case, a delay execution time for at least two first storage blocks is determined based on the number of at least two first storage blocks. When the delay time is reached, a delayed garbage collection operation is performed on the second valid data in the at least two first storage blocks to release the at least two first storage blocks and reduce real-time write amplification. If the first write amplification information is less than or equal to the set write amplification threshold, no delay execution time is set, and a delayed garbage collection operation is directly performed on the second valid data in the at least two first storage blocks to release the at least two first storage blocks, improving the execution efficiency of the delayed garbage collection operation. The setting of write amplification conditions allows for flexible determination of whether to set a delay execution time for the delayed garbage collection operation to reduce real-time write amplification.
[0078] The write amplification threshold can be set based on the statistical information of write amplification in the main garbage collection operation. For example, the write amplification threshold can be set based on the average write amplification, maximum write amplification, minimum write amplification, and median write amplification information of the main garbage collection engine.
[0079] In one optional embodiment, setting the write amplification condition is related to the real-time write amplification information of the currently executing main garbage collection operation. This allows for a more accurate determination of whether to set a delay execution time for delayed garbage collection operations, thereby reducing real-time write amplification. Specifically, based on the effective data volume of the first storage block of the currently executing main garbage collection operation, real-time write amplification information of the main garbage collection operation is generated as second write amplification information. If the first write amplification information is greater than the second write amplification information, then it is determined that the first write amplification information satisfies the set write amplification condition.
[0080] The primary garbage collection operation and the delayed garbage collection operation are decoupled. Garbage collection operations are continuously executed when the garbage collection trigger event is met. The currently executing primary garbage collection operation refers to the primary garbage collection operation that is being executed after determining that the delayed garbage collection operation has met its execution trigger condition. The effective data volume of the first storage block in the currently executing primary garbage collection operation can include both first and second effective data.
[0081] Optionally, if the first write amplification information is less than or equal to the second write amplification information, it means that the write amplification generated by performing the delayed garbage collection operation will not significantly improve the real-time write amplification. In this case, it is determined that the first write amplification information corresponding to the delayed garbage collection operation does not meet the set write amplification condition. There is no need to determine the delayed execution time. Instead, the delayed garbage collection operation is directly performed on the second valid data in at least two first storage blocks to release at least two first storage blocks and improve the execution efficiency of the delayed garbage collection operation.
[0082] The write amplification information is calculated as follows: (user write data volume + target storage medium internal write data volume) / user write data volume, where " / " represents a division operation.
[0083] An implementation method for generating second write amplification information for a main garbage collection operation based on the effective data volume of the first storage block of the currently executing main garbage collection operation includes: representing the user write data volume and the main memory reclamation write data volume as a whole with "1", and taking the effective data volume of the first storage block of the currently executing main garbage collection operation as the main memory reclamation write data volume, wherein the effective data volume is represented as a%, then the second write amplification information can be represented as: ( in, This indicates rounding down. The amount of write data within the target storage medium includes write data generated by garbage collection operations and write data from other operations. The amount of write data generated by the garbage collection operation refers to the amount of data used to migrate valid data from the first storage block currently being processed.
[0084] An implementation method for generating first write amplification information for a delayed garbage collection operation based on the effective data volume of multiple first storage blocks includes: representing the user write data volume and the delayed memory reclamation write data volume as a whole with "1", and using the write data volume of the delayed garbage collection operation as the delayed memory reclamation write data volume, wherein the write data volume is represented as less than or equal to M, wherein the number of multiple first storage blocks that meet the execution triggering condition is N, M is the number of second storage blocks, N > M, and N and M are positive integers, then the first write amplification information can be represented as: ( When M is N-1, the second amplified information is N. Wherein, This indicates rounding up. The amount of data written within the target storage medium includes the amount of data written during delayed garbage collection operations and the amount of data written during other operations.
[0085] Considering that the first amplification information is rounded up during the calculation process and the second amplification information is rounded down during the calculation process, when comparing the first amplification information and the second amplification information, the first amplification information can be subtracted by 1 before calculating the difference with the second amplification information.
[0086] In one alternative embodiment, the implementation of performing delayed garbage collection on second valid data in at least two first storage blocks to release at least two first storage blocks is not limited. An example is described below.
[0087] One implementation is as follows: based on the amount of data in at least two first storage blocks that meet the execution triggering condition, determine a third number of storage blocks for storing the second valid data in the at least two first storage blocks, the third number being less than or equal to the number of the at least two first storage blocks; select the third number of candidate storage blocks from the target storage medium as second storage blocks; migrate the second valid data in the multiple first storage blocks to the third number of second storage blocks, and release the multiple first storage blocks.
[0088] Another approach is to consider that multiple data blocks within the same data block have the same level of popularity. Therefore, the data blocks belonging to the same data block can be added to the same storage block. In subsequent processes, if the data block fails, the storage block containing the data block can be released directly without garbage collection, thereby reducing write amplification as a whole.
[0089] Specifically, for any data block of second valid data in at least two first storage blocks, other data blocks belonging to the same data block as any data block are obtained from other first storage blocks; the any data block and other data blocks are migrated to the same second storage block, wherein the other first storage blocks are storage blocks other than at least two first storage blocks among a plurality of first storage blocks.
[0090] In one optional embodiment, during garbage collection, the space occupancy rate of the target storage medium can be monitored. When the space occupancy rate of the storage medium approaches or reaches a threshold, priority is given to how to release more storage space to prevent the storage space from being completely exhausted and to reduce the probability of system crashes or a sharp drop in performance. Therefore, when the space occupancy rate of the target storage medium is detected to be greater than or equal to the set space occupancy rate threshold, the execution trigger condition is turned off, and a target storage block is selected from the currently existing first storage block, for example, a target storage block that can quickly release storage space. Delayed garbage collection is performed on the second valid data in the target storage block to efficiently release storage space and more flexibly cope with different workloads and storage needs.
[0091] The second space utilization threshold can be 90%, 95%, or 98%, etc. The implementation method for selecting the target storage block from the existing first storage blocks is not limited. For example, the first storage block with the least amount of effective data can be selected as the target storage block from the existing first storage blocks. Another example is selecting candidate first storage blocks with an effective data volume less than a set threshold from the existing first storage blocks, and then randomly selecting candidate storage blocks as the target storage block. By selecting storage blocks with a lower proportion of effective data for delayed garbage collection, space can be released more efficiently, unnecessary data migration can be reduced, and thus the allocation of storage resources can be optimized.
[0092] In one optional embodiment, an implementation method for dividing valid data in a first storage block into first valid data and second valid data includes: determining the popularity level of each data block in the first storage block based on the target number of garbage collections for each data block in the first storage block, wherein the number of garbage collections is directly proportional to the popularity level; designating data blocks with a popularity level higher than or equal to a set popularity level threshold as first valid data in the first storage block; and designating data blocks with a popularity level lower than the set popularity level threshold as second valid data in the first storage block.
[0093] For example, if the number of garbage collections does not exceed a set threshold (e.g., 3 times), the data block's popularity level is set to the first popularity level; if the number of garbage collections exceeds the threshold (e.g., 3 times), the data block's popularity level is set to the second popularity level. Data blocks of the first popularity level are considered the first valid data, and data blocks of the second popularity level are considered the second valid data. This popularity-level division of valid data within the first storage block facilitates targeted execution of primary and delayed garbage collection operations, while storing the second valid data separately reduces overall write amplification.
[0094] Optionally, the implementation method for determining the target number of garbage collections for a data block includes: counting the initial number of garbage collections for each data block in the first storage block; and performing numerical calculations on the initial number of garbage collections for each data block belonging to the same data block to obtain the target number of garbage collections for each data block belonging to the same data block.
[0095] Each storage block maintains metadata that records the initial garbage collection count for each data block. Numerical calculations can be performed by averaging the initial garbage collection counts for each data block within the same data block to obtain the target garbage collection count for that data block.
[0096] In one optional embodiment, the executing entities for the main garbage collection operation and the delayed garbage collection operation are not limited. For example, the same garbage collection engine (such as the main garbage collection engine) may execute the main garbage collection operation and the delayed garbage collection operation at different times. Alternatively, the main garbage collection operation and the delayed garbage collection operation may be executed by different garbage collection engines. For instance, a delayed garbage collection engine may be added on top of the main garbage collection engine, with the main garbage collection operation implemented by the main garbage collection (main GC) engine and the delayed garbage collection operation implemented by the delayed garbage collection (Aged GC) engine.
[0097] The main GC engine and the Aged GC engine can run independently and in parallel, better adapting to different workloads and needs. For example, the main GC engine can focus on garbage collection of the first valid data with high popularity, while the Aged GC engine can perform batch processing on the second valid data with lower popularity, improving garbage collection efficiency.
[0098] The following provides an illustrative example of the processes by which the main GC engine and the Aged GC engine perform main garbage collection operations and delayed garbage collection operations, respectively. Figure 3 As shown.
[0099] Main GC engine:
[0100] 31. In response to a garbage collection trigger event, determine the first storage block in the target storage medium that requires garbage collection operation;
[0101] 32. Divide the valid data in the first storage block into first valid data and second valid data;
[0102] 33. Perform a main garbage collection operation on the first valid data in the first storage block;
[0103] Aged GC engine:
[0104] 34. Multiple first storage blocks accumulated after the main garbage collection operation;
[0105] 35. Determine whether the target block group exists among the accumulated first storage blocks; if the target block group does not exist, continue accumulating first storage blocks and return to step 34;
[0106] 36. If a target block group exists, the first storage block in the target block group shall be used as at least two first storage blocks that satisfy the execution triggering condition;
[0107] 37. Determine whether the first write amplification information of the delayed garbage collection operation meets the write amplification condition;
[0108] 38. If the write amplification condition is met, then determine the delay execution time of at least two first storage blocks based on the number of at least two first storage blocks;
[0109] 39. When the delay time arrives, perform a delayed garbage collection operation on the second valid data in at least two first storage blocks to release at least two first storage blocks;
[0110] 40. If the write amplification condition is not met, perform delayed garbage collection on the second valid data in at least two first storage blocks to release at least two first storage blocks.
[0111] In one optional embodiment, to prevent data from becoming corrupted or lost due to long-term storage, data needs to be migrated periodically. For example, the metadata of the storage block maintains the write duration of each valid data in the storage block. If there is valid data whose write duration exceeds a set duration threshold (e.g., 7 days, 15 days, or 60 days), the Aged GC engine will migrate the valid data.
[0112] Optionally, if the amount of valid data whose writing time exceeds the set duration threshold is less than the set data volume threshold, a portion of the valid data is migrated at set time intervals (e.g., 2 minutes or 5 minutes). If the amount of valid data whose writing time exceeds the set duration threshold is less than the set data volume threshold, migration of a portion of the valid data is performed directly without adhering to the set time intervals, thereby improving data migration speed.
[0113] Regarding the embodiments provided in this application Figure 1 The detailed implementation methods and beneficial effects of each step in the method shown have been described in detail in the foregoing embodiments, and will not be elaborated here.
[0114] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 101 to 103 can be device A; or the execution subject of steps 101 and 102 can be device A, and the execution subject of step 103 can be device B; and so on.
[0115] Furthermore, some processes described in the above embodiments and accompanying drawings include multiple operations appearing in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 101, 102, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.
[0116] Figure 4 A schematic diagram of a waste recycling device provided as an exemplary embodiment of this application is shown below. Figure 4 As shown, the device includes: a determination module 41, a partitioning module 42, a main garbage collection module 43, and a delayed garbage collection module 44.
[0117] The determination module 41 is used to respond to a garbage collection trigger event and determine the first storage block in the target storage medium that needs to be garbage collected. The first storage block includes valid data.
[0118] The partitioning module 42 is used to divide the valid data in the first storage block into first valid data and second valid data, wherein the popularity level of the first valid data is higher than that of the second valid data.
[0119] The main garbage collection module 43 is used to perform a main garbage collection operation on the first valid data in the first storage block, so as to make the first valid data in the first storage block invalid data;
[0120] The delayed garbage collection module 44 is used to perform delayed garbage collection operations on the second valid data in the accumulated first storage blocks when multiple first storage blocks are accumulated after the main garbage collection operation.
[0121] In an optional embodiment, the delayed garbage collection module 44 is specifically used to: migrate second valid data from a plurality of first storage blocks to at least one second storage block, wherein the at least one second storage block is dedicated to storing the second valid data.
[0122] In an optional embodiment, the delayed garbage collection operation corresponds to an execution trigger condition. The delayed garbage collection module 44 is specifically used to: select at least two first storage blocks that meet the execution trigger condition in batches from a plurality of first storage blocks, wherein the at least two first storage blocks are part or all of the plurality of first storage blocks; and perform a delayed garbage collection operation on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
[0123] Optionally, the trigger condition is that the difference between the number of first storage blocks released and the number of second storage blocks consumed during the delayed garbage collection operation is greater than or equal to a number K, where K ≥ 1 and is a positive integer.
[0124] Optionally, the delayed garbage collection module 44 is specifically used to: determine whether a target block group exists in the multiple first storage blocks based on the amount of valid data in the multiple first storage blocks; the target block group includes at least two currently accumulated first storage blocks, and the number of second storage blocks required to perform delayed garbage collection operations on the second valid data in the at least two first storage blocks is less than the number of at least two first storage blocks; if a target block group exists, the first storage blocks in the target block group are used as at least two first storage blocks that meet the execution triggering conditions.
[0125] Alternatively, if no target block group exists, the first storage blocks continue to accumulate until a target block group is obtained, and the first storage blocks in the target block group are used as at least two first storage blocks that satisfy the execution triggering condition.
[0126] Optionally, the delayed garbage collection module 44 is specifically configured to: predict the first write amplification information corresponding to the delayed garbage collection operation performed on the second valid data in the at least two first storage blocks based on the effective data amount of the at least two first storage blocks; if the first write amplification information meets the set write amplification conditions, determine the delayed execution time corresponding to the at least two first storage blocks based on the number of the at least two first storage blocks; and when the delayed time arrives, perform the delayed garbage collection operation on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
[0127] Further optionally, the delayed garbage collection module 44 is also configured to: predict the second write amplification information corresponding to the main garbage collection operation based on the effective data volume of the first storage block of the currently executing main garbage collection operation; if the first write amplification information is greater than the second write amplification information, then determine that the first write amplification information meets the set write amplification conditions.
[0128] Further optionally, the delayed garbage collection module 44 is also configured to: if the first write amplification information is less than or equal to the second write amplification information, then directly perform a delayed garbage collection operation on the second valid data in at least two first storage blocks to release at least two first storage blocks.
[0129] In an optional embodiment, the delayed garbage collection module 44 is specifically used to: for any data block of second valid data in at least two first storage blocks, obtain other data blocks belonging to the same data block from other first storage blocks; migrate any data block and other data blocks to the same second storage block, wherein the other first storage blocks are storage blocks other than at least two first storage blocks among a plurality of first storage blocks.
[0130] In an optional embodiment, the delayed garbage collection module 44 is further configured to: disable the execution trigger condition and select a target storage block from the currently existing first storage block when the space occupancy rate of the target storage medium is detected to be greater than or equal to a set space occupancy rate threshold; and perform delayed garbage collection operation on the second valid data in the target storage block.
[0131] Further optionally, the partitioning module is specifically used to: determine the heat level of each data block in the first storage block according to the target number of garbage collections for each data block in the first storage block, wherein the number of garbage collections is directly proportional to the heat level; designate data blocks with a heat level higher than or equal to a set heat level threshold as the first valid data in the first storage block; and designate data blocks with a heat level lower than the set heat level threshold as the second valid data in the first storage block.
[0132] Optionally, the partitioning module is also used to: count the initial garbage collection counts for each data block in the first storage block;
[0133] The initial number of garbage collections for each data block belonging to the same data block is numerically calculated to obtain the target number of garbage collections for each data block belonging to the same data block.
[0134] Regarding the embodiments provided in this application Figure 4 The detailed implementation methods and beneficial effects of each step in the apparatus shown have been described in detail in the foregoing embodiments, and will not be elaborated here.
[0135] Figure 5 A schematic diagram of the structure of an electronic device provided as an exemplary embodiment of this application, such as... Figure 5 As shown, the device includes a memory 54 and a processor 55.
[0136] Memory 54 is used to store computer programs and can be configured to store various other data to support operation on the electronic device. Examples of this data include instructions for any application or method used to operate on the electronic device.
[0137] The processor 55, coupled to the memory 54, is used to execute a computer program in the memory 54 for: responding to a garbage collection trigger event; determining a first storage block in the target storage medium that requires garbage collection, the first storage block including valid data; dividing the valid data in the first storage block into first valid data and second valid data, the first valid data having a higher popularity level than the second valid data; performing a main garbage collection operation on the first valid data in the first storage block to invalidate the first valid data in the first storage block; and, if multiple first storage blocks accumulate after the main garbage collection operation, performing a delayed garbage collection operation on the second valid data in the accumulated multiple first storage blocks.
[0138] In an optional embodiment, when the processor 55 performs a delayed garbage collection operation on the second valid data accumulated in a plurality of first storage blocks, it is specifically configured to: migrate the second valid data in the plurality of first storage blocks to at least one second storage block, wherein the at least one second storage block is dedicated to storing the second valid data.
[0139] In an optional embodiment, the delayed garbage collection operation corresponds to an execution trigger condition. When the processor 55 performs the delayed garbage collection operation on the second valid data in the accumulated plurality of first storage blocks, it is specifically used to: select at least two first storage blocks that meet the execution trigger condition in batches from the plurality of first storage blocks, wherein the at least two first storage blocks are some or all of the plurality of first storage blocks; and perform the delayed garbage collection operation on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
[0140] Optionally, the trigger condition is that the difference between the number of first storage blocks released and the number of second storage blocks consumed during the delayed garbage collection operation is greater than or equal to a number K, where K ≥ 1 and is a positive integer.
[0141] Optionally, when the processor 55 selects at least two first storage blocks that satisfy the execution triggering condition from a plurality of first storage blocks, it specifically performs the following: based on the amount of valid data in the plurality of first storage blocks, it determines whether a target block group exists in the plurality of first storage blocks; the target block group includes at least two currently accumulated first storage blocks, and the number of second storage blocks required to perform delayed garbage collection operations on the second valid data in the at least two first storage blocks is less than the number of at least two first storage blocks; if a target block group exists, the first storage blocks in the target block group are selected as at least two first storage blocks that satisfy the execution triggering condition.
[0142] Further optionally, the processor 55 is also configured to continue accumulating the first storage blocks until the target block group is obtained if the target block group does not exist, and to use the first storage blocks in the target block group as at least two first storage blocks that satisfy the execution triggering condition.
[0143] Optionally, when the processor 55 performs a delayed garbage collection operation on the second valid data in at least two first storage blocks to release at least two first storage blocks, it specifically performs the following: predicts first write amplification information corresponding to the delayed garbage collection operation on the second valid data in at least two first storage blocks based on the amount of valid data in the at least two first storage blocks; if the first write amplification information satisfies the set write amplification condition, determines the delayed execution time corresponding to the at least two first storage blocks based on the number of at least two first storage blocks; and when the delayed time arrives, performs a delayed garbage collection operation on the second valid data in the at least two first storage blocks to release at least two first storage blocks.
[0144] Further optionally, the processor 55 is also configured to: predict the second write amplification information corresponding to the main garbage collection operation based on the effective data amount of the first storage block of the currently executing main garbage collection operation; and determine that the first write amplification information satisfies the set write amplification condition if the first write amplification information is greater than the second write amplification information.
[0145] In an optional embodiment, the processor 55 is further configured to: if the first write amplification information is less than or equal to the second write amplification information, perform a delayed garbage collection operation directly on the second valid data in at least two first storage blocks to release at least two first storage blocks.
[0146] In an optional embodiment, when the processor 55 performs a delayed garbage collection operation on second valid data in at least two first storage blocks to release at least two first storage blocks, it specifically performs the following: for any data block of the second valid data in at least two first storage blocks, it obtains other data blocks belonging to the same data block from other first storage blocks; and migrates the any data block and other data blocks to the same second storage block, wherein the other first storage blocks are storage blocks other than at least two first storage blocks among a plurality of first storage blocks.
[0147] In an optional embodiment, the processor 55 is further configured to: disable the execution trigger condition and select a target storage block from the currently existing first storage block when the space occupancy rate of the target storage medium is detected to be greater than or equal to a set space occupancy rate threshold; and perform a delayed garbage collection operation on the second valid data in the target storage block.
[0148] In an optional embodiment, when the processor 55 divides the valid data in the first storage block into first valid data and second valid data, it specifically performs the following: determining the heat level of each data block in the first storage block based on the target number of garbage collections for each data block in the first storage block, wherein the number of garbage collections is directly proportional to the heat level; designating data blocks with a heat level higher than or equal to a set heat level threshold as first valid data in the first storage block; and designating data blocks with a heat level lower than the set heat level threshold as second valid data in the first storage block.
[0149] Optionally, the processor 55 is further configured to: count the initial garbage collection counts of each data block in the first storage block; and perform numerical calculations on the initial garbage collection counts of each data block belonging to the same data block to obtain the target garbage collection counts of each data block belonging to the same data block.
[0150] Regarding the embodiments provided in this application Figure 5 The detailed implementation methods and beneficial effects of each step in the device shown have been described in detail in the foregoing embodiments, and will not be elaborated here.
[0151] Furthermore, such as Figure 5 As shown, the electronic device also includes other components such as a communication component 56, a display 57, a power supply component 58, and an audio component 59. Figure 5 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 5 The components shown. Additionally... Figure 5 The components within the dashed box are optional, not mandatory, and their specific requirements depend on the product form of the electronic device. The electronic device in this embodiment can be a desktop computer, laptop computer, smartphone, IoT (Internet of Things) device, or smart wearable device (such as a smartwatch or smart bracelet), or a server-side device such as a conventional server, cloud server, or server array. If the electronic device in this embodiment is a desktop computer, laptop computer, smartphone, or other terminal device, it may include... Figure 5 The components within the dashed box; if the electronic device in this embodiment is implemented as a conventional server, cloud server, or server array, etc., it may be omitted. Figure 5 The component within the dashed box.
[0152] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed, can perform the above-described functions. Figure 1 The steps in the method embodiment shown can be performed by an electronic device.
[0153] Accordingly, embodiments of this application also provide a computer program product, including a computer program / instructions, which, when executed by a processor, cause the processor to perform the above-described... Figure 1 The steps in the method embodiment shown can be performed by an electronic device.
[0154] The aforementioned memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0155] The aforementioned communication components are configured to facilitate wired or wireless communication between the device containing the communication components and other devices. The device containing the communication components can access wireless networks based on communication standards, such as WiFi, 2G, 3G, 4G / LTE, 5G, or combinations thereof. In one exemplary embodiment, the communication components receive broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication components also include a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth (BT), and other technologies.
[0156] The aforementioned display includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen can be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.
[0157] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.
[0158] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.
[0159] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, compact disc read-only memory (CD-ROM), optical storage, etc.) containing computer-usable program code.
[0160] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0161] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0162] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0163] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.
[0164] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0165] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, Digital Video Disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0166] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0167] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A waste recycling method, characterized in that, include: In response to a garbage collection trigger event, determine the first storage block in the target storage medium that requires garbage collection, wherein the first storage block includes valid data; The valid data in the first storage block is divided into first valid data and second valid data, and the popularity level of the first valid data is higher than that of the second valid data. A primary garbage collection operation is performed on the first valid data in the first storage block to invalidate the first valid data in the first storage block. If multiple first storage blocks accumulate after the main garbage collection operation, a delayed garbage collection operation is performed on the second valid data in the multiple accumulated first storage blocks.
2. The method according to claim 1, characterized in that, Perform delayed garbage collection operations on the second valid data in multiple accumulated first storage blocks, including: The second valid data in the plurality of first storage blocks is migrated to at least one second storage block, the at least one second storage block being dedicated to storing the second valid data.
3. The method according to claim 2, characterized in that, The delayed garbage collection operation corresponds to an execution trigger condition. Therefore, the delayed garbage collection operation is performed on the second valid data in the accumulated multiple first storage blocks, including: From the plurality of first storage blocks, at least two first storage blocks that satisfy the execution triggering condition are selected in batches, wherein the at least two first storage blocks are some or all of the plurality of first storage blocks; Perform a delayed garbage collection operation on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
4. The method according to claim 3, characterized in that, The execution trigger condition is that the difference between the number of first storage blocks released and the number of second storage blocks consumed during the delayed garbage collection operation is greater than or equal to the number K, where K≥1 and is a positive integer.
5. The method according to claim 3, characterized in that, From the plurality of first storage blocks, at least two first storage blocks that satisfy the execution triggering condition are selected, including: Based on the amount of valid data in the plurality of first storage blocks, determine whether a target block group exists in the plurality of first storage blocks; The target block group includes at least two currently accumulated first storage blocks, and the number of second storage blocks required to perform delayed garbage collection on the second valid data in the at least two first storage blocks is less than the number of the at least two first storage blocks; If the target block group exists, the first storage block in the target block group is used as at least two first storage blocks that satisfy the execution triggering condition.
6. The method according to claim 3, characterized in that, Performing delayed garbage collection on the second valid data in the at least two first storage blocks to release the at least two first storage blocks includes: Based on the effective data volume of the at least two first storage blocks, predict the first write amplification information corresponding to performing a delayed garbage collection operation on the second effective data in the at least two first storage blocks; When the first write amplification information satisfies the set write amplification condition, the delayed execution time corresponding to the at least two first storage blocks is determined according to the number of the at least two first storage blocks; When the delay time arrives, a delayed garbage collection operation is performed on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
7. The method according to claim 6, characterized in that, Also includes: Based on the effective data volume of the first storage block of the currently executing main garbage collection operation, predict the second write amplification information corresponding to the main garbage collection operation; If the first write amplification information is greater than the second write amplification information, then the first write amplification information is determined to meet the set write amplification condition.
8. The method according to claim 6, characterized in that, Also includes: If the first write amplification information is less than or equal to the second write amplification information, then a delayed garbage collection operation is directly performed on the second valid data in the at least two first storage blocks to release the at least two first storage blocks.
9. The method according to any one of claims 3-8, characterized in that, Performing delayed garbage collection on the second valid data in the at least two first storage blocks to release the at least two first storage blocks includes: For any data block of the second valid data in the at least two first storage blocks, obtain other data blocks that belong to the same data block from the other first storage blocks; The data block and the other data blocks are migrated to the same second storage block, wherein the other first storage blocks are storage blocks other than the at least two first storage blocks among the plurality of first storage blocks.
10. The method according to any one of claims 3-8, characterized in that, Also includes: If the space occupancy rate of the target storage medium is detected to be greater than or equal to the set space occupancy rate threshold, the execution trigger condition is turned off, and a target storage block is selected from the currently existing first storage block; a delayed garbage collection operation is performed on the second valid data in the target storage block.
11. The method according to any one of claims 1-8, characterized in that, The valid data in the first storage block is divided into first valid data and second valid data, including: Based on the target number of garbage collections for each data block in the first storage block, the heat level of each data block in the first storage block is determined, and the number of garbage collections is directly proportional to the heat level. Data blocks with a heat level higher than or equal to a set heat level threshold are used as the first valid data in the first storage block; Data with a heat level below a set heat level threshold is divided into blocks and used as the second valid data in the first storage block.
12. The method according to claim 11, characterized in that, Also includes: Count the initial garbage collection counts for each data block in the first storage block; The initial number of garbage collections for each data block belonging to the same data block is numerically calculated to obtain the target number of garbage collections for each data block belonging to the same data block.
13. An electronic device, characterized in that, include: Memory and processor; The memory is used to store a computer program; the processor, coupled to the memory, is used to execute the computer program to implement the steps of the method according to any one of claims 1-12.
14. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it causes the processor to perform the steps of the method according to any one of claims 1-12.
15. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the processor is caused to perform the steps in the method of any one of claims 1-12.