A hot data reading method and related apparatus

By storing the physical addresses of hot data in the solid-state drive based on counting identifiers and red-black tree structures, the problems of reduced read and write speeds after the SLC cache is full and hash index table collisions are solved, enabling efficient filtering and fast lookup of hot data.

CN115729955BActive Publication Date: 2026-02-06ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211486649.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-24
Publication Date
2026-02-06
Estimated Expiration
2042-11-24

AI Technical Summary

Technical Problem

In existing technologies, when solid-state drives migrate data to MLC/TLC mode after the SLC cache is full, the read and write speeds decrease, and the hash index table experiences collisions when there is too much hot data, resulting in a decrease in the indexing speed of hot data.

Method used

Hot data is identified by counting identifiers based on target data, and the physical address of hot data is stored using a red-black tree structure. It is then numbered using a hash algorithm to achieve fast lookup.

Benefits of technology

It improves the accuracy and speed of hot data filtering, reduces hash collisions, and maintains the high efficiency of hot data reading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115729955B_ABST
    Figure CN115729955B_ABST
Patent Text Reader

Abstract

The application discloses a hot data reading method and related device, and relates to the technical field of computers.In the application, the target data is determined as hot data based on a target count identifier of the target data; a target logical address of the target data is subjected to a shift operation according to a set step length, and a target number of a target red-black tree is obtained; the target red-black tree is obtained from a red-black tree set based on the target number; a target offset is obtained based on the target logical address and the set step length, a target physical address is obtained from the target red-black tree based on a first address of the target red-black tree and the target offset, and the target data is obtained according to the target physical address.In this way, cold and hot data are distinguished through variable count identifiers, the accuracy of hot data screening is improved, and the physical addresses of the hot data are stored in the red-black tree through a hash algorithm, so that the hot data searching speed is also improved in the case that the hot data amount is large.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, and in particular to a hot data reading method and related device. BACKGROUND

[0002] A solid state disk (SSD) is a computer external storage device, usually using flash memory as a storage medium. In a flash memory-based solid state disk, the storage unit includes a single layer cell flash memory (SLC), a multi-layer cell flash memory (MLC), and a trinary level cell (TLC). Each storage unit of the SLC can store one bit of data, each storage unit of the MLC can store two bits of data, and each storage unit of the TLC can store three bits of data. The SLC has the smallest storage capacity but the fastest read-write speed, and vice versa. The TLC has the largest storage capacity but the slowest read-write speed.

[0003] In a solid state disk, online data frequently accessed by a host is referred to as hot data, and offline data not frequently accessed is referred to as cold data. In related technologies, in order to improve the access speed of hot data, an SLC cache reading method can be used, that is, a part of the capacity of the MLC / TLC is simulated as an SLC cache, so as to achieve the read speed of data in the SLC mode.

[0004] However, when the SLC cache is full, data will be migrated to the MLC / TLC mode block in the MLC / TLC writing mode, and the read-write speed of the data will be reduced to the read-write speed of the MLC / TLC mode. In addition, data migration will increase the number of erasures of the SLC cache, thereby affecting the service life of the storage unit.

[0005] To solve the above problems, the prior art proposes to establish different index mechanisms for cold and hot data, to improve the read performance of hot data in the solid state disk by improving the search speed of hot data. The specific operation is to classify the data recently written into the solid state disk as hot data, and record the storage address of the hot data using a hash index.

[0006] However, merely classifying the data recently written into the solid state disk as hot data will result in inaccurate screening of hot data. On the other hand, if the number of hot data is too large, the hash index table will have too many collision phenomena, thereby degenerating into a linked list, greatly reducing the index speed of hot data.

[0007] Therefore, a new hot data reading method is needed to solve the above problems. SUMMARY

[0008] The application provides a hot data reading method and a related device to improve the reading speed of hot data.

[0009] In a first aspect, the application provides a hot data reading method, which includes:

[0010] Based on a target count identifier of the target data, the target data is determined to be hot data, and the target count identifier represents the number of times the target data is read within a set time length.

[0011] The target logical address of the target data is subjected to a shift operation according to a set step, and a target number of a target red-black tree is obtained, and the target physical address of the target data is saved in the target red-black tree.

[0012] Based on the target number, the target red-black tree is obtained from a red-black tree set, and the red-black tree set includes M red-black trees, and M is positively correlated with the number of hot data.

[0013] Based on the target logical address and the set step, a target offset is obtained, and based on the first address of the target red-black tree and the target offset, the target physical address is obtained from the target red-black tree, and the target data is obtained according to the target physical address.

[0014] In a second aspect, the application also provides a hot data reading device, which includes:

[0015] The screening module is configured to determine, based on a target count identifier of the target data, that the target data is hot data, and the target count identifier represents the number of times the target data is read within a set time length.

