WO2022233272A1 - 缓存内存块的淘汰方法、装置及电子设备 - Google Patents

缓存内存块的淘汰方法、装置及电子设备 Download PDF

Info

Publication number
WO2022233272A1
WO2022233272A1 PCT/CN2022/090269 CN2022090269W WO2022233272A1 WO 2022233272 A1 WO2022233272 A1 WO 2022233272A1 CN 2022090269 W CN2022090269 W CN 2022090269W WO 2022233272 A1 WO2022233272 A1 WO 2022233272A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory block
cache
target
eliminated
memory
Prior art date
Application number
PCT/CN2022/090269
Other languages
English (en)
French (fr)
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 北京奥星贝斯科技有限公司
Priority to EP22798613.0A priority Critical patent/EP4321980A1/en
Publication of WO2022233272A1 publication Critical patent/WO2022233272A1/zh
Priority to US18/501,844 priority patent/US20240061789A1/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
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/126Replacement control using replacement algorithms with special data handling, e.g. priority of data or instructions, handling errors or pinning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0608Saving storage space on storage systems
    • 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/122Replacement control using replacement algorithms of the least frequently used [LFU] type, e.g. with individual count value
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/064Management of blocks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/0647Migration mechanisms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/0671In-line storage system
    • G06F3/0683Plurality of storage devices
    • 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/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0866Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches for peripheral storage systems, e.g. disk cache
    • G06F12/0868Data transfer between cache memory and other subsystems, e.g. storage devices or host systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/21Employing a record carrier using a specific recording technology
    • G06F2212/214Solid state disk
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/31Providing disk cache in a specific location of a storage system
    • G06F2212/313In storage device

