WO2013189413A2 - 一种缓存处理方法及装置 - Google Patents

一种缓存处理方法及装置 Download PDF

Info

Publication number
WO2013189413A2
WO2013189413A2 PCT/CN2013/082050 CN2013082050W WO2013189413A2 WO 2013189413 A2 WO2013189413 A2 WO 2013189413A2 CN 2013082050 W CN2013082050 W CN 2013082050W WO 2013189413 A2 WO2013189413 A2 WO 2013189413A2
Authority
WO
WIPO (PCT)
Prior art keywords
data
start address
cache
cache space
space
Prior art date
Application number
PCT/CN2013/082050
Other languages
English (en)
French (fr)
Other versions
WO2013189413A3 (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 中兴通讯股份有限公司
Priority to EP13806128.8A priority Critical patent/EP2911061B1/en
Priority to JP2015543258A priority patent/JP6059360B2/ja
Priority to US14/442,066 priority patent/US9563584B2/en
Publication of WO2013189413A2 publication Critical patent/WO2013189413A2/zh
Publication of WO2013189413A3 publication Critical patent/WO2013189413A3/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/14Handling requests for interconnection or transfer
    • G06F13/16Handling requests for interconnection or transfer for access to memory bus
    • G06F13/1668Details of memory controller
    • G06F13/1673Details of memory controller using buffers
    • 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/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/468Specific access rights for resources, e.g. using capability register
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C8/00Arrangements for selecting an address in a digital store
    • G11C8/06Address interface arrangements, e.g. address buffers
    • 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/1041Resource optimization
    • G06F2212/1044Space efficiency improvement

Definitions

  • the present invention relates to the field of network storage, and more particularly to a cache processing method and apparatus. Background technique
  • SoC System-on-chip
  • CPU/MPU Central Processing Unit/Micro Process Unit
  • DSP digital information processor
  • storage Each subsystem, such as a peripheral interface, is integrated into a chip through a bus interconnect.
  • these subsystems often need to share centralized storage/cache for a variety of reasons, such as subsystems requiring data interaction buffers between each other; Share storage as you handle multi-user business.
  • These centralized caches shared by multiple sources/multiple users can be physically one or several storage units, a static random access memory (SRAM) or a dynamic random storage device (DRAM). , Dynamic Random-Access Memory, ) or any combination of them, but can be logically treated as a shared cache.
  • SRAM static random access memory
  • DRAM dynamic random storage device
  • Dynamic Random-Access Memory a Dynamic Random-Access Memory or any combination of them, but can be logically treated as a shared cache.
  • the shared cache described below is based on a logically one block of storage, and the actual physical implementation may be a combination of one or more blocks of memory.
  • the method of cache sharing in SoC design basically divides the shared cache into N equal-sized "slices".
  • the size of this "slice” is based on the minimum data required to accommodate each source/user.
  • the data takes up M "slices".
  • M is an integer and M is less than or equal to N.
  • the technical problem to be solved by the embodiments of the present invention is to provide a cache processing method and apparatus capable of better planning management and saving use of cache space.
  • an embodiment of the present invention provides a cache processing method, including: when a first data of a first user needs to be cached, reading a current storage start address; starting from the current storage start address The first data is cached, and the cache space occupied by the first data is a first cache space;
  • the first data storing storage location information including a start address and a space length of the first cache space, so that when the first data needs to be read, positioning according to the start address and the space length The first cache space, and reading the first data from the first cache space;
  • the method further includes:
  • the idle state of the first data is recorded, and based on the idle state, it is determined whether the first data is released.
  • the method further includes:
  • the threshold value is a buffer space size required for storing a maximum data; when the remaining cache space after the current storage start address is less than a preset threshold, the data of the cache space is sorted according to a preset method, and Update the starting point of each data after finishing
  • the preset method is: selecting an earliest stored invalid data in the cache space, and re-storing the valid data after the selected invalid data in the start address of the selected invalid data, The invalid data is continuously occupied by the cache space; wherein the invalid data is: data that has been released; the valid data is: data that has not been released; after the finishing is completed, updating the current storage
  • the start address is the next address of the last valid data in the cache space.
  • the preset method is specifically:
  • the method further includes:
  • the valid data being read or being collated is locked so that a valid data cannot be read and sorted at the same time during the locking process.
  • An embodiment of the present invention further provides a cache processing apparatus, including:
  • Reading a storage start address module configured to read a current storage start address when the first data of the first user needs to be cached
  • a cache module configured to store the first data to the cache space from the current storage start address, where the cache space occupied by the first data is a first cache space;
  • a storage data management module configured to correspond to the first data, and the saving includes the first The storage location information of the start address and the space length of the cache space, so that when the first data needs to be read, the first cache space is located according to the start address and the space length, and from the first cache The space reads the first data;
  • the storage start address module is configured to update the current storage start address to be the next address of the first cache space, so that the next data to be cached is cached from the updated current storage start address.
  • the storage data management module is further configured to: record an idle state of the first data, and determine, according to the idle state, whether the first data is released.
  • the device further includes:
  • the arranging module is configured to set a threshold, where the threshold is a size of a buffer space required for storing a maximum data; when the remaining cache space after the current storage start address is less than a preset threshold, the data of the cache space is determined according to a preset method. Sorting, and updating the starting address of each data after finishing; wherein, the preset method is: selecting an earliest stored invalid data in the cache space, at the starting address of the selected invalid data, The valid data after the selected invalid data is continuously stored until all the valid data has continuously occupied the cache space; wherein the invalid data is: data that has been released; the valid data is: not released And after updating, the current storage start address is updated to be the next address of the last valid data in the cache space.
  • the preset method is: selecting an earliest stored invalid data in the cache space, at the starting address of the selected invalid data, The valid data after the selected invalid data is continuously stored until all the valid data has continuously occupied the cache space; wherein the invalid data is: data that has been released; the valid data
  • the device further includes:
  • the locking module is configured to lock valid data being read or being collated so that a valid data cannot be read and organized simultaneously during the locking process.
  • the data is continuously stored in the cache space. Compared with the prior art, the cache space is divided into several segments, and the cache space can be better utilized. Further, in the prior art, in order to implement data reading, it is necessary to record these data.
  • the cache address of the fragment, the amount of information storage is extremely large, and Since the cache space of this embodiment continuously stores data, it is only necessary to record the start address and the space length in the buffer space where each data is located, and the information storage amount depends on the number of data packets.
  • FIG. 1 is a schematic diagram of a cache processing method according to Embodiment 1 of the present invention.
  • FIG. 2 is a flowchart of a specific cache processing method according to Embodiment 1 of the present invention.
  • FIG. 3 is a flow chart of sorting a cache space in a cache processing method according to Embodiment 1 of the present invention.
  • FIG. 4 is a schematic diagram of a cache processing apparatus according to Embodiment 2 of the present invention. detailed description
  • a cache processing method includes the following steps:
  • Step 1 when the first data of the first user needs to be cached, the current storage start address is read; Step 2, the first data is stored from the current storage start address to the cache space, where The buffer space occupied by one data is the first cache space;
  • Step 3 corresponding to the first data in the first user, storing storage location information including a start address and a space length of the first cache space, so that when the first data needs to be read, Locating the first cache space with the start address and the space length, and reading the first data from the first cache space;
  • Step 4 Update the current storage start address to a next address of the first cache space, so that the next data to be cached can be cached from the storage start address, so that each cached data is obtained.
  • Both of the cache spaces can be continuously occupied.
  • the method of the embodiment continuously stores the data in the cache space, and the cache space can be better utilized by dividing the cache space into a plurality of segments according to the prior art. Further, in the prior art, in order to implement data reading The cache address of these fragments needs to be recorded, and the amount of information storage is extremely large. However, since the cache space of this embodiment continuously stores data, it is only necessary to record the start address and the space length in the cache space of each data to be read. The amount of information stored depends on the number of packets.
  • Step S201 Read the current storage start address st_add.l;
  • Step S202 The first data of the first user is stored in the cache space, and the cache space occupied by the first data is the first cache space, starting from the current storage start address st_add.1;
  • step S203 In order to make each stored data continually occupy the buffer space, after the step S203 is completed, proceed to step S204, and update the current storage start to the next address of the first cache space; the storage start address at this time should be For st—add.2, when you need to continue storing data, such as storing the second data, you can perform the following steps:
  • Step S205 starting from st_add.2, storing the second data into the cache space, and the buffer space occupied by the second data is the second cache space (as shown in FIG. 2);
  • the second data is not necessarily the data that the first user needs to cache. Can also belong to other users;
  • Step S206 saving the starting address of the second buffer space ("st_add.2" as shown in FIG. 2) and the space length in the additional storage space ("len. 2" as shown in FIG. 2) And an idle state of the second data ("V” as shown in FIG. 2);
  • Step S207 Update the current storage start to the next address of the second cache space.
  • the remaining cache space after the storage start address may be insufficient for storage, and some cache data has been read and released, and the corresponding cache space is also cleared. This requires collating the entire cache space and consolidating the cache space that has been emptied into the remaining cache space after the current storage initial address.
  • the method is:
  • the threshold is a buffer space size that may be needed to store a maximum data; if the remaining cache space after the current storage start address is less than a preset threshold, the data of the cache space is collated according to a preset method. And updating the starting address of each data after finishing; wherein the preset method is: selecting an earliest stored invalid data in the cache space, and validating the data at the start address thereof The data is continuously stored until all the valid data has continuously occupied the cache space; wherein the invalid data is: data that has been released; the valid data is: data that has not been released.
  • the cache space is also cleared.
  • a threshold is preset, which is the size of the space required to store a maximum data. If the remaining buffer space is less than the preset threshold, the data cannot be stored without using the buffer space. 7, need to organize the cache space, the finishing steps are:
  • Step S1 updating the current storage start address as the start address of the data 2; and re-storing the data 3 at the start address of the data 2 (that is, moving the buffer space corresponding to the data 3 upward by a distance, the distance of which is equal to the data 2 Space length), and update the starting address of the recorded data 2 in the extra storage space;
  • Step S2 updating the current storage start address to the next address of the buffer space where the data 3 is located, re-storing the data 4 at the storage start address, and updating the start address of the data 4 in the additional storage space;
  • Step S3 updating the current storage
  • the starting address is the next address of the buffer space where the data 4 is located, and the data 6 is re-stored at the storage start address, so that the buffer space corresponding to the data 2 and the data 5 is integrated into the remaining cache space after the current storage start address. ; then update the starting address of the data 6 in the extra storage space;
  • Step S4 after the buffer space is sorted, the data 7 is stored. It should be noted that all valid data should be continuously occupied by the cache space.
  • the target data when the target data needs to be read, it may happen that the target data is being sorted, and the position of the cache space is changed due to the change of the position of the cache space.
  • the entire cache space is divided into several segments, and some large data is saved by a plurality of segments.
  • the cache addresses of the segments need to be recorded, and the information storage amount is extremely large.
  • the cache space since the cache space continuously stores data, it is only necessary to record the start address and the space length in the buffer space where each valid data is located, so that the reading can be realized.
  • a cache processing apparatus includes:
  • the read storage start address module 41 is configured to read the current storage start address when the first data of the first user needs to be cached
  • the cache module 42 is configured to store the first data from the current storage start address to the cache space, where the cache space occupied by the first data is the first cache space;
  • the storage data management module 43 is configured to store, according to the first data in the first user, storage location information including a start address and a space length of the first cache space, so that the first Data, the first cache space can be located according to the start address and the space length, and the first data is read from the first cache space;
  • the update storage start address module 44 is configured to update the current storage start address to be the next address of the first cache space, so that the next data to be cached can be cached from the storage start address, thereby Make each cached data continually occupy the cache space.
  • the storage data management module 43 may also record an idle state of the first data, and determine whether the first data is released according to the idle state.
  • the device further includes: a finishing module; wherein
  • the sorting module sets a threshold value, where the threshold value may require a buffer space for storing a maximum data; if the remaining buffer space after the current storage start address is less than a preset threshold, the method is performed according to a preset method.
  • the data of the cache space is sorted, and the start address of each data is updated after the collation; wherein the preset method is: selecting an earliest stored invalid data in the cache space, at the start address thereof, The valid data after the data is continuously stored until all the valid data has continuously occupied the cache space; wherein the invalid data is: data that has been released; the valid data is: data that has not been released .
  • the update storage start address module 44 updates the current storage start address to the next address of the last valid data in the cache space.
  • the preset method is specifically: selecting an earliest stored invalid data in the cache space, obtaining a start address of the invalid data in the cache space by using the storage location information, and updating a current storage start address as the a start address of the invalid data; storing the first valid data after the invalid data from the storage start address, updating the storage location information of the first valid data; updating the current storage start address to the first valid The next address of the cache space in which the data resides, so that the next valid data after it can be re-cached from the storage start address until each cached valid data can continuously occupy the cache space.
  • the device further comprises a locking module, which can lock the valid data being read or being sorted, so that a valid data is in the locking process. Can't be read and sorted at the same time.
  • the read storage start address module, the cache module, the storage data management module, the update storage start address module, the sorting module, and the lock module may be implemented by a central processing unit (CPU) in the cache processing device.
  • CPU central processing unit
  • DSP Digital Signal Processor
  • FPGA Field - Programmable Gate Array
  • the entire cache space is divided into several segments, and some large data is saved by a plurality of segments.
  • the cache addresses of the segments need to be recorded, and the information storage amount is extremely large.
  • the cache space since the cache space continuously stores data, it is only necessary to record the start address and the space length in the cache space of each valid data to be read.

Abstract

本发明提供一种缓存处理方法及装置。方法包括:在需要缓存第一用户的第一数据时,读取当前存储起始地址;从当前存储起始地址开始存储第一数据到缓存空间,所述第一数据占用的缓存空间为第一缓存空间;对应于所述第一数据,保存包括所述第一缓存空间的起始地址和空间长度的存储位置信息,使在需要读取第一数据时,根据起始地址和空间长度定位所述第一缓存空间,并从第一缓存空间读取第一数据;更新当前存储起始地址为第一缓存空间的下一地址,使下一个需要缓存的数据,从更新后的当前存储起始地址开始进行缓存。本发明更好地利用缓存空间,减少为读取而保存的地址信息。

Description

一种緩存处理方法及装置 技术领域
本发明涉及网络存储领域, 特别是一种緩存处理方法及装置。 背景技术
系统级芯片 (SoC, System on Chip ) 技术将中央处理器 /微处理器 ( CPU/MPU, Central Processing Unit/Micro Process Unit ), 数字信息号处理 器(DSP, Digital Signal Processor ), 硬件加速器、 存储、 外设接口等各个 子系统, 通过总线互联集成到一颗芯片上。 这些子系统除了其内部数据处 理所需要的本地专用存储 /緩存之外, 还往往由于各种各样的原因需要共享 集中的存储 /緩存, 如各子系统相互之间需要数据交互緩冲; 再如处理多用 户业务而共享存储。
这些由多源 /多用户共享的集中緩存可以在物理上是一块或几块存储单 元, 口一块静态存 4诸器 (SRAM, Static Random-Access Memory, )或一块 动态随机存 4诸器(DRAM, Dynamic Random- Access Memory, )或几块它们 的任意组合, 但可以在逻辑上把它们看作是一块共享緩存。 下文所述的共 享緩存均基于逻辑上是一块存储单元来论述, 而实际物理实现上可以是一 块或多块存储单元的组合。
如同任何公共资源一样, 多源 /多用户共享一块緩存的使用需要考虑存 储资源的分配与管理。
目前 SoC设计中的緩存共享使用方法基本上是将共享緩存划分为 N个 相等大小的 "片", 这个 "片" 的大小以能容纳下各源 /各用户所需的最小数 据为准, 大的数据就占用 M个 "片"。 这里, M为整数, M小于等于N。
这种方法的缺点是需要很大的存储空间来记录每个 "片" 的使用状态 及存储位置信息。 特别是当系统所需的最小数据的长度很小时, 相对于每 个 "片" 用于存储的空间也会随之很小, 在存储大数据时, 需要用到很多 的 "片"。 另外使用这方法还对共浪费享緩存空间, 如有些数据只比整数个 "片" 大一点点, 这就需要再单独使用一个 "片" 进行存储。 发明内容
本发明实施例要解决的技术问题是提供一种能够更好的进行规划管理 并能节约使用緩存空间的緩存处理方法及装置。
为解决上述技术问题, 本发明的实施例提供一种緩存处理方法, 包括: 在需要緩存第一用户的第一数据时, 读取当前存储起始地址; 从所述当前存储起始地址开始存储所述第一数据到緩存空间, 其中, 所述第一数据占用的緩存空间为第一緩存空间;
对应于所述第一数据, 保存包括所述第一緩存空间的起始地址和空间 长度的存储位置信息, 使在需要读取所述第一数据时, 根据所述起始地址 和空间长度定位所述第一緩存空间, 并从所述第一緩存空间读取所述第一 数据;
更新所述当前存储起始地址为所述第一緩存空间的下一地址, 使下一 个需要緩存的数据, 从更新后的当前存储起始地址开始进行緩存。
优选地, 从所述当前存储起始地址开始存储所述第一数据到緩存空间 后, 所述方法还包括:
记录所述第一数据的空闲状态, 根据所述空闲状态, 判断所述第一数 据是否被释放掉。
优选地, 所述方法还包括:
设置一阈值, 所述阈值为存储一个最大数据所需要的緩存空间大小; 当前存储起始地址之后的剩余緩存空间小于预设阈值时, 按照预设方 法对所述緩存空间的数据进行整理, 并在整理之后更新每个数据的起始地 址; 其中, 所述预设方法为: 在所述緩存空间中选择一个最早存储的失效 数据, 在选择的失效数据的起始地址, 重新对所述选择的失效数据之后的 有效数据连续存储, 直至全部有效数据均已连续占用所述緩存空间; 其中, 所述失效数据为: 已被释放的数据; 所述有效数据为: 未被释放掉的数据; 整理完成后, 更新所述当前存储起始地址为最后一个有效数据在所述 緩存空间的下一地址。
优选地, 所述预设方法具体为:
在所述緩存空间中选择一个最早存储的失效数据, 通过选择的失效数 据的存储位置信息, 获取所述选择的失效数据在所述緩存空间的起始地址, 更新当前存储起始地址为所述选择的失效数据的起始地址;
从更新后的当前存储起始地址开始存储在所述选择的失效数据之后的 第一有效数据, 更新第一有效数据的存储位置信息;
更新所述当前存储起始地址为所述第一有效数据所在緩存空间的下一 地址, 使第一有效数据之后的下一个有效数据从更新后的当前存储起始地 址开始重新进行緩存, 直至每个已緩存的有效数据均能连续占用所述緩存 空间。
优选地, 所述方法还包括:
对正被读取或者正被整理的有效数据进行锁定, 使一个有效数据在锁 定过程中不能同时被读取与整理。
本发明的实施例还提供一种緩存处理装置, 包括:
读取存储起始地址模块, 配置为在需要緩存第一用户的第一数据时, 读取当前存储起始地址;
緩存模块, 配置为从所述当前存储起始地址开始存储所述第一数据到 緩存空间, 其中, 所述第一数据占用的緩存空间为第一緩存空间;
存储数据管理模块, 配置为对应于所述第一数据, 保存包括所述第一 緩存空间的起始地址和空间长度的存储位置信息, 使在需要读取所述第一 数据时, 根据所述起始地址和空间长度定位所述第一緩存空间, 并从所述 第一緩存空间读取所述第一数据;
更新存储起始地址模块, 配置为更新所述当前存储起始地址为所述第 一緩存空间的下一地址, 使下一个需要緩存的数据, 从更新后的当前存储 起始地址开始进行緩存。
优选地, 所述存储数据管理模块还配置为: 记录所述第一数据的空闲 状态, 并根据所述空闲状态, 判断所述第一数据是否被释放掉。
优选地, 所述装置还包括:
整理模块, 配置为设置阈值, 所述阈值为存储一个最大数据所需要緩 存空间的大小; 当前存储起始地址之后的剩余緩存空间小于预设阈值时, 按照预设方法对所述緩存空间的数据进行整理, 并在整理之后更新每个数 据的起始地址; 其中, 所述预设方法为: 在所述緩存空间中选择一个最早 存储的失效数据, 在选择的失效数据的起始地址, 重新对所述选择的失效 数据之后的有效数据连续存储, 直至全部有效数据均已连续占用所述緩存 空间; 其中, 所述失效数据为: 已被释放的数据; 所述有效数据为: 未被 释放的数据; 并在整理完成后, 更新所述当前存储起始地址为最后一个有 效数据在所述緩存空间的下一地址。
优选地, 所述装置还包括:
锁定模块, 配置为对正被读取或者正被整理的有效数据进行锁定, 使 一个有效数据在锁定过程中不能同时被读取与整理。
本发明实施例的上述技术方案的有益效果如下:
将数据连续存储在緩存空间中, 相对于现有技术将緩存空间分成若干 个片段而言, 可以更好的利用緩存空间; 进一步地, 现有技术中, 为了实 现数据的读取, 需要记录这些片段的緩存地址, 信息存储量极为庞大, 而 本实施例的緩存空间由于连续存储数据, 只需要记录每个数据的所在緩存 空间中的起始地址以及空间长度就能实现读取, 其信息存储量取决于数据 包的数量。 附图说明
图 1为本发明实施例一的緩存处理方法的示意图;
图 2为本发明实施例一的具体的緩存处理方法的流程图;
图 3 为本发明实施例一的緩存处理方法中的对緩存空间进行整理的流 程图;
图 4为本发明实施例二的緩存处理装置的示意图。 具体实施方式
为使本发明要解决的技术问题、 技术方案和优点更加清楚, 下面将结 合附图及具体实施例进行详细描述。
实施例一
如图 1所示, 一种緩存处理方法, 包括如下步骤:
步骤 1, 在需要緩存第一用户的第一数据时, 读取当前存储起始地址; 步骤 2, 从所述当前存储起始地址开始存储所述第一数据到緩存空间, 其中, 所述第一数据占用的緩存空间为第一緩存空间;
步骤 3,对应于所述第一用户中的第一数据,保存包括所述第一緩存空 间的起始地址和空间长度的存储位置信息, 使得在需要读取所述第一数据 时, 能够根据所述起始地址和空间长度定位所述第一緩存空间, 并从所述 第一緩存空间读取所述第一数据;
步骤 4, 更新所述当前存储起始地址为所述第一緩存空间的下一地址, 使得下一个需要緩存的数据, 能够从该存储起始地址开始进行緩存, 从而 使每个已緩存的数据都能连续占用所述緩存空间。 本实施例的方法将数据连续存储在緩存空间中, 相对于现有技术将緩 存空间分成若干个片段而言, 可以更好的利用緩存空间; 进一步地, 现有 技术中, 为了实现数据的读取, 需要记录这些片段的緩存地址, 信息存储 量极为庞大, 而本实施例的緩存空间由于连续存储数据, 只需要记录每个 数据的所在緩存空间中的起始地址以及空间长度就能实现读取, 其信息存 储量取决于数据包的数量。
下面对图 1所示方法详细描述:
如图 2所示, 在需要緩存第一用户的第一数据时进行以下步骤: 步骤 S201, 读取当前存储起始地址 st— add. l ;
步骤 S202, 从当前存储起始地址 st— add.1开始, 将第一用户的第一数据 存储进緩存空间, 第一数据占用的緩存空间为第一緩存空间;
步骤 S203, 在额外存储空间中保存第一緩存空间的起始地址(如图中 2所示的 "st— add. l" )、 空间长度(如图中 2所示的 "len. 1" )以及第一数据 的空闲状态 (如图中 2所示的 "V", V=l表示该数据未被释放, V=0表示 数据已被释放掉), 使得在需要读取第一数据时, 只需找到第一緩存空间的 起始地址 st— add. l以及空间长度为 len. 1即可定位第一緩存空间,读取第一 数据;
根据所述第一数据的空闲状态, 判断所述第一数据是否被释放。
为了使每个存储的数据都能连续性占用緩存空间, 在步骤 S203完成之 后, 进行步骤 S204, 更新所述当前存储起始为第一緩存空间的下一地址; 此时的存储起始地址应为 st— add.2, 当需要继续存储数据时, 如存储第 二数据, 可进行以下步骤:
步骤 S205, 从 st— add.2开始, 将第二数据存储进緩存空间中, 第二数据 占用的緩存空间为第二緩存空间 (如图 2所示);
需要指出的是, 所述第二数据并不一定是第一用户需要緩存的数据, 也可以属于其他用户;
步骤 S206, 在额外存储空间中保存第二緩存空间的起始地址(如图中 2 所示的 "st— add.2" )、 空间长度(如图中 2所示的 "len. 2" ) 以及第二数据的 空闲状态 (如图中 2所示的 "V" );
步骤 S207, 更新所述当前存储起始为第二緩存空间的下一地址。
之后其它需要存储的数据都应按照上述方法保存进緩存空间中, 使得 每个已緩存的数据都能连续占用緩存空间, 并在额外存储空间中记录每个 数据的起始地址、 空间长度。
由于緩存空间有限, 当存储某一数据时, 可能会出现存储起始地址之 后的剩余緩存空间不足以再进行存储, 而有些緩存数据已经被读取并释放, 其对应的緩存空间也已清空, 这就需要对整个緩存空间进行整理, 将已被 清空的緩存空间整合到当前存储初始地址之后的剩余緩存空间中, 其方法 为:
设置一阈值, 所述阈值为存储一最大数据可能需要的緩存空间大小; 若在当前存储起始地址之后的剩余緩存空间小于预设阈值, 则按照预 设方法对所述緩存空间的数据进行整理, 并在整理之后更新每个数据的起 始地址; 其中, 所述预设方法为: 在所述緩存空间中选择一个最早存储的 失效数据, 在其起始地址, 重新对该数据之后的有效数据连续存储, 直至 全部有效数据都已连续占用所述緩存空间; 其中, 所述失效数据为: 已被 释放掉的数据; 所述有效数据为: 未被释放掉的数据。
下面对预设方法进行详细描述:
如图 3所示, 緩存空间中已存有 6个数据, 通过额外緩存空间记录的空 闲状态可知数据 2与数据 5为失效数据(即空闲状态 V=0 ), 都已被释放掉, 其所在的緩存空间也被清空。数据 1、 3、 4、 6为有效数据(即空闲状态 V=l ), 在緩存空间中未被释放。 当接到指令存储数据 7时, 预设一个阈值, 该阈值为存储一个最大数据 所需要的空间大小, 若剩余的緩存空间小于预设阀值, 则说明目前未被使 用緩冲空间无法存储数据 7, 需要对緩存空间进行整理, 整理步骤为:
步骤 S1, 更新当前存储起始地址为数据 2的起始地址; 将数据 3在数 据 2的起始地址开始重新存储 (即将数据 3所对应的緩存空间向上挪一段 距离, 其距离等于数据 2的空间长度), 并更新额外存储空间中记录数据 2 的起始地址;
步骤 S2, 更新当前存储起始地址为数据 3所在緩存空间的下一地址, 在 该存储起始地址重新存储数据 4, 并更新额外存储空间中数据 4的起始地址; 步骤 S3, 更新当前存储起始地址为数据 4所在緩存空间的下一地址, 在 该存储起始地址重新存储数据 6, 从而使数据 2与数据 5所对应的緩存空间整 合到当前存储起始地址之后的剩余緩存空间中; 之后更新额外存储空间中 数据 6的起始地址;
步骤 S4, 在緩存空间整理完成之后, 存储数据 7。 需要指出的是, 所有 有效数据都应是连续占用緩存空间。
另外当需要对目标数据进行读取时, 可能出现目标数据正被进行整理, 其在緩存空间的位置因为发生变化致使读取出现错误。 为了解决这一问题, 可以对正被读取或者正被整理的有效数据进行锁定, 在锁定过程中使得一 个有效数据不能同时被读取与整理。 例如: 在数据 3被整理的时候, 可将 其锁定, 直到整理完成后再解除锁定, 在数据 3被锁定的时, 无法接收读 取请求, 从而避免整理过程干扰读取过程。
本实施例的方法有益效果如下:
1. 将每个数据连续存储在緩存空间中, 可以更好的利用緩存空间, 节 约资源。
2. 对緩存空间进行整理, 将已被清空的緩存空间整合到当前存储初始 地址之后的剩余緩存空间中, 保持全部有效数据都已连续占用所述緩存空 间, 可以在有限緩存空间中存储更多的数据, 进一步节约资源。
3. 现有技术中, 将整个緩存空间分成若干个片段, 有些大数据会由很 多个片段来保存, 为了实现数据的读取, 需要记录这些片段的緩存地址, 信息存储量极为庞大, 而本实施例的由于緩存空间连续存储数据, 只需要 记录每个有效数据所在緩存空间中的起始地址以及空间长度就能实现读 取。
实施例二
如图 4所示, 一种緩存处理装置, 包括:
读取存储起始地址模块 41,配置为在需要緩存第一用户的第一数据时, 读取当前存储起始地址;
緩存模块 42, 配置为从所述当前存储起始地址开始存储所述第一数据 到緩存空间, 其中, 所述第一数据占用的緩存空间为第一緩存空间;
存储数据管理模块 43, 配置为对应于所述第一用户中的第一数据, 保 存包括所述第一緩存空间的起始地址和空间长度的存储位置信息, 使得在 需要读取所述第一数据时, 能够根据所述起始地址和空间长度定位所述第 一緩存空间, 并从所述第一緩存空间读取所述第一数据;
更新存储起始地址模块 44, 配置为更新所述当前存储起始地址为所述 第一緩存空间的下一地址, 使得下一个需要緩存的数据, 能够从该存储起 始地址开始进行緩存, 从而使每个已緩存的数据都能连续占用所述緩存空 间。
另外, 存储数据管理模块 43还可以记录所述第一数据的空闲状态, 并 根据所述空闲状态, 判断所述第一数据是否被释放掉。
由于緩存空间有限, 当存储某一数据时, 可能会出现存储起始地址之 后的剩余緩存空间不足以再进行存储, 而有些緩存的数据已经被读取并释 放, 其对应的緩存空间也已清空, 这就需要对整个緩存空间进行整理。 因此, 该装置还包括: 整理模块; 其中,
整理模块会设置一阀值, 所述阀值为存储一最大数据可能需要緩存空 间的大小; 若在当前存储起始地址之后的剩余緩存空间小于预设阀值, 则 按照预设方法对所述緩存空间的数据进行整理, 并在整理之后更新每个数 据的起始地址; 其中, 所述预设方法为: 在所述緩存空间中选择一个最早 存储的失效数据, 在其起始地址, 重新对该数据之后的有效数据连续存储, 直至全部有效数据都已连续占用所述緩存空间; 其中, 所述失效数据为: 已被释放掉的数据; 所述有效数据为: 未被释放掉的数据。 在整理完成后, 更新存储起始地址模块 44更新所述当前存储起始地址为最后一个有效数据 在所述緩存空间的下一地址。
所述预设方法具体为: 在所述緩存空间中选择一个最早存储的失效数 据, 通过其存储位置信息, 获取该失效数据在所述緩存空间的起始地址, 更新当前存储起始地址为该失效数据的起始地址; 从该存储起始地址开始 存储在该失效数据之后的第一有效数据, 更新第一有效数据的存储位置信 息; 更新所述当前存储起始地址为所述第一有效数据所在緩存空间的下一 地址, 使得在其之后的下一个有效数据能够从该存储起始地址开始重新进 行緩存, 直至每个已緩存的有效数据都能连续占用所述緩存空间。
为了避免整理模块在进行整理过程时, 干扰緩存空间中数据的读取, 本装置还包括一个锁定模块, 可以对正被读取或者正被整理的有效数据进 行锁定, 使得一个有效数据在锁定过程中不能同时被读取与整理。
在实际应用时, 读取存储起始地址模块、 緩存模块、 存储数据管理模 块、 更新存储起始地址模块、 整理模块、 以及锁定模块可由緩存处理装置 中的中央处理器 (CPU, Central Processing Unit ), 数字信号处理器 (DSP, Digital Signal Processor )或可编程遝辑阵歹1 J ( FPGA, Field - Programmable Gate Array ) 实现。
本实施例的方法有益效果如下:
1. 将每个数据连续存储在緩存空间中, 可以更好的利用緩存空间, 节 约资源;
2. 对緩存空间进行整理, 将已被清空的緩存空间整合到当前存储初始 地址之后的剩余緩存空间中, 保持全部有效数据都已连续占用所述緩存空 间, 可以在有限緩存空间中存储更多的数据, 进一步节约资源。
3. 现有技术中, 将整个緩存空间分成若干个片段, 有些大数据会由很 多个片段来保存, 为了实现数据的读取, 需要记录这些片段的緩存地址, 信息存储量极为庞大, 而本实施例的由于緩存空间连续存储数据, 只需要 记录每个有效数据的所在緩存空间中的起始地址以及空间长度就能实现读 取。
以上所述是本发明的优选实施方式, 应当指出, 对于本技术领域的普 通技术人员来说, 在不脱离本发明所述原理的前提下, 还可以作出若干改 进和润饰, 这些改进和润饰也应视为本发明的保护范围。

Claims

权利要求书
1. 一种緩存处理方法, 包括:
在需要緩存第一用户的第一数据时, 读取当前存储起始地址; 从所述当前存储起始地址开始存储所述第一数据到緩存空间, 其中, 所述第一数据占用的緩存空间为第一緩存空间;
对应于所述第一数据, 保存包括所述第一緩存空间的起始地址和空间 长度的存储位置信息, 使在需要读取所述第一数据时, 根据所述起始地址 和空间长度定位所述第一緩存空间, 并从所述第一緩存空间读取所述第一 数据;
更新所述当前存储起始地址为所述第一緩存空间的下一地址, 使下一 个需要緩存的数据, 从更新后的当前存储起始地址开始进行緩存。
2. 根据权利要求 1所述的緩存处理方法, 其中, 从所述当前存储起始 地址开始存储所述第一数据到緩存空间后, 所述方法还包括:
记录所述第一数据的空闲状态, 根据所述空闲状态, 判断所述第一数 据是否被释放。
3. 根据权利要求 2所述的緩存处理方法, 其中, 所述方法还包括: 设置一阈值, 所述阈值为存储一个最大数据所需要的緩存空间大小; 当前存储起始地址之后的剩余緩存空间小于预设阈值时, 按照预设方 法对所述緩存空间的数据进行整理, 并在整理之后更新每个数据的起始地 址; 其中, 所述预设方法为: 在所述緩存空间中选择一个最早存储的失效 数据, 在选择的失效数据的起始地址, 重新对所述选择的失效数据之后的 有效数据连续存储, 直至全部有效数据均已连续占用所述緩存空间; 其中, 所述失效数据为: 已被释放的数据; 所述有效数据为: 未被释放掉的数据; 整理完成后, 更新所述当前存储起始地址为最后一个有效数据在所述 緩存空间的下一地址。
4. 根据权利要求 3所述的緩存处理方法, 其中, 所述预设方法为: 在所述緩存空间中选择一个最早存储的失效数据, 通过选择的失效数 据的存储位置信息, 获取所述选择的失效数据在所述緩存空间的起始地址, 更新当前存储起始地址为所述选择的失效数据的起始地址;
从更新后的当前存储起始地址开始存储在所述选择的失效数据之后的 第一有效数据, 更新第一有效数据的存储位置信息;
更新所述当前存储起始地址为所述第一有效数据所在緩存空间的下一 地址, 使第一有效数据之后的下一个有效数据从更新后的当前存储起始地 址开始重新进行緩存, 直至每个已緩存的有效数据均能连续占用所述緩存 空间。
5. 根据权利要求 1至 4任一项所述的存储緩存的方法, 其中, 所述方 法还包括:
对正被读取或者正被整理的有效数据进行锁定, 使一个有效数据在锁 定过程中不能同时被读取与整理。
6. 一种緩存处理装置, 包括:
读取存储起始地址模块, 配置为在需要緩存第一用户的第一数据时, 读取当前存储起始地址;
緩存模块, 配置为从所述当前存储起始地址开始存储所述第一数据到 緩存空间, 其中, 所述第一数据占用的緩存空间为第一緩存空间;
存储数据管理模块, 配置为对应于所述第一数据, 保存包括所述第一 緩存空间的起始地址和空间长度的存储位置信息, 使在需要读取所述第一 数据时, 根据所述起始地址和空间长度定位所述第一緩存空间, 并从所述 第一緩存空间读取所述第一数据;
更新存储起始地址模块, 配置为更新所述当前存储起始地址为所述第 一緩存空间的下一地址, 使下一个需要緩存的数据, 从更新后的当前存储 起始地址开始进行緩存。
7. 根据权利要求 6所述的緩存处理装置, 其中, 所述存储数据管理模 块还配置为: 记录所述第一数据的空闲状态, 并根据所述空闲状态, 判断 所述第一数据是否被释放。
8. 根据权利要求 7所述的緩存处理装置, 其中, 所述装置还包括: 整理模块, 配置为设置阈值, 所述阈值为存储一个最大数据所需要緩 存空间的大小; 当前存储起始地址之后的剩余緩存空间小于预设阈值时, 按照预设方法对所述緩存空间的数据进行整理, 并在整理之后更新每个数 据的起始地址; 其中, 所述预设方法为: 在所述緩存空间中选择一个最早 存储的失效数据, 在选择的失效数据的起始地址, 重新对所述选择的失效 数据之后的有效数据连续存储, 直至全部有效数据均已连续占用所述緩存 空间; 其中, 所述失效数据为: 已被释放的数据; 所述有效数据为: 未被 释放的数据; 并在整理完成后, 更新所述当前存储起始地址为最后一个有 效数据在所述緩存空间的下一地址。
9. 根据权利要求 6、 7或 8所述的緩存处理装置, 其中, 所述装置还 包括:
锁定模块, 配置为对正被读取或者正被整理的有效数据进行锁定, 使 一个有效数据在锁定过程中不能同时被读取与整理。
PCT/CN2013/082050 2012-11-22 2013-08-22 一种缓存处理方法及装置 WO2013189413A2 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
EP13806128.8A EP2911061B1 (en) 2012-11-22 2013-08-22 Buffer processing method and device
JP2015543258A JP6059360B2 (ja) 2012-11-22 2013-08-22 バッファ処理方法及び装置
US14/442,066 US9563584B2 (en) 2012-11-22 2013-08-22 Method and device for buffer processing in system on chip

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210478383.4 2012-11-22
CN201210478383.4A CN103838679B (zh) 2012-11-22 2012-11-22 一种缓存处理方法及装置

Publications (2)

Publication Number Publication Date
WO2013189413A2 true WO2013189413A2 (zh) 2013-12-27
WO2013189413A3 WO2013189413A3 (zh) 2014-02-13

Family

ID=49769556

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/082050 WO2013189413A2 (zh) 2012-11-22 2013-08-22 一种缓存处理方法及装置

Country Status (5)

Country Link
US (1) US9563584B2 (zh)
EP (1) EP2911061B1 (zh)
JP (1) JP6059360B2 (zh)
CN (1) CN103838679B (zh)
WO (1) WO2013189413A2 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105550124A (zh) * 2015-12-09 2016-05-04 四川长虹电器股份有限公司 一种信息处理方法和电子设备

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0294499B1 (en) 1987-06-09 1992-08-26 International Business Machines Corporation Control scheme for segmented buffers based on a shared reference count
DE69332696T2 (de) * 1992-06-15 2003-08-21 Microsoft Corp Rechnerverfahren und System zur Speicherverwaltung
JPH06161864A (ja) * 1992-11-19 1994-06-10 Toshiba Corp オブジェクト記憶管理方法
JP3251414B2 (ja) * 1994-01-11 2002-01-28 三菱電機株式会社 プログラマブルコントローラおよびそのプログラム容量変更方法
JPH08241186A (ja) * 1995-03-07 1996-09-17 Fujitsu Ltd バッファメモリ管理ユニット及びバッファメモリ管理方法
US6970893B2 (en) 2000-10-27 2005-11-29 Bea Systems, Inc. System and method for regeneration of methods and garbage collection of unused methods
US6938126B2 (en) * 2002-04-12 2005-08-30 Intel Corporation Cache-line reuse-buffer
CN100366022C (zh) * 2004-04-02 2008-01-30 华为技术有限公司 一种缓存分配方法及装置
CN100474840C (zh) * 2004-07-22 2009-04-01 华为技术有限公司 一种基于信令协议的缓冲区的管理方法
TWI244087B (en) * 2004-08-12 2005-11-21 Via Tech Inc Method and device for memory space allocation
JP2006161864A (ja) 2004-12-02 2006-06-22 Calsonic Kansei Corp 自動変速機のセレクトアシスト装置
JP5073337B2 (ja) 2007-03-28 2012-11-14 株式会社ダイセル 点火器組立体
CN101122886B (zh) * 2007-09-03 2010-06-09 杭州华三通信技术有限公司 分配缓存空间的方法和装置以及缓存控制器
CN101196857B (zh) * 2008-01-04 2010-11-10 太原理工大学 双端口访问对称动态存储器的接口
WO2010049833A1 (en) * 2008-10-28 2010-05-06 Nxp B.V. Data processing circuit with cache and interface for a detachable device
CN102646084A (zh) * 2012-03-06 2012-08-22 上海纳轩电子科技有限公司 一种基于fpga实现的高效网络数据包存储方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
None

Also Published As

Publication number Publication date
WO2013189413A3 (zh) 2014-02-13
JP6059360B2 (ja) 2017-01-11
EP2911061A4 (en) 2015-11-11
EP2911061B1 (en) 2022-03-30
CN103838679A (zh) 2014-06-04
EP2911061A2 (en) 2015-08-26
JP2016504665A (ja) 2016-02-12
US9563584B2 (en) 2017-02-07
CN103838679B (zh) 2017-08-04
US20150317264A1 (en) 2015-11-05

Similar Documents

Publication Publication Date Title
US9471500B2 (en) Bucketized multi-index low-memory data structures
Debnath et al. BloomFlash: Bloom filter on flash-based storage
KR101599177B1 (ko) 복합식 비휘발성 저장 디바이스를 위한 데이터 이송
US20130290643A1 (en) Using a cache in a disaggregated memory architecture
JP7340326B2 (ja) メンテナンス動作の実行
JP7013510B2 (ja) ローカライズされたデータアフィニティシステム及びハイブリッド法
CN106537863A (zh) 网络设备中的处理并发性
WO2013091167A1 (zh) 日志存储方法及系统
WO2014101485A1 (zh) 一种内存监控方法及相关装置
Fan et al. I/o-cache: A non-volatile memory based buffer cache policy to improve storage performance
US7562204B1 (en) Identifying and relocating relocatable kernel memory allocations in kernel non-relocatable memory
JP2014199573A (ja) ストレージ制御装置、ストレージ制御装置の制御方法およびストレージ制御装置の制御プログラム
CN110162395B (zh) 一种内存分配的方法及装置
CN109983538B (zh) 存储地址转换
WO2013189413A2 (zh) 一种缓存处理方法及装置
CN110928803B (zh) 一种内存管理方法及装置
WO2020000734A1 (zh) 存储对象的空间管理方法、装置、计算机装置及存储介质
WO2014177080A1 (zh) 资源对象存储处理方法及装置
WO2016131175A1 (zh) 多核系统中数据访问者目录的访问方法及设备
CN115422604A (zh) 针对非易失内存的数据安全处理方法、内存控制器及系统
CN110413235B (zh) 一种面向ssd去重的数据分配方法及系统
US9846553B2 (en) Organization and management of key-value stores
US11874767B2 (en) Memory partitions for processing entities
WO2024054232A1 (en) Low-latency cache
CN117170863A (zh) 一种内存分配方法、装置、设备及存储介质

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

Country of ref document: EP

Kind code of ref document: A2

WWE Wipo information: entry into national phase

Ref document number: 14442066

Country of ref document: US

WWE Wipo information: entry into national phase

Ref document number: 2013806128

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2015543258

Country of ref document: JP

Kind code of ref document: A