[0016] The shift module is configured to subject the target logical address of the target data to a shift operation according to a set step, and obtain a target number of a target red-black tree, and the target physical address of the target data is saved in the target red-black tree.

[0017] The acquisition module is configured to obtain, based on the target number, the target red-black tree from a red-black tree set, and the red-black tree set includes M red-black trees, and M is positively correlated with the number of hot data.

[0018] The positioning module is configured to obtain, based on the target logical address and the set step, a target offset, and based on the first address of the target red-black tree and the target offset, the target physical address is obtained from the target red-black tree, and the target data is obtained according to the target physical address.

[0019] Optionally, when the screening module is configured to determine, based on the target count identifier of the target data, that the target data is hot data, the screening module is configured to:

[0020] Within a set time period, each time the target data is read, the target count flag of the target data is incremented by 1 until the target count flag equals the preset first hot data threshold, at which point the counting stops and the target data is determined to be hot data.

[0021] Optionally, the filtering module is also used for:

[0022] When the set time expires, obtain the target count identifier of the target data;

[0023] If the target count flag is less than the second hot data threshold, the target count flag will be cleared to zero, and counting will restart within the next set time period.

[0024] If the target count identifier of the target data is not less than the second hot data threshold and is less than the first hot data threshold, then the counting will continue for the next set time period.

[0025] Optionally, after determining that the target data is hot data, the filtering module is also used for:

[0026] If the target data is not read in the subsequent N read operations, the target count flag is decremented by 1;

[0027] If the physical block corresponding to the target data is erased, the target count flag is cleared to zero.

[0028] If the target count flag decreases to less than the preset second hot data threshold, or if the target count flag is cleared to zero, the target data is updated to cold data, and the target physical address of the target data is deleted from the target red-black tree.

[0029] Optionally, the red-black tree set is obtained by the acquisition module in the following way:

[0030] Based on the preset height of the red-black tree, determine the number of units that the red-black tree can store, and based on the number of hot data, determine the number M of red-black trees;

[0031] Based on the physical address of each hot data, the number of units that a red-black tree can store, and the number M of red-black trees, a preset hash algorithm is used to determine the number of each red-black tree.

[0032] Insert the physical address of each thermal data into the corresponding red-black tree;

[0033] The starting address and number of each red-black tree are saved to a hash table to obtain the red-black tree set.

[0034] Optionally, when inserting the physical addresses of each heat data point into the corresponding red-black trees, the acquisition module is also used for:

[0035] When inserting the physical address of a hot data item into the corresponding red-black tree, the following operations are performed:

[0036] If the red-black tree is empty, the physical address of a hot data is inserted into the red-black tree as a root node of the red-black tree.

[0037] If the red-black tree is not empty and the physical address of the hot data is smaller than the physical address stored in the root node of the red-black tree, the physical address of the hot data is inserted into the left subtree of the root node of the red-black tree.

[0038] If the red-black tree is not empty and the physical address of the hot data is greater than the physical address stored in the root node of the red-black tree, the physical address of the hot data is inserted into the right subtree of the root node of the red-black tree.

[0039] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable by the processor, and the processor implements the method according to any one of the first aspect when executing the computer program.

[0040] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, having a computer program stored thereon, and the computer program is executable by a processor to implement the steps of the method according to any one of the first aspect.

[0041] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when invoked by a computer, causes the computer to execute the method according to the first aspect.

[0042] In the embodiment of the present application, the target data is determined as hot data based on the target count identifier of the target data, the target logical address of the target data is shifted by a set step to obtain a target number of a target red-black tree, the target red-black tree is obtained from a red-black tree set based on the target number, the target offset is obtained based on the target logical address and the set step, the target physical address is obtained from the target red-black tree based on the first address of the target red-black tree and the target offset, and the target data is obtained according to the target physical address.

[0043] In this way, the hot and cold data are distinguished by the count identifier, the accuracy of hot data screening is improved, the physical addresses of the hot data are stored in the red-black tree by using the hash algorithm, and the hot data searching speed is also accelerated in the case of a large number of hot data. BRIEF DESCRIPTION OF DRAWINGS

[0044] Figure 1 FIG. 1 is a schematic diagram of a system architecture in an embodiment of the present application;

[0045] Figure 2 FIG. 2 is a detailed flowchart of hot data reading under the system architecture in an embodiment of the present application;

[0046] Figure 3 A flow chart for creating a red-black tree set under the system architecture in the embodiment of the present application;

[0047] Figure 4 A flow chart for inserting a target hot data physical address into a target red-black tree in the embodiment of the present application;

[0048] Figure 5 A schematic diagram of inserting a hot data physical address into a non-empty red-black tree provided in the embodiment of the present application;

[0049] Figure 6 A schematic diagram of inserting a hot data physical address into a multi-node red-black tree provided in the embodiment of the present application;

