A data processing method and device
By introducing an information table in the Cache to distinguish replaceable and non-replaceable data, and collaboratively managing the detection and replacement of hot and cold data streams, the problem of frequent replacement of hot data streams by cold data streams in the existing technology is solved, and the data efficiency is improved. Processing efficiency and Cache utilization.
Patent Information
- Application Number
- CN201880097522.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-10-12
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2038-10-12
AI Technical Summary
In the existing cache replacement strategy, the detection mechanisms of hot data streams and cold data streams are independent of each other, resulting in frequent replacement of hot data streams by cold data streams in the cache, which reduces the efficiency of data processing.
By introducing an information table in the Cache, recording the attribute identification of each address, distinguishing data that can be replaced and data that cannot be replaced, collaboratively managing the detection and replacement of hot and cold data flows, ensuring that only those that can be replaced are replaced. data.
It effectively reduces the probability of cold data streams replacing hot data streams in the cache, and improves data processing efficiency and cache utilization.
Smart Images

Figure CN112673359B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a data processing method and device. Background Art
[0002] Cache is used to store frequently used data for quick access. When using Cache, a copy of part of the content in the memory is saved in the Cache. When the central processing unit (CPU) reads and writes data, it first accesses the Cache. Only when there is no data required by the CPU in the Cache, the CPU will access the memory and transfer the entire data block containing this storage unit to the Cache, so that the subsequent accesses to the memory can be converted into accesses to the Cache. If the cache memory is full, it is necessary to replace the original block of information in the cache with this block of information under the control of the replacement control component according to a certain replacement algorithm / strategy.
[0003] In the existing cache replacement strategy, the detection of hot data streams (frequently accessed data) and cold data streams (infrequently accessed data) are independent of each other, each with a set of detection mechanisms, which consumes more resources. Moreover, this independent detection mechanism will lead to the frequent replacement of hot data streams by cold data streams in the cache, reducing the efficiency of data processing. Summary of the invention
[0004] The embodiments of the present application provide a data processing method and device, which can associate the detection mechanism of hot data flow and cold data flow. The two cooperate with each other and can effectively reduce the probability of the cold data flow replacing the hot data flow in the cache.
[0005] In order to achieve the above purpose, the embodiment of the present application adopts the following technical solution:
[0006] According to a first aspect of an embodiment of the present application, a data processing method is provided, the method comprising: receiving a request instruction, the request instruction carrying address information of requested data; determining whether the data requested by the request instruction has been stored in a cache memory Cache, and determining whether the data requested by the request instruction is a hot data stream, if it is determined that the data requested by the request instruction is not stored in the above-mentioned Cache, and the data requested by the request instruction is a hot data stream, querying a first information table according to the address information of the above-mentioned request data, and determining a target address of the above-mentioned request data in the Cache, wherein the hot data stream refers to data with an access frequency greater than or equal to a preset threshold; the above-mentioned first information table comprises one or more first addresses, the first addresses corresponding one-to-one to second addresses in the Cache, the above-mentioned first information table also comprises an attribute identifier corresponding to each first address, the attribute identifier comprises a first identifier and a second identifier, the first identifier is used to indicate that the data at the corresponding second address can be replaced, and the second identifier is used to indicate that the data at the corresponding second address cannot be replaced, and the above-mentioned target address is the second address corresponding to any one of the first addresses whose attribute identifier in the above-mentioned first information table is the first identifier; copying the data requested by the above-mentioned request instruction to the above-mentioned target address in the above-mentioned Cache. Based on this solution, the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table is determined as the target address of the hot data stream that is not stored in the cache. Therefore, when the data in the cache is replaced, only the data that can be replaced will be replaced, and the data that cannot be replaced will not be replaced. Therefore, the probability of the cold data stream replacing the hot data stream in the cache can be reduced.
[0007] In combination with the first aspect, in a possible implementation, the method further includes: if the data requested by the request instruction is successfully copied to the target address in the cache, resetting the attribute identifier of the first address corresponding to the target address in the first information table to a second identifier. Based on this solution, by successfully copying the hot data stream that has not been hit in the cache to the cache, and resetting the attribute identifier of the first address corresponding to the target address in the first information table to a second identifier, the requested data (hot data stream) is identified as data that cannot be replaced, which can effectively reduce the probability of the cold data stream replacing the hot data stream.
[0008] In combination with the first aspect and the above possible implementations, in another possible implementation, the address information of the request data includes row address information, the first information table includes one or more rows, each row includes one or more first addresses, and the first information table is queried based on the address information of the request data to determine the target address of the request data, including: searching the row indicated by the row address information in the first information table; in the row indicated by the row address information, selecting any first address with an attribute identifier as the first identifier, and determining the second address in the cache corresponding to the first address as the above target address. Based on this solution, any first address with an attribute identifier as the first identifier in the row indicated by the row address information can be determined as the target address, so that when replacing data in the cache, only the data that can be replaced is replaced, and the data that cannot be replaced will not be replaced, which can improve the data processing efficiency while reducing the probability of the cold data stream replacing the hot data stream in the cache.
[0009] In combination with the first aspect and the above possible implementations, in another possible implementation, the above method further includes: if it is determined that the data requested by the above request instruction is stored in the above cache, and the data requested by the above request instruction is a hot data stream, searching for the second address of the request data in the cache; resetting the attribute identifier of the first address corresponding to the second address in the above first information table to the second identifier. Based on this solution, by resetting the first address in the first information table corresponding to the second address of the hot data stream in the cache to the second identifier, the hot data stream is identified as data that cannot be replaced, which can reduce the probability of the cold data stream replacing the hot data stream in the cache.
[0010] In combination with the first aspect and the above possible implementation, in another possible implementation, the method further includes: if it is determined that the data requested by the request instruction is a cold data flow, according to the address information of the request data, in the second information table, the address information in any third address is replaced with the address information of the request data; wherein the cold data flow refers to data with an access frequency less than the above preset threshold; the second information table includes one or more third addresses, and the third address includes an address information. Based on this solution, the address information in any third address in the second information table can be replaced with the address information of the request data, so that when the access frequency of the request instruction is high, the data requested by the request instruction can be detected as a hot data flow.
[0011] In combination with the first aspect and the above possible implementation, in another possible implementation, the above second information table includes one or more rows, each row includes one or more third addresses, and the above replacing the address information in any third address with the address information of the above request data in the above second information table according to the address information of the above request data includes: replacing the address information in any third address in the row indicated by the above row address information with the address information of the above request data in the above second information table according to the address information of the above request data. Based on this solution, it is possible to improve data processing efficiency while ensuring that when the access frequency of the request instruction is high, the data requested by the request instruction can be detected as a hot data flow.
[0012] In combination with the first aspect and the above possible implementation, in another possible implementation, if all the attribute identifiers of any row in the above first information table are the second identifier, all the attribute identifiers in the row that are all the second identifiers are reset to the first identifier. Based on this solution, when all the attribute identifiers of a row in the first information table are the second identifier, all the attribute identifiers of the row can be reset to the first identifier, and a new round of detection can be restarted to improve the efficiency of the cache.
[0013] In combination with the first aspect and the above possible implementation, in another possible implementation, the method further includes: searching the second information table for the row indicated by the row address information according to the address information of the request data; if the address information of the request data is the same as the address information included in any third address in the row indicated by the row address information in the second information table, determining that the data requested by the request instruction is a hot data stream; if the address information of the request data is different from the address information included in all third addresses in the row indicated by the row address information in the second information table, determining that the data requested by the request instruction is a cold data stream. Based on this solution, it is possible to determine whether the data requested by the request instruction is a hot data stream or a cold data stream according to the second information table.
[0014] According to a second aspect of an embodiment of the present application, a chip is provided, the chip comprising a processor, a memory controller and a cache memory Cache, wherein the processor is used to send a request instruction, the request instruction carries address information of request data; the memory controller is used to receive the request instruction sent by the processor; determine whether the data requested by the request instruction has been stored in the cache memory Cache, and determine whether the data requested by the request instruction is a hot data stream; if it is determined that the data requested by the request instruction is not stored in the cache, and the data requested by the request instruction is a hot data stream, query a first information table according to the address information of the request data, and determine whether the request data is in the cache memory; he target address, wherein the hot data flow refers to data with an access frequency greater than or equal to a preset threshold; the above-mentioned first information table includes one or more first addresses, and the first address corresponds one-to-one to the second address in the Cache, and the above-mentioned first information table also includes an attribute identifier corresponding to each first address, and the attribute identifier includes a first identifier and a second identifier, the first identifier is used to indicate that the data on the corresponding second address can be replaced, and the second identifier is used to indicate that the data on the corresponding second address cannot be replaced, and the above-mentioned target address is the second address corresponding to any first address whose attribute identifier is the first identifier in the above-mentioned first information table; the data requested by the above-mentioned request instruction is copied to the above-mentioned target address in the above-mentioned Cache.
[0015] In combination with the second aspect, in a possible implementation method, the above-mentioned memory controller is also used to reset the attribute identifier of the first address corresponding to the above-mentioned target address in the above-mentioned first information table to the second identifier if the data requested by the above-mentioned request instruction is successfully copied to the above-mentioned target address in the above-mentioned cache.
[0016] In combination with the second aspect and the above-mentioned possible implementation methods, in another possible implementation method, the address information of the above-mentioned request data includes row address information, the above-mentioned first information table includes one or more rows, each row includes one or more first addresses, and the above-mentioned memory controller is also used to search for the row indicated by the above-mentioned row address information in the above-mentioned first information table; in the row indicated by the row address information, select any first address whose attribute identifier is the first identifier, and determine that the second address in the cache corresponding to the first address is the above-mentioned target address.
[0017] In combination with the second aspect and the above-mentioned possible implementation methods, in another possible implementation method, the above-mentioned memory controller is also used to, if it is determined that the data requested by the above-mentioned request instruction is stored in the above-mentioned cache, and the data requested by the above-mentioned request instruction is a hot data stream, search for the second address of the requested data in the cache; and reset the attribute identifier of the first address corresponding to the second address in the above-mentioned first information table to the second identifier.
[0018] In combination with the second aspect and the above-mentioned possible implementation methods, in another possible implementation method, the above-mentioned memory controller is also used to replace the address information in any third address in the above-mentioned second information table with the address information of the above-mentioned request data if it is determined that the data requested by the above-mentioned request instruction is a cold data stream; wherein, the cold data stream refers to data whose access frequency is less than the above-mentioned preset threshold; the second information table contains one or more third addresses, and the third address includes an address information.
[0019] In combination with the second aspect and the above-mentioned possible implementation methods, in another possible implementation method, the above-mentioned memory controller is specifically used to replace the address information in any third address in the row indicated by the above-mentioned row address information with the address information of the above-mentioned request data in the above-mentioned second information table according to the address information of the above-mentioned request data.
[0020] In combination with the second aspect and the above-mentioned possible implementation methods, in another possible implementation method, the above-mentioned memory controller is also used to reset all attribute identifiers in the row with all second identifiers to the first identifier if all attribute identifiers in any row of the above-mentioned first information table are second identifiers.
[0021] In combination with the second aspect and the above-mentioned possible implementation methods, in another possible implementation method, the above-mentioned memory controller is also used to search for the row indicated by the above-mentioned row address information in the second information table according to the address information of the above-mentioned request data; if the address information of the request data is the same as the address information included in any third address in the row indicated by the above-mentioned row address information in the above-mentioned second information table, it is determined that the data requested by the request instruction is a hot data stream; if the address information of the above-mentioned request data is different from the address information included in all third addresses in the row indicated by the above-mentioned row address information in the above-mentioned second information table, it is determined that the data requested by the request instruction is a cold data stream.
[0022] The description of the effects of the above-mentioned second aspect and various implementation methods of the second aspect can refer to the description of the corresponding effects of the first aspect, and will not be repeated here.
[0023] According to a third aspect of an embodiment of the present application, a server is provided, the structure of which includes a processor and a memory, the memory being used to couple with the processor to store program instructions and data necessary for the server, and the processor being used to execute program instructions stored in the memory, so that the server executes the above method.
[0024] According to a fourth aspect of an embodiment of the present application, a computer storage medium is provided, in which a computer program code is stored. When the computer program code runs on a processor, the processor executes the data processing method described in the first aspect or any possible implementation of the first aspect.
[0025] According to a fifth aspect of the embodiments of the present application, a computer program product is provided, which stores computer software instructions executed by the processor, and the computer software instructions include a program for executing the solutions described in the above aspects.
[0026] In the sixth aspect of the embodiments of the present application, a device is provided, which exists in the product form of a chip. The structure of the device includes a processor and a memory. The memory is used to couple with the processor to store necessary program instructions and data for the device. The processor is used to execute the program instructions stored in the memory, so that the device performs the functions of the data processing device in the above method. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A computer system architecture diagram provided for an embodiment of the present application;
[0028] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application;
[0029] Figure 3 A schematic diagram of a second information table provided in an embodiment of the present application;
[0030] Figure 4 A schematic diagram of a first information table provided in an embodiment of the present application;
[0031] Figure 5 A schematic diagram of an application of a data processing method provided in an embodiment of the present application;
[0032] Figure 6 A flowchart of another data processing method provided in an embodiment of the present application;
[0033] Figure 7 An application schematic diagram of another data processing method provided in an embodiment of the present application;
[0034] Figure 8 A flowchart of another data processing method provided in an embodiment of the present application;
[0035] Fig. 9 A flowchart of another data processing method provided in an embodiment of the present application;
[0036] Fig.10 An application schematic diagram of another data processing method provided in an embodiment of the present application;
[0037] Fig.11 A flowchart of another data processing method provided in an embodiment of the present application;
[0038] Fig.12 An application schematic diagram of another data processing method provided in an embodiment of the present application;
[0039] Fig.13 A schematic diagram of the composition of a data processing device provided in an embodiment of the present application;
[0040] Fig.14 A schematic diagram of the composition of another data processing device provided in an embodiment of the present application;
[0041] Fig.15 A schematic diagram of the composition of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0042] The present application provides a data processing method, which can be applied to Figure 1 In the computer system 100 shown, Figure 1 The computer system shown may include a processor 101 , a memory controller 102 , a first level memory 103 , and a second level memory 104 .
[0043] The processor 101 is the control center of the computer system 100 and is used to run the operating system of the computer system 100 and the application programs on the computer 100 (including system applications and third-party applications).
[0044] In the embodiment of the present application, the processor 101 may specifically be a central processing unit (CPU), which may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the contents disclosed in the embodiment of the present application; the processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc., which is not limited in the embodiment of the present application.
[0045] The memory controller 102 is used to manage data in the first-level memory and the second-level memory. Exemplarily, the memory controller may be a cache controller, which is used to manage data in the cache.
[0046] The first-level memory 103 is used to cache data in the second-level memory and to support cache access. Exemplarily, the first-level memory 103 can be a high-speed cache memory Cache between the processor and the memory, which is used to improve the read and write performance of the system. The data in the Cache can be a part of the data in the memory. Furthermore, if the Cache contains data to be accessed, the processor 101 can obtain the data to be accessed from the Cache instead of obtaining the data to be accessed from the memory, thereby speeding up the reading speed. It should be noted that the following embodiments of the present application are all described by taking the first-level memory as a high-speed cache memory Cache as an example.
[0047] The second level memory 104 is used to store all instructions and data. Exemplarily, the second level memory 104 may be the memory of the computer system 100 .
[0048] In an embodiment of the present application, the second-level memory 104 may specifically include a volatile memory (volatile memory), such as a random-access memory (random-access memory, RAM); the memory may also include a non-volatile memory (non-volatile memory), such as a read-only memory (Read Only Memory, ROM); the memory may also include a combination of the above-mentioned types of memory.
[0049] Understandably, Figure 1 This is only an example. In actual applications, the computer system 100 may include Figure 1 More or fewer components as shown, Figure 1 The structure shown does not impose any limitation on the computer system provided in the embodiments of the present application.
[0050] In order to solve the problem in the background technology that the detection mechanisms of hot data streams and cold data streams are independent of each other, resulting in the frequent replacement of hot data streams by cold data streams in the cache, thereby reducing the efficiency of data processing, an embodiment of the present application provides a data processing method, which can associate the detection mechanisms of hot data streams and cold data streams, and the two cooperate with each other to reduce the probability of cold data streams replacing hot data streams in the cache.
[0051] Combination Figure 1 ,like Figure 2 As shown, the data processing method provided in the embodiment of the present application may include steps S201-S203.
[0052] S201: The memory controller receives a request instruction.
[0053] The request instruction carries address information of the request data, and the address of the request data is a logical address.
[0054] Exemplarily, the memory controller may receive a request instruction sent by a processor, and the request instruction may be any access request sent by the processor.
[0055] Exemplarily, the request instruction may be a read request or a write request sent by a processor, and the read request or the write request is used to read or write data in the first-level memory and / or the second-level memory.
[0056] Exemplarily, the address information of the request data carried in the request instruction may include row address information, and the row address information may be row address information divided according to a preset rule, for example, the attributes of the data may be classified and divided into rows, which is not limited in the embodiment of the present application and is only an exemplary description. Exemplarily, the row address information may be recorded as RowID.
[0057] S202: If it is determined that the data requested by the request instruction is not stored in the cache, and the data requested by the request instruction is a hot data stream, query the first information table according to the address information of the request data to determine the target address of the request data in the cache.
[0058] Among them, hot data flow refers to data with an access frequency greater than or equal to a preset threshold, that is, data frequently accessed by the processor. The embodiment of the present application does not limit the specific value of the preset threshold, which can be determined according to actual applications.
[0059] Exemplarily, the method for determining whether the data requested by the request instruction is a hot data flow in the embodiment of the present application can be implemented in a variety of ways. For example, the number of access times of the requested data within a preset time can be compared with the preset access number. If the number of access times of the requested data within the preset time is greater than or equal to the preset access number, it can be determined that the requested data is a hot data flow; for another example, the access frequency of the requested data can be counted, and the access frequency of the requested data can be compared with a preset threshold. If the access frequency of the requested data is greater than or equal to the preset threshold, it can be determined that the requested data is a hot data flow; for another example, the address information of the requested data in the second information table can be searched. If the address information of the requested data matches the address information of any requested data in the second information table, it can be determined that the requested data is a hot data flow. The embodiment of the present application does not limit the specific method for determining whether the requested data is a hot data flow, and this is merely an exemplary description.
[0060] Exemplarily, the above-mentioned second information table may include one or more third addresses, each third address includes an address information, and the above-mentioned determination of whether the data requested by the request instruction is a hot data stream by searching the second information table may specifically include: searching in the second information table according to the address information of the request data, if the address information of the request data is the same as the address information included in any third address in the second information table, determining that the data requested by the request instruction is a hot data stream; if the address information of the request data is different from the address information included in all third addresses in the second information table, determining that the data requested by the request instruction is a cold data stream.
[0061] Exemplarily, the second information table may include one or more rows, each row including one or more third addresses, such as Figure 3 As shown, the second information table includes multiple rows, each row includes 8 information spaces, and each information space records the address information corresponding to 8 addresses (third addresses). Figure 3 The third address marked in black stores the address information of the requested data, and the third address marked in white stores the empty address information. The embodiment of the present application does not limit the specific specifications of the second information table, and only takes each row including 8 information spaces as an example for explanation.
[0062] Furthermore, the embodiments of the present application can match the address information of the requested data with the address information included in the third address in the second information table. If the address information of the requested data includes row address information, and the address information of the requested data is the same as the address information included in any third address in the row indicated by the row address information in the second information table, it can be considered that the data requested by the request instruction is data frequently accessed by the processor, and the data requested by the request instruction is determined to be a hot data stream; if the address information of the requested data is different from the address information included in all third addresses in the row indicated by the row address information in the second information table, it can be considered that the data requested by the request instruction is not data frequently accessed by the processor, and the data requested by the request instruction is determined to be a cold data stream.
[0063] Exemplarily, the target address is the target address of the data requested by the request instruction in the Cache. It can be understood that the data requested by the request instruction and the request data in the embodiment of the present application are the same data.
[0064] Exemplarily, the above-mentioned first information table is used to record the cache resources that can currently be used. The first information table may include one or more first addresses, which correspond one-to-one to the second addresses in the cache. The first information table may also include an attribute identifier corresponding to each first address, and the attribute identifier includes a first identifier and a second identifier. The first identifier is used to indicate that the data on the corresponding second address can be replaced, and the second identifier is used to indicate that the data on the corresponding second address cannot be replaced.
[0065] Exemplarily, the target address of the above-mentioned request data can be the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table. It can be understood that the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table can be determined as the target address, and since the data stored at the second address corresponding to the first address whose attribute is identified as the first identifier in the cache is data that can be replaced, the data stored at the target address of the request data is data that can be replaced, and the request data can be stored at the target address to replace the original data at the target address.
[0066] Furthermore, the first information table may include one or more rows, each row including one or more first addresses, such as Figure 4 As shown, each row includes 8 information spaces, and each information space records the attribute identifiers corresponding to 8 addresses (first addresses). The attribute identifier corresponding to each first address can be a first identifier or a second identifier. The first identifier can be recorded as 0, and the second identifier can be recorded as 1. The attribute identifier of 0 indicates that the data at the second address corresponding to the first address in the cache can be replaced, and the attribute identifier of 1 indicates that the data at the second address corresponding to the first address in the cache cannot be replaced. The first address corresponding to the hot data flow in the first information table in the embodiment of the present application can be identified as 1. The embodiment of the present application does not limit the specifications of the first information table and the specific forms of expression of the first identifier and the second identifier. Here, it is only taken as an example that each row in the first information table includes 8 information spaces, the first identifier is recorded as 0, and the second identifier is recorded as 1.
[0067] Exemplarily, the target address of the above-mentioned request data can be the second address corresponding to any first address with the attribute identifier being the first identifier in the row indicated by the row address information in the first information table. It can be understood that the second address corresponding to any first address with the attribute identifier being the first identifier in the row corresponding to the above-mentioned row address information in the first information table can be determined as the target address, and since the data stored at the second address corresponding to the first address with the attribute identifier being 0 in the cache is data that can be replaced, the data stored at the target address of the request data is data that can be replaced.
[0068] Exemplarily, the above-mentioned querying the first information table based on the address information of the requested data to determine the target address of the requested data in the Cache may include: searching the first information table for the row indicated by the row address information, selecting any first address with an attribute identifier as the first identifier in the row indicated by the row address information, and determining that the second address in the Cache corresponding to the first address is the target address.
[0069] For example, Figure 5 As shown, according to the row address RowID carried by the request instruction, if the row address is 2, in the row indicated by the row address RowID being 2, any first address (position) with an attribute identifier of 0 in the row is randomly selected, such as Figure 5 There are five first addresses with the attribute identifier of 0. A first address (position) can be randomly selected from these five first addresses (positions) with the attribute identifier of 0, such as Figure 5 The first address with a column identifier of 1 in the row indicated by RowID 2 (the position with a column identifier of 0 in the dotted box), and the second address corresponding to the first address in the Cache is determined as the target address. Since the data at the second address corresponding to the first address with an attribute identifier of 0 in the Cache can be replaced, and the data at the second address corresponding to the first address with an attribute identifier of 1 in the Cache cannot be replaced, the embodiment of the present application can ensure that the data stored at the selected target address is data that can be replaced, rather than data that cannot be replaced, by selecting the second address corresponding to any first address with an attribute identifier of 0 as the target address.
[0070] It can be understood that the data at the second address in the Cache corresponding to the first address with the attribute identifier of 0 in the first information table is data that can be replaced, and the data at the second address in the Cache corresponding to the first address with the attribute identifier of 1 in the first information table is data that cannot be replaced, wherein the hot data stream can be identified as 1, and the data processing method in the embodiment of the present application can determine the second address in the Cache corresponding to any first address with the attribute identifier of 0 in the first information table as the target address, that is, replace the data identified as 0, and will not replace the data identified as 1. Therefore, when replacing the data in the Cache, only the data that can be replaced will be replaced, and the data that cannot be replaced and is identified as 1 will not be replaced. Therefore, the use of the data processing method in the embodiment of the present application can reduce the probability of the cold data stream replacing the hot data stream in the prior art.
[0071] S203: The memory controller copies the data requested by the request instruction to the target address in the cache.
[0072] Exemplarily, the target address is the second address of the data that can be replaced and stored in the Cache. The data requested by the above request instruction is not stored in the Cache and is a hot data stream, so the requested data can be copied from the memory to the target address in the Cache. Since the target address is the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table, when the requested data is copied from the memory to the target address in the Cache, the data that can be replaced originally stored at the target address is replaced with the requested data, and when replacing, only the data that can be replaced will be replaced, and the data that cannot be replaced and is identified as 1 will not be replaced.
[0073] Exemplarily, before step S203, the process may further include: the memory controller obtains the requested data from the memory according to the address information of the requested data.
[0074] The data processing method provided by the embodiment of the present application receives a request instruction, which carries the address information of the requested data; if it is determined that the data requested by the request instruction is not stored in the cache, and the data requested by the request instruction is a hot data stream, the first information table is queried according to the address information of the request data to determine the target address of the request data in the cache, wherein the target address is the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table; and the data requested by the request instruction is copied to the target address in the cache. The embodiment of the present application determines the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table as the target address of the hot data stream that is not hit in the cache, so that when replacing the data in the cache, only the data that can be replaced will be replaced, and the data that cannot be replaced will not be replaced, so the probability of the cold data stream replacing the hot data stream in the cache can be effectively reduced.
[0075] This application also provides an embodiment, such as Figure 6 As shown, if the requested data is successfully copied to the Cache in step S203, the method further includes step S204; if the requested data is not successfully copied to the chip, a failure message is returned.
[0076] S204: The memory controller resets the attribute identifier of the first address corresponding to the target address in the first information table to a second identifier.
[0077] For example, Figure 7 As shown, after the requested data is successfully copied to the Cache, the attribute identifier of the first address corresponding to the target address in the first information table is reset to 1, so the attribute identifier of the first address corresponding to the requested data (hot data flow) in the first information table is a second identifier that cannot be replaced.
[0078] Exemplarily, the request data reset to the second identifier is data that cannot be replaced. Therefore, when the data requested by the next request instruction is a hot data stream and it does not hit in the cache, the request data reset to the second identifier cannot be replaced, thereby reducing the probability of the cold data stream replacing the hot data stream in the cache.
[0079] In this way, it is possible to determine through the second information table whether the data requested by the request instruction is a hot data stream or a cold data stream, and determine whether the resources in the cache can be replaced through the attribute identifier in the first information table. When it is determined that the data requested by the request instruction is not stored in the cache and is a hot data stream, after successfully copying the data requested by the request instruction to the second address (target address) that can be replaced in the cache, the attribute identifier of the first address corresponding to the target address in the first information table is reset to the second identifier that cannot be replaced, thereby unifying and coordinating the detection mechanisms for cold data streams and hot data streams; and because the embodiment of the present application only replaces the replaceable data identified as 0 when replacing the data in the cache, and does not replace the non-replaceable data identified as 1, the probability of the cold data stream replacing the hot data stream can be effectively downgraded.
[0080] The data processing method provided by the embodiment of the present application receives a request instruction, which carries the address information of the requested data; if it is determined that the data requested by the request instruction is not stored in the cache, and the data requested by the request instruction is a hot data stream, query the first information table according to the address information of the request data, and determine the target address of the requested data in the cache, wherein the target address is the second address corresponding to any first address whose attribute identifier is the first identifier in the first information table; copy the data requested by the request instruction to the target address in the cache; reset the attribute identifier of the first address corresponding to the target address in the first information table to the second identifier. The embodiment of the present application determines the second address corresponding to any first address whose attribute identifier is the first identifier in the first information table as the target address of the hot data stream that is not hit in the cache, so that when replacing the data in the cache, only the data that can be replaced will be replaced, and the data that cannot be replaced will not be replaced, so the probability of the cold data stream replacing the hot data stream in the cache can be effectively reduced.
[0081] This application also provides an embodiment, such as Figure 8 As shown, the data processing method also includes S205-S206.
[0082] S205: If it is determined that the data requested by the request instruction is stored in the Cache, and the data requested by the request instruction is a hot data stream, search for a second address of the requested data in the Cache.
[0083] Exemplarily, when the data requested by the request instruction is stored in the cache and is a hot data stream, the second address of the request data in the cache can be searched according to the address information of the request data carried in the request instruction, and the second address corresponds to the first address in the first information table.
[0084] S206: The memory controller resets the attribute identifier of the first address corresponding to the second address in the first information table to the second identifier.
[0085] Exemplarily, when the requested data is a hot data stream and hits in the Cache, the first address corresponding to the second address can be searched in the first information table according to the second address of the requested data in the Cache, and the first address can be reset to the second identifier. Exemplarily, before resetting the attribute identifier of the first address corresponding to the second address in the first information table, the attribute identifier of the first address corresponding to the second address can be the first identifier or the second identifier. Regardless of whether the attribute identifier of the first address corresponding to the target address before the reset is the first identifier or the second identifier, the attribute identifier must be reset to the second identifier.
[0086] It can be understood that after the attribute identifier of the first address corresponding to the second address in the first information table is reset to the second identifier, the request data is data that cannot be replaced.
[0087] Exemplarily, based on the second address of the requested data in the Cache, the attribute identifier of the first address corresponding to the second address in the first information table is set to 1. The attribute identifier of 1 indicates that the data stored at the second address cannot be replaced. Therefore, when the data requested by the next request instruction is a hot data stream and is stored in the Cache, the request data reset to the second identifier cannot be replaced.
[0088] In this way, it is possible to determine through the second information table whether the data requested by the request instruction is a hot data stream or a cold data stream, and to determine whether the resources in the Cache can be replaced through the attribute identifier in the first information table. When it is determined that the data requested by the request instruction is stored in the Cache and is a hot data stream, the attribute identifier of the corresponding address in the first information table can be reset to a second identifier that cannot be replaced, thereby unifying and coordinating the detection mechanisms for cold data streams and hot data streams. Furthermore, since the embodiment of the present application only replaces replaceable data identified as 0 when replacing data in the Cache, and does not replace non-replaceable data identified as 1, the probability of a situation where a cold data stream replaces a hot data stream can be effectively downgraded.
[0089] The data processing method provided by the embodiment of the present application receives a request instruction, which carries the address information of the requested data; if it is determined that the data requested by the request instruction is stored in the cache, and the data requested by the request instruction is a hot data stream, the second address of the requested data in the cache is searched; and the attribute identifier of the first address corresponding to the second address in the first information table is reset to the second identifier. By resetting the first address in the first information table corresponding to the second address of the hot data stream in the cache to the second identifier, the embodiment of the present application can replace the data stream with the attribute identifier of the second identifier in the first information table when replacing the data in the cache, thereby effectively reducing the probability of the cold data stream replacing the hot data stream in the cache.
[0090] This application also provides an embodiment, such as Fig. 9 As shown, the data processing method also includes S207.
[0091] S207: If it is determined that the data requested by the request instruction is a cold data stream, the memory controller replaces the address information in any third address in the second information table with the address information of the request data according to the address information of the request data.
[0092] Among them, cold data stream refers to data with an access frequency less than a preset threshold, that is, data that is not frequently accessed by the processor (accessed less frequently). The embodiment of the present application does not limit the specific value of the preset threshold, which can be determined according to actual applications.
[0093] Exemplarily, the above-mentioned replacing the address information in any third address in the second information table with the address information of the request data according to the address information of the request data may include: replacing the address information in any third address in the row indicated by the row address information in the second information table with the address information of the request data according to the address information of the request data. Fig.10 As shown, if it is determined that the data requested by the request instruction is a cold data stream (data that is not frequently accessed), any third address in the row indicated by the row address information can be replaced with the address information of the requested data, so that when the access frequency of the request instruction is high, the data requested by the request instruction can be detected as a hot data stream.
[0094] Exemplarily, replacing the instruction address information included in any third address in the row indicated by the row address information with the instruction address information of the requested data may include: if any third address in the row indicated by the row address information stores address information of requested data, the address information of the requested data stored in the third address may be replaced with the address information of the data requested by the request instruction; if any third address in the row indicated by the row address information stores empty address information, the empty address information stored in the third address may be replaced with the address information of the data requested by the request instruction.
[0095] Exemplarily, after replacing the instruction address information included in any third address in the row indicated by the row address information with the instruction address information of the request data, if the request instruction initiates a request again, the data requested by the request instruction is not stored in the cache and is a hot data stream, the request data can be processed in the manner of steps S201-S204; if the data requested by the request instruction is successfully copied to the cache, when the request instruction initiates a request again, the data requested by the request instruction is stored in the cache and is a hot data stream, the data processing method of steps S205-S206 can be used to reset the attribute identifier of the first address corresponding to the second address in the first information table to the second identifier. The probability of the cold data stream replacing the hot data stream can be reduced in the data processing process.
[0096] The data processing method provided by the embodiment of the present application receives a request instruction, which carries the address information of the request data, and the address information of the request data includes the row address information; if it is determined that the data requested by the request instruction is a cold data stream, the address information in any third address in the row indicated by the row address information in the second information table is replaced with the address information of the request data according to the address information of the request data. The embodiment of the present application replaces the address information in any third address in the row indicated by the row address information in the second information table with the address information of the request data, so that when the request instruction is initiated again, the data requested by the request instruction can be detected as a hot data stream and misses in the cache, and then according to step S202, the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table is determined as the target address of the data requested by the request instruction, so that when replacing the data in the cache, only the data that can be replaced will be replaced, and the data that cannot be replaced will not be replaced, so the probability of the cold data stream replacing the hot data stream in the cache can be effectively reduced.
[0097] This application also provides an embodiment, such as Fig.11 As shown, the data processing method also includes S208.
[0098] S208: If all the attribute identifiers in any row of the first information table are the second identifiers, the memory controller resets all the attribute identifiers in the row that are all the second identifiers to the first identifier.
[0099] For example, Fig.12 As shown, if all the attribute identifiers of any row in the first information table are 1, the row with all 1s is reset to 0, and then a new round of detection and processing is started.
[0100] Exemplarily, if all the attribute identifiers of any row in the first information table are the second identifier, it can be determined that the data of the second address corresponding to each first address in the row in the cache cannot be replaced, and the data corresponding to the row stored in the cache will become fixed data. In this way, if the data accessed by the processor is no longer the hot data stream stored in the current cache, the processor will need to continuously read data from the memory when accessing, and the high efficiency of the cache will not be utilized. Therefore, when all the attribute identifiers of a row in the first information table are the second identifier, the attribute identifiers of the row can be reset to the first identifier, so that the data stored in the cache is replaced and a new round of detection is restarted.
[0101] The data processing method provided by the embodiment of the present application receives a request instruction, which carries address information of requested data, and the address information of the requested data includes row address information; if it is determined that the data requested by the request instruction is not stored in the cache, and the data requested by the request instruction is a hot data stream, query the first information table according to the address information of the requested data, and determine the target address of the requested data in the cache, wherein the target address is a second address corresponding to any first address in the first information table whose attribute identifier is the first identifier; when all the attribute identifiers of any row in the first information table are the second identifier, the memory controller resets all the attribute identifiers in the row that are all the second identifiers to the first identifier. The embodiment of the present application determines the second address corresponding to any first address whose attribute is identified as the first identifier in the first information table as the target address of the hot data stream that is not hit in the cache. Therefore, when replacing the data in the cache, only the data that can be replaced will be replaced, and the data that cannot be replaced will not be replaced. Therefore, the probability of the cold data stream replacing the hot data stream in the cache can be effectively reduced; and when all the attribute identifiers of a row in the first information table are the second identifier, the attribute identifier of the row can be reset to the first identifier, and a new round of detection can be started, thereby improving the efficiency of the cache.
[0102] The above mainly introduces the solution provided by the embodiment of the present invention from the perspective of method steps. It is understandable that in order to realize the above functions, the computer includes a hardware structure and / or software module corresponding to each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiment disclosed herein, the present application can be implemented in the form of a combination of hardware and computer software. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0103] The embodiment of the present application can divide the computer into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present invention is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0104] In the case of dividing each functional module into corresponding functional modules, Fig.13 A possible structural diagram of the data processing device involved in the above embodiment is shown, and the data processing device 1300 includes: a receiving unit 1301, a processing unit 1302 and a resetting unit 1303. The receiving unit 1301 is used to support the data processing device 1300 to execute Figure 2 S201 in; the processing unit 1302 is used to support the data processing device 1300 to execute Figure 2 S202-S203 in, or Figure 8 S205 in or Fig. 9 The reset unit 1303 is used to support the data processing device 1300 to execute Figure 6 S204 in or Figure 8 S206 in or Fig.11 S208 in the above method embodiment. All relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here. Figure 1 As shown, the data processing device 1300 may be Figure 1 In the computer system 100 shown, at least one unit in the data processing device 1300 may be implemented in software, hardware, or a combination of software and hardware.
[0105] In the case of an integrated unit, Fig.14A possible structural diagram of the data processing device 1400 involved in the above embodiment is shown. The data processing device 1400 includes: a memory 1401 and a processor 1402. The processor 1402 is used to control and manage the actions of the data processing device. For example, the processor 1402 is used to support the data processing device to execute Figure 2 S201-S203, Figure 6 S201-S204, Figure 8 S201-S206, Fig. 9 S201-S207, Fig.11 S201-S208 in, and / or other processes for the technology described herein. The memory 1401 is used to store the program code and data corresponding to the data processing device 1400 executing any of the data processing methods provided above. The data processing device 1400 can be Figure 1 The computer system 100 shown above Figure 1 All relevant descriptions of the components involved can be found in Fig.14 The functional description of the corresponding components will not be repeated here.
[0106] The present application also provides a chip, such as Fig.15 As shown, the chip 1500 includes: a processor 1501, a memory controller 1502, and a cache memory Cache 1503, wherein the processor 1501 is used to send a request instruction; the memory controller 1502 is used to execute Figure 2 S201-S203, Figure 6 S201-S204, Figure 8 S201-S206, Fig. 9 S201-S207, Fig.11 S201-S208 in the high-speed cache memory Cache1503 is used to support high-speed cache access and improve the read and write performance of the system. The chip 1500 can be Figure 1 The chipset in the computer system 100 shown above Figure 1 All relevant descriptions of the components involved can be found in Fig.15 The functional description of the corresponding components will not be repeated here.
[0107] The steps of the method or algorithm described in conjunction with the disclosure of the present application may be implemented in hardware or by executing software instructions by a processor. The software instructions may be composed of corresponding software modules, which may be stored in a random access memory (RAM), a flash memory, an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a register, a hard disk, a mobile hard disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may be located in an ASIC. In addition, the ASIC may be located in a core network interface device. Of course, the processor and the storage medium may also exist in a core network interface device as discrete components.
[0108] Those skilled in the art will appreciate that in one or more of the above examples, the functions described in the present invention may be implemented in hardware, software, firmware, or any combination thereof. When implemented using software, the functions may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium may be any available medium that a general or special-purpose computer can access.
[0109] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A data processing method, characterized in that: The method comprises: receiving a request instruction, wherein the request instruction carries address information of the requested data; Determine whether the data requested by the request instruction has been stored in the cache memory Cache, and determine whether the data requested by the request instruction is a hot data stream. If it is determined that the data requested by the request instruction is not stored in the cache, and the data requested by the request instruction is a hot data stream, query the first information table according to the address information of the request data to determine the target address of the request data in the cache, wherein the hot data stream refers to data with an access frequency greater than or equal to a preset threshold; the first information table includes one or more first addresses, and the first addresses correspond to second addresses in the cache one by one. The first information table also includes an attribute identifier corresponding to each first address, and the attribute identifier includes a first identifier and a second identifier. The first identifier is used to indicate that the data at the corresponding second address can be replaced, and the second identifier is used to indicate that the data at the corresponding second address cannot be replaced. The target address is the second address corresponding to any first address in the first information table whose attribute identifier is the first identifier; The data requested by the request instruction is copied to the target address in the cache.
2. The data processing method according to claim 1, characterized in that: The method further comprises: If the data requested by the request instruction is successfully copied to the target address in the Cache, the attribute identifier of the first address corresponding to the target address in the first information table is reset to a second identifier.
3. The data processing method according to claim 1 or 2, characterized in that: The address information of the requested data includes row address information, the first information table includes one or more rows, each row includes one or more first addresses, and querying the first information table according to the address information of the requested data to determine the target address of the requested data in the cache includes: Searching the first information table for the row indicated by the row address information; In the row indicated by the row address information, any first address whose attribute identifier is a first identifier is selected, and a second address in the cache corresponding to the first address is determined as the target address.
4. The data processing method according to claim 3, characterized in that: The method further comprises: If it is determined that the data requested by the request instruction is stored in the cache, and the data requested by the request instruction is a hot data stream, searching for a second address of the requested data in the cache; The attribute identifier of the first address corresponding to the second address in the first information table is reset to the second identifier.
5. The data processing method according to claim 4, characterized in that: The method further comprises: If it is determined that the data requested by the request instruction is a cold data stream, according to the address information of the requested data, the address information in any third address in the second information table is replaced with the address information of the requested data; wherein the cold data stream refers to data whose access frequency is less than the preset threshold; the second information table contains one or more third addresses, and the third address includes an address information.
6. The data processing method according to claim 5, characterized in that: The second information table includes one or more rows, each row includes one or more third addresses, and the step of replacing the address information of any third address with the address information of the request data in the second information table according to the address information of the request data includes: According to the address information of the request data, in the second information table, the address information in any third address in the row indicated by the row address information is replaced with the address information of the request data.
7. The data processing method according to claim 1 or 2, characterized in that: If all the attribute identifiers in any row of the first information table are the second identifiers, all the attribute identifiers in the row that are all the second identifiers are reset to the first identifier.
8. The data processing method according to claim 3, characterized in that: The determining whether the data requested by the request instruction is a hot data stream includes: Searching the row indicated by the row address information in the second information table according to the address information of the request data; If the address information of the requested data is the same as the address information included in any third address in the row indicated by the row address information in the second information table, determining that the data requested by the request instruction is the hot data stream; If the address information of the requested data is different from the address information included in all third addresses in the row indicated by the row address information in the second information table, it is determined that the data requested by the request instruction is a cold data stream.
9. A chip, characterized in that: The chip includes a processor, a memory controller and a cache memory, wherein: The processor is used to send a request instruction, wherein the request instruction carries address information of the requested data; The memory controller is used to receive the request instruction sent by the processor; determine whether the data requested by the request instruction has been stored in the cache memory Cache, and determine whether the data requested by the request instruction is a hot data stream. If it is determined that the data requested by the request instruction is not stored in the Cache, and the data requested by the request instruction is a hot data stream, query the first information table according to the address information of the request data to determine the target address of the request data in the Cache, wherein the hot data stream refers to data with an access frequency greater than or equal to a preset threshold; the first information table includes one or more first addresses, and the first addresses correspond to the second addresses in the Cache one by one. The first information table also includes an attribute identifier corresponding to each first address, and the attribute identifier includes a first identifier and a second identifier. The first identifier is used to indicate that the data on the corresponding second address can be replaced, and the second identifier is used to indicate that the data on the corresponding second address cannot be replaced. The target address is the second address corresponding to any first address whose attribute identifier in the first information table is the first identifier; copy the data requested by the request instruction to the target address in the Cache.
10. The chip according to claim 9, characterized in that: The memory controller is further configured to reset the attribute identifier of the first address corresponding to the target address in the first information table to a second identifier if the data requested by the request instruction is successfully copied to the target address in the cache.
11. The chip according to claim 9 or 10, characterized in that: The address information of the request data includes row address information, the first information table includes one or more rows, each row includes one or more first addresses, The memory controller is also used to search the row indicated by the row address information in the first information table; in the row indicated by the row address information, select any first address with an attribute identifier as the first identifier, and determine that the second address in the cache corresponding to the first address is the target address.
12. The chip according to claim 11, characterized in that: The memory controller is also used to search for the second address of the requested data in the cache if it is determined that the data requested by the request instruction is stored in the cache and the data requested by the request instruction is a hot data stream; and reset the attribute identifier of the first address corresponding to the second address in the first information table to the second identifier.
13. The chip according to claim 12, characterized in that: The memory controller is also used to replace the address information in any third address with the address information of the requested data in the second information table if it is determined that the data requested by the request instruction is a cold data stream; wherein the cold data stream refers to data whose access frequency is less than the preset threshold; and the second information table includes one or more third addresses, and the third address includes an address information.
14. The chip according to claim 13, characterized in that: The second information table includes one or more rows, each row includes one or more third addresses, The memory controller is specifically configured to replace the address information in any third address in the row indicated by the row address information with the address information of the request data in the second information table according to the address information of the request data.
15. The chip according to claim 9 or 10, characterized in that: The memory controller is further configured to reset all attribute identifiers in any row having all second identifiers to first identifiers if all attribute identifiers in any row of the first information table are second identifiers.
16. The chip according to claim 11, characterized in that: The memory controller is further configured to search the row indicated by the row address information in the second information table according to the address information of the request data; if the address information of the request data is the same as the address information included in any third address in the row indicated by the row address information in the second information table, determine that the data requested by the request instruction is the hot data stream; If the address information of the requested data is different from the address information included in all third addresses in the row indicated by the row address information in the second information table, it is determined that the data requested by the request instruction is a cold data stream.
17. A computer storage medium having computer program code stored therein, characterized in that: When the computer program code runs on a processor, the processor is enabled to execute the data processing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Database cache management method and database server
CN102331986A
Data processing method, data processing device and data processing system
CN102609360A
Flash memory and method and system for automatically separating cold and hot data based on same
CN102902628A
Method and device for data management in flash memory device
CN103246615A
Solid state disk cache data update method and apparatus
CN105224473A