Definitions

  • This document belongs to the technical field of data storage, and in particular relates to a method, device and electronic device for eliminating cache memory blocks.
  • memory block refers to the storage unit of the cache
  • access heat so as to clear the memory block with lower value.
  • memory blocks in many storage systems do not store only one type of element (element refers to cache data), so there is a possibility that a few elements of a memory block are frequently accessed, while other elements are rarely accessed.
  • the overall heat of the memory block is relatively cold, and it is eventually eliminated by the storage system. Obviously, frequently accessed elements are removed from the cache, which will reduce the performance and revenue of the cache.
  • the purpose of the embodiments of this specification is to provide a method, device and electronic device for eliminating cache memory blocks, which can migrate valuable elements in the memory blocks that need to be eliminated to other memory blocks when eliminating memory blocks in the cache. Avoid impacting cache performance and profitability.
  • a method for eliminating cache memory blocks including: determining the heat index value of the memory blocks in the cache, and the memory blocks are the storage units of the cache; the heat index value of the memory block in the cache, determine the memory block to be eliminated in the cache that needs to be cleaned up; migrate the target element in the memory block to be eliminated to the target memory block in the cache, the target memory block The memory block reserved in the cache and the available storage space is greater than the storage space required by the target element; and the memory block to be eliminated is deleted from the cache.
  • a method for eliminating cache memory blocks is provided, which is applied to a storage system that adopts a log structure to merge an LSM tree storage architecture, including: determining the heat index of the memory block MemBlock in the memory table MemTable of the LSM tree of the storage system.
  • the MemTable is used to store the cached data of the storage system; based on the heat index value of the MemBlock in the MemTable, determine the MemBlock to be eliminated in the MemTable that needs to be cleaned up;
  • the target element is migrated to the target MemBlock in the MemTable, the target MemBlock is the MemBlock reserved in the MemTable and the available storage space is greater than the storage space required by the target element; the MemBlock to be eliminated is deleted from the MemTable.
  • a device for eliminating cache memory blocks including: a heat determination module, which determines a heat index value of the memory blocks in the cache, and the memory blocks are the storage units of the cache; and an elimination analysis module, based on the memory blocks in the cache The heat index value, to determine the memory block to be eliminated in the cache that needs to be cleaned; the element migration module, to migrate the target element in the memory block to be eliminated to the target memory block in the cache, and the target memory block is the The memory block reserved in the cache and the available storage space is greater than the storage space required by the target element; the elimination execution module deletes the memory block to be eliminated from the cache.
  • an electronic device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor: determining the memory in the cache The heat index value of the block, the memory block is the storage unit of the cache; based on the heat index value of the memory block in the cache, determine the memory block to be eliminated in the cache that needs to be cleaned up; the target element in the memory block to be eliminated is determined Migrating to the target memory block in the cache, the target memory block is the memory block reserved in the cache and the available storage space is greater than the storage space required by the target element; delete the memory to be eliminated from the cache piece.
  • a computer-readable storage medium is provided, a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
  • the block is the storage unit of the cache; based on the heat index value of the memory block in the cache, determine the to-be-eliminated memory block in the cache that needs to be cleaned up; migrate the target element in the to-be-eliminated memory block to the memory block in the cache.
  • a target memory block, the target memory block is a memory block reserved in the cache and the available storage space is greater than the storage space required by the target element; the memory block to be eliminated is deleted from the cache.
  • the solution of the embodiments of this specification can update the heat index value of the memory block in the cache, and when the cache space needs to be cleaned up, the memory block to be eliminated that needs to be cleaned is determined according to the updated heat index value of the memory block. Before cleaning, the valuable elements in the memory block to be eliminated are migrated to other memory blocks, so as to prevent the cache from losing high-value elements due to cleaning the memory block, which in turn leads to a decrease in performance and revenue.
  • FIG. 1 provides a schematic flowchart of a method for eliminating cache memory blocks according to an embodiment of the present specification.
  • FIG. 2 is a schematic structural diagram of a storage system according to an embodiment of the present specification.
  • FIG. 3 is a schematic structural diagram of an apparatus for eliminating cache memory blocks according to an embodiment of the present specification.
  • FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present specification.
  • the storage unit of the cache is called a memory block.
  • the value of the memory block is evaluated based on the access heat of the memory block, and low-value memory blocks are eliminated when the cache space needs to be released.
  • memory blocks in many storage systems do not store only one type of element (element refers to cache data), so there is a possibility that a few elements of a memory block are frequently accessed, while other elements are rarely accessed, making The overall temperature of the memory block is relatively cold, and it is eventually eliminated by the storage system. Obviously, frequently accessed elements are removed from the cache, which will reduce the performance and revenue of the cache.
  • this paper aims to provide a cache memory block elimination scheme, which can migrate valuable elements in the memory block that needs to be eliminated to other memory blocks when the memory block in the cache is eliminated, so as to avoid affecting the cache memory. performance and benefits.
  • FIG. 1 is a flowchart of a method for eliminating cache memory blocks according to an embodiment of the present specification.
  • the method shown in FIG. 1 can be executed by the corresponding hardware below, and includes the following steps: S102 , determine the heat index value of the memory block in the cache, and the memory block is the storage unit of the cache.
  • the heat index value of the memory block in the embodiment of the present specification may be determined based on the number of times the elements in the memory block are accessed.
  • the element weight coefficient can reflect the importance of the element
  • the timeliness of heat can also be introduced on the basis of the above, for example, the heat index value of the element is calculated based on the number of visits corresponding to the element, the heat index value of the previous cycle, the heat time decay coefficient and the element weight coefficient; The heat index value of each element in the memory block is calculated, and the heat index value of the memory block is calculated.
  • the element's last cycle heat index value and the heat time decay coefficient to calculate the element's current cycle heat index value can ensure that the element's heat will not lose its influence in a short time, but this influence will also weaken over time, so To a certain extent, it reflects the timeliness of heat.
  • the method of the embodiment of the present specification can determine the to-be-eliminated memory block to be cleaned up when the cache needs to be cleaned up. For example, when the storage space occupation of the cache reaches the upper limit, when the number of memory blocks in the cache reaches the upper limit, and when there are memory blocks in the cache that have not been accessed for a preset period of time, the selection of memory blocks to be eliminated can be started.
  • a memory block with a relatively low value should be selected as the memory block to be eliminated, that is, the heat index value of the memory block to be eliminated should be lower than that of other memory blocks that need to be retained in the cache.
  • a preset number of memory blocks can be selected as the target memory blocks to be cleaned in order of the heat index values from small to large; or, memory blocks whose heat index values in the cache do not reach the memory block heat threshold can also be determined as The target memory block that needs to be cleaned up. Since the selection strategy of the memory blocks to be eliminated is not unique, this article will not repeat them with examples.
  • S106 Migrate the target element in the memory block to be eliminated to the target memory block in the cache, where the target memory block is the memory block reserved in the cache and the available storage space is greater than the storage space required by the target element.
  • memory blocks reserved in the cache refer to other memory blocks in the cache except the memory blocks to be eliminated.
  • the memory blocks reserved in this step may still be reserved or eliminated in the next memory block elimination.
  • the embodiments of this specification can flexibly select target elements in the memory block to be eliminated according to the occupancy of the cache space. That is to say, the target element in the memory block to be eliminated is not unique, it can be all elements of the memory block to be eliminated, or it can be some elements whose heat index value in the memory block to be eliminated reaches the element heat threshold (those that reach the element heat threshold elements can be considered as elements that meet the value requirements).
  • the target element is all elements of the memory block to be eliminated. That is to say, in the case of being able to migrate all the elements of the eliminated memory block, all the elements of the eliminated memory block can be migrated out, so as to ensure that all the elements in the cache are not lost, and the eliminated memory block is cleaned up.
  • the target element is the element whose heat index value in the memory block to be eliminated reaches the element heat threshold. That is to say, elements worth migrating in the eliminated memory block are selected as target elements through the element heat threshold.
  • the migration can be implemented in the following ways:
  • memory block 1 is the memory block to be eliminated.
  • This memory block 1 has three high-value elements, element A, element B, and element C.
  • elements A and B need to be removed.
  • C to migrate here it is assumed that other memory blocks in the memory that do not need to be eliminated have no space to store elements A, B, and C.
  • the target memory block of other elements whose values are lower than the elements A, B, and C, and the three elements whose heat index values are lower than the elements A, B, and C in the target memory block are cleaned up to make room for memory High value elements A, B, C in block 1.
  • multiple target memory blocks can also be selected, where each target memory block stores at least other elements whose heat index values are lower than the elements A, B, and C, and retrieves data from the multiple target memory blocks.
  • Three elements whose heat index values are lower than the elements A, B, and C are removed from the block to make room for the high-value elements A, B, and C in memory block 1.
  • select the memory blocks 2, 3, and 4 in the cache that do not need to be eliminated as the target memory block and select an element whose heat index value is lower than the element A, B, and C from the memory blocks 2, 3, and 4 for cleaning. , so that memory block 2 stores element A of memory block 1, memory block 3 stores element B of memory block 1, and memory block 4 stores element C of memory block 1.
  • the element selection can be made based on the heat index value to ensure the maximum benefit of the cache.
  • the method of the embodiment of this specification can update the heat index value of the memory block in the cache, and when the cache space needs to be cleaned up, the memory block to be eliminated that needs to be cleaned is determined according to the updated heat index value of the memory block. Before cleaning, the valuable elements in the memory block to be eliminated are migrated to other memory blocks, so as to prevent the cache from losing high-value elements due to cleaning the memory block, which in turn leads to a decrease in performance and revenue.
  • this application scenario provides a storage system based on the LSM tree architecture, including a memory table (MemTable, Memory Table) storage structure and a sorted string table (SSTable, Sorted String Table) storage structure.
  • MemTable is used to store cache data of the storage system. All data updates of the storage system are completed in the memory table MemTable, and the background stores the cache elements in the MemTable to the SSTable through dumping.
  • the compactor in SSTable is responsible for sorting and compressing the data.
  • the storage system in this application scenario requires that the Cache elements in the MemTable have variable lengths.
  • a fixed-length memory block (MemBlock, Memory Block) is set as the minimum storage unit in MemTable.
  • MemBlock Memory Block
  • a unified Cache framework is designed. Different types of Caches of different tenants are managed by the framework, and different types of Cache elements are distinguished by different priorities.
  • the storage system calculates a score of access heat for each element in the MemBlock, and the more frequently accessed elements have a higher score. At the same time, for each MemBlock, there is a total score determined based on the scores of all elements in the MemBlock.
  • the elimination of the cache is based on MemBlock, the smallest unit of memory management.
  • the cache cleaning thread in the background of the storage system periodically calculates the scores of all elements in the MemTable and the scores of all MemBlocks, sorts all the current MemBlocks according to their scores, and eliminates MemBlocks with low scores.
  • the user writes data (elements to be cached) through IO.
  • the storage system allocates memory for the element to be cached: since the size of the cache element is not fixed, first calculate the actual memory size required. If it can be accommodated by the current MemBlock, it will be allocated to the current MemBlock; otherwise, a new MemBlock will be allocated for storage .
  • MemBlocks In the process of allocating new MemBlocks, if the MemTable does not have enough memory, or the number of MemBlocks reaches the upper limit, execute the elimination process of MemBlocks: traverse all cached MemBlocks, and update the current MemBlock's heat score. Based on the set upper and lower limit information of MemBlock, calculate the range of MemBlock that needs to be eliminated in this cache elimination process. Traverse all cached MemBlocks, sort the hotness scores of MemBlocks, and select the MemBlocks with the lowest hotness for elimination.
  • the backend of the storage system adjusts the hot elements in the MemBlock to be eliminated to other MemBlocks that are hot and do not need to be eliminated, so as to improve the cache hit rate, thereby reflecting higher performance and revenue.
  • the storage system in this scenario adopts a Cache element design of variable length in order to facilitate the management of various types of caches, and is stored by a fixed-length MemBlock, so as to realize cache cleaning with MemBlock as the granularity.
  • the storage system calculates the heat score for each Cache element. When a MemBlock is eliminated, the cache elements with high heat score can be migrated to other MemBlocks to avoid losing high heat elements when clearing the cache space.
  • the storage system of the application scenario can be used as the execution body to execute the steps in the elimination method shown in FIG. 1 , including: determining the MemBlock to be eliminated in the MemTable that needs to be cleaned up based on the heat index value of the MemBlock in the MemTable; The target element in is migrated to the target MemBlock in the MemTable, and the target MemBlock is the MemBlock reserved in the MemTable and the available storage space is greater than the storage space required by the target element; the MemBlock to be eliminated is deleted from the MemTable.
  • an embodiment of the present invention further provides a device for eliminating cache memory blocks.
  • 3 is a schematic structural diagram of an elimination device 300 according to an embodiment of the present invention, including: a heat determination module 310, which determines a heat index value of a memory block in a cache, and a memory block is a storage unit of the cache.
  • the elimination analysis module 320 determines the memory blocks to be eliminated in the cache that need to be cleaned up.
  • the element migration module 330 migrates the target element in the memory block to be eliminated to the target memory block in the cache, where the target memory block is the memory block reserved in the cache and the available storage space is larger than the target element required storage space.
  • the elimination execution module 340 deletes the memory block to be eliminated from the cache.
  • the device of the embodiment of the present specification can update the heat index value of the memory block in the cache, and when the cache space needs to be cleared, determine the memory block to be eliminated that needs to be cleaned according to the updated heat index value of the memory block. Before cleaning, the valuable elements in the memory block to be eliminated are migrated to other memory blocks, so as to prevent the cache from losing high-value elements due to cleaning the memory block, which in turn leads to a decrease in performance and revenue.
  • the target element is all elements of the memory block to be eliminated, or the target element is an element whose heat index value in the memory block to be eliminated reaches an element heat threshold.
  • the target element is all elements of the memory block to be eliminated. That is to say, in the case of being able to migrate all the elements of the eliminated memory block, all the elements of the eliminated memory block can be migrated out, so as to ensure that the eliminated memory block is cleaned up under the condition that the elements are not lost.
  • the target element is an element whose heat index value in the memory block to be eliminated reaches the element heat threshold. That is to say, elements worth migrating in the eliminated memory block are selected as target elements through the element heat threshold.
  • the element migration module 330 migrates the target element in the to-be-eliminated memory block to the target memory block in the cache, it is further configured to: select from the cache a reserved element that can store the target element. Other memory blocks are used as target memory blocks. Wherein, if there are no other memory blocks reserved in the cache that can store the target element, the element migration module 330 may delete the elements of other memory blocks reserved in the cache to clear out the elements for storing the target element. The storage space of the element is determined, and other memory blocks after the storage space is cleared are determined as the target memory block, wherein the heat index value of the deleted element in the other memory block is smaller than the heat index value of the target element.
  • the element selection can be performed based on the heat index value. If there is an element of the target element with the heat index value in the memory block that does not need to be eliminated, it can be deleted to free up storage space for the target element.
  • the elimination analysis module 320 determines, based on the heat index value of the memory block in the cache, that the execution condition of the target memory block that needs to be cleaned in the cache includes at least one of the following: the storage space occupation of the cache reaches the upper limit of occupation. ; the number of memory blocks in the cache reaches the upper limit; there are memory blocks in the cache that have not been accessed for a preset time.
  • the heat index value of the element in the memory block is calculated based on the access times corresponding to the element, the heat index value of the previous cycle, and the heat time decay coefficient.
  • the heat index value of the memory block is determined based on the heat index values of all elements in the memory block.
  • the elimination analysis module 320 may select a preset number of memory blocks as the target memory blocks to be cleaned up according to the order of the heat index value from small to large; or, the heat index value in the cache may not reach the memory block.
  • the memory block with the heat threshold is determined as the target memory block that needs to be cleaned up.
  • the cache is a MemTable of an LSM tree, and the MemTable is an element of a variable-length cache, and the data occupied by the element is not larger than the storage space provided by the memory block.
  • the elimination device in the embodiment of the present specification can be used as the execution body of the elimination method shown in FIG. 1 , and thus can realize the functions implemented by the elimination method in FIG. 1 . Since the principle is the same, this article will not repeat them.
  • FIG. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present specification.
  • the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory.
  • the memory may include memory, such as high-speed random-access memory (Random-Access Memory, RAM), or may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
  • RAM Random-Access Memory
  • non-volatile memory such as at least one disk memory.
  • the electronic equipment may also include hardware required for other services.
  • the processor, network interface and memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Component Interconnect Standard) bus. Industry Standard Architecture, extended industry standard structure) bus, etc.
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one bidirectional arrow is used in FIG. 4, but it does not mean that there is only one bus or one type of bus.
  • the program may include program code, and the program code includes computer operation instructions.
  • the memory may include memory and non-volatile memory and provide instructions and data to the processor.
  • the processor reads the corresponding computer program from the non-volatile memory into the memory and runs it, and caches the elimination device of the memory block at the logical level.
  • the elimination device may refer to the storage system or a component of the storage system.
  • the processor executes the program stored in the memory, and is specifically configured to perform the following operations: determine the heat index value of the memory block in the cache, and the memory block is the storage unit of the cache.
  • the memory block to be eliminated is deleted from the cache.
  • the electronic device of the embodiment of the present specification can update the heat index value of the memory block in the cache, and when the cache space needs to be cleared, determine the memory block to be eliminated that needs to be cleaned according to the updated heat index value of the memory block. Before cleaning, the valuable elements in the memory block to be eliminated are migrated to other memory blocks, so as to prevent the cache from losing high-value elements due to cleaning the memory block, which in turn leads to a decrease in performance and revenue.
  • a processor may be an integrated circuit chip with signal processing capabilities.
  • each step of the above-mentioned method can be completed by a hardware integrated logic circuit in a processor or an instruction in the form of software.
  • the above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field Programmable Gate Array
  • a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
  • the steps of the methods disclosed in conjunction with the embodiments of this specification may be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
  • the software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art.
  • the storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
  • the electronic devices in this specification do not exclude other implementations, such as logic devices or the combination of software and hardware, etc. That is to say, the execution subjects of the following processing procedures are not limited to each logic unit. It can also be a hardware or logic device.
  • the embodiments of this specification also provide a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, and the one or more programs include instructions, and the instructions, when stored in a portable computer including multiple application programs
  • the portable electronic device can be made to execute the method of the embodiment shown in FIG. 1 , and is specifically used for executing the following steps: determining the heat index value of the memory block in the cache, and the memory block is the storage unit of the cache.
  • the memory block to be eliminated is deleted from the cache.
  • the embodiments of the present specification may be provided as a method, a system or a computer program product. Accordingly, this description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.