[0050] Figure 7 A schematic diagram of a red-black tree after balance adjustment provided in the embodiment of the present application;

[0051] Figure 8 A schematic diagram of inserting another hot data physical address into a non-empty red-black tree provided in the embodiment of the present application;

[0052] Figure 9 A schematic diagram of inserting another hot data physical address into a multi-node red-black tree provided in the embodiment of the present application;

[0053] Figure 10 A schematic diagram of another red-black tree after balance adjustment provided in the embodiment of the present application;

[0054] Figure 11 A detailed flow chart of hot data reading in actual application provided in the embodiment of the present application;

[0055] Figure 12 A scene schematic diagram of hot data reading in actual application provided in the embodiment of the present application;

[0056] Figure 13 A structure schematic diagram of a hot data reading device provided in the embodiment of the present application;

[0057] Figure 14 A structure schematic diagram of an electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0058] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be described in detail below with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments described in the present application, all the other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the technical solutions of the present application.

[0059] Some concepts involved in the embodiments of the present application will be introduced below.

[0060] (1) Data Block Unit (DBU): the minimum unit of data writing in a solid state disk.

[0061] (2) Logical Allocation Address (LAA): in a computer with address conversion function, the address (operand) given by an internal instruction is called logical address.

[0062] (3) Physical Allocation Address (PAA): the actual effective address in the memory obtained by calculating or converting the logical address through the addressing mode, called physical address, that is, the address used to describe the physical location of each DBU.

[0063] (4) Red-Black Tree: a self-balancing binary search tree, which can complete data searching, adding, deleting and other operations in a small time complexity.

[0064] (5) Hash Algorithm: a specific function is used to map a set of keys to a limited address interval. Hash algorithm is a basic technology used for information storage and query. Its main advantages are simple operation, short pre-processing time, low memory consumption, fast matching search speed, easy maintenance and refreshing, and support for a large number of matching rules.

[0065] The preferred embodiments of the present application will be described in detail below with reference to the drawings.

[0066] Reference is made to Figure 1As shown, in the embodiment of the present application, a hash table 100 and a plurality of red-black trees 101 are included, wherein the hash table 100 stores the numbers and the first addresses of the red-black trees 101, the number of each red-black tree 101 is mapped by a preset hash algorithm based on the physical address of each hot data, the number of the red-black trees 101 that can be stored, and the number M of the red-black trees 101, and each red-black tree 101 stores the physical address of each hot data. When the host needs to read the target hot data in the solid state disk, the corresponding red-black tree number is obtained through the logical address of the hot data, and then the first address of the red-black tree with the corresponding number is found in the hash table to obtain the physical address of the target hot data, and finally the target data is read according to the physical address.

[0067] Based on the above system architecture, refer to Figure 2 As shown, in the embodiment of the present application, the detailed process of the HOST reading the hot data of the solid state disk is as follows:

[0068] Step 201: Based on the target count identifier of the target data, it is determined that the target data is hot data.

[0069] The target count identifier represents the number of times the target data is read within a set time period.

[0070] Specifically, in the embodiment of the present application, within a set time period, each time the target data is read, the target count identifier of the target data is incremented by 1, until the target count identifier is equal to the first hot data threshold, the counting is stopped, and the target data is determined to be hot data.

[0071] For example, within half a year, each time data A is read by the HOST, its count identifier is incremented by 1, and when the count identifier increases to the first hot data threshold 1000, the count identifier is no longer increased, data A is determined to be hot data, and its physical address is saved to the corresponding red-black tree.

[0072] Further, at the end of the set time period, i.e. when the counting time period is half a year, the target count identifier of the target data is obtained, including the following two cases:

[0073] Case one: if the target count identifier is less than the second hot data threshold, the target count identifier is cleared, and the counting is restarted in the next set time period.

[0074] For example, if the count identifier of data A is 500, which is less than the second hot data threshold 800, the count identifier of data A is cleared, and the counting is restarted when data A is read by the HOST in the next half year.

[0075] Case two: if the target count identifier of the target data is not less than the second hot data threshold and less than the first hot data threshold, the counting is continued in the next set time period.

[0076] For example, if the count identifier of data A is 900, greater than the second hot data threshold 800 and less than the first hot data threshold 1000, then the count identifier of data A will continue from 900 in the next half year.

[0077] On the other hand, in the embodiments of the present application, when the count identifier of data A is equal to 1000 and the data A is determined as hot data, the count identifier of data A can be reduced, including but not limited to the following two cases:

[0078] Case one: if the target data is not read in the next N read operations, the target count identifier is reduced by 1.

[0079] For example, assuming N = 200, if data A is not read in the next 20 read operations, the count identifier of data A is reduced by 1, that is, if data A is not read in a round of 20 read operations, the count identifier of data A is reduced by 1.

[0080] Case two: if the physical block corresponding to the target data is erased, the target count identifier is cleared.

