Method and device for separating cold and hot data of solid state disk and solid state disk
Through the LBA space division and frequency statistics of SSDs, combined with the red-black tree and small top heap algorithms, we can quickly determine the hot and cold attributes of data, which solves the problem of hot and cold data separation occupying resources in the existing technology, and improves the performance and life of SSD. .
Patent Information
- Application Number
- CN202410256115.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-06
- Publication Date
- 2024-08-23
AI Technical Summary
The existing method of separating hot and cold data in solid-state drives takes up more storage resources and affects the write performance and service life of the SSD.
Multiple LBA areas are formed by dividing the logical block address LBA space of the solid state drive. According to the access frequency statistics of each area, it is determined whether the data is cold data or hot data, and a red-black tree or queue is used to store the hot data area identification, using a small The top heap algorithm or binary search algorithm quickly determines the hot and cold attributes of the data to be written, and dynamically adjusts the K value to optimize data separation.
It effectively reduces the occupation of storage resources by the hot and cold data separation function, and improves the write performance and service life of SSD.
Smart Images

Figure CN118535084A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage, and in particular to a method and device for separating hot and cold data of a solid state hard disk, and a solid state hard disk. Background Art
[0002] Solid State Disk (Solid State Disk or Solid State Drive, referred to as SSD), also known as solid state drive, is a hard disk composed of a control unit and a storage unit (DRAM or FLASH chip). Generally, solid state drives are divided into two types according to the storage medium, one is to use flash memory (FLASH chip) as the storage medium, and the other is to use DRAM as the storage medium. The solid state drive storage medium described in the present invention is based on flash memory (FLASH chip). The solid state drive is almost exactly the same as the traditional mechanical hard disk in terms of interface definition, function and usage method, and is widely used in data centers, video surveillance, military industry, electricity and other industries. With the rapid development of the Internet, big data, and artificial intelligence, people have higher and higher requirements for the performance of storage devices. The read and write performance of solid state drives with FLASH as the storage medium has been greatly improved compared to traditional mechanical hard disks. At present, the trend of using solid state drives to replace traditional mechanical hard disks in the storage field is becoming more and more obvious. Solid state drives are essentially an embedded device, and people usually call the control software running on SSDs firmware. Flash memory (FLASH chip) cannot be overwritten, so compared to mechanical hard disks, SSDs that use flash memory (FLASH chip) as storage media need to erase the flash memory before writing data. When the data block A to be erased in the flash memory contains valid data of the host, the garbage collection module (GC) in the firmware needs to move the valid data in the data block A to be erased to a new block B before erasing the data block A. This additional data movement operation is called write amplification. Obviously, write amplification not only affects the write performance of the SSD but also reduces the service life of the SSD.
[0003] At present, the main directions commonly used to reduce write amplification are: 1. Improving the OP of the solid-state drive during operation. The calculation formula of the OP is: OP = (SSD total physical capacity / user visible capacity) - 1. Although improving the OP can reduce the write amplification of the SSD, it brings about a reduction in user-visible space, and when the OP is increased to a certain value, the increase in the write amplification of the SSD may not be very obvious; 2. Optimizing the algorithm of the garbage collection module (GC) including the wear leveling module. This direction can reduce write amplification but cannot fundamentally reduce write amplification; 3. Reduce write amplification by separating the cold and hot data of the host. Among them, cold data refers to data that is rarely modified by the host within a period of time. For example, the host writes an application execution file to the SSD, and the file occupies LBA0~LBA3. Since executable files often have read-only attributes, there will be no new write operations to LBA0~LBA3 in the future. At this time, LBA0~LBA3 in the SSD can be called cold data; hot data refers to data that is frequently modified by the host within a period of time. For example, the host uses a certain LBA space in the SSD as a virtual cache, and will often write to this LBA. For example, the host frequently modifies LBA0, then LBA0 is called hot data.
[0004] Among them, there are two specific implementation methods for reducing write amplification by separating hot and cold data: 1. Post-determination, first store the data written by the host in the SSD cache, and then determine whether the data corresponding to a certain LBA is cold or hot based on the write frequency of the LBA when the cache space reaches a certain size; 2. Pre-determination, determine whether the LBA is cold data or hot data based on the access frequency of a certain LBA in history, and when the host has an LBA write operation, determine the current cold and hot properties of the LBA based on the cold and hot properties of the LBA in history. For example: passively separate hot and cold data by using the characteristics of garbage collection itself. When the hot data of a block is gradually marked invalid due to continuous updates, the proportion of valid cold data in the block increases. At this time, garbage collection is performed on the block, and the proportion of cold data in the newly combined block will increase, realizing the gradual separation of hot and cold data; for another example, determine whether the block stores hot data based on the time when the data was last written to a certain logical address page. If the interval between the last data write of the logical address page and the current data write is not greater than a certain threshold time, the data on the page is judged to be hot data and the data will be written to the hot data block; if the interval between the last data write of the logical address page and the current data write is greater than a certain threshold time, the data on the page is judged to be cold data and the data will be written to the cold data block; for example, the host actively informs the SSD through the SATA protocol whether the written data is hot or cold data to determine the hot and cold data, which can better separate the hot and cold data. In summary, the existing hot and cold data separation method of the SSD has the following technical problems: the existing hot and cold data separation function will occupy more storage resources and have a great impact on the SSD write performance. Summary of the invention
[0005] In view of the above problems, the present invention is proposed to provide a method, device and solid state drive for realizing cold and hot data separation of a solid state drive that overcomes the above problems or at least partially solves the above problems.
[0006] One aspect of the present invention provides a method for separating cold and hot data of a solid state drive, the method comprising:
[0007] The logical block address LBA space of the solid state drive is divided into multiple LBA areas, and a unique identifier is added to each LBA area;
[0008] Whenever a write command is received from the host, the target LBA carried by the write command is obtained, and the access count value of the LBA area corresponding to each target LBA in the current statistical time segment is accumulated;
[0009] Determine whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the last statistical time segment, wherein the LBA areas in the hot data LBA area set are K LBA areas with the largest access frequencies counted in the last statistical time segment;
[0010] If the target LBA area is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment, the data to be written is determined to be hot data and written to the hot data block; otherwise, the data to be written is determined to be cold data and written to the cold data block.
[0011] Optionally, the hot data LBA area set is stored in the form of a red-black tree, and an LBA area identifier is used in the red-black tree to represent the corresponding LBA area;
[0012] Further, the step of determining whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in a set of hot data LBA areas corresponding to a previous statistical time segment includes:
[0013] It is determined whether the identifier of the target LBA area corresponding to the start LBA in the target LBA is in the red-black tree corresponding to the hot data LBA area set.
[0014] Optionally, the method further comprises:
[0015] At the end of the current statistical time segment, the small top heap algorithm is used to find the K LBA areas with the largest access count value in the current statistical time segment;
[0016] A red-black tree with a depth of logK is established for the K LBA areas according to the corresponding area identifiers.
[0017] Optionally, the method further comprises:
[0018] Compare the first write rate of the host in the current statistical time segment with the second write rate of the host in the previous statistical time segment. When the first write rate is greater than the second write rate, reduce the K value; when the first write rate is less than the second write rate, increase the K value.
[0019] Optionally, the method further comprises:
[0020] An adjustment level matching the difference between the first write rate and the second write rate is selected according to the difference, and the K value is adjusted according to the corresponding adjustment level.
[0021] Optionally, the hot data LBA area set is stored in the form of a queue, and an LBA area identifier is used in the queue to represent the corresponding LBA area;
[0022] Further, the step of determining whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment includes:
[0023] A binary search algorithm is used to determine whether the identifier of the target LBA area corresponding to the start LBA in the target LBA is in the queue corresponding to the hot data LBA area set.
[0024] Optionally, when the logical block address LBA space of the solid state drive is divided, each LBA can correspond to only one LBA area.
[0025] In a second aspect, the present invention further provides a device for separating hot and cold data of a solid state drive, the device comprising:
[0026] A region division module is used to divide the logical block address LBA space of the solid state drive into multiple LBA regions, and add a unique identifier to each LBA region;
[0027] The statistics module is used to obtain the target LBA carried by the write instruction whenever receiving the write instruction from the host, and accumulate the access count value of the LBA area corresponding to each target LBA in the current statistical time segment;
[0028] A judgment module is used to judge whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the last statistical time segment, wherein the LBA areas in the hot data LBA area set are K LBA areas with the largest access frequency counted in the last statistical time segment;
[0029] The control module is used to determine that the data to be written is hot data and write it into a hot data block when the target LBA area is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment; otherwise, determine that the data to be written is cold data and write it into a cold data block.
[0030] Optionally, the statistical module is also used to use a mini-heap algorithm to find the K LBA areas with the largest access count values in the current statistical time segment at the end of the current statistical time segment; and establish a red-black tree with a depth of logK for the K LBA areas according to corresponding area identifiers.
[0031] In a third aspect, the present invention also provides a solid-state hard disk, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for separating cold and hot data of a solid-state hard disk as described above when executing the computer program.
[0032] The method for implementing hot and cold data separation of a solid-state drive provided by an embodiment of the present invention proposes a concept of LBA region, and forms multiple LBA regions by dividing the logical block address LBA space of the solid-state drive. When LBA usage frequency is counted based on the LBA region, the storage resources occupied by the hot and cold data separation function can be greatly reduced. By judging whether the LBA region corresponding to the current LBA of the data to be written falls into the K LBA regions with the highest access frequency in the previous statistical time segment, it can be more accurately determined whether the data to be written by the current host is cold data or hot data, and the host cold and hot data can be efficiently separated. By separating the host cold and hot data, write amplification can be effectively reduced, thereby increasing the service life of the SSD.
[0033] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0035] Figure 1 A flow chart of a method for implementing hot and cold data separation of a solid state drive provided by an embodiment of the present invention;
[0036] Figure 2A structural diagram of the LBA area proposed in an embodiment of the present invention;
[0037] Figure 3 A schematic diagram of access frequencies of 12 LBA areas proposed in an embodiment of the present invention;
[0038] Figure 4 A schematic diagram of a small top heap initially established according to the access frequencies of 12 LBA areas proposed in an embodiment of the present invention;
[0039] Figure 5 A schematic diagram of a small top heap generated when a Top-KLBA area is found according to the access frequency of 12 LBA areas proposed in an embodiment of the present invention;
[0040] Figure 6 Shows the Figure 5 Schematic diagram of a red-black tree established by the small top heap node according to the identification of the LBA area;
[0041] Figure 7 A specific implementation flow chart of the method for separating hot and cold data on a solid state drive provided by an embodiment of the present invention;
[0042] Figure 8 A structural block diagram of a device for implementing cold and hot data separation of a solid state drive provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0043] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0044] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0045] Those skilled in the art will appreciate that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as those generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined.
[0046] Figure 1 The flowchart of a method for implementing hot and cold data separation of a solid state drive according to an embodiment of the present invention is schematically shown. Figure 1 The method for implementing hot and cold data separation of a solid state drive according to an embodiment of the present invention specifically comprises the following steps:
[0047] S11, dividing the logical block address LBA space of the solid state drive into multiple LBA areas, and adding a unique identifier to each LBA area.
[0048] Furthermore, when the logical block address LBA space of the solid state drive is divided, each LBA can only correspond to one LBA region, and the description information of each LBA region includes the starting LBA and the access count value of the current LBA region. For example, a continuous LBA (such as 1000) is formed into an LBA region (i.e., an LBA region), so that the LBA space of the entire SSD can form several LBA regions; it should be noted that each LBA can only correspond to one LBA region.
[0049] Figure 2 The structural diagram of the LBA region proposed in the embodiment of the present invention is shown. There is a member in the LBA region that describes the number of accesses V of the LBA region within a certain time slice. For the convenience of subsequent description, the i-th LBA region is recorded as R(i), and the number of accesses of R(i) is recorded as V(i). Assuming that the SSD has M LBAs, and N LBAs form an LBA region, the SSD will have a total of M / N LBA regions. Obviously, the starting LBA corresponding to R(i) is (i*N), and the LBA region corresponding to LBA=L is (L / N). It should be noted that each LBA has and can only correspond to one LBA region. Figure 2 Displays all LBA regions of the SSD.
[0050] S12. Whenever a write instruction is received from the host, the target LBA carried by the write instruction is obtained, and the access count value of the LBA area corresponding to each target LBA in the current statistical time segment is accumulated.
[0051] In this embodiment, at the beginning of a statistical time segment, the access counts V of all LBA regions are reset to zero. When the firmware processes each host write, the access count V of the LBA region corresponding to each LBA of the write is increased by 1.
[0052] S13. Determine whether the target LBA area corresponding to the starting LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment, wherein the LBA area in the hot data LBA area set is the K LBA areas with the largest access frequency counted in the previous statistical time segment.
[0053] In this embodiment, when the SSD is running, the firmware divides the time into continuous time slices, such as 1 second as a statistical time slice. When the previous statistical time slice is about to end, the K LBA regions with the highest access frequency in the statistical time slice are pre-counted. The firmware determines whether the host writes cold data or hot data in the next statistical time slice based on the K LBA regions with the highest access frequency in the previous statistical time slice. Among them, K is an integer greater than or equal to 0, and the value of K can be adjusted according to the write rate of the host in the current statistical time slice. When K is equal to 0, the cold and hot data separation function is turned off. When K is greater than 0, the host writes cold data or hot data in the next statistical time slice based on the K LBA regions with the highest access frequency in the previous statistical time slice.
[0054] S14, if the target LBA area is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment, determine that the data to be written is hot data and write it into the hot data block;
[0055] S15: If the target LBA area is not an LBA area in the hot data LBA area set corresponding to the previous statistical time segment, determine that the data to be written is cold data and write it into a cold data block.
[0056] The method for implementing hot and cold data separation of a solid-state drive provided by an embodiment of the present invention proposes a concept of LBA region, and forms multiple LBA regions by dividing the logical block address LBA space of the solid-state drive. When LBA usage frequency is counted based on the LBA region, the storage resources occupied by the hot and cold data separation function can be greatly reduced. By judging whether the LBA region corresponding to the current LBA of the data to be written falls into the K LBA regions with the highest access frequency in the previous statistical time segment, it can be more accurately determined whether the data to be written by the current host is cold data or hot data, and the host cold and hot data can be efficiently separated. By separating the host cold and hot data, write amplification can be effectively reduced, thereby increasing the service life of the SSD.
[0057] In one embodiment of the present invention, the hot data LBA area set is stored in the form of a red-black tree, and the LBA area identifier is used in the red-black tree to represent the corresponding LBA area. Further, the determination of whether the target LBA area corresponding to the starting LBA in the target LBA is the LBA area in the hot data LBA area set corresponding to the previous statistical time segment includes: determining whether the identifier of the target LBA area corresponding to the starting LBA in the target LBA is in the red-black tree corresponding to the hot data LBA area set.
[0058] Specifically, whenever a statistical time segment ends, the firmware uses the mini-heap algorithm to find the K LBA regions with the highest access frequency in this time segment, namely Top-K; whenever a statistical time segment ends, the firmware establishes a red-black tree with a depth of logK for the K LBAregions according to the LBAregion id; when processing each host write, the firmware uses the LBA region id corresponding to the starting LBA as an index to traverse the red-black tree generated by the previous statistical time segment. When the LBAregion id is not in the red-black tree, it is determined to be cold data, otherwise it is hot data. When it is determined to be cold data, the host write is written to the cold data block, otherwise it is written to the hot data block. The use of the red-black tree can quickly determine whether the current host write is cold data or hot data.
[0059] The method for realizing hot and cold data separation of a solid-state hard disk provided by an embodiment of the present invention can more accurately and quickly determine whether the data to be written by the current host is cold data or hot data by using a red-black tree method to determine whether the LBA area corresponding to the current LBA of the data to be written falls into the K LBA areas with the highest access frequency in the previous statistical time segment, and efficiently separate the cold and hot data of the host. By separating the cold and hot data of the host, the write amplification can be effectively reduced, thereby increasing the service life of the SSD.
[0060] In an embodiment of the present invention, at the end of the current statistical time segment, a mini-heap algorithm can be used to find the K LBA areas with the largest access count values within the current statistical time segment; a red-black tree with a depth of logK is established for the K LBA areas according to the corresponding area identifiers.
[0061] Among them, the mini-heap is a complete binary tree, and the value of its root node will not exceed the value of the left and right subtrees, and the left and right subtrees are also mini-heap trees. The present invention uses the mini-heap to obtain the K LBA regions with the highest access frequency in a certain statistical time segment. Assuming that there are M LBA regions, the time complexity of obtaining the K largest LBA regions is O(M*logK). The red-black tree is a special balanced binary tree, which can be completed with a time complexity of O(logN) to search for an element in data with a data volume of N. The present invention will establish a red-black tree based on the LBA region id for the K LBA regions with the highest access frequency in the previous statistical time segment, and then use the red-black tree in the next statistical time segment to determine whether the host writes cold data or hot data.
[0062] In this embodiment, whenever a statistical time segment is about to end, it is necessary to count the K LBA regions with the highest access frequency in the statistical time segment. The present invention can use the mini-heap algorithm to obtain the K LBA regions with the highest access frequency in a certain time segment. Assuming there are M LBA regions, the time complexity of obtaining the K largest LBA regions is O(M*logK). For example, assuming there are 12 LBA regions, Figure 3 As shown in the figure, R(i) represents the i-th LBA region, and V(i) represents the access frequency of the i-th LBA region. Now we need to use the small top heap algorithm to count the top K (K=5) LBA regions with the highest access frequency. The specific method is: first, create a small top heap for V(0)~V(4). The created small top heap is as follows: Figure 4 As shown; then traverse the remaining access frequencies V(i)(5≤i≤11). If V(i) is smaller than the root node value of the small top heap, V(i) is not the K LBA region with the highest access frequency. Otherwise, use V(i) to replace the root node of the small top heap and adjust the small top heap. When the scan of V(i)(5≤i≤11) is completed, the small top heap tree is the K LBA region with the highest access frequency. Figure 5 The small top pile built last.
[0063] When the statistical time segment is about to end, a red-black tree needs to be established based on the LBA region id for the top K LBA regions with the highest access frequency. Figure 6Shows the Figure 5 The red-black tree of the small top heap node is established based on the LBA region id.
[0064] In one embodiment of the present invention, whenever a statistical time segment is about to end, the first write rate of the host in the current statistical time segment is compared with the second write rate of the host in the previous statistical time segment, and when the first write rate is greater than the second write rate, the K value is reduced, and when the first write rate is less than the second write rate, the K value is increased. Further, according to the size of the difference between the first write rate and the second write rate, an adjustment level matching the difference is selected, and the K value is adjusted according to the corresponding adjustment level, that is, when the first write rate is greater than the second write rate, the K value is reduced according to the corresponding adjustment level, and when the first write rate is less than the second write rate, the K value is increased according to the corresponding adjustment level.
[0065] In this embodiment, whenever a statistical time segment is about to end, the firmware compares the write rate of the host in the current time segment with the write rate of the host in the previous statistical time segment. When it is found that the host write rate increases and exceeds a certain threshold, the K value is appropriately reduced, otherwise the K value is appropriately increased. The K value can be divided into several gears, such as the LBA region with the top 30% of access frequency, the LBA region with the top 20% of access frequency, the LBA region with the top 10% of access frequency, turning off the hot and cold data separation function, etc. The present invention dynamically adjusts the K value size according to the current write load, that is, dynamically adjusts the height of the red-black tree, so that the hot and cold data of the host can be separated and the impact on the write performance when separating the hot and cold data can be reduced, and the impact of the hot and cold data separation on the write performance can be reduced.
[0066] In another optional embodiment of the present invention, the hot data LBA area set is stored in the form of a queue, and the LBA area identifier is used to represent the corresponding LBA area in the queue. Wherein, the queue is formed by sorting the access count values corresponding to the LBA areas in the hot data LBA area set. Further, the determination of whether the target LBA area corresponding to the starting LBA in the target LBA is the LBA area in the hot data LBA area set corresponding to the previous statistical time segment may also include: using a binary search algorithm to determine whether the identifier of the target LBA area corresponding to the starting LBA in the target LBA is in the queue corresponding to the hot data LBA area set. In this embodiment, when the K value of Top-K is small, the LBA region id can be sorted and then the binary search algorithm can be used to determine the hot and cold data of the host in the next statistical time segment, which should also be within the scope of the present invention.
[0067] exist Figure 7The basic process of judging the hot and cold data of the host within a certain statistical time segment is described in . When the firmware receives a write command from the host, it first increases the number of accesses to the LBA region corresponding to each LBA in the host write command by 1, and updates the write speed within this statistical time segment. Then, it uses the LBA region id corresponding to the starting LBA as an index to traverse the red-black tree generated in the previous time segment, and judges whether the LBA region identifier corresponding to the starting LBA is in the red-black tree. If such an LBAregion identifier is found in the red-black tree, the host write is judged to be hot data, and the host write data is written to the hot data block. Otherwise, the host write is judged to be cold data. For example, the firmware receives a write command from the host, and the LBA region corresponding to the starting LBA of the write command is 0, then the traversal Figure 6 The red-black tree shown only needs to be compared with nodes R(7), R(5), and R(4) to determine that the host write is cold data.
[0068] The method for realizing hot and cold data separation of a solid-state hard disk provided by the present invention proposes a concept of an LBA area, so that the storage resources required for counting the usage frequency of LBA can be greatly reduced. By judging whether the LBA region corresponding to a certain LBA falls into the K LBA regions with the highest access frequency in the previous time slice, it is possible to more accurately determine whether the LBA is hot or cold data, and the K LBA regions with the highest access frequency in a certain time slice can be quickly found using the mini-heap algorithm. The present invention uses a red-black tree to quickly determine whether the host writes cold data or hot data in the next time slice; the height of the red-black tree is dynamically adjusted according to the current write load, so that the cold and hot data of the host can be separated and the impact on the write performance when separating the cold and hot data can be reduced.
[0069] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0070] In addition, an embodiment of the present invention further provides a device for separating hot and cold data of a solid state drive, wherein the device includes a functional module for implementing the method for separating hot and cold data of a solid state drive as described above. Figure 8 The structure block diagram of a device for implementing cold and hot data separation of a solid state drive according to an embodiment of the present invention is schematically shown. Figure 8The device for separating hot and cold data of a solid state drive according to an embodiment of the present invention specifically includes a region division module 201, a statistics module 202, a judgment module 203 and a control module 204, wherein:
[0071] The region division module 201 is used to divide the logical block address LBA space of the solid state drive into multiple LBA regions, and add a unique identifier to each LBA region;
[0072] The statistics module 202 is used for obtaining the target LBA carried by the write instruction whenever receiving the write instruction from the host, and accumulating the access count value of the LBA area corresponding to each target LBA in the current statistical time segment;
[0073] The judgment module 203 is used to judge whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the last statistical time segment, wherein the LBA areas in the hot data LBA area set are K LBA areas with the largest access frequency counted in the last statistical time segment;
[0074] The control module 204 is used to determine that the data to be written is hot data and write it to the hot data block when the target LBA area is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment; otherwise, determine that the data to be written is cold data and write it to the cold data block.
[0075] In an embodiment of the present invention, the statistical module 202 is also used to use a mini-heap algorithm to find the K LBA areas with the largest access count values within the current statistical time segment at the end of the current statistical time segment; and establish a red-black tree with a depth of logK for the K LBA areas according to the corresponding area identifiers.
[0076] In an embodiment of the present invention, the hot data LBA area set is stored in the form of a red-black tree, and the LBA area identifier is used in the red-black tree to represent the corresponding LBA area; further, the judgment module 203 is specifically used to judge whether the identifier of the target LBA area corresponding to the starting LBA in the target LBA is in the red-black tree corresponding to the hot data LBA area set.
[0077] In the embodiment of the present invention, the statistical module 202 is also used to count and update the first write speed in the current statistical time segment, compare the first write rate of the host in the current statistical time segment with the second write rate of the host in the previous statistical time segment, and reduce the K value when the first write rate is greater than the second write rate, and increase the K value when the first write rate is less than the second write rate. Further, the statistical module 202 is also used to select an adjustment level that matches the difference between the first write rate and the second write rate according to the size of the difference between the first write rate and the second write rate, and adjust the K value according to the corresponding adjustment level.
[0078] In an embodiment of the present invention, the hot data LBA area set is stored in the form of a queue, and the LBA area identifier is used to represent the corresponding LBA area in the queue; further, the judgment module 203 is specifically used to use a binary search algorithm to determine whether the identifier of the target LBA area corresponding to the starting LBA in the target LBA is in the queue corresponding to the hot data LBA area set.
[0079] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment, and it has corresponding technical effects.
[0080] In addition, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for separating hot and cold data of a solid-state hard disk are implemented as described above.
[0081] In this embodiment, if the method for realizing the separation of hot and cold data of a solid state drive is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0082] In addition, an embodiment of the present invention further provides a solid state drive, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for separating hot and cold data of a solid state drive when executing the computer program. Figure 1 Alternatively, when the processor executes the computer program, the functions of each module / unit in the above-mentioned device for separating hot and cold data of a solid state drive are realized, for example Figure 8 The area division module 201, the statistical module 202, the judgment module 203 and the control module 204 are shown.
[0083] The method, device and solid-state hard disk for implementing cold and hot data separation of a solid-state hard disk provided by the embodiment of the present invention propose a concept of LBA region, and form multiple LBA regions by dividing the logical block address LBA space of the solid-state hard disk. When the LBA usage frequency is counted based on the LBA region, the storage resources occupied by the cold and hot data separation function can be greatly reduced. By using a red-black tree method to determine whether the LBA region corresponding to the current LBA of the data to be written falls into the K LBA regions with the highest access frequency in the previous statistical time segment, it can be more accurately and quickly determined whether the data to be written by the current host is cold data or hot data, and the host cold and hot data can be efficiently separated. By separating the host cold and hot data, write amplification can be effectively reduced, thereby increasing the service life of the SSD.
[0084] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, any one of the claimed embodiments may be used in any combination.
[0085] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for separating hot and cold data in a solid state drive, characterized in that: The method comprises: The logical block address LBA space of the solid state drive is divided into multiple LBA areas, and a unique identifier is added to each LBA area; Whenever a write command is received from the host, the target LBA carried by the write command is obtained, and the access count value of the LBA area corresponding to each target LBA in the current statistical time segment is accumulated; Determine whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the last statistical time segment, wherein the LBA areas in the hot data LBA area set are K LBA areas with the largest access frequencies counted in the last statistical time segment; If the target LBA area is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment, the data to be written is determined to be hot data and written to the hot data block; otherwise, the data to be written is determined to be cold data and written to the cold data block.
2. The method according to claim 1, characterized in that: The hot data LBA area set is stored in the form of a red-black tree, and the LBA area identifier is used in the red-black tree to represent the corresponding LBA area; Further, the step of determining whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in a set of hot data LBA areas corresponding to a previous statistical time segment includes: It is determined whether the identifier of the target LBA area corresponding to the start LBA in the target LBA is in the red-black tree corresponding to the hot data LBA area set.
3. The method according to claim 1, characterized in that The method further comprises: At the end of the current statistical time segment, the small top heap algorithm is used to find the K LBA areas with the largest access count value in the current statistical time segment; A red-black tree with a depth of logK is established for the K LBA areas according to the corresponding area identifiers.
4. The method according to claim 1, characterized in that: The method further comprises: Compare the first write rate of the host in the current statistical time segment with the second write rate of the host in the previous statistical time segment. When the first write rate is greater than the second write rate, reduce the K value; when the first write rate is less than the second write rate, increase the K value.
5. The method according to claim 4, characterized in that The method further comprises: An adjustment level matching the difference between the first write rate and the second write rate is selected according to the difference, and the K value is adjusted according to the corresponding adjustment level.
6. The method according to claim 1, characterized in that The hot data LBA area set is stored in the form of a queue, and the LBA area identifier is used in the queue to represent the corresponding LBA area; Further, the step of determining whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment includes: A binary search algorithm is used to determine whether the identifier of the target LBA area corresponding to the start LBA in the target LBA is in the queue corresponding to the hot data LBA area set.
7. The method according to claim 1, characterized in that When the logical block address LBA space of the solid state drive is divided, each LBA can only correspond to one LBA area.
8. A device for separating hot and cold data in a solid state drive, characterized in that: The device comprises: A region division module is used to divide the logical block address LBA space of the solid state drive into multiple LBA regions, and add a unique identifier to each LBA region; The statistics module is used to obtain the target LBA carried by the write instruction whenever receiving the write instruction from the host, and accumulate the access count value of the LBA area corresponding to each target LBA in the current statistical time segment; A judgment module is used to judge whether the target LBA area corresponding to the start LBA in the target LBA is an LBA area in the hot data LBA area set corresponding to the last statistical time segment, wherein the LBA areas in the hot data LBA area set are K LBA areas with the largest access frequency counted in the last statistical time segment; The control module is used to determine that the data to be written is hot data and write it into a hot data block when the target LBA area is an LBA area in the hot data LBA area set corresponding to the previous statistical time segment; otherwise, determine that the data to be written is cold data and write it into a cold data block.
9. The device according to claim 7, characterized in that The statistical module is also used to use a mini-heap algorithm to find the K LBA areas with the largest access count values in the current statistical time segment when the current statistical time segment ends; and establish a red-black tree with a depth of logK for the K LBA areas according to the corresponding area identifiers.
10. A solid state hard disk, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 7 when executing the computer program.
Citation Information
Cited By
Port data tracing method and system and related equipment
CN121879689A