Landscapes

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

Abstract

本说明书实施例提供一种缓存内存块的淘汰方法、装置及电子设备,属于数据存储技术领域。其中,缓存内存块的淘汰方法包括:确定缓存中内存块的热度指标值,内存块为缓存的存储单位。基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块。将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间。从所述缓存中删除所述待淘汰内存块。

Description

缓存内存块的淘汰方法、装置及电子设备 技术领域
本文件属于数据存储技术领域,尤其涉及一种缓存内存块的淘汰方法、装置及电子设备。
背景技术
目前的存储***都会基于一定策略释放缓存空间。比如,基于访问热度来评估缓存中内存块的价值(内存块指缓存的存储单位),从而清理掉价值较低的内存块。但是,很多存储***中的内存块并不只存储一种元素(元素指缓存数据),因此存在一种可能,就是一个内存块的少部分元素被频繁访问,而另一部分元素则被很少访问,使得内存块整体热度偏冷,最终被存储***淘汰。显然,被频繁访问的元素从缓存中清理出去,会降低缓存的性能和收益。
为此,当前亟需一种方案,能够避免存储***在淘汰内存块时淘汰掉访问频率高的元素。
发明内容
本说明书实施例目的是提供一种缓存内存块的淘汰方法、装置及电子设备,能够在淘汰缓存中的内存块时,将需要淘汰的内存块中有价值的元素随迁移至其他内存块,以避免影响缓存的性能和收益。
为了实现上述目的,本说明书实施例是这样实现的:第一方面,提供一种缓存内存块的淘汰方法,包括:确定缓存中内存块的热度指标值,内存块为缓存的存储单位;基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间;从所述缓存中删除所述待淘汰内存块。
第二方面,提供一种缓存内存块的淘汰方法,应用于采用日志结构合并LSM树存储架构的存储***,包括:确定所述存储***的LSM树的内存表MemTable中的内存块MemBlock的热度指标值,其中,所述MemTable用于存储所述存储***的缓存数据; 基于所述MemTable中的MemBlock的热度指标值,确定所述MemTable中需要清理的待淘汰MemBlock;将所述待淘汰MemBlock中的目标元素迁移至所述MemTable中的目标MemBlock,所述目标MemBlock为所述MemTable中保留的MemBlock且可用存储空间大于所述目标元素需要的存储空间;从所述MemTable中删除所述待淘汰MemBlock。
第三方面,提供一种缓存内存块的淘汰装置,包括:热度确定模块,确定缓存中内存块的热度指标值,内存块为缓存的存储单位;淘汰分析模块,基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;元素迁移模块,将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间;淘汰执行模块,从所述缓存中删除所述待淘汰内存块。
第四方面,提供一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:确定缓存中内存块的热度指标值,内存块为缓存的存储单位;基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间;从所述缓存中删除所述待淘汰内存块。
第五方面,提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:确定缓存中内存块的热度指标值,内存块为缓存的存储单位;基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间;从所述缓存中删除所述待淘汰内存块。
本说明书实施例的方案可以更新缓存中内存块的热度指标值,并在需要清理缓存空间时,根据更新到的内存块热度指标值确定出需要清理的待淘汰内存块。在清理前,将待淘汰内存块中有价值的元素迁移至其他内存块,从而避免缓存因清理内存块而丢失高价值的元素,进而导致性能和收益的下降。
附图说明
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现 有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书实施例中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本说明书实施例提供缓存内存块的淘汰方法的流程示意图。
图2为本说明书实施例提供的存储***的结构示意图。
图3为本说明书实施例提供缓存内存块的淘汰装置的结构示意图。
图4为本说明书实施例提供的电子设备的结构示意图。
具体实施方式
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。
如前所述,目前的存储***都会基于一定策略释放缓存空间。这里,将缓存的存储单位称为内存块,一般情况下都是基于内存块的访问热度来评估内存块的价值,并在需要释放缓存空间时淘汰低价值的内存块。但是,很多存储***中的内存块并不只存储一种元素(元素指缓存数据),因此存在一种可能就是一个内存块的少部分元素被频繁访问,而另一部分元素则被很少访问,使得内存块整体热度偏冷,最终被存储***淘汰。显然,被频繁访问的元素从缓存中清理出去,会降低缓存的性能和收益。
为此,本文旨在提供一种缓存内存块的淘汰的方案,能够在淘汰缓存中的内存块时,将需要淘汰的内存块中有价值的元素随迁移至其他内存块,以避免影响缓存的性能和收益。
图1是本说明书实施例缓存内存块的淘汰方法的流程图。图1所示的方法可以由下文相对应的硬件执行,包括如下步骤:S102,确定缓存中内存块的热度指标值,内存块为缓存的存储单位。
应理解,内存块的热度指标值的计算方式并不唯一,这里本文不作具体限定。
作为示例性介绍,本说明书实施例内存块的热度指标值可以基于内存块中元素的被 访问次数确定得到。
比如,以元素为粒度,先通过元素对应的访问次数和元素权重系数(元素权重系数可以反映元素的重要性)计算出元素的热度指标值,进而再通过内存块中各元素的热度指标值,计算出内存块的热度指标值。
此外,还可以在上述基础之上引入热度的时效性,比如基于元素对应的访问次数、上一周期热度指标值、热度时间衰减系数以及元素权重系数计算出元素的热度指标值;之后,再通过内存块中各元素的热度指标值,计算出内存块的热度指标值。显然,引用元素上一周期热度指标值以及热度时间衰减系数计算出元素当前周期的热度指标值可以保证元素的热度不会在短时间内失去影响,但这种影响也会随时间推移衰弱,从而在一定程度上体现出热度的时效性。
S104,基于缓存中内存块的热度指标值,确定缓存中需要清理的待淘汰内存块。
具体地,本说明书实施例的方法可以在缓存有清理需求时,确定待清理的待淘汰内存块。比如,可以在缓存的存储空间占用达到占用上限时、缓存中的内存块数量达到数量上限时以及缓存中存在持续预设时间未被访问的内存块时,开始挑选待淘汰内存块。
应理解,本步骤应选取价值相对较低的内存块作为待淘汰内存块,也就是说待淘汰内存块的热度指标值上要低于缓存中需要保留的其他内存块。
比如,可以按照热度指标值由小到大的顺序,选取预设数量的内存块作为需要清理的目标内存块;或者,也可以将缓存中热度指标值未达到内存块热度阈值的内存块确定为需要清理的目标内存块。由于待淘汰内存块选取策略并不唯一,这里本文不再一一举例赘述。
S106,将待淘汰内存块中的目标元素迁移至缓存中的目标内存块,目标内存块为缓存中保留的内存块且可用存储空间大于目标元素需要的存储空间。
应理解,缓存中保留的内存块是指缓存中除待淘汰内存块以外的其他内存块。本步骤中保留的内存块在下一次的内存块淘汰中,可能还会被保留,也可能被淘汰。
在实际应用中,本说明书实施例可以根据缓存空间的占用情况,灵活挑选待淘汰内存块中的目标元素。也就是说,待淘汰内存块中的目标元素并不唯一,可以是待淘汰内存块的全部元素,也可以是待淘汰内存块中热度指标值达到元素热度阈值的部分元素(达到元素热度阈值的元素可以视为符合价值要求的元素)。
比如:缓存中存在保留的能够存储待淘汰内存块全部元素的内存块,则目标元素为待淘汰内存块的全部元素。也就是说,在有能力将淘汰内存块全部元素迁移的情况下,可以将淘汰内存块全部元素迁移出去,从而保证在缓存中所有元素不丢失的情况下,清理掉淘汰内存块。
当然,若缓存中不存在保留的能够存储待淘汰内存块全部元素的内存块,则目标元素为待淘汰内存块中热度指标值达到元素热度阈值的元素。也就是说,通过元素热度阈值选取淘汰内存块中值得迁移的元素作为目标元素。
在迁移过程中,如果先前是基于元素热度阈值选取淘汰内存块中的目标元素,但缓存中依然不存在保留的够存储目标元素的其他内存块,则可以通过下述方式实现迁移:
删除缓存中保留的其他内存块的元素,以清理出用于存储目标元素的存储空间,并将存储空间清理后的其他内存块确定为目标内存块,其中该其他内存块中被删除的元素的热度指标值小于目标元素的热度指标值。
为方便理解,这里假设内存块1为待淘汰内存块,该内存块1有元素A、元素B、元素C三个高价值元素,在对内存块1进行淘汰前,需要将其中元素A、B、C进行迁移,这里假设内存中其他不需要淘汰的内存块都没有空间存放元素A、B、C,则此时需要对缓存中不需要淘汰的内存块进行遍历,找到至少存储有三个热度指标值低于该元素A、B、C的其他元素的目标内存块,并将该目标内存块中三个热度指标值低于该元素A、B、C的元素进行清理,以腾出空间存放内存块1中高价值的元素A、B、C。
当然,除了上述方式外,也可以挑选出多个目标内存块,这里每个目标内存块都至少存储有热度指标值低于该元素A、B、C的其他元素,并从该多个目标内存块中清理掉三个热度指标值低于该元素A、B、C的元素,以腾出空间存放内存块1中高价值的元素A、B、C。比如,选取缓存中不需要淘汰的内存块2、3、4作为目标内存块,并分别从内存块2、3、4中挑选一个热度指标值低于该元素A、B、C的元素进行清理,以让内存块2存放内存块1的元素A,让内存块3存放内存块1的元素B,让内存块4存放内存块1的元素C。
显然,基于上述设计,如果缓存中所有不需要淘汰的内存块均没有空间存储待淘汰内存块中需要迁移的目标元素,则可以基于热度指标值,来进行元素取舍,从而保证缓存的最大收益。
S108,从缓存中删除待淘汰内存块。
本说明书实施例的方法可以更新缓存中内存块的热度指标值,并在需要清理缓存空间时,根据更新到的内存块热度指标值确定出需要清理的待淘汰内存块。在清理前,将待淘汰内存块中有价值的元素迁移至其他内存块,从而避免缓存因清理内存块而丢失高价值的元素,进而导致性能和收益的下降。
下面结合实际应用场景对本说明书实施例的方法进行详细介绍。
如图2所示,本应用场景提供一种基于LSM树架构的存储***,包括内存表(MemTable,Memory Table)存储结构和排序字符串表(SSTable,Sorted String Table)存储结构。其中,MemTable用于存储所述存储***的缓存数据。存储***所有的数据更新均在内存表MemTable完成,后台通过转储进场将MemTable中的缓存(Cache)元素久化存储至SSTable。SSTable中的压缩工具(compactor)负责整理和压缩数据。
为了便于compactor进行数据压缩和清理,同时也为了方便管理多种类的Cache,本应用场景的存储***要求MemTable中的Cache元素不定长。为了管理变长Cache元素,在MemTable中设置定长的内存块(MemBlock,Memory Block)作为最小存储单位。尽管存储***有很多种不同类型且不定长的Cache元素,但是设计了统一的Cache框架,不同租户的不同种类Cache都由框架统一管理,通过不同的优先级去区分不同类型的Cache元素。
进一步地,存储***为每个MemBlock中的元素都计算了访问热度的分值,越频繁访问的元素分值越高。同时,对于每一个MemBlock,又有基于MemBlock内部所有元素分值所确定的总分值。
在本说明书实施例中,缓存的淘汰是以管理内存的最小单位MemBlock为单位的。存储***后台的缓存清理线程会定时地计算MemTable中所有元素分值以及所有MemBlock分值,并对当前所有MemBlock按照分值进行排序,淘汰分值低的MemBlock。
在具体应用中,用户通过IO写入数据(待缓存的元素)。
存储***为待缓存的元素分配内存:由于缓存元素大小不定长,先计算实际需要的内存大小,如果能够被当前MemBlock容纳下,那么就会被分配到当前MemBlock中;否则分配新的MemBlock进行存储。
在分配新MemBlock的过程中,如果MemTable没有足够的内存,或者MemBlock数量达到上限,那么执行MemBlock的淘汰流程:遍历所有的缓存MemBlock,更新当前MemBlock的热度分值。基于已经设定的MemBlock上下限信息,计算本次缓存淘汰 过程需要淘汰掉的MemBlock范围。遍历所有的缓存MemBlock,对MemBlock的热度分值进行排序,选择出热度最低的MemBlock进行淘汰。
在淘汰过程中,存储***的后台将待淘汰的MemBlock中热度高的元素调整到其他热度高且不需要淘汰的MemBlock中,以提高缓存的命中率,从而体现更高的性能和收益。
基于上述内容可以知道,本应场景的存储***为了方便管理多种类型的Cache,采用不定长的Cache元素设计,且由定长的MemBlock进行存储,从而以MemBlock为粒度实现缓存清理。同时,存储***对于每个Cache元素都计算了热度分值,在淘汰某个MemBlock时,可以将高热度分值Cache元素迁移至其他MemBlock中,避免清理缓存空间时,丢失高热度元素。
以上应用场景是对本发明实施例方法的示例性介绍。应理解,应用场景的存储***能够作为执行主体执行图1所示的淘汰方法中的步骤,包括:基于MemTable中的MemBlock的热度指标值,确定MemTable中需要清理的待淘汰MemBlock;将待淘汰MemBlock中的目标元素迁移至MemTable中的目标MemBlock,目标MemBlock为MemTable中保留的MemBlock且可用存储空间大于所述目标元素需要的存储空间;从MemTable中删除所述待淘汰MemBlock。
此外,对应于图1所示的缓存内存块的淘汰方法,本发明实施例还提供一种缓存内存块的淘汰装置。图3是本发明实施例淘汰装置300的结构示意图,包括:热度确定模块310,确定缓存中内存块的热度指标值,内存块为缓存的存储单位。
淘汰分析模块320,基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块。
元素迁移模块330,将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间。
淘汰执行模块340,从所述缓存中删除所述待淘汰内存块。
本说明书实施例的装置可以更新缓存中内存块的热度指标值,并在需要清理缓存空间时,根据更新到的内存块热度指标值确定出需要清理的待淘汰内存块。在清理前,将待淘汰内存块中有价值的元素迁移至其他内存块,从而避免缓存因清理内存块而丢失高价值的元素,进而导致性能和收益的下降。
可选地,所述目标元素为所述待淘汰内存块的全部元素,或者,所述目标元素为所述待淘汰内存块中热度指标值达到元素热度阈值的元素。
若所述缓存中存在保留的能够存储所述待淘汰内存块全部元素的内存块,则所述目标元素为所述待淘汰内存块的全部元素。也就是说,在有能力将淘汰内存块全部元素迁移的情况下,可以将淘汰内存块全部元素迁移出去,从而保证在元素不丢失的情况下,清理掉淘汰内存块。
若所述缓存中不存在保留的能够存储所述待淘汰内存块全部元素的内存块,则所述目标元素为所述待淘汰内存块中热度指标值达到元素热度阈值的元素。也就是说,通过元素热度阈值选取淘汰内存块中值得迁移的元素作为目标元素。
可选地,元素迁移模块330将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块前,还用于:从所述缓存中选取保留的能够存储所述目标元素的其他内存块作为目标内存块。其中,若所述缓存中不存在保留的能够储所述目标元素的其他内存块,则元素迁移模块330可以删除所述缓存中保留的其他内存块的元素,以清理出用于存储所述目标元素的存储空间,并将存储空间清理后的其他内存块确定为目标内存块,其中该其他内存块中被删除的元素的热度指标值小于所述目标元素的热度指标值。
基于上述元素迁移模块330的删除方式,如果缓存中所有不需要淘汰的内存块均没有空间存储待淘汰内存块中需要迁移的目标元素,则可以基于热度指标值,来进行元素取舍。如果,不需要淘汰的内存块中存在热度指标值地域目标元素的元素,则可以进行删除,为目标元素腾出存储空间。
可选地,淘汰分析模块320基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的目标内存块的执行条件包括以下至少一者:所述缓存的存储空间占用达到占用上限;所述缓存中的内存块数量达到数量上限;所述缓存中存在持续预设时间未被访问的内存块。
可选地,内存块中元素的热度指标值是基于元素对应的访问次数、上一周期热度指标值以及热度时间衰减系数计算得到的。内存块的热度指标值是基于内存块中所有元素的热度指标值所确定得到的。
可选地,淘汰分析模块320可以按照热度指标值由小到大的顺序,选取预设数量的内存块作为需要清理的目标内存块;或,可以将所述缓存中热度指标值未达到内存块热度阈值的内存块确定为需要清理的目标内存块。
可选地,所述缓存为LSM树的MemTable,所述MemTable不定长缓存的元素,且元素的数据占用不大于内存块提供的存储空间。
显然,本说明书实施例的淘汰装置可以作为上述图1所示的淘汰方法的执行主体,因此能够实现淘汰方法在图1所实现的功能。由于原理相同,本文不再赘述。
图4是本说明书的一个实施例电子设备的结构示意图。请参考图4,在硬件层面,该电子设备包括处理器,可选地还包括内部总线、网络接口、存储器。其中,存储器可能包含内存,例如高速随机存取存储器(Random-Access Memory,RAM),也可能还包括非易失性存储器(non-volatile memory),例如至少1个磁盘存储器等。当然,该电子设备还可能包括其他业务所需要的硬件。
处理器、网络接口和存储器可以通过内部总线相互连接,该内部总线可以是ISA(Industry Standard Architecture,工业标准体系结构)总线、PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图4中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。
存储器,用于存放程序。具体地,程序可以包括程序代码,所述程序代码包括计算机操作指令。存储器可以包括内存和非易失性存储器,并向处理器提供指令和数据。
处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,在逻辑层面上缓存内存块的淘汰装置,该淘汰装置可以是指存储***,也可以是指存储***的部件。处理器,执行存储器所存放的程序,并具体用于执行以下操作:确定缓存中内存块的热度指标值,内存块为缓存的存储单位。
基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块。
将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间。
从所述缓存中删除所述待淘汰内存块。
本说明书实施例的电子设备可以更新缓存中内存块的热度指标值,并在需要清理缓存空间时,根据更新到的内存块热度指标值确定出需要清理的待淘汰内存块。在清理前,将待淘汰内存块中有价值的元素迁移至其他内存块,从而避免缓存因清理内存块而丢失高价值的元素,进而导致性能和收益的下降。
上述如本说明书图1所示实施例揭示的淘汰方法可以应用于处理器中,或者由处理器实现。处理器可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本说明书实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本说明书实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。
应理解,本说明书实施例的电子设备可以实现上述共识方法在图1和图2所示的实施例的功能。由于原理相同,本文不再赘述。
当然,除了软件实现方式之外,本说明书的电子设备并不排除其他实现方式,比如逻辑器件抑或软硬件结合的方式等等,也就是说以下处理流程的执行主体并不限定于各个逻辑单元,也可以是硬件或逻辑器件。
此外,本说明书实施例还提出了一种计算机可读存储介质,该计算机可读存储介质存储一个或多个程序,该一个或多个程序包括指令,该指令当被包括多个应用程序的便携式电子设备执行时,能够使该便携式电子设备执行图1所示实施例的方法,并具体用于执行以下步骤:确定缓存中内存块的热度指标值,内存块为缓存的存储单位。
基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块。
将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间。
从所述缓存中删除所述待淘汰内存块。
本领域技术人员应明白,本说明书的实施例可提供为方法、***或计算机程序产品。因此,本说明书可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施 例的形式。而且,本说明书可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
以上仅为本说明书的实施例而已,并不用于限制本说明书。对于本领域技术人员来说,本说明书可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本说明书的权利要求范围之内。此外,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本文件的保护范围。