[0081] For example, when the physical block corresponding to data A in the solid state disk is erased, the count identifier corresponding to data A is cleared.

[0082] Further, if the target count identifier is reduced to less than the second preset hot data threshold, or the target count identifier is cleared, the target data is updated to cold data, and the target physical address of the target data is deleted from the target red-black tree.

[0083] For example, if the count identifier of data A is reduced to less than the second hot data threshold 800, or the count identifier is cleared, the HOST updates data A to cold data, and deletes the physical address of data A from the corresponding red-black tree.

[0084] Based on the step 201, each DBU corresponds to a count identifier, which is used to represent the "temperature" of the data in the DBU, which improves the accuracy of hot data screening. At the same time, when the count identifier is reduced to less than the second hot data threshold, the data is updated to cold data, which provides a buffer period for the switching of hot data to cold data, and can avoid frequent insertion and deletion operations of the red-black tree.

[0085] Step 202: performing a shift operation on the target logical address of the target data according to a set step, to obtain a target number of the target red-black tree.

[0086] The target red-black tree stores the target physical address of the target data.

[0087] For example, assuming that the logical address of the data A is LAA_a, and the step length is set to 4, the red-black tree number corresponding to the data A is ID = LAA_a >> 4, that is, the logical address LAA_a of the data A is right shifted by 4 bits to obtain the number ID of the red-black tree corresponding to the data A.

[0088] Step 203: obtaining the target red-black tree from the red-black tree set based on the target number.

[0089] The red-black tree set includes M red-black trees, and M is positively correlated with the number of hot data.

[0090] Specifically, referring to FIG. 2, in the embodiment of the present application, the red-black tree set is obtained in the following manner: Figure 3

[0091] Step 301: determining the number of units that can be stored in a red-black tree based on the preset height of the red-black tree, and determining the number M of red-black trees based on the number of hot data.

[0092] For example, assuming that the preset height of the red-black tree is H, the number of units that can be stored in the red-black tree is CNT, and the number of hot data is NUM, then the number of red-black trees is M = NUM / CNT.

[0093] Step 302: determining the number of each red-black tree based on the physical address of each hot data, the number of units that can be stored in the red-black tree, and the number M of red-black trees, by using a preset hash algorithm.

[0094] For example, PAA represents the physical address of each hot data, and the number ID of each red-black tree corresponding to each hot data can be obtained by using a preset hash algorithm: ID = (PAA / CNT) % M.

[0095] Step 303: inserting the physical address of each hot data into the corresponding red-black tree.

[0096] Step 304: saving the first address and the number of each red-black tree in a hash table to obtain the red-black tree set.

[0097] Specifically, when step 303 is performed, referring to FIG. 3, when the physical address of one hot data is inserted into the corresponding red-black tree, the following operations are performed: Figure 4

[0098] Step 3031: if one red-black tree is empty, inserting the physical address of one hot data as the root node of one red-black tree into the red-black tree.

[0099] For example, if the red-black tree with ID = 1 is empty, when the physical address PAA_a of the data A is inserted into the red-black tree with ID = 1, PAA_a is the root node of the red-black tree, and the root node is black. ​​

[0100] Step 3032: If a red-black tree is not empty, and a physical address of a hot data is less than a physical address saved in a root node of a red-black tree, then insert the physical address of the hot data into a left sub-tree of the root node of the red-black tree.

[0101] For example, referring to FIG. 6, if there already exists a black root node PAA l in the red-black tree of ID = 1, and the physical address PAA a of data A is less than PAA l, then insert PAA a as a left sub-tree of the root node PAA l into the red-black tree, and the node corresponding to PAA a is red (in the figure, 20% pure color filling represents black, and 10% pure color filling represents red). Figure 5 For example, referring to FIG. 6, if there already exists a black root node PAA l in the red-black tree of ID = 1, and the physical address PAA a of data A is less than PAA l, then insert PAA a as a left sub-tree of the root node PAA l into the red-black tree, and the node corresponding to PAA a is red (in the figure, 20% pure color filling represents black, and 10% pure color filling represents red).

[0102] Figure 6 For example, referring to FIG. 6, if there already exists a black root node PAA l in the red-black tree of ID = 1, and the physical address PAA a of data A is less than PAA l, then insert PAA a as a left sub-tree of the root node PAA l into the red-black tree, and the node corresponding to PAA a is red (in the figure, 20% pure color filling represents black, and 10% pure color filling represents red). Figure 7 For example, referring to FIG. 6, if there already exists a black root node PAA l in the red-black tree of ID = 1, and the physical address PAA a of data A is less than PAA l, then insert PAA a as a left sub-tree of the root node PAA l into the red-black tree, and the node corresponding to PAA a is red (in the figure, 20% pure color filling represents black, and 10% pure color filling represents red).

