WO2018082695A1 - Cache replacement method and device - Google Patents

Cache replacement method and device Download PDF

Info

Publication number
WO2018082695A1
WO2018082695A1 PCT/CN2017/109553 CN2017109553W WO2018082695A1 WO 2018082695 A1 WO2018082695 A1 WO 2018082695A1 CN 2017109553 W CN2017109553 W CN 2017109553W WO 2018082695 A1 WO2018082695 A1 WO 2018082695A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
area
memory
access request
memory controller
Prior art date
Application number
PCT/CN2017/109553
Other languages
French (fr)
Chinese (zh)
Inventor
陈明宇
潘海洋
刘宇航
阮元
陈少杰
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2018082695A1 publication Critical patent/WO2018082695A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/128Replacement control using replacement algorithms adapted to multidimensional cache systems, e.g. set-associative, multicache, multiset or multilevel

Definitions

  • the present invention relates to the field of data processing technologies, and in particular, to a method and device for cache replacement.
  • the computer system may include a memory controller, a dynamic random access memory (DRAM), and a non-volatile memory (NVM).
  • the DRAM includes one or more cache blocks for storing data.
  • the memory controller receives the access request, if the access request misses the DRAM and the DRAM is full, the data to be accessed is obtained from the NVM, and a cache block in the DRAM is randomly used as the cache block to be replaced, and will be The data in the replacement cache block is replaced with the data to be accessed.
  • the memory controller randomly uses one cache block in the DRAM as the cache block to be replaced, so that it is possible to replace the data with high access frequency, which reduces the cache hit ratio.
  • Embodiments of the present invention provide a method and apparatus for cache replacement to improve cache hit ratio.
  • a method of cache replacement for use in a computer system including a memory controller and hybrid memory.
  • the hybrid memory includes a first level memory and a second level memory.
  • the first level of memory is used to cache data in the second level of memory, the first level of memory supports cache access, and the second level of memory is NVM.
  • the method may include: the memory controller receiving the first access request carrying the first target address, wherein the first target address is an address of the first data to be accessed by the first access request in the second level memory; The memory controller determines, according to the first target address, that the first access request misses the first area and the second area in the first level memory, and acquires the first data from the second level memory according to the first target address, where the first The level memory includes a first area for buffering hot data, a second area for buffering cold data, and a third area for buffering data that is replaced from the second area.
  • the memory controller acquires the first data requested by the access request from the second level memory, and then, the memory controller according to the first carried in the access request
  • the target address determines that the first access request misses the third zone
  • the first cache block to be replaced is determined in the second zone.
  • the first area is for buffering hot data
  • the second area is for buffering cold data
  • the third area is for recording an address in the second level memory of data that is replaced from the second area. That is to say, in the technical solution provided by the embodiment of the present invention, if the probability of the third zone miss is high, the probability that the cached cold data in the first zone is replaced is increased, so that the first level cache is More cached hot data. Therefore, the cache hit ratio can be improved as compared with the cache block to be replaced that is randomly determined in the first level buffer provided in the prior art.
  • the second level of memory is a non-volatile memory NVM.
  • the method may further include: the memory controller storing the address of the data in the first cache block in the third In the district.
  • the possible design is used to determine whether to determine the cache block to be replaced from the first zone during the subsequent cache replacement process.
  • the cache block to be replaced is determined from the second zone. Specifically, if the memory controller determines that the first target address is stored in the third area, the first data is considered to be hot data, and the cache block to be replaced is determined in the first area; if it is determined that the first area is not stored in the third area The target address is considered to be cold data, and the cache block to be replaced is determined in the second area.
  • the method may further include: the memory controller receiving the second access request carrying the second target address, and the second target address being the second access request to access the second data in the second level memory Address; then, when determining that the second access request misses the first region and the second region in the first level memory according to the second target address, the memory controller is from the second level memory according to the second target address Obtaining the second data; subsequently, when determining that the second access request hits the third region according to the second target address, the memory controller determines the second cache block to be replaced in the first region; finally, the memory controller will use the second cache The data in the block is replaced with the second data.
  • the first zone is larger than the second zone.
  • the number of cache blocks included in the first zone may be greater than the number of cache blocks included in the second zone, that is, the area in which the hot data is stored may be larger than the area in which the cold data is stored. Since the hit rate of hot data access is higher than the hit rate of cold data access, expanding the area of hot data can increase the cache hit rate.
  • the memory controller determines the first cache block to be replaced in the second area, and may include: the memory controller writes any data in the second area or is first written into the first level memory The cache block in which the data is located is determined as the first cache block to be replaced.
  • the third zone is less than or equal to a predetermined threshold.
  • the value of the preset threshold is not limited.
  • the preset threshold is small, that is, the storage space of the third area is small, so that as much cold data as possible stored in the second area is replaced. The hot data stored in the first area is replaced as little as possible, thereby improving the cache hit rate.
  • the specific analysis process can be referred to below.
  • a computing device can include a memory controller and a hybrid memory, the mixed memory including a first level memory and a second level memory, wherein the first level memory is used to cache data in the second level memory, The first level of memory supports the cache access, and the memory controller is configured to: receive the first access request, where the first access request carries the first target address, and the first target address is the first data to be accessed by the first access request.
  • An address in the second level memory when determining that the first access request misses the first area and the second area in the first level memory according to the first target address, acquiring the first from the second level memory according to the first target address Data, wherein the first level memory comprises a first area for buffering hot data, a second area for buffering cold data, and a third area for buffering from the second area An address of the replaced data in the second level memory; when it is determined that the first access request misses the third area according to the first target address, determining the to-be-replaced in the second area A cache block; replaces data in the first cache block is a first data.
  • the memory controller is further configured to: store the address of the data in the first cache block in the third zone.
  • the memory controller is further configured to: receive a second access request, where the second access request carries a second target address, and the second target address is a second access request to be accessed by the second data.
  • An address in the secondary storage device when determining that the second access request misses the first region and the second region in the first level memory according to the second target address, acquiring the second data from the memory according to the second target address;
  • the second target address determines that the second access request hits the third area, the second cache block to be replaced is determined in the first area; the data in the second cache block is replaced with the second data.
  • the first zone is larger than the second zone.
  • the second level of memory is a non-volatile memory NVM.
  • the memory controller is specifically configured to: determine, as the first cache block to be replaced, the cache block in which any data in the second area or the data that is first written into the first level memory is located.
  • the third zone is less than or equal to a predetermined threshold.
  • an embodiment of the present invention provides a memory controller, where the memory controller includes modules for performing the foregoing first aspect and the method shown in each possible implementation manner of the first aspect.
  • a computer readable storage medium wherein computer executable instructions are stored, wherein when the at least one processor of the computing device executes the computer to execute the instructions, the computing device performs the above aspects or any of the above aspects A possible implementation of the cache replacement method provided.
  • a computer program product comprising computer executable instructions stored in a computer readable storage medium; at least one processor of the computing device can read the computer readable storage medium The computer executes the instructions, and the at least one processor executes the computer to execute the instructions such that the computing device implements the cache replacement method provided by the above aspects or any of the possible implementations of the above aspects.
  • any of the computing devices or computer storage media provided above are used to perform the cache replacement method provided above, and therefore, the beneficial effects that can be achieved can be referred to the corresponding cache replacement provided above. The beneficial effects of the method are not repeated here.
  • FIG. 1 is a structural diagram of a computer system to which an embodiment of the present invention is applied;
  • FIG. 2 is a schematic structural diagram of a cache system according to an embodiment of the present invention.
  • FIG. 3 is a flowchart of a method for cache replacement according to an embodiment of the present invention.
  • FIG. 4 is a structural diagram of a first level memory according to an embodiment of the present invention.
  • FIG. 5 is a structural diagram of another first level memory according to an embodiment of the present disclosure.
  • FIG. 6 is an interaction diagram of a method for cache replacement according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a memory controller according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of another memory controller according to an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of a computing device according to an embodiment of the present invention.
  • the technical solution provided by the embodiment of the present invention can be applied to the computer system architecture shown in FIG. 1.
  • the computer system shown in FIG. 1 can include a processor, a memory controller, and a hybrid memory.
  • the processor is the control center of the computer system.
  • the hybrid memory includes a first level memory and a second level memory.
  • the first level of memory is used to cache data in the second level of memory and is also used to support cache access.
  • DRAM-NVM memory system DRAM can be used as the first level of memory in the computer system provided in FIG. 1, and NVM can be used as the second level of memory in the computer system provided in FIG.
  • the technical solution provided by the embodiment of the present invention can also be applied to the cache system architecture shown in FIG. 2.
  • the cache system shown in FIG. 2 can include a processor, a cache, a cache controller, a memory controller, and a memory.
  • the processor is the control center of the cache system.
  • Cache is a high-speed memory between the processor and memory, mainly used for Improve the read and write performance of the system.
  • the cache controller is used to manage the data in the cache.
  • the data in the cache can be part of the data in memory. Further, if the cache contains data to be accessed, the processor can obtain the data to be accessed from the cache without acquiring the data to be accessed from the memory, thereby speeding up the reading speed.
  • the functions performed by the memory controller in FIG. 1 can be analogized to the functions performed by the cache controller in FIG. 2.
  • the first level of memory in Figure 1 can be analogized to the cache in Figure 2.
  • the second level of memory in Figure 1 can be analogized to the memory in Figure 2.
  • first and second and the like are used herein to distinguish different objects, rather than to describe a particular order of the objects.
  • plural refers to two or more.
  • the character “/” in this article indicates that the contextual object is an "or” relationship.
  • the computer system may include a processor, a memory controller, and a first Level memory and second level memory.
  • the first level of memory includes a first zone, a second zone, and a third zone.
  • the first area is for buffering hot data
  • the second area is for buffering cold data
  • the third area is for buffering addresses in the second level memory of data that is replaced from the second area.
  • the data stored in the first area is considered to be hot data
  • the data stored in the second area is cold data.
  • the locations of the cache blocks included in the first zone, the second zone, and the third zone may be continuous or discontinuous.
  • the method may include the following steps S101-S104:
  • the memory controller receives the first access request.
  • the first access request carries a first target address, where the first target address is an address of the first data to be accessed by the first access request in the second level memory.
  • S101 may include: the memory controller receiving the first access request sent by the processor.
  • the first access request may be any one of the access requests sent by the processor.
  • the method may further include: determining, by the memory controller, whether the first access request hits any one of the first zone and the second zone in the first level memory according to the first target address.
  • the first data may be any data stored in the hybrid memory; and the first data may be data stored in the first level memory or may not be data stored in the first level memory.
  • the first area may include one or more cache blocks
  • the second area may include one or more cache blocks
  • the third area may include one or more cache blocks.
  • the number of cache blocks included in the first area may be greater than the number of cache blocks included in the second area, that is, the area where the hot data is stored may be larger than the area where the cold data is stored. Since the hit rate of hot data access is higher than the hit rate of cold data access, expanding the area of hot data can increase the cache hit rate.
  • the obtaining the first data from the second level memory in S102 may include: the memory controller transmitting the first access request to the second level memory; the second level memory receiving the first access request, and sending the access to the memory controller And a response message, wherein the access response message carries the first data; the memory controller receives the access response message.
  • the memory controller determines that the first access request misses the third area according to the first target address, the first data is considered to be cold data, and the first data is to be placed in the second area, that is, determined in the second area.
  • the first cache block that is replaced.
  • the determining, by the memory controller, the first cache block to be replaced in the second area may include: the memory controller randomly determining, in the second area, the cache block where the data in the second level memory is located according to a random algorithm.
  • the first cache block to be replaced; or, according to the first-in first-out algorithm, the first cache block to be replaced is determined by the cache block in which the data originally written in the first-level memory is located.
  • the specific content of the random algorithm and the first-in first-out algorithm can refer to the prior art.
  • S104 The memory controller replaces the data in the first cache block with the first data.
  • the memory controller obtains the first data from the second level memory according to the first target address if it is determined that the first access request misses the first area and the second area in the first level memory. If the first level memory is full and the third area does not store the first target address, then in this case, the memory controller preferentially determines the first cache block to be replaced in the second area, and the first cache block The data is replaced with the first data. Since the second area stores cold data, the embodiment of the present invention ensures that the cold data is preferentially replaced, thereby improving the cache hit ratio.
  • the first level of memory includes six cache blocks, each of which stores data and an address of the data.
  • the first level of memory includes a first zone, a second zone, and a third zone.
  • the data block 3 and the address 3 are stored in the cache block 1 of the first area
  • the data 4 and the address 4 are stored in the cache block 2
  • the data 5 and the address 5 are stored in the cache block 3
  • the data 1 and the address are stored in the cache block 4 of the second area.
  • Cache block 5 stores data 2 and address 2
  • the cache block 6 of the third area does not store an address, as shown in FIG. If the first access request received by the memory controller at the first time includes the address 6, after the cache is replaced, the information stored in the cache block 4 of the second area may be data 6 and address 6, and the cache block 6 of the third area may be Store address 1, as shown in Figure 5.
  • the memory controller may write the first data into any of the free cache blocks.
  • the memory controller when the access request misses the first level memory, acquires the first data requested by the access request from the second level memory, and then, the memory controller according to the access request
  • the carried first target address determines that the first access request misses the third area
  • the first cache block to be replaced is determined in the second area.
  • the first area is for buffering hot data
  • the second area is for buffering cold data
  • the third area is for recording an address in the second level memory of data that is replaced from the second area.
  • the cache hit ratio can be improved as compared with the cache block to be replaced that is randomly determined in the first level buffer provided in the prior art.
  • the memory controller can add a flag bit to each cache block included in the DRAM and set an initial value of each cache block. If the DRAM controller determines that the data to be accessed is stored in the DRAM, that is, the hit, the DRAM controller sends an access response message including the data to be accessed to the processor, and updates the to-be-accessed data information. Updating the data information to be accessed may include, but is not limited to, zeroing the value of the flag bit of the cache block in which the data to be accessed is located, and increasing the value of the flag bit of all cache blocks in the DRAM from which the cache block is removed. In specific implementation, the initial value of the set cache block and the magnitude of the value of the added flag bit are not limited.
  • the memory controller sets the initial value of each cache block to 1. If the cache hits, the value of the flag bit of the cache block where the data to be accessed is located may be updated from “1" to "0", and The initial value of the flag bit of all cache blocks in the DRAM except the cache block is updated from “1" to "2".
  • the memory controller processes the The device sends an access response message including the data to be accessed, and does not need to update the data information to be accessed, so that the overhead of updating the data information to be accessed when hitting can be eliminated as compared with the prior art.
  • the method may further include: the memory controller receives the second access request, where the second access request carries the second target address, and the second target address is the second access request to be accessed.
  • the address in the secondary storage When determining that the second access request misses the first area and the second area in the first level memory according to the second target address, the memory controller acquires the second data from the memory according to the second target address. When it is determined that the second access request hits the third region according to the second target address, the memory controller determines the second cache block to be replaced in the first region. The memory controller replaces the data in the second cache block with the second data.
  • the second access request may be any access request sent by the processor.
  • the first access request and the second access request may be the same and may be different.
  • the first cache block to be replaced and the second cache block to be replaced may be the same and may be different.
  • the embodiment of the present invention is described as an example in which the first access request and the second access request are the same, and the first cache block and the second cache block are the same.
  • the method may further include: the memory controller storing the address of the data in the first cache block in the third area.
  • the address of the data in the cache block can include an address portion that can be used to tag the address of the data.
  • the memory controller stores the address of the data in the first cache block in the third area, and specifically includes: the memory controller stores the address of the data in the first cache block in the third area. In this way, if the memory controller determines that the address is stored in the third area, the data is considered to be hot data, and the second cache block to be replaced is determined in the first area; if it is determined that the address is not stored in the third area, The data is cold data, and the first cache block to be replaced is determined in the second zone.
  • the third zone is less than or equal to a preset threshold.
  • the value of the preset threshold is not limited.
  • the preset threshold is small, that is, the storage space of the third area is small. Since the third area is used to buffer the address in the second level memory of the data that is replaced from the second area, if the storage space of the third area is large, the first access request may continuously hit the third area due to In the embodiment of the present invention, the first area is considered to store hot data, and in this case, a lot of hot data is replaced. Therefore, the storage space of the third area should be made small so as to store as much as possible in the second area. The cold data is replaced, so that the hot data stored in the first zone is replaced as little as possible, thereby improving the cache hit ratio.
  • FIG. 6 is an interaction diagram of a method for cache replacement according to an embodiment of the present invention.
  • the processor sends a pending access request to the memory controller, and the pending access request carries the data address to be accessed" as an example.
  • the method shown in Figure 6 includes:
  • the processor sends a to-be-access request to the memory controller.
  • the to-be-accessed request carries the to-be-accessed data address, and the to-be-accessed data address is the address of the to-be-accessed data in the second-level memory.
  • the memory controller receives the to-be-accessed request, and determines, according to the to-be-accessed data address, whether the to-be-accessed request hits the first zone and the second zone in the first-level memory.
  • S203 The memory controller sends an access response message to the processor, where the access response message includes data to be accessed.
  • S204 The memory controller sends a to-be-access request to the second-level memory.
  • the second level memory receives the to-be-accessed request, and sends an access response message to the memory controller, where the access response message includes data to be accessed.
  • S206 The memory controller receives the to-be-accessed data, and determines whether the to-be-accessed request hits the third zone.
  • the memory controller determines the cache block to be replaced in the first area, and replaces the data in the cache block to be replaced with the data to be accessed.
  • the memory controller determines the cache block to be replaced in the second area, replaces the data in the cache block to be replaced with the data to be accessed, and then stores the address of the data in the cache block to be replaced in the third area.
  • the memory controller includes hardware structures and/or software modules corresponding to the execution of the respective functions.
  • the present invention can be implemented in a combination of hardware or hardware and computer software in combination with the modules and algorithm steps of the various examples described in the embodiments disclosed herein. Whether a function is implemented in hardware or computer software to drive hardware depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.
  • the embodiment of the present invention may divide the function module into the memory controller according to the foregoing method example.
  • each function module may be divided according to each function, or two or more functions may be integrated into one processing module.
  • the above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of the module in the embodiment of the present invention is schematic, and is only a logical function division, and the actual implementation may have another division manner.
  • FIG. 7 shows a schematic structural diagram of a memory controller 7.
  • the memory controller 7 may include a receiving module 701, an obtaining module 702, a determining module 703, and a replacement module 704.
  • the memory controller 7 further includes: a cache module 705.
  • the function of each of the functional modules may be inferred according to the steps in the method embodiments provided above, or may refer to the content provided in the above content of the invention, and details are not described herein again. .
  • the above-mentioned obtaining module 702, determining module 703, replacing module 704 and cache module 705 can all be integrated into one processing module in the memory controller 7. Both the receiving module 701 and the transmitting module described above can be integrated into one communication module in the memory controller 7. A storage module 706 may also be included in the memory controller 7.
  • FIG. 8 is a schematic structural diagram of a memory controller 8 according to an embodiment of the present invention.
  • the memory controller 8 may include a processing module 801 and a communication module 802.
  • the processing module 801 is used to control and manage the operation of the memory controller 8.
  • the processing module 801 is configured to support the memory controller 8 to execute S102-S104 in FIG. 3, S202 and S206-S208 in FIG. 6, and the like. And/or other processes for the techniques described herein.
  • the communication module 802 is configured to support communication between the memory controller 8 and other network entities.
  • the communication module 802 is configured to support the memory controller 8 to execute S101 in FIG. 3, S201 and S203-S206 in FIG. 6, etc., and/or Other processes of the techniques described herein.
  • the memory controller 8 may further include: a storage module 803.
  • the storage module 803 is configured to store a corresponding method of the memory controller 8 to perform any of the cache replacements provided above. Program code and data.
  • FIG. 9 is a schematic structural diagram of a computing device 9 according to an embodiment of the present invention.
  • the computing device 9 can include a processor 901, a memory controller 902, a first level memory 903, a second level memory 904, a transceiver 905, and a bus 906.
  • the second level memory 904 and the transceiver 905 are connected to each other through a bus 906.
  • the processor 901 can be a CPU, a general purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or Other programmable logic devices, transistor logic devices, hardware components, or any combination thereof.
  • DSP digital signal processor
  • ASIC application-specific integrated circuit
  • FPGA field programmable gate array
  • the processor may also be a combination of computing functions, such as one or more microprocessor combinations, a combination of a DSP and a microprocessor, and the like.
  • the bus 906 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in Figure 9, but it does not mean that there is only one bus or one type of bus.
  • the steps of the method or algorithm described in connection with the present disclosure may be implemented in a hardware manner, or may be implemented by a processing module executing software instructions.
  • the software instructions may be composed of corresponding software modules, which may be stored in a random access memory (RAM), a flash memory, a read only memory (ROM), an erasable programmable read only memory ( Erasable programmable ROM (EPROM), electrically erasable programmable read only memory (EEPROM), registers, hard disk, removable hard disk, compact disk read only (CD-ROM) or any other form of storage medium known in the art.
  • An exemplary storage medium is coupled to the processor to enable the processor to read information from, and write information to, the storage medium.
  • the storage medium can also be an integral part of the processor.
  • the processor and the storage medium can be located in an ASIC.
  • the functions described herein can be implemented in hardware, software, firmware, or any combination thereof.
  • the functions may be stored in a computer readable medium or transmitted as one or more instructions or code on a computer readable medium.
  • Computer readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another.
  • a storage medium may be any available media that can be accessed by a general purpose or special purpose computer.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

A cache replacement method and a device, for application in a computer system; the computer system comprises a memory controller, a first tier storage and second tier storage, the method comprising: the memory controller receiving a first access request, wherein a first target address is carried in the first access request, and the first target address is an address of to-be-accessed first data of the first access request, which is in the second tier storage (S101); when determining, according to the first target address, that the first access request does not hit a first region and a second region in the first tier storage, the memory controller acquiring first data from the second tier storage according to the first target address, wherein the first tier storage comprises a first region, a second region and a third region, the first region being for use in caching hot data, the second region being for use in caching cold data, and the third region being for use in caching an address, which is in the second tier storage, of data which is from the second region and which is replaced (S102); when determining, according to the first target address, that the first access request does not hit the third region, the memory controller determining, in the second region, a first cache block to be replaced (S103); and the memory controller replacing data from the first cache block with the first data (S104).

Description

一种缓存替换的方法和设备Method and device for cache replacement 技术领域Technical field
本发明涉及数据处理技术领域,尤其涉及一种缓存替换的方法和设备。The present invention relates to the field of data processing technologies, and in particular, to a method and device for cache replacement.
背景技术Background technique
计算机系统可以包括内存控制器、动态随机存取存储器(dynamic random access memory,DRAM)和非易失性存储器(non-volatile memory,NVM)。其中,DRAM包括一个或多个用于存储数据的缓存块。内存控制器接收到访问请求后,若该访问请求未命中DRAM且DRAM已满,则将从NVM中获取到待访问数据,并随机将DRAM中的一个缓存块作为待替换缓存块,并将待替换缓存块中的数据替换为待访问数据。The computer system may include a memory controller, a dynamic random access memory (DRAM), and a non-volatile memory (NVM). Wherein, the DRAM includes one or more cache blocks for storing data. After the memory controller receives the access request, if the access request misses the DRAM and the DRAM is full, the data to be accessed is obtained from the NVM, and a cache block in the DRAM is randomly used as the cache block to be replaced, and will be The data in the replacement cache block is replaced with the data to be accessed.
上述提供的缓存替换的方法中,内存控制器随机将DRAM中的一个缓存块作为待替换缓存块,这样,很可能替换掉访问频率高的数据,这样会减小缓存命中率。In the cache replacement method provided above, the memory controller randomly uses one cache block in the DRAM as the cache block to be replaced, so that it is possible to replace the data with high access frequency, which reduces the cache hit ratio.
发明内容Summary of the invention
本发明的实施例提供一种缓存替换的方法和设备,用以提高缓存命中率。Embodiments of the present invention provide a method and apparatus for cache replacement to improve cache hit ratio.
为达到上述目的,本发明的实施例采用如下技术方案:In order to achieve the above object, embodiments of the present invention adopt the following technical solutions:
一方面,提供一种缓存替换的方法,应用于包括内存控制器和混合内存的计算机系统中。其中,混合内存包括第一级存储器以及第二级存储器。第一级存储器用于缓存第二级存储器中的数据,第一级存储器支持高速缓存访问,第二级存储器为NVM。该方法可以包括:内存控制器接收携带有第一目标地址的第一访问请求,其中,第一目标地址为第一访问请求待访问的第一数据在第二级存储器中的地址;然后,当内存控制器根据第一目标地址确定第一访问请求未命中第一级存储器中的第一区和第二区时,根据第一目标地址从第二级存储器中获取第一数据,其中,第一级存储器包括第一区、第二区以及第三区,第一区用于缓存热数据,第二区用于缓存冷数据,第三区用于缓存从第二区被替换出的数据的在第二级存储器中的地址;后续,当内存控制器根据第一目标地址确定第一访问请求未命中第三区时,在第二区中确定待替换的第一缓存块;最后,内存控制器将第一缓存块中的数据替换为第一数据。In one aspect, a method of cache replacement is provided for use in a computer system including a memory controller and hybrid memory. The hybrid memory includes a first level memory and a second level memory. The first level of memory is used to cache data in the second level of memory, the first level of memory supports cache access, and the second level of memory is NVM. The method may include: the memory controller receiving the first access request carrying the first target address, wherein the first target address is an address of the first data to be accessed by the first access request in the second level memory; The memory controller determines, according to the first target address, that the first access request misses the first area and the second area in the first level memory, and acquires the first data from the second level memory according to the first target address, where the first The level memory includes a first area for buffering hot data, a second area for buffering cold data, and a third area for buffering data that is replaced from the second area. An address in the second level memory; subsequently, when the memory controller determines that the first access request misses the third area according to the first target address, determining the first cache block to be replaced in the second area; and finally, the memory controller The data in the first cache block is replaced with the first data.
在该技术方案中,当访问请求未命中第一级存储器时,内存控制器从第二级存储器中获取该访问请求所请求的第一数据,然后,内存控制器根据访问请求中携带的第一目标地址确定第一访问请求未命中第三区时,在第二区中确定待替换的第一缓存块。其中,第一区用于缓存热数据,第二区用于缓存冷数据,第三区用于记录从第二区被替换出的数据的在第二级存储器中的地址。也就是说,本发明实施例提供的技术方案中,若第三区未命中的概率较高时,可以使得第一区中缓存的冷数据被替换出去的概率提高,从而使得第一级缓存中缓存的热数据较多。因此,与现有技术中提供的在第一级缓存器中随机确定待替换的缓存块相比,能够提高缓存命中率。In the technical solution, when the access request misses the first level memory, the memory controller acquires the first data requested by the access request from the second level memory, and then, the memory controller according to the first carried in the access request When the target address determines that the first access request misses the third zone, the first cache block to be replaced is determined in the second zone. The first area is for buffering hot data, the second area is for buffering cold data, and the third area is for recording an address in the second level memory of data that is replaced from the second area. That is to say, in the technical solution provided by the embodiment of the present invention, if the probability of the third zone miss is high, the probability that the cached cold data in the first zone is replaced is increased, so that the first level cache is More cached hot data. Therefore, the cache hit ratio can be improved as compared with the cache block to be replaced that is randomly determined in the first level buffer provided in the prior art.
在一种可能的设计中,所述第二级存储器为非易失性存储器NVM。In one possible design, the second level of memory is a non-volatile memory NVM.
在一种可能的设计中,在内存控制器将第一缓存块中的数据替换为第一数据之后,该方法还可以包括:内存控制器将第一缓存块中的数据的地址存储在第三区中。该可能的设计用于在后续缓存替换过程中,确定从第一区中确定待替换的缓存块还是 从第二区中确定待替换的缓存块。具体的,内存控制器若确定第三区中存储有第一目标地址,则认为第一数据是热数据,在第一区确定待替换的缓存块;若确定第三区中未存储该第一目标地址,则认为第一数据是冷数据,在第二区确定待替换的缓存块。In a possible design, after the memory controller replaces the data in the first cache block with the first data, the method may further include: the memory controller storing the address of the data in the first cache block in the third In the district. The possible design is used to determine whether to determine the cache block to be replaced from the first zone during the subsequent cache replacement process. The cache block to be replaced is determined from the second zone. Specifically, if the memory controller determines that the first target address is stored in the third area, the first data is considered to be hot data, and the cache block to be replaced is determined in the first area; if it is determined that the first area is not stored in the third area The target address is considered to be cold data, and the cache block to be replaced is determined in the second area.
在一种可能的设计中,该方法还可以包括:内存控制器接收携带有第二目标地址的第二访问请求,第二目标地址为第二访问请求待访问的第二数据在第二级存储器中的地址;然后,当根据第二目标地址确定第二访问请求未命中第一级存储器中的第一区和第二区时,内存控制器根据第二目标地址从所述第二级存储器中获取第二数据;后续,当根据第二目标地址确定第二访问请求命中第三区时,内存控制器在第一区中确定待替换的第二缓存块;最后,内存控制器将第二缓存块中的数据替换为第二数据。In a possible design, the method may further include: the memory controller receiving the second access request carrying the second target address, and the second target address being the second access request to access the second data in the second level memory Address; then, when determining that the second access request misses the first region and the second region in the first level memory according to the second target address, the memory controller is from the second level memory according to the second target address Obtaining the second data; subsequently, when determining that the second access request hits the third region according to the second target address, the memory controller determines the second cache block to be replaced in the first region; finally, the memory controller will use the second cache The data in the block is replaced with the second data.
在一种可能的设计中,第一区大于第二区。第一区包括的缓存块的个数可以大于第二区包括的缓存块的个数,即存储热数据的区域可以大于存储冷数据的区域。由于热数据被访问的命中率高于冷数据被访问的命中率,因此,扩大热数据的区域可以提高缓存命中率。In one possible design, the first zone is larger than the second zone. The number of cache blocks included in the first zone may be greater than the number of cache blocks included in the second zone, that is, the area in which the hot data is stored may be larger than the area in which the cold data is stored. Since the hit rate of hot data access is higher than the hit rate of cold data access, expanding the area of hot data can increase the cache hit rate.
在一种可能的设计中,内存控制器在第二区中确定待替换的第一缓存块,可以包括:内存控制器将第二区中的任一数据或最早被写入第一级存储器中的数据所在的缓存块确定为待替换的第一缓存块。In a possible design, the memory controller determines the first cache block to be replaced in the second area, and may include: the memory controller writes any data in the second area or is first written into the first level memory The cache block in which the data is located is determined as the first cache block to be replaced.
在一种可能的设计中,第三区小于或等于预设阈值。本发明实施例对预设阈值的取值不进行限定,一般地,预设阈值较小,即第三区的存储空间较小,以使尽可能多的存储于第二区的冷数据被替换掉,使存储于第一区的热数据尽可能少的被替换掉,从而提高缓存命中率。具体分析过程可参考下文。In one possible design, the third zone is less than or equal to a predetermined threshold. In the embodiment of the present invention, the value of the preset threshold is not limited. Generally, the preset threshold is small, that is, the storage space of the third area is small, so that as much cold data as possible stored in the second area is replaced. The hot data stored in the first area is replaced as little as possible, thereby improving the cache hit rate. The specific analysis process can be referred to below.
另一方面,提供一种计算设备,该计算设备可以包括内存控制器和混合内存,混合内存包括第一级存储器以及第二级存储器,第一级存储器用于缓存第二级存储器中的数据,第一级存储器支持高速缓存访问,内存控制器可以用于:接收第一访问请求,第一访问请求中携带有第一目标地址,第一目标地址为第一访问请求待访问的第一数据在第二级存储器中的地址;当根据第一目标地址确定第一访问请求未命中第一级存储器中的第一区和第二区时,根据第一目标地址从第二级存储器中获取第一数据,其中,第一级存储器包括第一区、第二区以及第三区,第一区用于缓存热数据,第二区用于缓存冷数据,第三区用于缓存从第二区被替换出的数据的在第二级存储器中的地址;当根据第一目标地址确定第一访问请求未命中第三区时,在第二区中确定待替换的第一缓存块;将第一缓存块中的数据替换为第一数据。In another aspect, a computing device is provided, the computing device can include a memory controller and a hybrid memory, the mixed memory including a first level memory and a second level memory, wherein the first level memory is used to cache data in the second level memory, The first level of memory supports the cache access, and the memory controller is configured to: receive the first access request, where the first access request carries the first target address, and the first target address is the first data to be accessed by the first access request. An address in the second level memory; when determining that the first access request misses the first area and the second area in the first level memory according to the first target address, acquiring the first from the second level memory according to the first target address Data, wherein the first level memory comprises a first area for buffering hot data, a second area for buffering cold data, and a third area for buffering from the second area An address of the replaced data in the second level memory; when it is determined that the first access request misses the third area according to the first target address, determining the to-be-replaced in the second area A cache block; replaces data in the first cache block is a first data.
在一种可能的设计中,内存控制器还用于:将第一缓存块中的数据的地址存储在第三区中。In a possible design, the memory controller is further configured to: store the address of the data in the first cache block in the third zone.
在一种可能的设计中,内存控制器还用于:接收第二访问请求,第二访问请求中携带有第二目标地址,第二目标地址为第二访问请求待访问的第二数据在第二级存储器中的地址;当根据第二目标地址确定第二访问请求未命中第一级存储器中的第一区和第二区时,根据第二目标地址从内存中获取第二数据;当根据第二目标地址确定第二访问请求命中第三区时,在第一区中确定待替换的第二缓存块;将第二缓存块中的数据替换为第二数据。In a possible design, the memory controller is further configured to: receive a second access request, where the second access request carries a second target address, and the second target address is a second access request to be accessed by the second data. An address in the secondary storage device; when determining that the second access request misses the first region and the second region in the first level memory according to the second target address, acquiring the second data from the memory according to the second target address; When the second target address determines that the second access request hits the third area, the second cache block to be replaced is determined in the first area; the data in the second cache block is replaced with the second data.
在一种可能的设计中,第一区大于第二区。 In one possible design, the first zone is larger than the second zone.
在一种可能的设计中,所述第二级存储器为非易失性存储器NVM。In one possible design, the second level of memory is a non-volatile memory NVM.
在一种可能的设计中,内存控制器具体用于:将第二区中的任一数据或最早被写入第一级存储器中的数据所在的缓存块确定为待替换的第一缓存块。In a possible design, the memory controller is specifically configured to: determine, as the first cache block to be replaced, the cache block in which any data in the second area or the data that is first written into the first level memory is located.
在一种可能的设计中,第三区小于或等于预设阈值。In one possible design, the third zone is less than or equal to a predetermined threshold.
又一方面,本发明实施例提供了一种内存控制器,所述内存控制器中包含有分别用于执行上述第一方面以及第一方面的各可能的实施方式中所示的方法的模块。In another aspect, an embodiment of the present invention provides a memory controller, where the memory controller includes modules for performing the foregoing first aspect and the method shown in each possible implementation manner of the first aspect.
又一方面,提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,当计算设备的至少一个处理器执行该计算机执行指令时,计算设备执行上述方面或者上述方面的任一种可能的实现方式所提供的缓存替换的方法。In still another aspect, a computer readable storage medium is provided, wherein computer executable instructions are stored, wherein when the at least one processor of the computing device executes the computer to execute the instructions, the computing device performs the above aspects or any of the above aspects A possible implementation of the cache replacement method provided.
另一方面,提供一种计算机程序产品,该计算机程序产品包括计算机执行指令,该计算机执行指令存储在计算机可读存储介质中;计算设备的至少一个处理器可以从计算机可读存储介质读取该计算机执行指令,至少一个处理器执行该计算机执行指令使得计算设备实施上述方面或者上述方面的任一种可能的实现方式所提供的缓存替换的方法。In another aspect, a computer program product is provided, the computer program product comprising computer executable instructions stored in a computer readable storage medium; at least one processor of the computing device can read the computer readable storage medium The computer executes the instructions, and the at least one processor executes the computer to execute the instructions such that the computing device implements the cache replacement method provided by the above aspects or any of the possible implementations of the above aspects.
可以理解地,上述提供的任一种计算设备或计算机存储介质均用于执行上文所提供的缓存替换的方法,因此,其所能达到的有益效果可参考上文所提供的相应的缓存替换的方法中的有益效果,此处不再赘述。It can be understood that any of the computing devices or computer storage media provided above are used to perform the cache replacement method provided above, and therefore, the beneficial effects that can be achieved can be referred to the corresponding cache replacement provided above. The beneficial effects of the method are not repeated here.
附图说明DRAWINGS
图1为本发明实施例所适用的一种计算机系统架构图;1 is a structural diagram of a computer system to which an embodiment of the present invention is applied;
图2为本发明实施例所适用的一种缓存系统架构图;2 is a schematic structural diagram of a cache system according to an embodiment of the present invention;
图3为本发明实施例提供的一种缓存替换的方法的流程图;FIG. 3 is a flowchart of a method for cache replacement according to an embodiment of the present invention;
图4为本发明实施例提供的一种第一级存储器的结构图;4 is a structural diagram of a first level memory according to an embodiment of the present invention;
图5为本发明实施例提供的另一种第一级存储器的结构图;FIG. 5 is a structural diagram of another first level memory according to an embodiment of the present disclosure;
图6为本发明实施例提供的一种缓存替换的方法的交互图;FIG. 6 is an interaction diagram of a method for cache replacement according to an embodiment of the present invention;
图7为本发明实施例提供的一种内存控制器的结构示意图;FIG. 7 is a schematic structural diagram of a memory controller according to an embodiment of the present disclosure;
图8为本发明实施例提供的另一种内存控制器的结构示意图;FIG. 8 is a schematic structural diagram of another memory controller according to an embodiment of the present disclosure;
图9为本发明实施例提供的一种计算设备的结构示意图。FIG. 9 is a schematic structural diagram of a computing device according to an embodiment of the present invention.
具体实施方式detailed description
本发明实施例提供的技术方案可以应用于如图1所示的计算机系统架构中,图1所示的计算机系统可以包括处理器、内存控制器和混合内存。其中,处理器是计算机系统的控制中心。混合内存包括第一级存储器和第二级存储器。第一级存储器用于缓存第二级存储器中的数据,还用于支持高速缓存访问。在DRAM-NVM内存系统中,DRAM可以作为图1提供的计算机系统中的第一级存储器,NVM可以作为图1提供的计算机系统中的第二级存储器。The technical solution provided by the embodiment of the present invention can be applied to the computer system architecture shown in FIG. 1. The computer system shown in FIG. 1 can include a processor, a memory controller, and a hybrid memory. Among them, the processor is the control center of the computer system. The hybrid memory includes a first level memory and a second level memory. The first level of memory is used to cache data in the second level of memory and is also used to support cache access. In a DRAM-NVM memory system, DRAM can be used as the first level of memory in the computer system provided in FIG. 1, and NVM can be used as the second level of memory in the computer system provided in FIG.
本发明实施例提供的技术方案还可以应用于如图2所示的缓存系统架构中,图2所示的缓存系统可以包括处理器、缓存、缓存控制器、内存控制器和内存。其中,处理器是缓存系统的控制中心。缓存是介于处理器和内存之间的高速存储器,主要用于 提升系统的读写性能。缓存控制器用于对缓存中的数据进行管理。缓存中的数据可以是内存中的一部分数据。进一步的,若缓存包含待访问数据,则处理器可以从缓存中获取待访问数据,而不用从内存中获取待访问数据,从而加快了读取速度。The technical solution provided by the embodiment of the present invention can also be applied to the cache system architecture shown in FIG. 2. The cache system shown in FIG. 2 can include a processor, a cache, a cache controller, a memory controller, and a memory. Among them, the processor is the control center of the cache system. Cache is a high-speed memory between the processor and memory, mainly used for Improve the read and write performance of the system. The cache controller is used to manage the data in the cache. The data in the cache can be part of the data in memory. Further, if the cache contains data to be accessed, the processor can obtain the data to be accessed from the cache without acquiring the data to be accessed from the memory, thereby speeding up the reading speed.
需要说明的是,图1中的内存控制器执行的功能可以类比于图2中的缓存控制器执行的功能。图1中的第一级存储器可以类比于图2中的缓存。图1中的第二级存储器可以类比于图2中的内存。It should be noted that the functions performed by the memory controller in FIG. 1 can be analogized to the functions performed by the cache controller in FIG. 2. The first level of memory in Figure 1 can be analogized to the cache in Figure 2. The second level of memory in Figure 1 can be analogized to the memory in Figure 2.
本文中的术语“第一”和“第二”等是用于区别不同的对象,而不是用于描述对象的特定顺序。本文中的术语“多个”是指两个或两个以上。本文中字符“/”,表示前后关联对象是一种“或”的关系。The terms "first" and "second" and the like are used herein to distinguish different objects, rather than to describe a particular order of the objects. The term "plurality" as used herein refers to two or more. The character "/" in this article indicates that the contextual object is an "or" relationship.
如图3所示,为本发明实施例提供的一种缓存替换的方法的流程图,可以应用于如图1所示的计算机系统架构中,计算机系统可以包括处理器、内存控制器、第一级存储器和第二级存储器。第一级存储器包括第一区、第二区和第三区。其中,第一区用于缓存热数据,第二区用于缓存冷数据,第三区用于缓存从第二区被替换出的数据的在第二级存储器中的地址。本发明实施例中认为存储在第一区内的数据为热数据,存储在第二区的数据为冷数据。第一区、第二区和第三区包括的缓存块的位置可以是连续的,也可以是不连续的。As shown in FIG. 3, a flowchart of a cache replacement method according to an embodiment of the present invention may be applied to a computer system architecture as shown in FIG. 1. The computer system may include a processor, a memory controller, and a first Level memory and second level memory. The first level of memory includes a first zone, a second zone, and a third zone. The first area is for buffering hot data, the second area is for buffering cold data, and the third area is for buffering addresses in the second level memory of data that is replaced from the second area. In the embodiment of the present invention, the data stored in the first area is considered to be hot data, and the data stored in the second area is cold data. The locations of the cache blocks included in the first zone, the second zone, and the third zone may be continuous or discontinuous.
基于此,该方法可以包括以下步骤S101-S104:Based on this, the method may include the following steps S101-S104:
S101:内存控制器接收第一访问请求。其中,第一访问请求中携带有第一目标地址,第一目标地址为第一访问请求待访问的第一数据在第二级存储器中的地址。S101: The memory controller receives the first access request. The first access request carries a first target address, where the first target address is an address of the first data to be accessed by the first access request in the second level memory.
具体的,S101可以包括:内存控制器接收处理器发送的第一访问请求。第一访问请求可以是处理器发送的任一次访问请求。Specifically, S101 may include: the memory controller receiving the first access request sent by the processor. The first access request may be any one of the access requests sent by the processor.
在S101之前,该方法还可以包括:内存控制器根据第一目标地址,判断第一访问请求是否命中第一级存储器中的第一区和第二区中的任一区。Before S101, the method may further include: determining, by the memory controller, whether the first access request hits any one of the first zone and the second zone in the first level memory according to the first target address.
S102:当根据第一目标地址确定第一访问请求未命中第一级存储器中的第一区和第二区时,内存控制器根据第一目标地址从第二级存储器中获取第一数据。S102: When determining that the first access request misses the first area and the second area in the first level memory according to the first target address, the memory controller acquires the first data from the second level memory according to the first target address.
第一数据可以是混合内存中存储的任一数据;且第一数据可以是第一级存储器中存储的数据,也可以不是第一级存储器中存储的数据。The first data may be any data stored in the hybrid memory; and the first data may be data stored in the first level memory or may not be data stored in the first level memory.
可选的,内存控制器将第一级存储器分区之后,第一区可以包括一个或多个缓存块,第二区可以包括一个或多个缓存块,第三区可以包括一个或多个缓存块。其中,第一区包括的缓存块的个数可以大于第二区包括的缓存块的个数,即存储热数据的区域可以大于存储冷数据的区域。由于热数据被访问的命中率高于冷数据被访问的命中率,因此,扩大热数据的区域可以提高缓存命中率。Optionally, after the memory controller partitions the first level memory, the first area may include one or more cache blocks, the second area may include one or more cache blocks, and the third area may include one or more cache blocks. . The number of cache blocks included in the first area may be greater than the number of cache blocks included in the second area, that is, the area where the hot data is stored may be larger than the area where the cold data is stored. Since the hit rate of hot data access is higher than the hit rate of cold data access, expanding the area of hot data can increase the cache hit rate.
S102中的从第二级存储器中获取第一数据,可以包括:内存控制器向第二级存储器发送该第一访问请求;第二级存储器接收该第一访问请求,并向内存控制器发送访问响应消息,其中,访问响应消息携带第一数据;内存控制器接收该访问响应消息。The obtaining the first data from the second level memory in S102 may include: the memory controller transmitting the first access request to the second level memory; the second level memory receiving the first access request, and sending the access to the memory controller And a response message, wherein the access response message carries the first data; the memory controller receives the access response message.
S103:当根据第一目标地址确定第一访问请求未命中第三区时,内存控制器在第二区中确定待替换的第一缓存块。S103: When determining that the first access request misses the third area according to the first target address, the memory controller determines the first cache block to be replaced in the second area.
若内存控制器根据第一目标地址确定第一访问请求未命中第三区,则认为该第一数据是冷数据,要把该第一数据放在第二区,即在第二区中确定待替换的第一缓存块。 If the memory controller determines that the first access request misses the third area according to the first target address, the first data is considered to be cold data, and the first data is to be placed in the second area, that is, determined in the second area. The first cache block that is replaced.
在S103中,内存控制器在第二区中确定待替换的第一缓存块具体可以包括:内存控制器在第二区中根据随机算法,随机将第二级存储器中的数据所在的缓存块确定待替换的第一缓存块;或者,根据先入先出算法,将最早被写入第一级存储器中的数据所在的缓存块确定待替换的第一缓存块。关于随机算法和先入先出算法的具体内容可以参考现有技术。In S103, the determining, by the memory controller, the first cache block to be replaced in the second area may include: the memory controller randomly determining, in the second area, the cache block where the data in the second level memory is located according to a random algorithm. The first cache block to be replaced; or, according to the first-in first-out algorithm, the first cache block to be replaced is determined by the cache block in which the data originally written in the first-level memory is located. The specific content of the random algorithm and the first-in first-out algorithm can refer to the prior art.
S104:内存控制器将第一缓存块中的数据替换为第一数据。S104: The memory controller replaces the data in the first cache block with the first data.
内存控制器若确定第一访问请求未命中第一级存储器中的第一区和第二区时,则根据第一目标地址从第二级存储器中获取第一数据。若第一级存储器已满且第三区未存储第一目标地址,则该情况下,内存控制器会优先在第二区中确定待替换的第一缓存块,并将第一缓存块中的数据替换为第一数据。由于第二区存储冷数据,因此本发明实施例保证了优先替换冷数据,从而提高了缓存命中率。The memory controller obtains the first data from the second level memory according to the first target address if it is determined that the first access request misses the first area and the second area in the first level memory. If the first level memory is full and the third area does not store the first target address, then in this case, the memory controller preferentially determines the first cache block to be replaced in the second area, and the first cache block The data is replaced with the first data. Since the second area stores cold data, the embodiment of the present invention ensures that the cold data is preferentially replaced, thereby improving the cache hit ratio.
示例的,假设第一级存储器包括6个缓存块,每个缓存块中存储有数据和该数据的地址。第一级存储器包括第一区、第二区和第三区。第一区的缓存块1中存储数据3和地址3、缓存块2中存储数据4和地址4、缓存块3中存储数据5和地址5,第二区的缓存块4中存储数据1和地址1、缓存块5中存储数据2和地址2,第三区的缓存块6中未存储地址,如图4所示。若第一时刻内存控制器接收的第一访问请求包括地址6,则缓存替换后,第二区的缓存块4中存储的信息可以为数据6和地址6、第三区的缓存块6中可以存储地址1,如图5所示。By way of example, assume that the first level of memory includes six cache blocks, each of which stores data and an address of the data. The first level of memory includes a first zone, a second zone, and a third zone. The data block 3 and the address 3 are stored in the cache block 1 of the first area, the data 4 and the address 4 are stored in the cache block 2, the data 5 and the address 5 are stored in the cache block 3, and the data 1 and the address are stored in the cache block 4 of the second area. 1. Cache block 5 stores data 2 and address 2, and the cache block 6 of the third area does not store an address, as shown in FIG. If the first access request received by the memory controller at the first time includes the address 6, after the cache is replaced, the information stored in the cache block 4 of the second area may be data 6 and address 6, and the cache block 6 of the third area may be Store address 1, as shown in Figure 5.
具体实现时,若第一级存储器未满,则内存控制器可以将第一数据写入任一个空闲的缓存块中。In a specific implementation, if the first level memory is not full, the memory controller may write the first data into any of the free cache blocks.
本发明实施例提供的技术方案中,当访问请求未命中第一级存储器时,内存控制器从第二级存储器中获取该访问请求所请求的第一数据,然后,内存控制器根据访问请求中携带的第一目标地址确定第一访问请求未命中第三区时,在第二区中确定待替换的第一缓存块。其中,第一区用于缓存热数据,第二区用于缓存冷数据,第三区用于记录从第二区被替换出的数据的在第二级存储器中的地址。也就是说,本发明实施例提供的技术方案中,若第三区未命中的概率较高时,可以使得第一区中缓存的冷数据被替换出去的概率提高,从而使得第一级缓存中缓存的热数据较多。因此,与现有技术中提供的在第一级缓存器中随机确定待替换的缓存块相比,能够提高缓存命中率。In the technical solution provided by the embodiment of the present invention, when the access request misses the first level memory, the memory controller acquires the first data requested by the access request from the second level memory, and then, the memory controller according to the access request When the carried first target address determines that the first access request misses the third area, the first cache block to be replaced is determined in the second area. The first area is for buffering hot data, the second area is for buffering cold data, and the third area is for recording an address in the second level memory of data that is replaced from the second area. That is to say, in the technical solution provided by the embodiment of the present invention, if the probability of the third zone miss is high, the probability that the cached cold data in the first zone is replaced is increased, so that the first level cache is More cached hot data. Therefore, the cache hit ratio can be improved as compared with the cache block to be replaced that is randomly determined in the first level buffer provided in the prior art.
现有技术中,内存控制器可以给DRAM包括的每个缓存块添加一个标志位,并设置每个缓存块的初始值。DRAM控制器若确定DRAM中存储有待访问数据,即命中,则向处理器发送包括待访问数据的访问响应消息,并更新待访问数据信息。更新待访问数据信息可以包括但不限于将待访问数据所在的缓存块的标志位的值置零,将DRAM中除去该缓存块的所有缓存块的标志位的值增大。具体实现时,对设置的缓存块的初始值和增加的标志位的值的幅度不进行限定。示例的,假设内存控制器将每个缓存块的初始值设置为1,若缓存命中,则可以将待访问数据所在的缓存块的标志位的值由“1”更新为“0”,可以将DRAM中的除去该缓存块的所有缓存块的标志位的初始值由“1”更新为“2”。In the prior art, the memory controller can add a flag bit to each cache block included in the DRAM and set an initial value of each cache block. If the DRAM controller determines that the data to be accessed is stored in the DRAM, that is, the hit, the DRAM controller sends an access response message including the data to be accessed to the processor, and updates the to-be-accessed data information. Updating the data information to be accessed may include, but is not limited to, zeroing the value of the flag bit of the cache block in which the data to be accessed is located, and increasing the value of the flag bit of all cache blocks in the DRAM from which the cache block is removed. In specific implementation, the initial value of the set cache block and the magnitude of the value of the added flag bit are not limited. For example, suppose the memory controller sets the initial value of each cache block to 1. If the cache hits, the value of the flag bit of the cache block where the data to be accessed is located may be updated from "1" to "0", and The initial value of the flag bit of all cache blocks in the DRAM except the cache block is updated from "1" to "2".
基于此,本发明实施例中提供的技术方案中,若缓存命中,则内存控制器向处理 器发送包括待访问数据的访问响应消息,不需更新待访问数据信息,这样,与现有技术相比,可以消除命中时更新待访问数据信息的开销。Based on this, in the technical solution provided in the embodiment of the present invention, if the cache hits, the memory controller processes the The device sends an access response message including the data to be accessed, and does not need to update the data information to be accessed, so that the overhead of updating the data information to be accessed when hitting can be eliminated as compared with the prior art.
可选的,该方法还可以包括:内存控制器接收第二访问请求;其中,第二访问请求中携带有第二目标地址,第二目标地址为第二访问请求待访问的第二数据在第二级存储器中的地址。当根据第二目标地址确定第二访问请求未命中第一级存储器中的第一区和第二区时,内存控制器根据第二目标地址从内存中获取第二数据。当根据第二目标地址确定第二访问请求命中第三区时,内存控制器在第一区中确定待替换的第二缓存块。内存控制器将第二缓存块中的数据替换为第二数据。需要说明的是,第二访问请求可以是处理器发送的任一次访问请求。第一访问请求与第二访问请求可以相同,可以不同。待替换的第一缓存块和待替换的第二缓存块可以相同,可以不同。本发明实施例以“第一访问请求和第二访问请求相同,第一缓存块和第二缓存块相同”为例进行说明。Optionally, the method may further include: the memory controller receives the second access request, where the second access request carries the second target address, and the second target address is the second access request to be accessed. The address in the secondary storage. When determining that the second access request misses the first area and the second area in the first level memory according to the second target address, the memory controller acquires the second data from the memory according to the second target address. When it is determined that the second access request hits the third region according to the second target address, the memory controller determines the second cache block to be replaced in the first region. The memory controller replaces the data in the second cache block with the second data. It should be noted that the second access request may be any access request sent by the processor. The first access request and the second access request may be the same and may be different. The first cache block to be replaced and the second cache block to be replaced may be the same and may be different. The embodiment of the present invention is described as an example in which the first access request and the second access request are the same, and the first cache block and the second cache block are the same.
可选的,在S104之后,该方法还可以包括:内存控制器将第一缓存块中的数据的地址存储在第三区中。缓存块中的数据的地址可以包括地址部分,地址部分可以用于标记数据的地址。内存控制器将第一缓存块中的数据的地址存储在第三区中,具体可以包括:内存控制器将第一缓存块中的数据的地址存储在第三区中。这样,内存控制器若确定第三区中存储有该地址,则认为该数据是热数据,在第一区确定待替换的第二缓存块;若确定第三区中未存储该地址,则认为该数据是冷数据,在第二区确定待替换的第一缓存块。Optionally, after S104, the method may further include: the memory controller storing the address of the data in the first cache block in the third area. The address of the data in the cache block can include an address portion that can be used to tag the address of the data. The memory controller stores the address of the data in the first cache block in the third area, and specifically includes: the memory controller stores the address of the data in the first cache block in the third area. In this way, if the memory controller determines that the address is stored in the third area, the data is considered to be hot data, and the second cache block to be replaced is determined in the first area; if it is determined that the address is not stored in the third area, The data is cold data, and the first cache block to be replaced is determined in the second zone.
另外可选的,第三区小于或等于预设阈值。本发明实施例对预设阈值的取值不进行限定,一般地,预设阈值较小,也就是说,第三区的存储空间较小。由于第三区用于缓存从第二区被替换出的数据的在第二级存储器中的地址,若第三区的存储空间较大,则第一访问请求可能会连续命中第三区,由于本发明实施例中认为第一区存储热数据,该情况下会有很多热数据被替换掉,因此,应使第三区的存储空间较小,以使尽可能多的存储于第二区的冷数据被替换掉,使存储于第一区的热数据尽可能少的被替换掉,从而提高缓存命中率。Alternatively, the third zone is less than or equal to a preset threshold. In the embodiment of the present invention, the value of the preset threshold is not limited. Generally, the preset threshold is small, that is, the storage space of the third area is small. Since the third area is used to buffer the address in the second level memory of the data that is replaced from the second area, if the storage space of the third area is large, the first access request may continuously hit the third area due to In the embodiment of the present invention, the first area is considered to store hot data, and in this case, a lot of hot data is replaced. Therefore, the storage space of the third area should be made small so as to store as much as possible in the second area. The cold data is replaced, so that the hot data stored in the first zone is replaced as little as possible, thereby improving the cache hit ratio.
下面通过一个具体的示例对上文提供的缓存替换的方法进行说明。The method of cache replacement provided above is explained by a specific example below.
如图6所示,为本发明实施例提供的一种缓存替换的方法的交互图。下文以“处理器向内存控制器发送待访问请求,待访问请求中携带有待访问数据地址”为例进行说明。图6所示的方法包括:FIG. 6 is an interaction diagram of a method for cache replacement according to an embodiment of the present invention. The following is an example of "the processor sends a pending access request to the memory controller, and the pending access request carries the data address to be accessed" as an example. The method shown in Figure 6 includes:
S201:处理器向内存控制器发送待访问请求。其中,待访问请求中携带有待访问数据地址,待访问数据地址为待访问数据在第二级存储器中的地址。S201: The processor sends a to-be-access request to the memory controller. The to-be-accessed request carries the to-be-accessed data address, and the to-be-accessed data address is the address of the to-be-accessed data in the second-level memory.
S202:内存控制器接收该待访问请求,并根据待访问数据地址,判断待访问请求是否命中第一级存储器中的第一区和第二区。S202: The memory controller receives the to-be-accessed request, and determines, according to the to-be-accessed data address, whether the to-be-accessed request hits the first zone and the second zone in the first-level memory.
若是,则执行S203;若否,则执行S204。If yes, execute S203; if no, execute S204.
S203:内存控制器向处理器发送访问响应消息,其中,访问响应消息包括待访问数据。S203: The memory controller sends an access response message to the processor, where the access response message includes data to be accessed.
执行S203之后,则结束。After executing S203, it ends.
S204:内存控制器向第二级存储器发送待访问请求。 S204: The memory controller sends a to-be-access request to the second-level memory.
S205:第二级存储器接收该待访问请求,并向内存控制器发送访问响应消息,其中,访问响应消息包括待访问数据。S205: The second level memory receives the to-be-accessed request, and sends an access response message to the memory controller, where the access response message includes data to be accessed.
S206:内存控制器接收该待访问数据,并判断待访问请求是否命中第三区。S206: The memory controller receives the to-be-accessed data, and determines whether the to-be-accessed request hits the third zone.
若是,则执行S207;若否,则执行S208。If yes, execute S207; if no, execute S208.
S207:内存控制器在第一区中确定待替换缓存块,并将待替换缓存块中的数据替换为待访问数据。S207: The memory controller determines the cache block to be replaced in the first area, and replaces the data in the cache block to be replaced with the data to be accessed.
执行S207之后,则结束。After executing S207, it ends.
S208:内存控制器在第二区中确定待替换缓存块,并将待替换缓存块中的数据替换为待访问数据,然后将待替换缓存块中的数据的地址存储在第三区中。S208: The memory controller determines the cache block to be replaced in the second area, replaces the data in the cache block to be replaced with the data to be accessed, and then stores the address of the data in the cache block to be replaced in the third area.
执行S208之后,则结束。After executing S208, it ends.
上述主要从内存控制器的角度对本发明实施例提供的方案进行了介绍。可以理解的是,为了实现上述各个功能,内存控制器包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的模块及算法步骤,本发明能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。The solution provided by the embodiment of the present invention is mainly introduced from the perspective of a memory controller. It can be understood that in order to implement the above various functions, the memory controller includes hardware structures and/or software modules corresponding to the execution of the respective functions. Those skilled in the art will readily appreciate that the present invention can be implemented in a combination of hardware or hardware and computer software in combination with the modules and algorithm steps of the various examples described in the embodiments disclosed herein. Whether a function is implemented in hardware or computer software to drive hardware depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.
本发明实施例可以根据上述方法示例对内存控制器进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本发明实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiment of the present invention may divide the function module into the memory controller according to the foregoing method example. For example, each function module may be divided according to each function, or two or more functions may be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of the module in the embodiment of the present invention is schematic, and is only a logical function division, and the actual implementation may have another division manner.
在采用各个功能划分的各个功能模块的情况下,图7示出了一种内存控制器7的结构示意图。内存控制器7可以包括:接收模块701、获取模块702、确定模块703和替换模块704。可选的,内存控制器7还可以包括:缓存模块705。这各功能模块中的每个功能模块所具有的功能可以根据上文所提供的各方法实施例中的各步骤推断出来,或者可以参考上文发明内容部分所提供的内容,此处不再赘述。In the case of using various functional modules divided by respective functions, FIG. 7 shows a schematic structural diagram of a memory controller 7. The memory controller 7 may include a receiving module 701, an obtaining module 702, a determining module 703, and a replacement module 704. Optionally, the memory controller 7 further includes: a cache module 705. The function of each of the functional modules may be inferred according to the steps in the method embodiments provided above, or may refer to the content provided in the above content of the invention, and details are not described herein again. .
在采用集成的模块的情况下,上述获取模块702、确定模块703、替换模块704和缓存模块705均可以集成为内存控制器7中的一个处理模块。上述接收模块701和发送模块均可以集成为内存控制器7中的一个通信模块。内存控制器7中还可以包括存储模块706。In the case of adopting an integrated module, the above-mentioned obtaining module 702, determining module 703, replacing module 704 and cache module 705 can all be integrated into one processing module in the memory controller 7. Both the receiving module 701 and the transmitting module described above can be integrated into one communication module in the memory controller 7. A storage module 706 may also be included in the memory controller 7.
如图8所示,为本发明实施例提供的一种内存控制器8的结构示意图。内存控制器8可以包括:处理模块801和通信模块802。其中,处理模块801用于对内存控制器8的工作进行控制管理,例如,处理模块801用于支持内存控制器8执行图3中的S102-S104、图6中的S202和S206-S208等,和/或用于本文所描述的技术的其它过程。通信模块802用于支持内存控制器8与其他网络实体的通信,例如通信模块802用于支持内存控制器8执行图3中的S101、图6中的S201和S203-S206等,和/或用于本文所描述的技术的其它过程。另外,内存控制器8还可以包括:存储模块803。存储模块803用于存储内存控制器8执行上文所提供的任一缓存替换的方法所对应的 程序代码和数据。FIG. 8 is a schematic structural diagram of a memory controller 8 according to an embodiment of the present invention. The memory controller 8 may include a processing module 801 and a communication module 802. The processing module 801 is used to control and manage the operation of the memory controller 8. For example, the processing module 801 is configured to support the memory controller 8 to execute S102-S104 in FIG. 3, S202 and S206-S208 in FIG. 6, and the like. And/or other processes for the techniques described herein. The communication module 802 is configured to support communication between the memory controller 8 and other network entities. For example, the communication module 802 is configured to support the memory controller 8 to execute S101 in FIG. 3, S201 and S203-S206 in FIG. 6, etc., and/or Other processes of the techniques described herein. In addition, the memory controller 8 may further include: a storage module 803. The storage module 803 is configured to store a corresponding method of the memory controller 8 to perform any of the cache replacements provided above. Program code and data.
如图9所示,为本发明实施例提供的一种计算设备9的结构示意图。计算设备9可以包括:处理器901、内存控制器902、第一级存储器903、第二级存储器904、收发器905以及总线906;其中,处理器901、内存控制器902、第一级存储器903、第二级存储器904、收发器905通过总线906相互连接。处理器901可以是CPU,通用处理器,数字信号处理器(digital signal processor,DSP),专用集成电路(application-specific integrated circuit,ASIC),现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本发明公开内容所描述的各种示例性的逻辑方框,模块和电路。所述处理器也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,DSP和微处理器的组合等。总线906可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图9中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。FIG. 9 is a schematic structural diagram of a computing device 9 according to an embodiment of the present invention. The computing device 9 can include a processor 901, a memory controller 902, a first level memory 903, a second level memory 904, a transceiver 905, and a bus 906. The processor 901, the memory controller 902, and the first level memory 903 The second level memory 904 and the transceiver 905 are connected to each other through a bus 906. The processor 901 can be a CPU, a general purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or Other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It is possible to implement or carry out the various illustrative logical blocks, modules and circuits described in connection with the present disclosure. The processor may also be a combination of computing functions, such as one or more microprocessor combinations, a combination of a DSP and a microprocessor, and the like. The bus 906 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is shown in Figure 9, but it does not mean that there is only one bus or one type of bus.
结合本发明公开内容所描述的方法或者算法的步骤可以硬件的方式来实现,也可以是由处理模块执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于随机存取存储器(random access memory,RAM)、闪存、只读存储器(read only memory,ROM)、可擦除可编程只读存储器(erasable programmable ROM,EPROM)、电可擦可编程只读存储器(electrically EPROM,EEPROM)、寄存器、硬盘、移动硬盘、只读光盘(CD-ROM)或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。The steps of the method or algorithm described in connection with the present disclosure may be implemented in a hardware manner, or may be implemented by a processing module executing software instructions. The software instructions may be composed of corresponding software modules, which may be stored in a random access memory (RAM), a flash memory, a read only memory (ROM), an erasable programmable read only memory ( Erasable programmable ROM (EPROM), electrically erasable programmable read only memory (EEPROM), registers, hard disk, removable hard disk, compact disk read only (CD-ROM) or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor to enable the processor to read information from, and write information to, the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an ASIC.
本领域技术人员应该可以意识到,在上述一个或多个示例中,本发明所描述的功能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在计算机可读介质中或者作为计算机可读介质上的一个或多个指令或代码进行传输。计算机可读介质包括计算机存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的任何介质。存储介质可以是通用或专用计算机能够存取的任何可用介质。Those skilled in the art will appreciate that in one or more examples described above, the functions described herein can be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored in a computer readable medium or transmitted as one or more instructions or code on a computer readable medium. Computer readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one location to another. A storage medium may be any available media that can be accessed by a general purpose or special purpose computer.
以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围。 The specific embodiments of the present invention have been described in detail with reference to the preferred embodiments of the present invention. protected range.

Claims (12)

  1. 一种缓存替换的方法,其特征在于,所述方法应用于计算机系统中,所述计算机系统包括内存控制器和混合内存,所述混合内存包括第一级存储器以及第二级存储器,所述第一级存储器用于缓存所述第二级存储器中的数据,所述第一级存储器支持高速缓存访问,所述方法包括:A method of cache replacement, the method being applied to a computer system, the computer system comprising a memory controller and a hybrid memory, the hybrid memory comprising a first level memory and a second level memory, the A primary memory is used to cache data in the second level of memory, the first level of memory supports cache access, and the method includes:
    所述内存控制器接收第一访问请求,所述第一访问请求中携带有第一目标地址,所述第一目标地址为所述第一访问请求待访问的第一数据在所述第二级存储器中的地址;The memory controller receives a first access request, where the first access request carries a first target address, and the first target address is the first data to be accessed by the first access request at the second level The address in the memory;
    当根据所述第一目标地址确定所述第一访问请求未命中所述第一级存储器中的第一区和第二区时,所述内存控制器根据所述第一目标地址从所述第二级存储器中获取所述第一数据,其中,所述第一级存储器包括所述第一区、所述第二区以及第三区,所述第一区用于缓存热数据,所述第二区用于缓存冷数据,所述第三区用于缓存从所述第二区被替换出的数据的在所述第二级存储器中的地址;When determining that the first access request misses the first area and the second area in the first level memory according to the first target address, the memory controller is from the first target address according to the first target address Acquiring the first data in the secondary memory, wherein the first level memory includes the first area, the second area, and a third area, where the first area is used to cache hot data, the first The second area is for buffering cold data, and the third area is for buffering an address in the second level memory of data that is replaced from the second area;
    当根据所述第一目标地址确定所述第一访问请求未命中所述第三区时,所述内存控制器在所述第二区中确定待替换的第一缓存块;When determining that the first access request misses the third area according to the first target address, the memory controller determines a first cache block to be replaced in the second area;
    所述内存控制器将所述第一缓存块中的数据替换为所述第一数据。The memory controller replaces data in the first cache block with the first data.
  2. 根据权利要求1所述的方法,其特征在于,在所述内存控制器将所述第一缓存块中的数据替换为所述第一数据之后,所述方法还包括:The method according to claim 1, wherein after the memory controller replaces the data in the first cache block with the first data, the method further includes:
    所述内存控制器将所述第一缓存块中的数据的地址存储在所述第三区中。The memory controller stores an address of the data in the first cache block in the third zone.
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:The method according to claim 1 or 2, wherein the method further comprises:
    所述内存控制器接收第二访问请求,所述第二访问请求中携带有第二目标地址,所述第二目标地址为所述第二访问请求待访问的第二数据在所述第二级存储器中的地址;The memory controller receives a second access request, where the second access request carries a second target address, and the second target address is the second access request to be accessed second data at the second level The address in the memory;
    当根据所述第二目标地址确定所述第二访问请求未命中所述第一级存储器中的第一区和第二区时,所述内存控制器根据所述第二目标地址从所述第二级存储器中获取所述第二数据;When determining that the second access request misses the first area and the second area in the first level memory according to the second target address, the memory controller is from the second target address according to the second target address Acquiring the second data in the secondary storage;
    当根据所述第二目标地址确定所述第二访问请求命中所述第三区时,所述内存控制器在所述第一区中确定待替换的第二缓存块;When determining that the second access request hits the third area according to the second target address, the memory controller determines a second cache block to be replaced in the first area;
    所述内存控制器将所述第二缓存块中的数据替换为所述第二数据。The memory controller replaces data in the second cache block with the second data.
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述第一区大于所述第二区。The method according to any one of claims 1 to 3, wherein the first zone is larger than the second zone.
  5. 根据权利要求1所述的方法,其特征在于,所述内存控制器在所述第二区中确定待替换的第一缓存块,包括:The method according to claim 1, wherein the memory controller determines the first cache block to be replaced in the second area, including:
    所述内存控制器在所述第二区中的任一数据或将最早被写入的数据所在的缓存块确定为待替换的第一缓存块。The memory controller determines any of the data in the second zone or a cache block in which the earliest data to be written is located as the first cache block to be replaced.
  6. 根据权利要求1至5任一项所述的方法,其特征在于,所述第三区小于或等于预设阈值。The method according to any one of claims 1 to 5, wherein the third zone is less than or equal to a preset threshold.
  7. 一种计算设备,其特征在于,所述计算设备包括内存控制器和混合内存, 所述混合内存包括第一级存储器以及第二级存储器,所述第一级存储器用于缓存所述第二级存储器中的数据,所述第一级存储器支持高速缓存访问,所述内存控制器用于:A computing device, characterized in that the computing device comprises a memory controller and a hybrid memory. The hybrid memory includes a first level memory for buffering data in the second level memory, and a first level memory supporting cache access, the memory controller to:
    接收第一访问请求,所述第一访问请求中携带有第一目标地址,所述第一目标地址为所述第一访问请求待访问的第一数据在所述第二级存储器中的地址;Receiving a first access request, where the first access request carries a first target address, where the first target address is an address of the first data to be accessed by the first access request in the second level memory;
    当根据所述第一目标地址确定所述第一访问请求未命中所述第一级存储器中的第一区和第二区时,根据所述第一目标地址从所述第二级存储器中获取所述第一数据,其中,所述第一级存储器包括所述第一区、所述第二区以及第三区,所述第一区用于缓存热数据,所述第二区用于缓存冷数据,所述第三区用于缓存从所述第二区被替换出的数据的在所述第二级存储器中的地址;Obtaining, according to the first target address, that the first access request misses the first area and the second area in the first level memory, acquiring from the second level memory according to the first target address The first data, wherein the first level memory includes the first area, the second area, and a third area, the first area is used to cache hot data, and the second area is used to cache Cold data, the third area is for buffering an address in the second level memory of data that is replaced from the second area;
    当根据所述第一目标地址确定所述第一访问请求未命中所述第三区时,在所述第二区中确定待替换的第一缓存块;Determining, in the second area, a first cache block to be replaced when determining that the first access request misses the third area according to the first target address;
    将所述第一缓存块中的数据替换为所述第一数据。The data in the first cache block is replaced with the first data.
  8. 根据权利要求7所述的计算设备,其特征在于,所述内存控制器还用于:The computing device of claim 7, wherein the memory controller is further configured to:
    将所述第一缓存块中的数据的地址存储在所述第三区中。The address of the data in the first cache block is stored in the third zone.
  9. 根据权利要求7或8所述的计算设备,其特征在于,所述内存控制器还用于:The computing device according to claim 7 or 8, wherein the memory controller is further configured to:
    接收第二访问请求,所述第二访问请求中携带有第二目标地址,所述第二目标地址为所述第二访问请求待访问的第二数据在所述第二级存储器中的地址;Receiving a second access request, where the second access request carries a second target address, where the second target address is an address of the second data to be accessed by the second access request in the second level memory;
    当根据所述第二目标地址确定所述第二访问请求未命中所述第一级存储器中的第一区和第二区时,根据所述第二目标地址从所述第二级存储器中获取所述第二数据;When determining that the second access request misses the first area and the second area in the first level memory according to the second target address, acquiring from the second level memory according to the second target address The second data;
    当根据所述第二目标地址确定所述第二访问请求命中所述第三区时,在所述第一区中确定待替换的第二缓存块;Determining, in the first area, a second cache block to be replaced when determining that the second access request hits the third area according to the second target address;
    将所述第二缓存块中的数据替换为所述第二数据。The data in the second cache block is replaced with the second data.
  10. 根据权利要求7至9任一项所述的计算设备,其特征在于,所述第一区大于所述第二区。The computing device of any of claims 7 to 9, wherein the first zone is larger than the second zone.
  11. 根据权利要求7所述的计算设备,其特征在于,所述内存控制器具体用于:The computing device of claim 7, wherein the memory controller is specifically configured to:
    将所述第二区中的任一数据或最早的数据所在的缓存块确定为待替换的第一缓存块。The cache block in which any of the second area or the oldest data is located is determined as the first cache block to be replaced.
  12. 根据权利要求7至11任一项所述的计算设备,其特征在于,所述第三区小于或等于预设阈值。 The computing device of any of claims 7 to 11, wherein the third zone is less than or equal to a predetermined threshold.
PCT/CN2017/109553 2016-11-07 2017-11-06 Cache replacement method and device WO2018082695A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610986946.9 2016-11-07
CN201610986946.9A CN108073527B (en) 2016-11-07 2016-11-07 Cache replacement method and equipment

Publications (1)

Publication Number Publication Date
WO2018082695A1 true WO2018082695A1 (en) 2018-05-11

Family

ID=62076674

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/109553 WO2018082695A1 (en) 2016-11-07 2017-11-06 Cache replacement method and device

Country Status (2)

Country Link
CN (1) CN108073527B (en)
WO (1) WO2018082695A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109274760A (en) * 2018-10-19 2019-01-25 西安瑜乐文化科技股份有限公司 A kind of cold and hot data resolution method of Mobile Development
CN112699061A (en) * 2020-12-07 2021-04-23 海光信息技术股份有限公司 Systems, methods, and media for implementing cache coherency for PCIe devices

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020073328A1 (en) * 2018-10-12 2020-04-16 华为技术有限公司 Data processing method and device
CN112558889B (en) * 2021-02-26 2021-05-28 北京微核芯科技有限公司 Stacked Cache system based on SEDRAM, control method and Cache device
CN113572582B (en) * 2021-07-15 2022-11-22 中国科学院计算技术研究所 Data transmission and retransmission control method and system, storage medium and electronic device
CN115586869B (en) * 2022-09-28 2023-06-06 中国兵器工业计算机应用技术研究所 Ad hoc network system and stream data processing method thereof
CN116107926B (en) * 2023-02-03 2024-01-23 摩尔线程智能科技(北京)有限责任公司 Cache replacement policy management method, device, equipment, medium and program product

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999444A (en) * 2012-11-13 2013-03-27 华为技术有限公司 Method and device for replacing data in caching module
CN103885890A (en) * 2012-12-21 2014-06-25 华为技术有限公司 Replacement processing method and device for cache blocks in caches
US20140208038A1 (en) * 2009-06-17 2014-07-24 International Business Machines Corporation Sectored cache replacement algorithm for reducing memory writebacks
US20140289477A1 (en) * 2013-03-25 2014-09-25 International Business Machines Corporation Lightweight primary cache replacement scheme using associated cache
CN105095116A (en) * 2014-05-19 2015-11-25 华为技术有限公司 Cache replacing method, cache controller and processor

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101236530B (en) * 2008-01-30 2010-09-01 清华大学 High speed cache replacement policy dynamic selection method
KR101826073B1 (en) * 2013-09-27 2018-02-06 인텔 코포레이션 Cache operations for memory management
CN104834608B (en) * 2015-05-12 2017-09-29 华中科技大学 A kind of buffer replacing method under isomery memory environment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140208038A1 (en) * 2009-06-17 2014-07-24 International Business Machines Corporation Sectored cache replacement algorithm for reducing memory writebacks
CN102999444A (en) * 2012-11-13 2013-03-27 华为技术有限公司 Method and device for replacing data in caching module
CN103885890A (en) * 2012-12-21 2014-06-25 华为技术有限公司 Replacement processing method and device for cache blocks in caches
US20140289477A1 (en) * 2013-03-25 2014-09-25 International Business Machines Corporation Lightweight primary cache replacement scheme using associated cache
CN105095116A (en) * 2014-05-19 2015-11-25 华为技术有限公司 Cache replacing method, cache controller and processor

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109274760A (en) * 2018-10-19 2019-01-25 西安瑜乐文化科技股份有限公司 A kind of cold and hot data resolution method of Mobile Development
CN112699061A (en) * 2020-12-07 2021-04-23 海光信息技术股份有限公司 Systems, methods, and media for implementing cache coherency for PCIe devices
CN112699061B (en) * 2020-12-07 2022-08-26 海光信息技术股份有限公司 Systems, methods, and media for implementing cache coherency for PCIe devices

Also Published As

Publication number Publication date
CN108073527A (en) 2018-05-25
CN108073527B (en) 2020-02-14

Similar Documents

Publication Publication Date Title
WO2018082695A1 (en) Cache replacement method and device
US11237728B2 (en) Method for accessing extended memory, device, and system
US10210101B2 (en) Systems and methods for flushing a cache with modified data
JP6277572B2 (en) Data caching method, cache and computer system
WO2021008105A1 (en) Data transmission method and device in tee system
US9740612B2 (en) Systems and methods for maintaining the coherency of a store coalescing cache and a load cache
US20170300426A1 (en) Read cache management method and apparatus based on solid state drive
TWI606340B (en) Method, computer readable storage medium and system for data caching
CN105677580A (en) Method and device for accessing cache
US20160103765A1 (en) Apparatus, systems, and methods for providing a memory efficient cache
US20170091099A1 (en) Memory controller for multi-level system memory having sectored cache
CN108021514B (en) Cache replacement method and equipment
US20080307169A1 (en) Method, Apparatus, System and Program Product Supporting Improved Access Latency for a Sectored Directory
JP2007048296A (en) Method, apparatus and system for invalidating multiple address cache entries
CN115269454A (en) Data access method, electronic device and storage medium
JP5831319B2 (en) Control device, management device, information processing system, operation method of control device, operation method of management device, operation method of information processing system, and program
WO2017016427A1 (en) Method and device for maintaining cache data consistency according to directory information
US20080301376A1 (en) Method, Apparatus, and System Supporting Improved DMA Writes
US9501414B2 (en) Storage control device and storage control method for cache processing according to time zones
US20210365378A1 (en) Method of cache prefetching that increases the hit rate of a next faster cache
US10565121B2 (en) Method and apparatus for reducing read/write contention to a cache
US20190179758A1 (en) Cache to cache data transfer acceleration techniques
TW201441817A (en) Data caching system and method
WO2017015952A1 (en) Method of replacing stored data in cache and device utilizing same
JP5633569B2 (en) Information processing apparatus, memory control method, and memory control apparatus

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17866847

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17866847

Country of ref document: EP

Kind code of ref document: A1