Claims (15)

  1. 一种缓存内存块的淘汰方法,包括:
    确定缓存中内存块的热度指标值,内存块为缓存的存储单位;
    基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;
    将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间;
    从所述缓存中删除所述待淘汰内存块。
  2. 根据权利要求1所述的方法,
    所述目标元素为所述待淘汰内存块的全部元素,或者,所述目标元素为所述待淘汰内存块中热度指标值达到元素热度阈值的元素。
  3. 根据权利要求2所述的方法,
    若所述缓存中存在保留的能够存储所述待淘汰内存块全部元素的内存块,则所述目标元素为所述待淘汰内存块的全部元素。
  4. 根据权利要求2所述的方法,
    若所述缓存中不存在保留的能够存储所述待淘汰内存块全部元素的内存块,则所述目标元素为所述待淘汰内存块中热度指标值达到元素热度阈值的元素。
  5. 根据权利要求1所述的方法,
    将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块前,还包括:
    从所述缓存中选取保留的能够存储所述目标元素的其他内存块作为目标内存块。
  6. 根据权利要求5所述的方法,
    若所述缓存中不存在保留的能够储所述目标元素的其他内存块,则从所述缓存中选取保留的能够存储所述目标元素的其他内存块作为目标内存块,还包括:
    删除所述缓存中保留的其他内存块的元素,以清理出用于存储所述目标元素的存储空间,并将存储空间清理后的其他内存块确定为目标内存块,其中该其他内存块中被删除的元素的热度指标值小于所述目标元素的热度指标值。
  7. 根据权利要求1所述的方法,
    基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的目标内存块的执行条件包括以下至少一者:
    所述缓存的存储空间占用达到占用上限;
    所述缓存中的内存块数量达到数量上限;
    所述缓存中存在持续预设时间未被访问的内存块。
  8. 根据权利要求1所述的方法,
    内存块中元素的热度指标值是基于元素对应的访问次数计算得到的。
  9. 根据权利要求8所述的方法,
    内存块中元素的热度指标值还基于元素对应的上一周期热度指标值、热度时间衰减系数,和/或,元素权重系数计算得到的。
  10. 根据权利要求8或9所述的方法,
    内存块的热度指标值是基于内存块中所有元素的热度指标值所确定得到的。
  11. 根据权利要求1所述的方法,
    基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的目标内存块,包括:
    按照热度指标值由小到大的顺序,选取预设数量的内存块作为需要清理的目标内存块;
    或,
    将所述缓存中热度指标值未达到内存块热度阈值的内存块确定为需要清理的目标内存块。
  12. 一种缓存内存块的淘汰方法,应用于采用日志结构合并LSM树存储架构的存储***,包括:
    确定所述存储***的LSM树的内存表MemTable中的内存块MemBlock的热度指标值,其中,所述MemTable用于存储所述存储***的缓存数据;
    基于所述MemTable中的MemBlock的热度指标值,确定所述MemTable中需要清理的待淘汰MemBlock;
    将所述待淘汰MemBlock中的目标元素迁移至所述MemTable中的目标MemBlock,所述目标MemBlock为所述MemTable中保留的MemBlock且可用存储空间大于所述目标元素需要的存储空间;
    从所述MemTable中删除所述待淘汰MemBlock。
  13. 一种缓存内存块的淘汰装置,包括:
    热度确定模块,确定缓存中内存块的热度指标值,内存块为缓存的存储单位;
    淘汰分析模块,基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;
    元素迁移模块,将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的 存储空间;
    淘汰执行模块,从所述缓存中删除所述待淘汰内存块。
  14. 一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:
    确定缓存中内存块的热度指标值,内存块为缓存的存储单位;
    基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;
    将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间;
    从所述缓存中删除所述待淘汰内存块。
  15. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:
    确定缓存中内存块的热度指标值,内存块为缓存的存储单位;
    基于所述缓存中内存块的热度指标值,确定所述缓存中需要清理的待淘汰内存块;
    将所述待淘汰内存块中的目标元素迁移至所述缓存中的目标内存块,所述目标内存块为所述缓存中保留的内存块且可用存储空间大于所述目标元素需要的存储空间;
    从所述缓存中删除所述待淘汰内存块。