[0103] For example, referring to FIG. 6, if there already exists a black root node PAA l in the red-black tree of ID = 1, and the physical address PAA a of data A is less than PAA l, then insert PAA a as a left sub-tree of the root node PAA l into the red-black tree, and the node corresponding to PAA a is red (in the figure, 20% pure color filling represents black, and 10% pure color filling represents red).

[0104] Figure 8 For example, referring to FIG. 6, if there already exists a black root node PAA l in the red-black tree of ID = 1, and the physical address PAA a of data A is less than PAA l, then insert PAA a as a left sub-tree of the root node PAA l into the red-black tree, and the node corresponding to PAA a is red (in the figure, 20% pure color filling represents black, and 10% pure color filling represents red).

[0105] For example, referring to FIG. 6, if there already exists a black root node PAA l in the red-black tree of ID = 1, and the physical address PAA a of data A is less than PAA l, then insert PAA a as a left sub-tree of the root node PAA l into the red-black tree, and the node corresponding to PAA a is red (in the figure, 20% pure color filling represents black, and 10% pure color filling represents red). Figure 9 Figure 10 ​​​​As shown, the PAA_4 node is taken as the root node and modified to black, and the PAA_3 node is taken as the left child node of the PAA_4 node and modified to red.

[0106] The balance adjustment of the red-black tree is a prior art and will not be described here.

[0107] Based on the step 203, the data structure of the red-black tree is used to store the physical addresses of the hot data, which can accelerate the searching speed of the hot data. Meanwhile, each red-black tree is numbered by using the hash algorithm, which can accelerate the searching speed of each red-black tree. Since the number of the red-black trees is positively correlated with the number of the hot data, i.e., the more the number of the hot data, the more the number of the red-black trees, the generation of the hash conflict can be avoided. In the case of a large number of hot data, the method still has a high hot data searching speed. When the physical address of a hot data is obtained, the red-black tree in which the hot data is located will be read into the memory, so that the searching speed of other hot data whose physical addresses are stored in the red-black tree can be further accelerated.

[0108] Step 204: Based on the target logical address and the set step length, a target offset is obtained, and based on the first address of the target red-black tree and the target offset, a target physical address is obtained from the target red-black tree, and based on the target physical address, a target data is obtained.

[0109] For example, based on the algorithm offset = LAA_a & ((1 << 4) - 1), i.e., the result of the set step length 4 left shifted by 1 and then subtracted by 1 is ANDed with the logical address LAA_a of the data A, the offset of the node in which the physical address of the data A is stored relative to the first address of the corresponding red-black tree is obtained. The first address of the red-black tree plus the offset offset can find the physical address PAA_a of the data A in the red-black tree. Finally, the data A is obtained in the solid state disk according to the physical address PAA_a.

[0110] Optionally, in the above embodiment, the values of the first hot data threshold, the second hot data threshold, and the set time length are only used to illustrate the present application, and should be determined according to the actual situation. Meanwhile, the selection of the set step length is related to the addressing bit number of the computer and the storage mode of the red-black tree, and should be determined according to the actual situation.

[0111] The above embodiment will be further described in detail through two specific application scenarios.

[0112] Referring to Figure 11 As shown, the specific process of reading the hot data in the embodiment of the present application is as follows:

[0113] Suppose the HOST wants to read the data B with the logical address 0x11, the HOST first executes the step 1101:

[0114] Step 1101: judging whether the data B is hot data, if yes, executing step 1102, otherwise executing step 1106.

[0115] Specifically, referring to Figure 12 Fig. 2, the count identifier of the data B is 1000, so it is determined that the data B is hot data.

[0116] Step 1102: obtaining the number of the target red-black tree according to the logical address of the data B, and executing step 1103.

[0117] Specifically, referring to Figure 12 Fig. 2, the logical address 0x11 of the data B is right shifted by 4 bits, and the number of the target red-black tree is obtained as ID = 1.

[0118] Step 1103: obtaining the target offset according to the logical address of the data B, and executing step 1104.

[0119] Specifically, referring to Figure 12 Fig. 2, the result of left shifting the step length 4 by 1 bit is reduced by 1, and the logical address 0x11 of the data B is subjected to AND operation, and the target offset offset = 0x01 is obtained.

[0120] Step 1104: obtaining the physical address of the data B according to the first address of the target red-black tree and the target offset, and executing step 1105.

[0121] Specifically, the first address 0xA1 of the target red-black tree is added to the target offset 0x01, and the node address 0xA2 where the physical address of the data B is stored is obtained, and then the physical address PAA_b of the data B is obtained.

[0122] Step 1105: reading the data B in the solid state disk according to the physical address of the data B.

[0123] Step 1106: obtaining the physical address of the data B according to the conventional addressing mode, and executing step 1105.

