SLC cache block management method and device based on data access frequency, computer equipment and storage medium
By managing SLC cache blocks in solid-state drives based on data access frequency, obtaining the cache block with the earliest generation time and setting a threshold, the problem of degraded read performance in SLC cache block management is solved, and fast access to high-frequency data and rational utilization of resources are achieved.
Patent Information
- Application Number
- CN202510802884.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2025-09-26
AI Technical Summary
In existing technologies of solid-state drives, the SLC cache block management method fails to effectively consider the frequency of data access, resulting in frequently accessed data being moved to ordinary blocks with lower read performance, affecting read performance, especially in application scenarios where data is frequently read.
By obtaining the SLC cache block with the earliest generation time, counting its access frequency, and setting a preset threshold, high-frequency data is retained in the SLC cache block, and low-frequency data is moved to ordinary blocks when the host is idle, so as to rationally utilize SLC cache block resources.
Significantly improves read performance, ensures fast access to high-frequency read data, rationally utilizes SLC cache block resources, guarantees space for subsequent write operations, and reduces read speed degradation.
Smart Images

Figure CN120704604A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of solid-state drives, and more specifically to a method, device, computer equipment, and storage medium for managing SLC cache blocks based on data access frequency. Background Art
[0002] In consumer solid-state drive (SSD) applications, as data storage demands continue to grow, performance requirements for SSDs are also increasing. Write performance, as one of the key performance indicators of SSDs, directly affects the speed and efficiency of data writes. To improve SSD write performance, a common technical approach is to convert normal blocks in NAND memory (typically in MLC or TLC mode) to single-layer cell (SLC) mode. Compared to MLC or TLC mode, SLC mode offers faster write speeds and higher reliability, but at the expense of significantly reduced storage capacity.
[0003] Specifically, during SSD operation, to ensure sufficient SLC cache blocks are available for subsequent writes, the system typically moves data from SLC cache blocks to regular blocks when the host is idle, based on the order in which the data was written. While this process helps free up space in the SLC cache blocks, it also introduces a significant problem: the read performance of regular blocks is much lower than that of SLC cache blocks.
[0004] When the host attempts to read data moved from the SLC cache blocks to the regular blocks, the read speed will drop significantly due to the limited read performance of the regular blocks, which will affect the user experience and overall system performance. This performance degradation is particularly noticeable in application scenarios that require frequent reads of this data, such as database operations and video editing.
[0005] Furthermore, traditional SLC cache block management methods often only consider the order in which data is written, while ignoring the frequency of data access. This results in some frequently accessed data being moved to ordinary blocks with lower read performance, further exacerbating the problem of degraded read performance.
[0006] Therefore, how to effectively improve the read performance while ensuring the SSD write performance, especially how to reasonably manage the data movement between SLC cache blocks and ordinary blocks when the host is idle, has become a technical problem that needs to be solved urgently in the current SSD technology field. Summary of the Invention
[0007] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method, apparatus, device and medium for SLC cache block management based on data access frequency.
[0008] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0009] In a first aspect, a method for managing SLC cache blocks based on data access frequency is provided, including:
[0010] Get the SLC cache block with the earliest generation time to obtain the current SLC cache block;
[0011] Read the access frequency of the current SLC cache block to obtain the access frequency value;
[0012] Determine whether the access frequency value is lower than a preset threshold;
[0013] If the access frequency value is lower than the preset threshold, the data in the current SLC cache block is moved to the normal block.
[0014] In a second aspect, an SLC cache block management device based on data access frequency is provided, including:
[0015] A first acquiring unit is configured to acquire an SLC cache block with the earliest generation time to obtain a current SLC cache block;
[0016] A reading unit, used for reading the access frequency of the current SLC cache block to obtain an access frequency value;
[0017] A first judging unit, configured to judge whether the access frequency value is lower than a preset threshold;
[0018] The moving unit is used to move the data in the current SLC cache block to the common block if the access frequency value is lower than a preset threshold.
[0019] In a third aspect, the present invention provides a computer device, comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the above method when executing the computer program.
[0020] In a fourth aspect, the present invention provides a storage medium storing a computer program, wherein the computer program implements the above method when executed by a processor.
[0021] Compared with the prior art, the beneficial effects of the present invention are as follows: by counting the access frequency of the SLC cache block and setting a preset threshold, the data blocks that are accessed frequently can continue to be retained in the SLC cache block. Since the SLC cache block has higher read performance, the data that is read frequently can be accessed by the host more quickly, thereby significantly improving the read performance. In addition, by obtaining the SLC cache block with the earliest generation time as the current processing object, the rational utilization of the SLC cache block resources is ensured. When the host is idle, the system can specifically move the SLC cache block data with lower access frequency to the ordinary block, thereby freeing up the SLC cache block space and providing protection for subsequent high-frequency write operations.
[0022] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 A flow chart of an SLC cache block management method based on data access frequency provided by an embodiment of the present invention;
[0025] Figure 2 A schematic diagram of the amount of data read based on a sliding window statistics block according to an embodiment of the present invention;
[0026] Figure 3 A schematic block diagram of an SLC cache block management device based on data access frequency provided by an embodiment of the present invention;
[0027] Figure 4 Schematic diagram of the structure of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0029] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0030] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0031] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0032] See also Figure 1 and Figure 2 In the specific embodiment shown, the present invention discloses a method for managing SLC cache blocks based on data access frequency, comprising the following steps:
[0033] S110, obtaining the SLC cache block with the earliest generation time to obtain the current SLC cache block;
[0034] Specifically, the system maintains a queue of SLC cache blocks, sorted by the time they were generated. When data needs to be moved, the oldest SLC cache block at the head of the queue is retrieved as the current target. Sequential management of SLC cache blocks can be achieved through data structures (such as linked lists or queues), ensuring that the oldest cache block is always accurately retrieved.
[0035] In one embodiment, obtaining the SLC cache block with the earliest generation time to obtain the current SLC cache block includes:
[0036] Create and initialize a cache block list to store the unique identifier and generation time of the SLC cache block;
[0037] Specifically, in the SSD's firmware or software layer, a data structure (such as a linked list, array, or dynamic list) is defined to store information about SLC cache blocks. This list needs to be able to store each cache block's unique identifier (such as a block ID or address) and generation time (usually recorded as a timestamp or write time). A data structure library in a programming language (such as C++'s std::list or std::vector, Python's list, etc.) can be used to create and initialize this cache block list.
[0038] Traverse all SLC cache blocks and add their unique identifiers and generation times to the cache block list;
[0039] Specifically, all cache blocks currently in SLC mode are traversed through the SSD's internal management mechanisms or firmware interfaces. For each cache block, its unique identifier and generation time are obtained. Cache block traversal can be performed using the SSD's internal data structures or APIs, typically involving reading the SSD's metadata area or using specific firmware commands.
[0040] For each SLC cache block traversed, its unique identifier and generation time are added as a pair of data items to the cache block list created previously. Cache block information can be added to the list through list operations in the programming language (such as push_back, append, etc.).
[0041] Sort the cache block list according to the generation time, and make the cache block with the earliest generation time at the beginning of the list;
[0042] Specifically, use a sorting algorithm (such as quick sort or merge sort) to sort the cache block list based on the generation time of each cache block. Ensure that the cache block with the earliest generation time is at the beginning of the list. You can use the sorting function in the programming language (such as C++'s std::sort or Python's sorted()) to sort the list. When sorting, specify a comparison function or use the generation time as the sort key.
[0043] Take the first element from the sorted cache block list as the current SLC cache block and record its unique identifier.
[0044] Specifically, after sorting is complete, the cache block information is retrieved from the first position in the list. This cache block is the SLC cache block with the earliest generation time. Its unique identifier is recorded so that subsequent operations (such as reading access frequency and moving data) can accurately reference this cache block. The first element of the list can be obtained through list access operations in the programming language (such as list[0] or first()) and its unique identifier can be extracted.
[0045] In other words, by creating, initializing, and sorting a cache block list, the system can quickly locate the SLC cache block with the oldest generation time. This reduces the time spent searching for the target cache block within a large number of cache blocks and improves data processing efficiency. Furthermore, orderly management of SLC cache blocks allows the system to allocate resources more effectively. For example, when data needs to be moved, cache blocks with the oldest generation time are prioritized, ensuring efficient utilization of SLC cache block space. Furthermore, orderly cache block management makes system behavior more predictable. When the host is idle, the system can process cache blocks according to established rules (such as generation time order), reducing uncertainty and potential problems, thereby enhancing system stability. Furthermore, by creating and sorting the cache block list, the system provides the foundation for implementing more complex management strategies, such as cache block management based on access frequency. For example, in subsequent steps, the system can further filter and process cache blocks based on access frequency, all of which is based on the ordered cache block list.
[0046] S120, reading the access frequency of the current SLC cache block to obtain an access frequency value;
[0047] Specifically, the system maintains an access frequency record table that records the access frequency value of each SLC cache block. After obtaining the current SLC cache block, the corresponding access frequency value is searched and read from the access frequency record table using its unique identifier. Hash tables or database indexing techniques can be used to quickly locate and read the access frequency value of the cache block.
[0048] In one embodiment, reading the access frequency of the current SLC cache block to obtain the access frequency value includes:
[0049] Use a sliding window approach to count the access frequency of SLC cache blocks;
[0050] Specifically, the system uses a sliding window mechanism to count the access frequency of each SLC cache block within a period of time. The size of the sliding window can be adjusted according to actual needs. For example, it can be set to the access data in the last few minutes or hours. At the end of each time slice, the system updates the access data in the sliding window and calculates the access frequency of each cache block in that time period. At the software level, data structures such as counters or hash tables can be used to record the number of accesses to each cache block in each time slice. When the time slice ends, the data in these counters or hash tables are added to the access frequency corresponding to the sliding window, and the counter of the current time slice is reset.
[0051] Maintain an access frequency record table that records the unique identifier of each SLC cache block and its corresponding access frequency value;
[0052] Specifically, the system maintains an access frequency record table that records the unique identifier (such as block ID or address) of each SLC cache block and its corresponding access frequency value. This record table can be a data structure in memory or a table in persistent storage. The access frequency record table can be implemented using a hash table, database table, or other efficient data structures. Each entry contains the unique identifier of the cache block and the corresponding access frequency value. When the sliding window updates the access frequency, the corresponding entry in the access frequency record table is updated synchronously.
[0053] According to the unique identifier of the current SLC cache block, search and locate the corresponding record in the access frequency record table;
[0054] Specifically, when reading the access frequency of a specific SLC cache block, the system first obtains the unique identifier of the cache block and then searches and locates the corresponding record in the access frequency record table. The fast search feature of hash tables or the index mechanism of database tables can be used to quickly locate the corresponding entry in the access frequency record table based on the unique identifier of the cache block.
[0055] The access frequency value of the current SLC cache block is read from the located record.
[0056] Specifically, after locating the corresponding entry in the access frequency record table, the system reads the access frequency value in the entry as the access frequency value of the current SLC cache block. The access frequency value can be obtained through simple data access operations (such as reading the value of a hash table or the field of a database table).
[0057] In other words, by counting access frequencies using a sliding window method, the system can more accurately reflect the actual access situation of the SLC cache block over a period of time, avoiding the deviation caused by statistics at a single time point. In addition, maintaining the access frequency record table enables the system to understand the access situation of each SLC cache block in real time, thereby rationally allocating resources according to the access frequency, such as giving priority to cache blocks with high frequency access, thereby improving the overall performance of the system. In addition, by quickly locating the corresponding entry in the access frequency record table through a unique identifier, the system can quickly read the access frequency value of the required cache block, reducing the search and reading time and improving data reading efficiency. The sliding window mechanism enables the system to dynamically adapt to changes in access patterns. When the access pattern changes, the system can automatically adjust the statistical results of the access frequency, providing an accurate basis for subsequent data migration and management strategies.
[0058] See also Figure 2 As shown, in one embodiment, a sliding window is used to count the amount of read data for each block within the last two time slices as the block's access frequency. The block's access frequency at t3.x is 80 + 50 = 130. At t4, due to the sliding window, the access data from t2 to t3 is removed from the statistics, and the access frequency at this time is 110.
[0059] S130 , determining whether the access frequency value is lower than a preset threshold; if the access frequency value is not lower than the preset threshold, jumping to S150 .
[0060] Specifically, the system sets a preset threshold to determine whether the access frequency of an SLC cache block is high enough to determine whether to move its data. The read access frequency value is compared with the preset threshold. This comparison can be implemented using a simple conditional statement.
[0061] In one embodiment, determining whether the access frequency value is lower than a preset threshold value includes:
[0062] Get the preset threshold from the configuration;
[0063] Specifically, in the SSD's firmware or software system, preset thresholds are usually stored in configuration files, registers, or specific management interfaces. When the system starts or needs to determine the access frequency value, it reads the preset thresholds from these configuration sources. The preset thresholds can be set and adjusted based on factors such as the SSD's performance requirements, storage capacity planning, and data access patterns. The preset thresholds can be obtained by reading configuration files (such as XML, JSON, etc.), accessing hardware registers, or calling management interfaces. At the software level, a configuration management module can be used to encapsulate this process and provide a unified interface for other modules to call.
[0064] The access frequency value of the current SLC cache block is compared with a preset threshold value to determine whether the access frequency value is lower than the preset threshold value.
[0065] Specifically, after obtaining the access frequency value of the current SLC cache block and the preset threshold, the system will perform a comparison operation to determine whether the access frequency value is lower than the preset threshold. This comparison operation is usually a simple numerical comparison and can be implemented through a conditional judgment statement (such as an if statement). In the programming language, comparison operators (such as <, >, ==, etc.) can be used to compare the access frequency value and the preset threshold. Based on the comparison result, the system can perform different operations, such as moving the data to a normal block or retaining it in the SLC cache block.
[0066] In other words, by obtaining preset thresholds from the configuration, the system can flexibly adjust the thresholds based on different application scenarios and performance requirements, thereby optimizing data management strategies. For example, in scenarios requiring higher read performance, the preset thresholds can be lowered to retain more frequently accessed data in the SLC cache blocks. Furthermore, dynamic adjustment of the preset thresholds allows the system to better adapt to varying data access patterns. As data access patterns change, the system can maintain efficient data management by adjusting the preset thresholds.
[0067] S140: If the access frequency value is lower than a preset threshold, move the data in the current SLC cache block to a normal block.
[0068] Specifically, if the access frequency falls below a preset threshold, the system moves the data in the current SLC cache block to a regular block. During this migration, data integrity and consistency are ensured. Data replication or migration algorithms are used to efficiently and accurately move data from the SLC cache block to regular blocks, while also updating the relevant metadata.
[0069] In one embodiment, moving the data in the current SLC cache block to the normal block includes:
[0070] Select one or more target blocks from the common blocks to receive the data moved from the current SLC cache blocks;
[0071] Specifically, the system selects one or more target blocks from the set of common blocks to receive the data moved from the SLC cache blocks based on factors such as the remaining space of the current common blocks, access performance, and data distribution strategy. The selection process may involve operations such as scanning, evaluating, and sorting common blocks to ensure that the selected target blocks can meet the requirements of data migration. By traversing the common block list, it can be checked whether the remaining space of each block is sufficient to accommodate the data to be moved. The candidate blocks are sorted according to the read and write performance indicators of the common blocks (such as latency, throughput, etc.), and blocks with better performance are preferentially selected as target blocks.
[0072] Start the data migration process to copy the data in the current SLC cache block to the selected target common block.
[0073] Specifically, once the target block is determined, the system will start the data migration process. This process involves reading data from the current SLC cache block and copying it to the selected target common block. During the data migration process, it is necessary to ensure the integrity and consistency of the data to avoid data loss or corruption. By reading the data to be moved from the SLC cache block, technologies such as DMA (direct memory access) can be used to improve data reading efficiency. The read data is written to the selected target common block, and technologies such as DMA can also be used to optimize write performance. During the data migration process, error detection and correction mechanisms such as checksums and ECC (error correction codes) are implemented to ensure data integrity. At the same time, the progress of the data migration is recorded so that the migration can be restored or restarted if an abnormality occurs during the migration process. After the data migration is completed, the resources occupied by the SLC cache block are released, and related metadata (such as cache block status, data mapping relationship, etc.) are updated.
[0074] In other words, by migrating data from SLC cache blocks to regular blocks, the system can free up space in the SLC cache blocks, providing more cache resources for subsequent high-frequency write operations, thereby improving overall storage space utilization. Furthermore, by properly selecting target blocks, the system can ensure a more balanced distribution of the migrated data within regular blocks, helping to optimize subsequent data access performance. For example, migrating frequently accessed data to higher-performance regular blocks can reduce access latency. Furthermore, error handling and progress tracking mechanisms during data migration ensure data integrity and consistency, avoiding system crashes or data loss caused by failed data migrations, thereby enhancing system stability. By optimizing data migration strategies, the system can respond to read and write requests more quickly, reducing user wait time and improving the user experience. This optimization effect is particularly pronounced in scenarios where frequent data migration is required, such as SSD garbage collection and wear leveling operations.
[0075] In one embodiment, after moving the data in the current SLC cache block to the normal block, the method further includes:
[0076] S150, obtaining the next SLC cache block to obtain the latest SLC cache block;
[0077] Specifically, after completing the data migration of the current SLC cache block, the system needs to continue processing subsequent SLC cache blocks. The system maintains a processing queue or linked list of SLC cache blocks, which are arranged in a certain order (such as generation time, access frequency, etc.). When obtaining the next SLC cache block, the system takes out the cache block from the head or next position of the queue or linked list and processes it as the latest SLC cache block. The sequential processing of SLC cache blocks can be achieved by traversing and retrieving data structures (such as linked lists and queues). When retrieving a cache block, the pointer or index of the queue or linked list is updated so that subsequent operations can correctly obtain the next cache block.
[0078] S160, determine whether the latest SLC cache block is a legal block; if the latest SLC cache block is not a legal block, end;
[0079] Specifically, after acquiring the latest SLC cache block, the system needs to determine whether the cache block is a legitimate block. This legitimacy determination may involve checking the cache block's status (e.g., whether it has been marked invalid, whether it is being used by other operations, etc.), verifying whether the cache block's identifier or address is valid, etc. This legitimacy determination can be achieved by reading the cache block's status information, verifying the identifier or address, etc. If the cache block's status is valid and the identifier or address is legitimate, the cache block is considered a legitimate block; otherwise, the cache block is considered an illegal block.
[0080] S170 : If the latest SLC cache block is a valid block, read the access frequency of the latest SLC cache block to obtain an access frequency value, and return to execute a determination whether the access frequency value is lower than a preset threshold.
[0081] Specifically, if the latest SLC cache block is judged to be a legal block, the system will read the access frequency value of the cache block. The access frequency value is read in the same way as described previously, that is, it is obtained through the access frequency record table or related data structure. After obtaining the access frequency value, the system will return to execute S130 to decide whether the data of the cache block needs to be moved to a normal block. The access frequency reading mechanism implemented previously can be used to obtain the access frequency value of the latest SLC cache block. Then, through conditional judgment statements (such as if statements) and function calls, the logic of determining whether the access frequency value is lower than the preset threshold is returned.
[0082] That is to say, by obtaining the next SLC cache block and judging its legitimacy, the system can implement cyclic processing of the SLC cache blocks, which ensures that all SLC cache blocks can be processed and managed in a timely manner, and avoids the situation where some cache blocks are missed or not processed for a long time. In addition, performing a legitimacy judgment before processing each SLC cache block can ensure that the system only processes valid cache blocks, avoiding errors or anomalies caused by processing illegal blocks, which improves the accuracy and reliability of data management. In addition, by cyclically processing SLC cache blocks and deciding whether to move data based on the access frequency value, the system can more reasonably allocate SLC cache block resources and optimize read and write performance. Frequently accessed data can be retained in the SLC cache blocks, while less frequently accessed data is moved to ordinary blocks, thereby improving the performance of the overall storage system.
[0083] In one embodiment, the process of setting the preset threshold includes:
[0084] Get the first block to get the current block;
[0085] Specifically, the system needs to iterate through all blocks in the storage device to obtain the first block to be processed. This is typically achieved by maintaining a block list or using the storage device's block management interface. The system begins processing from the beginning of the list or the first block returned by the interface. At the software level, this can be accomplished using a loop structure to iterate through the block list or by calling the storage device's API to obtain block information.
[0086] Determine whether the current block is a user data block;
[0087] Specifically, the system needs to determine whether the current block stores user data. This can be achieved by checking the block's metadata, flags, or content. For example, some storage devices may mark the block type (such as user data block, system block, etc.) in the block's metadata. By reading the block's metadata or flags, the system determines whether the block is a user data block based on pre-set rules or conditions.
[0088] If the current block is a user data block, the reading amount of the previous unit time is set as the current reading amount, and the reading amount of the current time is cleared to zero, thereby obtaining the preset threshold value.
[0089] Specifically, if the current block is judged to be a user data block, the system uses the read volume of the block in the previous unit time (such as a window size) as the preset threshold. At the same time, the system clears the read volume counter of the current time window to start counting the read volume in the new time window. The system needs to maintain a data structure (such as a hash table, array, etc.) to record the read volume of each user data block in different time windows. At the end of each time window, the system sets the read volume of the previous time window to the preset threshold of the corresponding block. Clear the read volume counter of the current time window to restart the statistics. In addition, the system needs to set a timer or event mechanism to trigger an update operation at fixed intervals (such as a window size). In the update operation, the system traverses all user data blocks, eliminates the read volume statistics in the old time window, and sets the read volume counter of the new time window to 0.
[0090] If the current block is not a user data block, the next block is obtained and it is determined whether the block is a legal block. If the block is a legal block, the execution is jumped to determine whether the current block is a user data block; if the block is not a legal block, the process ends.
[0091] In other words, by updating the preset thresholds at regular intervals, the system can dynamically adapt to changes in data access patterns. When data access patterns change, the system automatically adjusts the preset thresholds to better reflect current data access conditions. Furthermore, by properly setting the preset thresholds, the system can more effectively allocate SLC cache block resources. Frequently accessed data blocks will receive higher thresholds, making them more likely to be retained in the SLC cache, improving read and write performance. Furthermore, regularly updating the preset thresholds helps reduce performance fluctuations caused by changing data access patterns. This allows the system to operate more stably, reducing issues caused by improper resource allocation or data access delays.
[0092] In one embodiment, after moving the data in the current SLC cache block to the normal block, the method further includes:
[0093] Get the first block, which is the current block;
[0094] Specifically, the system obtains the first block from a block management list or data structure of the storage device as the currently processed block, which is usually achieved by traversing the block list or calling an API of the storage device.
[0095] Determine whether the current block is a normal user data block; if the current block is not a normal user data block, jump to the next block;
[0096] Specifically, the system checks the metadata, flags, or content of the current block to determine whether it is a normal user data block. This may involve reading the block's type information or performing other forms of identification verification. The block type can be determined by reading specific fields of the block or calling relevant functions. If it is not a normal user data block, a jump instruction (such as a goto or function call) is used to obtain the next block and continue processing.
[0097] If the current block is a common user data block, the access frequency of the current block is obtained to obtain the access frequency value;
[0098] Specifically, the system obtains the access frequency value of the current common user data block from the access frequency record table or related data structure. The access frequency value can be obtained using a hash table, database query or other efficient data access methods.
[0099] Determine whether the access frequency value is lower than the threshold; if the access frequency value is lower than the threshold, jump to execute and obtain the next block;
[0100] Specifically, the system compares the access frequency value obtained with a preset threshold. A conditional statement (such as an if statement) can be used to compare the access frequency value and the threshold. If the access frequency value is lower than the threshold, the system jumps to the next block.
[0101] If the access frequency value is not lower than the threshold, then determine whether the remaining free blocks in the system are greater than 50% of the total number of blocks; if the remaining free blocks in the system are not greater than 50% of the total number of blocks, then end;
[0102] Specifically, the system checks the number of free blocks in the current system and calculates its proportion to the total number of blocks. The number of free blocks and the proportion calculation can be obtained by reading system status information or calling related functions.
[0103] If the number of free blocks in the system is greater than 50% of the total number of blocks, the data in the normal user data block is moved to the SLC cache block;
[0104] Specifically, if the system has enough free blocks (greater than 50% of the total number of blocks), the system will move the data in the current normal user data blocks to the SLC cache blocks. The data migration process is initiated, including reading data from normal blocks, writing data to SLC cache blocks, and updating related metadata (such as block status and data mapping relationships).
[0105] Set the SLC cache block access quota to the original normal block access quota;
[0106] Specifically, the system sets the access quota (or access frequency) of the SLC cache block to the same value as the original ordinary block to maintain data access consistency. The corresponding entry in the access frequency record table or related data structure is updated, and the access quota of the SLC cache block is set to the access quota of the original ordinary block.
[0107] Get the next block;
[0108] Specifically, the system obtains the next block from the block management list or data structure as the currently processed block.
[0109] Determine whether the block is a legal block;
[0110] Specifically, the system checks the legitimacy of the current block, including whether its status, identifier or address are valid, etc. The legitimacy of the block can be determined by reading the block's status information, verifying the identifier or address, etc.
[0111] If the block is a legal block, then return to determine whether the current block is a normal user data block;
[0112] Specifically, if the current block is a valid block, the system will return to the previous step of determining the block type to continue processing subsequent blocks. The process jump can be achieved through a loop structure or a function call return mechanism.
[0113] If the block is not a legal block, then end.
[0114] Specifically, if the current block is not a valid block, the system will end the entire processing flow. The processing flow can be ended by exiting the loop, returning, or terminating the function.
[0115] In other words, by moving frequently accessed ordinary user data blocks to SLC cache blocks, the system can significantly improve the read and write performance of this data, because SLC cache blocks generally have higher read and write speeds and lower latency. In addition, the system can more reasonably utilize storage resources by dynamically adjusting the usage ratio of SLC cache blocks and ordinary blocks. When the system has a large number of remaining free blocks, moving frequently accessed data to SLC cache blocks can free up space in ordinary blocks and provide more options for subsequent data storage. In addition, by regularly checking and processing blocks, and reasonably setting access frequency thresholds and free block ratios, the system can operate more stably, which helps reduce problems caused by improper resource allocation or data access conflicts. That is, when the host is idle, it traverses the user data blocks and moves ordinary blocks with an access frequency exceeding the threshold back to the SLC cache blocks. After the move is completed, the read data volume of the ordinary blocks is also migrated to the corresponding SLC cache blocks, which can improve the host read performance.
[0116] The present invention counts the access frequency of SLC cache blocks and sets a preset threshold, so that frequently accessed data blocks can continue to remain in the SLC cache blocks. Since the SLC cache blocks have higher read performance, the frequently read data can be accessed more quickly by the host, thereby significantly improving read performance. In addition, by obtaining the SLC cache block with the earliest generation time as the current processing object, the rational utilization of SLC cache block resources is ensured. When the host is idle, the system can specifically move the SLC cache block data with lower access frequency to ordinary blocks, thereby freeing up SLC cache block space and providing protection for subsequent high-frequency write operations. At the same time, for SLC cache blocks whose access frequency exceeds the threshold, the system will not temporarily perform the move operation, ensuring that this frequently accessed data can continue to enjoy the high-performance read and write services of the SLC cache blocks.
[0117] Figure 3 FIG is a schematic block diagram of an SLC cache block management device 300 based on data access frequency provided by an embodiment of the present invention. Figure 3 As shown, corresponding to the above-mentioned SLC cache block management method based on data access frequency, the present invention also provides an SLC cache block management device 300 based on data access frequency. The SLC cache block management device 300 based on data access frequency includes a unit for executing the above-mentioned SLC cache block management method based on data access frequency, and the device can be configured in a server. Specifically, please refer to Figure 3 The SLC cache block management device 300 based on data access frequency includes:
[0118] A first acquiring unit 301 is configured to acquire an SLC cache block with the earliest generation time to obtain a current SLC cache block;
[0119] The reading unit 302 is used to read the access frequency of the current SLC cache block to obtain an access frequency value;
[0120] The first judging unit 303 is used to judge whether the access frequency value is lower than a preset threshold;
[0121] The moving unit 304 is configured to move the data in the current SLC cache block to a common block if the access frequency value is lower than a preset threshold.
[0122] In one embodiment, the acquiring unit 301 includes:
[0123] Create a module for creating and initializing a cache block list for storing the unique identifier and generation time of the SLC cache block;
[0124] The traversal module is used to traverse all SLC cache blocks and add their unique identifiers and generation times to the cache block list;
[0125] A sorting module is used to sort the cache block list according to the generation time, and make the cache block with the earliest generation time be located at the beginning of the list;
[0126] The record fetching module is used to fetch the first element from the sorted cache block list as the current SLC cache block and record its unique identifier.
[0127] In one embodiment, the reading unit 302 includes:
[0128] A statistics module is used to count the access frequency of SLC cache blocks using a sliding window method;
[0129] A maintenance module, configured to maintain an access frequency record table, which records a unique identifier of each SLC cache block and its corresponding access frequency value;
[0130] A search and positioning module is used to search and locate the corresponding record in the access frequency record table according to the unique identifier of the current SLC cache block;
[0131] The reading module is used to read the access frequency value of the current SLC cache block from the located record.
[0132] In one embodiment, the determining unit 303 includes:
[0133] The acquisition module is used to obtain the preset threshold from the configuration;
[0134] The comparison module is used to compare the access frequency value of the current SLC cache block with a preset threshold value to determine whether the access frequency value is lower than the preset threshold value.
[0135] In one embodiment, the moving unit 304 includes:
[0136] A selection module is used to select one or more target blocks from the common blocks to receive data moved from the current SLC cache blocks;
[0137] The copy module is used to start the data migration process and copy the data in the current SLC cache block to the selected target common block.
[0138] In one embodiment, the apparatus further comprises:
[0139] A second acquiring unit 305 is configured to acquire a next SLC cache block to obtain a latest SLC cache block;
[0140] The second judging unit 306 is configured to judge whether the latest SLC cache block is a valid block;
[0141] The read execution unit 307 is configured to read the access frequency of the latest SLC cache block to obtain an access frequency value if the latest SLC cache block is a valid block, and return to execute a determination as to whether the access frequency value is lower than a preset threshold.
[0142] In one embodiment, the preset threshold includes: obtaining the first block to obtain the current block; determining whether the current block is a user data block; if the current block is a user data block, setting the reading amount of the previous unit time as the current reading amount, and clearing the current time reading amount to zero, thereby obtaining the preset threshold.
[0143] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned SLC cache block management device 300 based on data access frequency and each unit can refer to the corresponding description in the aforementioned method embodiment. For the convenience and brevity of the description, it will not be repeated here.
[0144] The above-mentioned SLC cache block management device 300 based on data access frequency can be implemented in the form of a computer program. The computer program can be used in a computer system such as Figure 4 Runs on the computer equipment shown.
[0145] See also Figure 4 , Figure 4 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a server, wherein the server may be an independent server or a server cluster composed of multiple servers.
[0146] See Figure 4 The computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0147] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, which, when executed, can enable the processor 502 to perform a method for dynamic short message shielding.
[0148] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
[0149] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a method for dynamic short message shielding.
[0150] The network interface 505 is used to communicate with other devices through the network. Figure 4 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0151] The processor 502 is configured to execute a computer program 5032 stored in the memory to implement the following steps:
[0152] Obtain the SLC cache block with the earliest generation time to obtain the current SLC cache block; read the access frequency of the current SLC cache block to obtain the access frequency value; determine whether the access frequency value is lower than a preset threshold; if the access frequency value is lower than the preset threshold, move the data in the current SLC cache block to a common block.
[0153] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0154] Those skilled in the art will appreciate that all or part of the steps in the method of the above-described embodiment can be implemented by instructing the relevant hardware through a computer program. The computer program includes program instructions, which can be stored in a storage medium that is computer-readable. The program instructions are executed by at least one processor in the computer system to implement the steps in the method of the above-described embodiment.
[0155] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor performs the following steps:
[0156] Obtain the SLC cache block with the earliest generation time to obtain the current SLC cache block; read the access frequency of the current SLC cache block to obtain the access frequency value; determine whether the access frequency value is lower than a preset threshold; if the access frequency value is lower than the preset threshold, move the data in the current SLC cache block to a common block.
[0157] The storage medium may be any computer-readable storage medium that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.
[0158] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0159] In the several embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the various units is merely a logical functional division, and actual implementation may employ other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not implemented.
[0160] The steps in the methods of the embodiments of the present invention may be adjusted in order, combined, or deleted as needed. The units in the devices of the embodiments of the present invention may be combined, divided, or deleted as needed. Furthermore, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.
[0161] If this integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, terminal, or network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present invention.
[0162] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. An SLC cache block management method based on data access frequency, characterized in that: include: Get the SLC cache block with the earliest generation time to obtain the current SLC cache block; Read the access frequency of the current SLC cache block to obtain the access frequency value; Determine whether the access frequency value is lower than a preset threshold; If the access frequency value is lower than the preset threshold, the data in the current SLC cache block is moved to the normal block.
2. The SLC cache block management method based on data access frequency according to claim 1, characterized in that: The acquiring of the SLC cache block with the earliest generation time to obtain the current SLC cache block includes: Create and initialize a cache block list to store the unique identifier and generation time of the SLC cache block; Traverse all SLC cache blocks and add their unique identifiers and generation times to the cache block list; Sort the cache block list according to the generation time, and make the cache block with the earliest generation time at the beginning of the list; Take the first element from the sorted cache block list as the current SLC cache block and record its unique identifier.
3. The SLC cache block management method based on data access frequency according to claim 1, characterized in that: The reading of the access frequency of the current SLC cache block to obtain the access frequency value includes: Use a sliding window approach to count the access frequency of SLC cache blocks; Maintain an access frequency record table that records the unique identifier of each SLC cache block and its corresponding access frequency value; According to the unique identifier of the current SLC cache block, search and locate the corresponding record in the access frequency record table; The access frequency value of the current SLC cache block is read from the located record.
4. The SLC cache block management method based on data access frequency according to claim 1, wherein: The determining whether the access frequency value is lower than a preset threshold value includes: Get the preset threshold from the configuration; The access frequency value of the current SLC cache block is compared with a preset threshold value to determine whether the access frequency value is lower than the preset threshold value.
5. The SLC cache block management method based on data access frequency according to claim 1, characterized in that: The step of moving the data in the current SLC cache block to the common block includes: Select one or more target blocks from the common blocks to receive the data moved from the current SLC cache blocks; Start the data migration process to copy the data in the current SLC cache block to the selected target common block.
6. The SLC cache block management method based on data access frequency according to claim 1, characterized in that: After the data in the current SLC cache block is moved to the normal block, the method further includes: Get the next SLC cache block to get the latest SLC cache block; Determine whether the latest SLC cache block is a legal block; If the latest SLC cache block is a valid block, the access frequency of the latest SLC cache block is read to obtain an access frequency value, and the process returns to determine whether the access frequency value is lower than a preset threshold.
7. The SLC cache block management method based on data access frequency according to claim 1, characterized in that: After the data in the current SLC cache block is moved to the normal block, the method further includes: Get the first block, which is the current block; Determine whether the current block is a normal user data block; if the current block is not a normal user data block, jump to the next block; If the current block is a common user data block, the access frequency of the current block is obtained to obtain the access frequency value; Determine whether the access frequency value is lower than the threshold; if the access frequency value is lower than the threshold, jump to execute and obtain the next block; If the access frequency value is not lower than the threshold, it is determined whether the remaining free blocks in the system are greater than 50% of the total number of blocks; If the number of free blocks in the system is greater than 50% of the total number of blocks, the data in the normal user data block is moved to the SLC cache block; Set the SLC cache block access quota to the original normal block access quota; Get the next block; Determine whether the block is a legal block; If the block is a legal block, then return to determine whether the current block is a normal user data block; If the block is not a legal block, then end.
8. An SLC cache block management device based on data access frequency, characterized in that: include: A first acquiring unit is configured to acquire an SLC cache block with the earliest generation time to obtain a current SLC cache block; A reading unit, used for reading the access frequency of the current SLC cache block to obtain an access frequency value; A first judging unit, configured to judge whether the access frequency value is lower than a preset threshold; The moving unit is used to move the data in the current SLC cache block to the common block if the access frequency value is lower than a preset threshold.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A storage medium, wherein the computer-readable storage medium stores a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.