PCT/CN2022/090269 2021-05-06 2022-04-29 缓存内存块的淘汰方法、装置及电子设备 WO2022233272A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP22798613.0A EP4321980A1 (en) 2021-05-06 2022-04-29 Method and apparatus for eliminating cache memory block, and electronic device
US18/501,844 US20240061789A1 (en) 2021-05-06 2023-11-03 Methods, apparatuses, and electronic devices for evicting memory block in cache

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110490282.8A CN112905129B (zh) 2021-05-06 2021-05-06 缓存内存块的淘汰方法、装置及电子设备
CN202110490282.8 2021-05-06

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US18/501,844 Continuation US20240061789A1 (en) 2021-05-06 2023-11-03 Methods, apparatuses, and electronic devices for evicting memory block in cache

Publications (1)

Publication Number Publication Date
WO2022233272A1 true WO2022233272A1 (zh) 2022-11-10

Family

ID=76108971

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/090269 WO2022233272A1 (zh) 2021-05-06 2022-04-29 缓存内存块的淘汰方法、装置及电子设备

Country Status (4)

Country Link
US (1) US20240061789A1 (zh)
EP (1) EP4321980A1 (zh)
CN (2) CN113805805B (zh)
WO (1) WO2022233272A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117093508A (zh) * 2023-10-17 2023-11-21 苏州元脑智能科技有限公司 一种内存资源管理方法、装置、电子设备及存储介质
CN117235088A (zh) * 2023-11-09 2023-12-15 苏州元脑智能科技有限公司 一种存储***的缓存更新方法、装置、设备、介质及平台
CN117493400A (zh) * 2024-01-02 2024-02-02 中移(苏州)软件技术有限公司 数据处理方法、装置及电子设备

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113805805B (zh) * 2021-05-06 2023-10-13 北京奥星贝斯科技有限公司 缓存内存块的淘汰方法、装置及电子设备
CN113672166A (zh) * 2021-07-08 2021-11-19 锐捷网络股份有限公司 数据处理方法、装置、电子设备及存储介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160054917A1 (en) * 2014-08-19 2016-02-25 Sang-Kil Lee Mobile electronic device including embedded memory
CN106227598A (zh) * 2016-07-20 2016-12-14 浪潮电子信息产业股份有限公司 一种缓存资源的回收方法
CN107305475A (zh) * 2016-04-22 2017-10-31 中国科学院微电子研究所 一种flashcache混合存储***的缓存调度方法及***
CN109491619A (zh) * 2018-11-21 2019-03-19 浙江中智达科技有限公司 缓存数据处理方法、装置和***
CN109960662A (zh) * 2017-12-25 2019-07-02 华为技术有限公司 一种内存回收方法及设备
CN110427158A (zh) * 2019-07-29 2019-11-08 浙江大华技术股份有限公司 固态硬盘的写入方法及固态硬盘
CN112905129A (zh) * 2021-05-06 2021-06-04 蚂蚁金服(杭州)网络技术有限公司 缓存内存块的淘汰方法、装置及电子设备