[0124] On the other hand, the specific process of inserting the physical address of the hot data into the red-black tree in the embodiment of the application is as follows:

[0125] Suppose that before the half-year time limit, the count identifier of the data C is 999, and the HOST reads the data C again, at this moment, the count identifier of the data C is 1000, which is equal to the first hot data threshold, so the data C is hot data, and its physical address needs to be saved into the corresponding red-black tree.

[0126] First, the ID corresponding to the target red-black tree of the data C is obtained by ID=(PAA_c / CNT) %M. Specifically, assuming that the physical address PAA_c of the data C is 0xC580, the number of units CNT that can be stored in each red-black tree is 4096, and the number of red-black trees M is 250, then the ID of the target red-black tree corresponding to the data C is ID=(0xC580 / 4096) %250=200.

[0127] The first address of the red-black tree with ID=200 is obtained in the hash table. Starting from the root node, if PAA_c is less than the physical address saved in the root node, then PAA_c is saved to the left subtree of the root node, otherwise, it is saved to the right subtree of the root node. Further, if the left subtree or the right subtree of the root node has a next layer of nodes, then the comparison of the next layer is continued. Finally, after PAA_c is inserted into the target red-black tree, it is determined whether the newly inserted PAA_c node causes the red-black tree to be unbalanced, and the balancing adjustment is performed.

[0128] In addition, although the operations of the method of the present application are described in a specific order in the accompanying drawings, this does not require or imply that the operations must be performed in this specific order, or that all of the shown operations must be performed to achieve the desired result. Additionally or alternatively, certain steps can be omitted, combined into one step, and / or divided into multiple steps.

[0129] Based on the same technical concept, referring to Figure 13 The embodiment of the present application also provides a hot data reading device, which comprises:

[0130] The screening module 1301 is configured to determine that the target data is hot data based on a target count identifier of the target data, and the target count identifier represents the number of times that the target data is read within a set time length.

[0131] The shifting module 1302 is configured to perform a shifting operation on a target logical address of the target data according to a set step length, and obtain a target number of a target red-black tree, and the target physical address of the target data is saved in the target red-black tree.

[0132] The obtaining module 1303 is configured to obtain the target red-black tree from the red-black tree set based on the target number, wherein the red-black tree set comprises M red-black trees, and M is positively correlated with the number of hot data.

[0133] The positioning module 1304 is configured to obtain a target offset based on the target logical address and the set step length, obtain the target physical address from the target red-black tree based on the first address of the target red-black tree and the target offset, and obtain the target data according to the target physical address.

[0134] Optionally, based on the target count identifier of the target data, when the target data is determined as hot data, the screening module 1301 is configured to:

[0135] Within the set time length, each time the target data is read, the target count identifier of the target data is increased by 1, until the target count identifier is equal to the first hot data threshold, the counting is stopped, and the target data is determined as hot data.

[0136] Optionally, the screening module 1301 is further configured to:

[0137] At the end of the set time length, the target count identifier of the target data is obtained;

[0138] If the target count identifier is less than the second hot data threshold, the target count identifier is cleared, and the counting is restarted in the next set time length.

[0139] If the target count identifier of the target data is not less than the second hot data threshold and is less than the first hot data threshold, the counting is continued in the next set time length.

[0140] Optionally, after the target data is determined as hot data, the screening module 1301 is further configured to:

[0141] If the target data is not read in the subsequent N read operations, the target count identifier is decreased by 1;

[0142] If the physical block corresponding to the target data is erased, the target count identifier is cleared;

[0143] If the target count identifier is decreased to be less than the second hot data threshold, or the target count identifier is cleared, the target data is updated as cold data, and the target physical address of the target data is deleted from the target red-black tree.

[0144] Optionally, the red-black tree set is obtained by the obtaining module 1303 in the following manner:

[0145] Based on the height of the preset red-black tree, the number of units that can be stored in the red-black tree is determined, and based on the number of hot data, the number M of red-black trees is determined;

[0146] Based on the physical address of each hot data, the number of units that can be stored in the red-black tree, and the number M of red-black trees, a preset hash algorithm is used to determine the number of each red-black tree;

[0147] The physical address of each hot data is inserted into the corresponding red-black tree;

[0148] The first address and the number of each red-black tree are saved in a hash table to obtain the red-black tree set.

[0149] Optionally, when inserting the physical address of each hot data into the corresponding red-black tree, the obtaining module 1303 is further configured to:

[0150] When inserting the physical address of one hot data into the corresponding red-black tree, the following operations are performed:

[0151] If the red-black tree is empty, the physical address of one hot data is inserted into the red-black tree as the root node of the red-black tree.

[0152] If the red-black tree is not empty and the physical address of one hot data is smaller than the physical address stored in the root node of the red-black tree, the physical address of one hot data is inserted into the left subtree of the root node of the red-black tree.