Family Cites Families (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010109674A1 (en) * 2009-03-24 2010-09-30 Hitachi, Ltd. Storage apparatus and its data control method
US8838895B2 (en) * 2011-06-09 2014-09-16 21Vianet Group, Inc. Solid-state disk caching the top-K hard-disk blocks selected as a function of access frequency and a logarithmic system time
CN103167036A (zh) * 2013-01-28 2013-06-19 浙江大学 基于分布式多级缓存***的栅格数据存取方法
US9904556B1 (en) * 2013-03-15 2018-02-27 The Boeing Company Executing a boot sequence including movement of data through a buffer memory
CN107122124B (zh) * 2016-02-25 2021-06-15 中兴通讯股份有限公司 数据处理方法及装置
US10168917B2 (en) * 2016-04-05 2019-01-01 International Business Machines Corporation Hotness based data storage for facilitating garbage collection
US10635581B2 (en) * 2017-01-20 2020-04-28 Seagate Technology Llc Hybrid drive garbage collection
CN107391392A (zh) * 2017-07-21 2017-11-24 重庆大学 一种基于闪存存储设备并行特征的垃圾回收优化方法
CN109947787A (zh) * 2017-10-30 2019-06-28 阿里巴巴集团控股有限公司 一种数据分层存储、分层查询方法及装置
CN109815005A (zh) * 2017-11-22 2019-05-28 华为技术有限公司 一种管理内存的方法、装置和存储***
CN108628758A (zh) * 2018-03-14 2018-10-09 深圳忆联信息***有限公司 一种选择垃圾回收目标块的方法及固态硬盘
CN108920096A (zh) * 2018-06-06 2018-11-30 深圳忆联信息***有限公司 一种ssd的数据储存方法、装置、计算机设备及存储介质
CN110858124B (zh) * 2018-08-24 2021-06-01 华为技术有限公司 数据迁移方法及装置
CN109783402A (zh) * 2018-12-28 2019-05-21 深圳竹云科技有限公司 一种动态调整缓存热点数据的方法
US11321636B2 (en) * 2019-07-18 2022-05-03 Innogrit Technologies Co., Ltd. Systems and methods for a data storage system
CN110442309A (zh) * 2019-07-24 2019-11-12 广东紫晶信息存储技术股份有限公司 一种基于光存储的冷热数据交换方法及***
CN110674056B (zh) * 2019-09-02 2021-11-23 新华三大数据技术有限公司 一种垃圾回收方法及装置
JP2021047948A (ja) * 2019-09-19 2021-03-25 キオクシア株式会社 記憶装置およびメモリコントローラ
CN111324303B (zh) * 2020-01-21 2023-07-04 深圳忆联信息***有限公司 Ssd垃圾回收方法、装置、计算机设备及存储介质
CN111309650B (zh) * 2020-02-11 2024-01-05 广州市百果园信息技术有限公司 缓存控制方法、装置、存储介质及设备
CN111858405B (zh) * 2020-07-10 2022-07-19 苏州浪潮智能科技有限公司 一种分布式存储的数据缓存方法和装置

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160054917A1 (en) * 2014-08-19 2016-02-25 Sang-Kil Lee Mobile electronic device including embedded memory
CN107305475A (zh) * 2016-04-22 2017-10-31 中国科学院微电子研究所 一种flashcache混合存储***的缓存调度方法及***
CN106227598A (zh) * 2016-07-20 2016-12-14 浪潮电子信息产业股份有限公司 一种缓存资源的回收方法
CN109960662A (zh) * 2017-12-25 2019-07-02 华为技术有限公司 一种内存回收方法及设备
CN109491619A (zh) * 2018-11-21 2019-03-19 浙江中智达科技有限公司 缓存数据处理方法、装置和***
CN110427158A (zh) * 2019-07-29 2019-11-08 浙江大华技术股份有限公司 固态硬盘的写入方法及固态硬盘
CN112905129A (zh) * 2021-05-06 2021-06-04 蚂蚁金服(杭州)网络技术有限公司 缓存内存块的淘汰方法、装置及电子设备
CN113805805A (zh) * 2021-05-06 2021-12-17 北京奥星贝斯科技有限公司 缓存内存块的淘汰方法、装置及电子设备

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117093508A (zh) * 2023-10-17 2023-11-21 苏州元脑智能科技有限公司 一种内存资源管理方法、装置、电子设备及存储介质
CN117093508B (zh) * 2023-10-17 2024-01-23 苏州元脑智能科技有限公司 一种内存资源管理方法、装置、电子设备及存储介质
CN117235088A (zh) * 2023-11-09 2023-12-15 苏州元脑智能科技有限公司 一种存储***的缓存更新方法、装置、设备、介质及平台
CN117235088B (zh) * 2023-11-09 2024-02-13 苏州元脑智能科技有限公司 一种存储***的缓存更新方法、装置、设备、介质及平台
CN117493400A (zh) * 2024-01-02 2024-02-02 中移(苏州)软件技术有限公司 数据处理方法、装置及电子设备
CN117493400B (zh) * 2024-01-02 2024-04-09 中移(苏州)软件技术有限公司 数据处理方法、装置及电子设备

Also Published As

Publication number Publication date
CN112905129A (zh) 2021-06-04
EP4321980A1 (en) 2024-02-14
CN112905129B (zh) 2021-08-13
US20240061789A1 (en) 2024-02-22
CN113805805B (zh) 2023-10-13
CN113805805A (zh) 2021-12-17

Similar Documents

Publication Publication Date Title
WO2022233272A1 (zh) 缓存内存块的淘汰方法、装置及电子设备
CN110879800B (zh) 数据写入、压缩和读取方法、数据处理方法及装置
CN107526550B (zh) 一种基于日志结构合并树的两阶段合并方法
CN108920387B (zh) 降低读延迟的方法、装置、计算机设备及存储介质
US9727479B1 (en) Compressing portions of a buffer cache using an LRU queue
WO2016141735A1 (zh) 缓存数据的确定方法及装置
CN110727685B (zh) 一种基于Cassandra数据库的数据压缩方法、设备以及存储介质
CN110555001B (zh) 数据处理方法、装置、终端及介质
CN104503703B (zh) 缓存的处理方法和装置
CN108984130A (zh) 一种分布式存储的缓存读取方法及其装置
US20170315924A1 (en) Dynamically Sizing a Hierarchical Tree Based on Activity
CN110147331A (zh) 缓存数据处理方法、***及可读存储介质
WO2021062982A1 (zh) 管理hmb内存的方法、装置、计算机设备及存储介质
CN110750211A (zh) 一种存储空间的管理方法及装置
CN112711564B (zh) 合并处理方法以及相关设备
CN110502535B (zh) 数据访问方法、装置、设备和存储介质
CN106537321B (zh) 存取文件的方法、装置和存储***
CN114116634B (zh) 一种缓存方法、装置及可读存储介质
CN110825732A (zh) 数据查询方法、装置、计算机设备和可读存储介质
CN116027982A (zh) 数据处理方法、设备及可读存储介质
CN115576924A (zh) 一种数据迁移的方法
CN116775580A (zh) 一种文件***中的热度识别方法、装置及计算机设备
CN115904211A (zh) 一种存储***、数据处理方法及相关设备
CN114116711A (zh) 数据处理方法、装置、数据库、存储介质及程序产品
JP6112193B2 (ja) アクセス制御プログラム、ディスク装置及びアクセス制御方法

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: 22798613

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2022798613

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2022798613

Country of ref document: EP

Effective date: 20231106

NENP Non-entry into the national phase

Ref country code: DE