[0153] If the red-black tree is not empty and the physical address of one hot data is greater than the physical address stored in the root node of the red-black tree, the physical address of one hot data is inserted into the right subtree of the root node of the red-black tree.

[0154] Based on the same technical concept, the embodiments of the present application further provide an electronic device, which can implement the method flow of reading hot data provided by the above-mentioned embodiments of the present application.

[0155] In one embodiment, the electronic device can be a server, a terminal device or other electronic device.

[0156] Referring to Figure 14 As shown in the figure, the electronic device can include:

[0157] At least one processor 1401 and a memory 1402 connected with the at least one processor 1401, in the embodiments of the present application, the specific connection medium between the processor 1401 and the memory 1402 is not limited, Figure 14 In the embodiment, the connection between the processor 1401 and the memory 1402 is taken as an example through the bus 1400. The bus 1400 is represented by a thick line in Figure 14 In the embodiment, only one thick line is used to represent the connection between other components, which is only a schematic representation and is not limited. The bus 1400 can be divided into an address bus, a data bus, a control bus, etc., for the convenience of representation, Figure 14 In the embodiment, only one thick line is used to represent the connection between other components, which is only a schematic representation and is not limited. The bus 1400 can be divided into an address bus, a data bus, a control bus, etc., for the convenience of representation,

[0158] In the embodiments of the present application, the memory 1402 stores instructions executable by the at least one processor 1401, and the at least one processor 1401 can execute the hot data reading method discussed above by executing the instructions stored in the memory 1402. The processor 1401 can implement Figure 13Functions of the various modules in the illustrated apparatus.

[0159] The processor 1401 is the control center of the apparatus, which can connect all the parts of the apparatus through various interfaces and lines, and monitor the whole apparatus by running or executing the instructions stored in the memory 1402 and calling the data stored in the memory 1402, so as to process the data and realize various functions of the apparatus.

[0160] In a possible design, the processor 1401 can include one or more processing units, and the processor 1401 can integrate an application processor and a modem processor, where the application processor mainly processes operating systems, user interfaces, and application programs, and the modem processor mainly processes wireless communication. It can be understood that the modem processor can also not be integrated into the processor 1401. In some embodiments, the processor 1401 and the memory 1402 can be implemented on the same chip, and in some embodiments, they can also be implemented on separate chips respectively.

[0161] The processor 1401 can be a general-purpose processor, for example, a CPU, a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the hot data reading method disclosed in the embodiments of the present application can be directly embodied by a hardware processor for execution, or be executed by a combination of hardware and software modules in the processor.

[0162] The memory 1402, as a non-volatile computer readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 1402 can include at least one type of storage medium, for example, can include flash memory, hard disk, multimedia card, card type memory, random access memory (RAM), static random access memory (SRAM), programmable read only memory (PROM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. The memory 1402 is any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited thereto. The memory 1402 in the embodiments of the present application can also be a circuit or any other device capable of realizing a storage function, used for storing program instructions and / or data.

[0163] By designing and programming the processor 1401, the code corresponding to the hot data reading method introduced in the foregoing embodiments can be fixed in the chip, so that the chip can execute the steps of the hot data reading method of the embodiments shown in the running time. Figure 2 How to design and program the processor 1401 is a technology known to those skilled in the art, and will not be described here.

[0164] Based on the same inventive concept, the embodiments of the present application also provide a storage medium storing computer instructions, when the computer instructions run on a computer, the computer instructions make the computer execute the hot data reading method discussed above.

[0165] In some possible implementations, the various aspects of the hot data reading method provided by the present application can also be implemented in the form of a program product, which includes program code for making the control device execute the steps of the hot data reading method according to various exemplary embodiments of the present application described above in the specification when the program product runs on the device.

[0166] It should be noted that, although several units or sub-units of the apparatus are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, according to an embodiment of the application, the features and functionalities of two or more units described above can be embodied in one unit. Conversely, the features and functionalities of one unit described above can be further divided into units embodied by several units.

[0167] Moreover, although the operations of the method(s) herein can be described in a particular, sequential order, this order is not meant to be a limitation and is not intended to imply that

[0168] Those of skill in the art would understand that embodiments of the present application can be provided as a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, and the like) embodying computer readable program code.

[0169] The present application is described in reference to flow diagrams and / or block diagrams of methods, apparatus (systems) and computer program products according to this application. It will be understood that each block of the flow diagrams and / or block diagrams, and combinations of blocks in the flow diagrams and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagram and / or block diagram in the flow diagrams and / or block diagrams can represent one or more of any of the following: a flowchart, a flow diagram, a structure chart, a Figure 1 An apparatus embodying a function specified in one or more of the flow diagrams and / or block diagrams.

[0170] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow diagrams and / or block diagrams flow or flows and / or block or blocks. Figure 1 The flow diagram and / or block diagram in the flow diagrams and / or block diagrams can represent one or more of any of the following: a flowchart, a flow diagram, a structure chart, a Figure 1 An apparatus embodying a function specified in one or more of the flow diagrams and / or block diagrams.

[0171] These computer program instructions can also be loaded into a computer or other programmable data processing devices, so that a series of operational steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide processes for implementing the functions specified in the flowchart Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1 flowchart or multiple flows and / or blocks Figure 1 Figure 1

Claims

1. A method of reading hot data, characterized by, The method comprises: determining, based on a target count identifier of target data, that the target data is hot data, the target count identifier representing a number of times the target data is read within a set time length; performing a shift operation on a target logical address of the target data according to a set step to obtain a target number of a target red-black tree in which a target physical address of the target data is stored; obtaining the target red-black tree from a red-black tree set based on the target number, wherein the red-black tree set comprises M red-black trees, and M is positively correlated with a number of the hot data; obtaining a target offset based on the target logical address and the set step, and obtaining the target physical address from the target red-black tree based on a first address of the target red-black tree and the target offset, and obtaining the target data according to the target physical address; wherein the red-black tree set is obtained in the following manner: determining a number of units that can be stored in the red-black tree based on a height of the red-black tree, and determining the number M of the red-black trees based on the number of the hot data; determining a number of each red-black tree based on a physical address of each hot data, the number of units that can be stored in the red-black tree, and the number M of the red-black trees, by using a preset hash algorithm; inserting the physical address of each hot data into a corresponding red-black tree; storing the first address and the number of each red-black tree in a hash table to obtain the red-black tree set.

2. The method of claim 1, wherein, The method comprises: when the target data is read once within the set time length, increasing the target count identifier of the target data by 1, until the target count identifier is equal to a preset first hot data threshold, stopping counting, and determining that the target data is hot data.

3. The method of claim 2, wherein, The method further comprises: acquiring the target count identifier of the target data at the end of the set time length; if the target count identifier is less than a second hot data threshold, clearing the target count identifier, and starting counting again in a next set time length; if the target count identifier of the target data is not less than the second hot data threshold and is less than the first hot data threshold, continuing counting in the next set time length.

4. The method of claim 2, wherein, After determining that the target data is hot data, the method further comprises: if the target data is not read in subsequent N read operations, decreasing the target count identifier by 1; if a physical block corresponding to the target data is erased, clearing the target count identifier; if the target count identifier is decreased to be less than a preset second hot data threshold, or the target count identifier is cleared, updating the target data to be cold data, and deleting the target physical address of the target data from the target red-black tree.

5. The method of claim 1, wherein, The method comprises: when inserting a physical address of a hot data into a corresponding red-black tree, the following operations are performed: If the one red-black tree is empty, a physical address of the one hot data is inserted into the one red-black tree as a root node of the one red-black tree; If the one red-black tree is not empty and the physical address of the one hot data is smaller than a physical address saved in a root node of the one red-black tree, the physical address of the one hot data is inserted into a left sub-tree of the root node of the one red-black tree; If the one red-black tree is not empty and the physical address of the one hot data is greater than the physical address saved in the root node of the one red-black tree, the physical address of the one hot data is inserted into a right sub-tree of the root node of the one red-black tree.

6. A thermal data reading device, characterized by, Comprise: The screening module is used for determining the target data as hot data based on a target count identifier of the target data, and the target count identifier represents a number of times that the target data is read within a set time length; The shift module is used for performing a shift operation on a target logical address of the target data according to a set step length, to obtain a target number of a target red-black tree, and the target red-black tree saves a target physical address of the target data; The acquisition module is used for obtaining the target red-black tree from a red-black tree set based on the target number, wherein the red-black tree set comprises M red-black trees, and M is positively correlated with a number of the hot data; The positioning module is used for obtaining a target offset based on the target logical address and the set step length, obtaining the target physical address from the target red-black tree based on a first address of the target red-black tree and the target offset, and obtaining the target data according to the target physical address; The red-black tree set is obtained in the following manner: Based on a preset height of a red-black tree, a number of units that can be stored in the red-black tree is determined, and a number M of the red-black trees is determined based on a number of the hot data; Based on the physical address of each hot data, the number of units that can be stored in the red-black tree, and the number M of the red-black trees, a preset hash algorithm is used to determine a number of each red-black tree; The physical address of each hot data is inserted into a corresponding red-black tree; The first address and the number of each red-black tree are saved into a hash table to obtain the red-black tree set.

7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the method of any one of claims 1-5.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1-5.

9. A computer program product, characterised in that, The computer program product, when invoked by a computer, causes the computer to execute the method of any one of claims 1-5.

Citation Information

Patent Citations

  • ROM snapshot reading method and device and storage medium

    CN111090614A

  • Memory load balancing method, device and equipment

    CN114281242A