WO2014075428A1 - 一种用于替换缓存模块中数据的方法及装置 - Google Patents

一种用于替换缓存模块中数据的方法及装置 Download PDF

Info

Publication number
WO2014075428A1
WO2014075428A1 PCT/CN2013/074843 CN2013074843W WO2014075428A1 WO 2014075428 A1 WO2014075428 A1 WO 2014075428A1 CN 2013074843 W CN2013074843 W CN 2013074843W WO 2014075428 A1 WO2014075428 A1 WO 2014075428A1
Authority
WO
WIPO (PCT)
Prior art keywords
cache
quota
block
module
virtual machine
Prior art date
Application number
PCT/CN2013/074843
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 华为技术有限公司
Publication of WO2014075428A1 publication Critical patent/WO2014075428A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/15Use in a specific computing environment
    • G06F2212/151Emulated environment, e.g. virtual machine

Definitions

  • the present invention relates to a cache management technique in cloud computing, and more particularly to a method and apparatus for replacing data in a cache module.
  • a desktop cloud separates a personal computer desktop environment from a physical machine through a cloud computing mode, and becomes a service that can provide a desktop to the outside.
  • a desktop cloud system virtualized with a virtualization architecture (Xen)
  • the privileged domain ( Domain 0 ) in Xen virtualizes the CPU, input and output (10) bus, storage, etc. for the server.
  • the virtual machine domain ( Domain U ) in Xen is used.
  • many optimization softwares have designed a cache (Cache) module for Domain U in Domain 0.
  • the Cache module is used to cache the hotspot data of the mirrors used by each Domain U to reduce the input and output per second of the 10 pairs of remote storage generated by each Domain U using the mirrored data on the remote storage (Input and Output Per Second, IOPS). )pressure.
  • IOPS Input and Output Per Second
  • the capacity of the Cache module is small compared to tens of thousands, gigabytes, or even more data. It is often the case that new data entering the Cache module is cached in the Cache module. The old hotspot data is replaced, which causes the hit rate of each domain U to decrease in the Cache module, which seriously affects the performance of the mirror or virtual machine, thus seriously affecting the user experience.
  • the cache replacement algorithm is usually used to perform the preliminary replacement sorting of the cache blocks in the Cache module. Preparing the cache block that is replaced first. After the management module of the Cache module receives the new data block or the information to be written into the new data block, the cache unit used to prepare the cache block that is replaced first is used to store the new data block. The cache block that was replaced first is replaced. For example, the Least Recently Used (LRU) cache replacement algorithm caches data blocks in the Cache module.
  • LRU Least Recently Used
  • the LRU cache replacement algorithm can keep the most recently accessed data in the Cache module as much as possible, and replace the most recently unaccessed data with the Cache module, thereby improving the cache hit rate of the hotspot data in the Cache module, and reducing the cache hit rate by 10 ring Time should be, improve user experience
  • the existing cache replacement algorithm treats all 10 access behaviors of the Cache equally, and manages all 10 access events with the same policy.
  • each process contends to use the Cache space to store its own use. The data.
  • the access behavior of each process is different. Some processes prefer to use the Cache that is already their own. Some processes will rob the Cache used by other processes and affect the execution of other processes.
  • the data blocks they read for 10 accesses may occupy a larger amount of Cache space. For example, according to the characteristics of the LRU replacement algorithm, this may cause other temporarily relatively less active images to be in the Cache.
  • the data in the module is replaced by a large number of Cache modules. In this way, after the data block in the Cache module is replaced, most of the data stored in the Cache module is the hotspot data of the image. If the mirror is not active for a certain period of time, it is caused by the frequent 10 behaviors of other active images. If the hotspot data of this image is replaced by the Cache, the hit rate of the image in the cache is seriously degraded, and the response delay of the image 10 is increased, thereby reducing the processing performance of the image and affecting the user experience.
  • the embodiments of the present invention provide a method and an apparatus for replacing data in a cache module, which are used to solve the problem that the cache space of a mirror or a virtual machine with different degrees of activity is unbalanced.
  • a first aspect of the embodiments of the present invention provides a method for replacing data in a cache module, including: receiving new data blocks or writing information of new data blocks to a cache module; occupying a space of the cache module a cache block is selected as a preliminary replacement block according to the quota; the cache block is a data block stored in the cache module; and the preliminary replacement block is replaced by the new data block. .
  • Another aspect of the embodiments of the present invention provides an apparatus for replacing data in a cache module, including: a data receiving module, configured to receive a new data block or write information of a new data block into a cache module; And in the case that the space of the cache module is occupied, selecting a cache block in the cache module according to the quota as a preliminary replacement block; the cache block is stored in the cache a data block in the module; a replacement module, configured to replace the preliminary replacement block with the new data block.
  • the method and apparatus for replacing data in a cache module provided by the embodiment of the present invention limit a cache block of a mirror or a virtual machine in a cache module by selecting a cache block in the cache module according to a quota as a preliminary replacement block.
  • the number of the mirrors or the virtual machine occupies a large amount of Cache module space, thereby solving the problem that the cache space of the mirror or virtual machine with different degrees of activity is not balanced.
  • FIG. 1 is a flow chart of a method for replacing data in a cache module according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a cache queue in a method for replacing data in a cache module according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an apparatus for replacing data in a cache module according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram and an application diagram of another apparatus for replacing data in a cache module according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of an application scenario of an apparatus for replacing data in a cache module according to an embodiment of the present disclosure
  • FIG. 6 is a process flow diagram of an apparatus for replacing data in a cache module according to an embodiment of the present invention.
  • Step 11 Receive a new data block or write information of a new data block to a cache module.
  • the management module of the cache module receives a new data block of a certain image or virtual machine, or receives information for writing a new data block into the cache module, and learns that a new data block is to be written into the cache module.
  • the information of writing a new data block to the cache module it can also be known which mirror or virtual machine the new data block to be written into the cache module comes from.
  • Step 12 In a case where the space of the cache module is occupied, a cache block is selected in the cache module according to the quota as a preliminary replacement block.
  • the cache block is a data block stored in the cache module, that is, the data block stored in the cache module is referred to as a cache block.
  • the cache of the new data block or the cache block of the virtual machine is prepared for the cache that is replaced first.
  • the number of mirrors or virtual machines This avoids the more active mirroring by limiting the number of cache blocks in the cache module or the virtual machine in the cache module, or limiting the number of cache units occupied by the mirror or virtual machine in the cache module.
  • the virtual machine occupies a large amount of Cache module space, and the hotspot data cached by other mirrors or virtual machines is replaced by the Cache module, and the performance of other mirrors or virtual machines is degraded.
  • the cache block in the quota range or the cache block in the virtual machine is prepared as the cache block that is replaced first.
  • the cache replacement algorithm On the basis of the cache replacement algorithm, the number of cache units that are limited to be smaller than the minimum quota or the cache block of the virtual machine is replaced by the Cache module, ensuring that the hot data of the inactive mirror or the virtual machine cache is not easily
  • the Cache module is replaced to effectively balance the buffer space occupied by each mirror or virtual machine to ensure the performance of each mirror or virtual machine.
  • the cache replacement algorithm may be an LRU cache replacement algorithm, may be a Most Recently Used (MRU) cache replacement algorithm, or may be other efficient cache replacement algorithms.
  • the cache block that is prepared to be replaced first is the cache block pointed to by the LRU end of the LRU cache replacement algorithm cache queue; for the MRU cache replacement algorithm, the cache block that is prepared to be replaced first is the MRU cache replacement algorithm cache queue.
  • the MRU side points to the cache block. According to other efficient
  • the cache replacement algorithm obtained by the cache replacement algorithm is similar to the cache block that is replaced first, and will not be described here. Step 13. Replace the above-mentioned preliminary replacement block with the above new data block.
  • the method further includes: calculating a maximum quota H and a minimum quota L of each mirror or virtual machine including the mirror or the virtual machine to which the new data block belongs, wherein the highest quota H and the lowest quota L are as described above.
  • This method realizes the dynamic adjustment of the cache quota by recalculating the mirrors or virtual machines of the cache module service after adding a mirror or a virtual machine, so that after the mirroring or virtual machine of the cache module service is added, each image of the cache module service or The virtual machine can still perform cache replacement based on the new quota, ensuring that the cache space of each mirror or virtual machine is balanced, and performance can still be guaranteed.
  • the method further includes: receiving a command to turn off the mirror or the virtual machine; according to the command, clearing the cache block indicating the closed mirror or the virtual machine, and calculating the maximum quota H and the minimum quota L of the remaining mirror or the virtual machine, wherein the highest quota H and The minimum quota L is detailed in the above description.
  • the foregoing embodiment is directed to the problem that when one or several mirrors or virtual machines are active, the Cache module space may be occupied by a large amount, and the hotspot data cached by other mirrors or virtual machines is replaced by the Cache module.
  • the method of the cache quota management alleviates the problem that the performance of each image or virtual machine is unbalanced when the situation occurs.
  • a quota range is set for each mirror or virtual machine, and the number of cache blocks occupied by each mirror or virtual machine in the Cache module is limited, so that the hot data of the inactive mirror or the virtual machine cache is not lighted. Almost replace the Cache module, which effectively balances the cache space occupied by each image or virtual machine, ensuring the performance of each image or virtual machine.
  • the following describes a method for replacing data in a cache module by taking a cache replacement process with quota management for multiple images as an example.
  • the cache replacement algorithm is the LRU cache replacement algorithm.
  • the fixed quota method is used.
  • the maximum quota for each mirror is 4 and the minimum quota is 2.
  • the MRU end points to the latest cache block or the most recently accessed cache block in the Cache module.
  • the LRU cache replacement algorithm will cache the block information of the LRU end in the LRU cache queue. Move out, correspondingly delete the cache block pointed to by the LRU end of the LRU cache queue in the Cache module.
  • the LRU end points to the cache block that has not been accessed for the longest time in the Cache module. After deleting the cache block pointed to by the LRU end, the free space is used for the writing of the new data block, and this process is also called cache replacement.
  • the cache replacement algorithm is used for cache replacement. Assume that after a period of operation, the Cache module caches four cache blocks of mirror one, two cache blocks of mirror two, and three cache blocks of mirror three. Each cache block occupies one cache unit, which occupies a cache. The space of all 9 cache units of the module, namely the Cache module, is occupied. The order of these cache blocks in the LRU cache queue is shown in Figure 2. The LRU end points to the cache block of the mirror two, and the MRU end points to the cache block of the mirror one.
  • the preliminary replacement block is selected in the order from the LRU end to the MRU end.
  • the cache block pointed to by the LRU end of the LRU cache queue is mirrored, and the number of cache units occupied by the mirror 2 in the Cache module is 2, which is not higher than the minimum quota 2, so the next cache block is continuously acquired.
  • the next cache block is the cache block of the mirror one, and the number of cache units occupied by the mirror one in the Cache module is higher than the lowest quota 2, so the cache block of the mirror one is replaced with the new data block written.
  • the quota management makes the number of cache units occupied by each mirror in the Cache module not too much or too small, so as to balance the number of cache units of each mirror.
  • the following takes the setting of quota management in the scenario of the virtual desktop infrastructure (VDI) in the desktop cloud as an example to explain the implementation process of the data replacement method in the Cache module.
  • the Cache module is set up in the memory of Dom 0 in the Xen virtualization environment, and its total capacity is 4 GB, and each cache unit size is 4 KB (the total number of cache units I of the Cache module is 1 M), and the quota scaling factor b For 120%, the quota reduction factor s is 12%.
  • the LRU-side cache block of the mirror in the LRU cache queue refers to a cache block in the Cache module pointed to by the cache block information of the cache block of the cached block in the LRU cache queue starting from the LRU end.
  • the LRU-side cache block of the LRU cache queue refers to a cache block in the Cache module pointed to by the cache block information of the LUR end of the LRU cache queue.
  • the method of cache replacement is similar to the embodiment shown in FIG. 2. The foregoing embodiment performs the cache quota management in units of mirroring.
  • the technical solution provided by the foregoing embodiment may be extended to perform cache quota management in units of virtual machines using multiple mirrors.
  • the existing replacement algorithm may also be an MRU cache replacement algorithm, and may also be other efficient Cache cache replacement algorithms.
  • the aforementioned program can be stored in a computer readable storage medium. When the program is executed, the steps including the foregoing method embodiments are performed; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
  • FIG. 3 is a schematic structural diagram of an apparatus for replacing data in a cache module according to an embodiment of the present invention.
  • the device provided in this embodiment is used to implement the method provided in the embodiment shown in FIG. 1.
  • the device includes: a data receiving module 31, a replacement selecting module 32, and a replacement module 33.
  • the data receiving module 31 is configured to receive new data blocks or write information of new data blocks into the cache module.
  • the replacement selection module 32 is configured to select a cache block in the cache module according to the quota as a preliminary replacement block in the case that the space of the cache module is occupied; the cache block is a data block stored in the cache module.
  • the replacement module 33 is for replacing the above-mentioned preliminary replacement block with a new data block.
  • the replacement selection module 32 is specifically configured to: when the number of cache blocks of the mirror or the virtual machine to which the new data block belongs does not reach the maximum quota H, according to the cache replacement algorithm, the mirror or virtual machine cache in the quota range
  • the cache block that is replaced first is prepared as a preliminary replacement block;
  • the mirror or virtual machine in the quota range is a mirror or virtual machine whose number of cache units occupying the cache module is greater than the minimum quota L and less than the highest quota H.
  • the apparatus for replacing data in the cache module further includes: a first quota setting module, configured to mirror the mirror to which the new data block belongs or the cache block to which the virtual machine and the cache module belong If the virtual machine is different, the replacement selection module selects a cache block in the storage module according to the quota, and calculates the maximum quota of each image or virtual machine including the mirror or virtual machine to which the new data block belongs before the preliminary replacement block. H and minimum quota L.
  • the apparatus for replacing data in the cache module provided by the embodiment of the present invention further includes: a command receiving module and a second quota setting module.
  • the command receiving module is configured to: when the mirror or virtual machine to which the new data block belongs is different from the mirror or virtual machine to which the cache block in the cache module belongs, the replacement selection module selects a cache block in the storage module according to the quota, as a preliminary replacement. Before the block, it receives a command to close the mirror or virtual machine.
  • the second quota setting module is configured to: according to the command received by the command receiving module, clear the cache block of the mirror or the virtual machine that the command indicates to be closed, and calculate the highest quota H and the lowest quota of the remaining mirror or virtual machine.
  • s is the quota reduction factor, 0 ⁇ s ⁇ l
  • I is the number of mirrors or virtual machines served by the cache module.
  • the foregoing device embodiment performs the cache quota management by replacing the selection module, for example, the method of selecting a replacement block according to the quota, and mitigating that when one or several mirrors or virtual machines are active, the Cache module space may be occupied by a larger amount.
  • the hotspot data cached by other mirrors or virtual machines is replaced by the Cache module, causing imbalances in the cache space of each image or virtual machine.
  • a quota range is set for each mirror or virtual machine, and the number of cache blocks occupied by each mirror or virtual machine in the Cache module is limited, so that the hot data of the inactive mirror or the virtual machine cache is not easily replaced by the cache.
  • FIG. 4 is a schematic diagram of another structure and application of an apparatus for replacing data in a cache module according to an embodiment of the present invention.
  • the apparatus for replacing data in the cache module includes a cache capacity management module 41, a quota setting module 42, a quantity management module 43, a cache replacement module 44, a quota management module 45, and an addition and deletion management module 46.
  • the cache module may be a high-speed storage, such as a storage device with a storage speed and an IOPS much larger than that of an ordinary hard disk, such as a memory that does not support power-off protection, or a non-volatile random access memory device that supports power-off protection (Non - Volatile Random Access Memory (NVRAM), or a storage device such as a Solid State Disk (SSD) that can interoperate at high speed.
  • the cache module caches the images running in the desktop cloud VDI scenario. When quota management is performed on a mirror or virtual machine running in a desktop cloud VDI scenario, association operations are performed between modules. The association relationship is shown in Figure 4.
  • the cache capacity management module 41 is configured to acquire the number of cache units in the cache module from the cache module.
  • the quantity management module 43 is configured to obtain the number of running images or virtual machines from the desktop cloud VDI scenario.
  • the quota range may also be provided by the outside world to the quota setting module 42. In this case, the quota setting module 42 does not need to perform quota calculation.
  • the cache replacement module 44 caches the cache module with a cache replacement algorithm.
  • the cache replacement algorithm refers to a cache replacement algorithm of various replacement strategies, and may be an LRU cache replacement algorithm, an MRU cache replacement algorithm, or other efficient cache cache replacement algorithms.
  • the cache module In a desktop cloud VDI scenario using high-speed storage as a cache module, the cache module has an absolute advantage of fast data access speed compared to normal storage, but due to limited capacity, when the normal storage utilizes the cache module for data caching, data must exist.
  • block replacement in the process of writing the block contents into the cache module, when there is a free cache unit in the cache module, only the cache replacement module 44 is used for cache replacement.
  • the quota management module 45 adjusts the cache block replacement policy according to the mirror or the highest quota and the lowest quota set by the quota setting module 42.
  • This determination and adjustment process is an embodiment of the present invention.
  • the addition and deletion management module 46 is configured to obtain the information of the mirror or the virtual machine, or to determine whether the image or the virtual machine is added, that is, the addition and deletion management module 46 is configured to know whether the number of mirrors or virtual machines running in the desktop cloud VDI scenario changes. .
  • the quota setting module 42 re-calculates the quota range of each mirror or virtual machine running in the desktop cloud VDI scenario when the number of mirrors or virtual machines changes according to the addition/deletion management module 46. In this way, when adding/deleting a mirror or a virtual machine, the quota setting module 42 will dynamically adjust the quota range of the mirror or the virtual machine in the cache module, and then perform the mirroring or virtual machine cache block in the cache module according to the quota range. Cache scheduling management. When the mirroring or virtual machine is added or deleted in the desktop cloud VDI scenario, the number of mirrors in the desktop cloud VDI scenario changes, and the number of quotas of the mirrored data blocks in the cache module space is changed.
  • FIG. 5 is a schematic diagram of an application scenario of an apparatus for replacing data in a cache module according to an embodiment of the present invention.
  • the cache module and the replacement device 51 include a cache module and a device for replacing data in the cache module. That is, in this embodiment, the cache module and the data used in the cache module are replaced.
  • the device is integrated.
  • the cache module and the replacement device 51 are virtually obtained by the virtualization software system in the desktop cloud VDI technology on the server domain Domain 0, and provide a cache service for the image or virtual machine running on the domain U.
  • the processing flow of the cache module and the replacement device 51 is as shown in FIG. 6, and includes: Step 61: Write the data block into the cache module.
  • Step 63 The cache module and the replacing device 51 acquires a cache unit for storing a data block to be written into the cache module. Determine whether the cache unit is successfully obtained. If yes, go to step 64.
  • Step 64 Store the data block to be written in step 61 in the obtained cache unit, and update the cache information, and the data block is successfully written.
  • Step 65 The cache module and the replacing device 51 determines whether the mirror to which the data block to be written in step 61 or the number of cache blocks of the virtual machine in the cache module has reached the highest quota. If yes, go to step 66. Otherwise, go to step 67.
  • Step 66 The cache module and the replacing device 51 finds the cache block A that is prepared to be replaced first according to the cache replacement algorithm. The cache block A is from the mirror or virtual machine to which the data block to be written in step 61 belongs.
  • the storage unit occupied by the cache block A is used as a storage space for storing the data block in the step 61, and then the step is executed.
  • Step 69 The cache module and the replacing device 51 regard the storage unit occupied by the cache block B as the storage space of the data block in the preparation step 61, and then perform step 64.
  • Step 610 The cache module and the replacing device 51 find the cache block C information that is next to the cache block B to be replaced from the cache queue of the cache replacement algorithm, and then perform step 68 on the cache block, that is, replace the cache block B in step 68. For the cache block C, and so on, until the found cache block, such as the mirror to which the cache block D belongs, or the number of cache blocks of the virtual machine in the cache module is greater than the minimum quota, the storage unit occupied by the cache block D is stored in the preparation step 61. The storage space of the data block, and then go to step 64. In the case of the desktop cloud VDI scenario, multiple mirrors or virtual machines with different levels of activity are used.
  • the foregoing embodiment performs cache replacement according to quotas, which alleviates the problem that some active mirrors or virtual machines preempt a large amount of cache module space, and inactive mirrors or The hotspot data cached by the virtual machine is not easily replaced by the cache module, thereby effectively balancing the cache space of each image or virtual machine, and ensuring the performance of each image or virtual machine.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明提供一种用于替换缓存模块中数据的方法及装置,方法包括:接收新数据块或向缓存模块中写入新数据块的信息;在缓存模块的空间被占满的情况下,根据配额在所述缓存模块中选择一个缓存块,作为预备替换块;所述缓存块为存储在所述缓存模块中的数据块;用所述新数据块替换所述预备替换块。通过根据配额在所述缓存模块中选择一个缓存块,作为预备替换块,限制了镜像或虚拟机在缓存模块中的缓存块的数量,避免了较活跃的镜像或虚拟机较大量地占用Cache模块空间,从而解决了活跃程度不同的镜像或虚拟机的缓存空间不均衡的问题。

Description

一种用于替换緩存模块中数据的方法及装置 本申请要求于 2012 年 11 月 13 日提交中国专利局、 申请号为 201210453459.8、 发明名称为 "一种用于替换緩存模块中数据的方法及装置" 的中国专利申请的优先权, 其全部内容通过引用结合在本申请中。
技术领域 本发明涉及云计算中的緩存管理技术,尤其涉及一种用于替换緩存模块中 数据的方法及装置。
背景技术 桌面云是将个人计算机桌面环境通过云计算模式从物理机分离出来,成为 一种可以对外提供桌面的服务。 在使用一种虚拟化体系架构(Xen )虚拟化的 桌面云系统中, Xen中的特权域( Domain 0 )虚拟出 CPU、输入输出( Input and Output, 10 )总线、存储等资源,供服务器上的 Xen中的虚拟机域( Domain U ) 使用。 目前很多优化软件都在 Domain 0 中设计了针对 Domain U 的緩存 ( Cache )模块。 该 Cache模块用于緩存各个 Domain U所使用镜像的热点数 据, 以减少各个 Domain U使用远端存储上镜像的数据而产生的 10对远端存 储每秒输入输出量( Input and Output Per Second, IOPS )的压力。 但是, 由于 Cache模块的容量有限, 相对于每个镜像动辄几十、 上百 GB容量甚至更多的 数据来说容量很少, 经常会出现新进入 Cache模块的新数据把緩存在 Cache 模块中的老热点数据替换出去,造成各个 Domain U在 Cache模块中的命中率 降低, 严重影响了镜像或虚拟机的性能, 从而严重影响了用户体验。 针对各个 Domain U在 Cache模块中的命中率降低的问题, 目前通常釆用 緩存替换算法对 Cache模块中的緩存块进行预备替换排序。预备最先被替换的 緩存块在 Cache模块的管理模块接收到新数据块或要写入新数据块的信息后, 用预备最先被替换的緩存块占用的緩存单元存储新数据块,预备最先被替换的 緩存块被替换。 如最近最久使用 ( Least Recently Used, LRU )緩存替换算法 对 Cache模块内的数据块进行緩存管理。 该 LRU緩存替换算法能将最近最新 访问的数据尽可能地保留在 Cache模块中,而将最近最久未访问的数据替换出 Cache模块, 从而可提高热点数据在 Cache模块中的緩存命中率, 减少 10响 应时间, 提高用户体验 |。 但是, 现有的緩存替换算法将所有对 Cache的 10访问行为一视同仁, 以 相同的策略管理所有的 10访问事件, 当多个镜像的进程并发运行时, 各个进 程竟争使用 Cache空间, 存储自己使用的数据。 但各个进程的访存行为不同, 有的进程更倾向于使用已经属于自己的 Cache, 有的进程则会抢夺其它进程使 用的 Cache, 影响其他进程的执行。 当一个或几个镜像相对比较活跃时, 它们 进行 10访问读取的数据块可能会较大量地占用 Cache空间,如根据 LRU替换 算法的特点,这会导致其它暂时相对不太活跃的镜像在 Cache模块中的数据被 大量替换出 Cache模块。 这样,镜像緩存在 Cache模块中的数据块在经过一番 替换后, 留下来的大多是此镜像的热点数据, 若某一段时间镜像不活跃时, 如 果因其它活跃的镜像的频繁 10行为而导致此镜像的热点数据被替换出 Cache , 则会导致此镜像在緩存中的命中率严重下降, 并增加了该镜像 10响应时延, 从而降低了镜像的 10处理性能, 影响了用户体验。
发明内容 本发明实施例提供一种用于替换緩存模块中数据的方法及装置,用于解决 活跃程度不同的镜像或虚拟机的緩存空间不均衡的问题。 本发明实施例的第一个方面是提供一种用于替换緩存模块中数据的方法, 包括: 接收新数据块或向緩存模块中写入新数据块的信息; 在緩存模块的空间被占满的情况下,根据配额在所述緩存模块中选择一个 緩存块, 作为预备替换块; 所述緩存块为存储在所述緩存模块中的数据块; 用所述新数据块替换所述预备替换块。 本发明实施例的另一个方面是提供一种用于替换緩存模块中数据的装置, 包括: 数据接收模块, 用于接收新数据块或向緩存模块中写入新数据块的信息; 替换选择模块, 用于在緩存模块的空间被占满的情况下,根据配额在所述 緩存模块中选择一个緩存块,作为预备替换块; 所述緩存块为存储在所述緩存 模块中的数据块; 替换模块, 用于用所述新数据块替换所述预备替换块。 本发明实施例提供的用于替换緩存模块中数据的方法及装置,通过根据配 额在所述緩存模块中选择一个緩存块,作为预备替换块, 限制了镜像或虚拟机 在緩存模块中的緩存块的数量, 避免了较活跃的镜像或虚拟机较大量地占用 Cache模块空间, 从而解决了活跃程度不同的镜像或虚拟机的緩存空间不均衡 的问题。
附图说明
图 1为本发明实施例提供的一种用于替换緩存模块中数据的方法的流程 图;
图 2为本发明实施例提供的用于替换緩存模块中数据的方法中緩存队列的 示意图;
图 3为本发明实施例提供的一种用于替换緩存模块中数据的装置的结构示 意图;
图 4为本发明实施例提供的另一种用于替换緩存模块中数据的装置的结构 及应用示意图;
图 5为本发明实施例提供的用于替换緩存模块中数据的装置的应用场景示 意图;
图 6 为本发明实施例提供的用于替换緩存模块中数据的装置的处理流程 图。
具体实施方式 图 1为本发明实施例提供的一种用于替换緩存模块中数据的方法的流程 图。 如图 1所示, 该方法包括: 步骤 11、 接收新数据块或向緩存模块中写入新数据块的信息。 例如緩存模块的管理模块接收某一镜像或虚拟机的新数据块,或者接收向 緩存模块中写入新数据块的信息, 获知有新数据块要写入緩存模块。根据该向 緩存模块中写入新数据块的信息还可以获知即将写入緩存模块的新数据块来 自哪个镜像或虚拟机。 步骤 12、在緩存模块的空间被占满的情况下,根据配额在该緩存模块中选 择一个緩存块,作为预备替换块。其中,緩存块为存储在緩存模块中的数据块, 即緩存模块中存储的数据块均称为緩存块。 例如当上述新数据块所属的镜像或虚拟机的緩存块的数量达到最高配额 H时, 按照緩存替换算法, 将该新数据块所属的镜像或虚拟机的緩存块中预备 最先被替换的緩存块作为预备替换块; 其中, 最高配额H=N χ b/I, N为緩存模 块中的緩存单元的数量, 该緩存单元为一个緩存块占用的空间, b>l , I为该緩 存模块服务的镜像或虚拟机的数量。这种在緩存替换算法的基础上,通过限制 镜像或虚拟机在緩存模块中的緩存块的数量,或者说限制镜像或虚拟机在緩存 模块中占用的緩存单元的数量, 避免了较活跃的镜像或虚拟机较大量地占用 Cache模块空间, 导致的其它镜像或虚拟机緩存的热点数据被替换出 Cache模 块, 而产生的其他镜像或虚拟机性能下降的问题。 当上述新数据块所属的镜像或虚拟机的緩存块的数量未达到最高配额 H 时,按照緩存替换算法,将配额范围内的镜像或虚拟机的緩存块中预备最先被 替换的緩存块作为预备替换块;该配额范围内的镜像或虚拟机为占用緩存模块 的緩存单元的数量大于最低配额 L且小于最高配额 H的镜像或虚拟机; 其中, 最高配额H=N χ b/I同上述最高配额 H, 最低配额L=N χ s/I, N同上述 N, 为緩 存模块中的緩存单元的数量, 緩存单元为一个緩存块占用的空间, b为配额比 例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为緩存模块服务的镜像或 虚拟机的数量。这种在緩存替换算法的基础上, 限制占用的緩存单元的数量小 于最低配额的镜像或虚拟机的緩存块被替换出 Cache模块, 保证了不活跃镜像 或虚拟机緩存的热点数据不被轻易地替换出 Cache模块, 有效地均衡了各镜像 或虚拟机占用的緩存空间, 保证了各镜像或虚拟机的性能。 其中, 緩存替换算法可为 LRU緩存替换算法, 可为最新最近使用 (Most Recently Used, MRU )緩存替换算法, 也可为其他高效的緩存替换算法。 对于 LRU緩存替换算法 ,预备最先被替换的緩存块是 LRU緩存替换算法緩 存队列的 LRU端指向的緩存块; 对于 MRU緩存替换算法, 预备最先被替换的 緩存块是 MRU緩存替换算法緩存队列的 MRU端指向的緩存块。 根据其他高效 的緩存替换算法得到的预备最先被替换的緩存块类似, 这里不再赘述。 步骤 13、 用上述新数据块替换上述预备替换块。
可选地,在上述新数据块所属的镜像或虚拟机与緩存模块中的緩存块所属 的镜像或虚拟机不同的情况下,根据配额在存储模块中选择一个緩存块,作为 预备替换块之前, 还包括: 计算包括上述新数据块所属的镜像或虚拟机在内的各镜像或虚拟机的最 高配额 H和最低配额 L, 其中, 最高配额 H和最低配额 L详见上述说明。 这种通过在新增镜像或虚拟机后重新计算緩存模块服务的各镜像或虚拟 机, 实现了緩存配额的动态调整, 使得緩存模块服务的镜像或虚拟机增加后, 緩存模块服务的各镜像或虚拟机仍能够根据新的配额进行緩存替换,保证各镜 像或虚拟机的緩存空间均衡, 性能仍能够得到保障。 可选地,在上述新数据块所属的镜像或虚拟机与緩存模块中的緩存块所属 的镜像或虚拟机不同的情况下,根据配额在存储模块中选择一个緩存块,作为 预备替换块之前, 还包括: 接收指示关闭镜像或虚拟机的命令; 根据该命令清除指示关闭的镜像或虚拟机的緩存块,并计算剩余镜像或虚 拟机的最高配额 H和最低配额 L,其中,最高配额 H和最低配额 L详见上述说明。 这种通过在关闭某一或某些镜像或虚拟机后重新计算緩存模块服务的各镜像 或虚拟机, 实现了緩存配额的动态调整,使得緩存模块服务的某一或某些镜像 或虚拟机关闭后, 剩余的镜像或虚拟机仍能够根据新的配额进行緩存替换,保 证各镜像或虚拟机的緩存空间均衡, 性能仍能够得到保障。 上述实施例针对当某一个或几个镜像或虚拟机比较活跃时,可能会较大量 地占用 Cache模块空间, 而导致其它镜像或虚拟机緩存的热点数据被替换出 Cache模块的问题, 通过釆用緩存配额管理的方法, 如根据配额选择预备替换 块的方法, 减轻这种情况发生时引起的各镜像或虚拟机性能不均衡的问题。具 体地, 对每一个镜像或虚拟机设置配额范围, 限制每个镜像或虚拟机在 Cache 模块中占用的緩存块的数量,使得不活跃镜像或虚拟机緩存的热点数据不被轻 易地替换出 Cache模块, 从而有效地均衡了各镜像或虚拟机占用的緩存空间, 保证了各镜像或虚拟机的性能。 下面以对多个镜像进行带配额管理的緩存替换过程为例对用于替换緩存 模块中数据的方法进行说明。 假设 Cache模块总容量空间大小为 9个緩存单元, 所服务的镜像有 3个, 緩 存替换算法为 LRU緩存替换算法, 釆用固定配额方式,每个镜像的最大配额为 4, 最小配额为 2。 当数据块写入该 Cache模块时,如果 Cache模块中有空闲的緩存单元, 直接 从空闲的緩存单元中获取用于存储新写入数据块的緩存单元,在获取的緩存单 元中写入新的数据块。新写入的数据块成为新的緩存块, 将新的緩存块的信息 如标识信息从 LRU替换算法緩存队列 (以下简称 LRU緩存队列) 中的 MRU端 插入, 如图 2所示。 其中, MRU端指向 Cache模块中最新的緩存块或最近被访 问的緩存块。 当 Cache模块空间满即没有空闲的緩存单元时, 在没有配额管理 的情况下, 如果有新的数据块要写入 Cache模块时, LRU緩存替换算法将会把 LRU緩存队列中 LRU端的緩存块信息移出, 相应地删除 Cache模块中 LRU緩存 队列的 LRU端指向的緩存块。 其中, LRU端指向 Cache模块中最久未被访问的 緩存块。 删除该 LRU端指向的緩存块后, 腾出的空间用于新的数据块的写入, 这个过程也叫緩存替换。 在 Cache模块空间未占满即 Cache模块中有空闲緩存单元的情况下,釆用上 述緩存替换算法进行緩存替换。 假设经过一段时间运行后, Cache模块中緩存 了镜像一的 4个緩存块、 镜像二的 2个緩存块和镜像三的 3个緩存块, 每个緩存 块占用 1个緩存单元,共占用了 Cache模块的所有 9个緩存单元即 Cache模块的空 间被占满。 这些緩存块在 LRU緩存队列中的顺序如图 2所示, LRU端指向的是 镜像二的緩存块, MRU端指向的是镜像一的緩存块。 当再往该 Cache模块中写入新的数据块时: 若写入的新的数据块来自于镜像一, 由于镜像一在 Cache模块中的緩存块 数量已经达到最高配额 4, 因此, 虽然 LRU替换算法緩存队列中的 LRU端指向 的是镜像二的緩存块, 但是镜像二的緩存块不会被替换出 Cache模块, 而是从 LRU緩存队列中的 LRU端起查找镜像一的緩存块, 进行緩存替换, 即用新的数 据块替换从 LRU端开始的指向的第一个镜像一的緩存块。 图 2中为与 LRU端相 应的緩存块信息指向的镜像一的緩存块。 若写入的新的数据块来自镜像三, 由于镜像三在 Cache模块中占用的緩存 单元数量未达到最高配额 4, 因此, 按照从 LRU端到 MRU端的顺序选择预备替 换块。 由于获取得到 LRU緩存队列中的 LRU端指向的緩存块是镜像二的, 而镜 像二在 Cache模块中占用的緩存单元数量为 2 , 不高于最低配额 2 , 因此继续获 取下一个緩存块。 下一个緩存块是镜像一的緩存块, 而镜像一在 Cache模块中 占用的緩存单元数量高于最低配额 2 , 因此, 用写入的新的数据块替换该镜像 一的緩存块。 从上面的示例可以看出: 配额管理使得各镜像在 Cache模块中占用的緩存 单元数量不会太多也不会太少, 从而达到均衡各镜像的緩存单元数量的特性。 下面再以在桌面云虚拟桌面架构( Virtual Desktop Infrastructure , VDI )场 景中进行带配额管理的设置为例, 对 Cache模块中的数据替换方法的实施过程 进行说明。 设 Cache模块在 Xen虚拟化环境中 Dom 0的内存中建立, 其总容量为 4GB, 每个緩存单元大小为 4KB (则该 Cache模块总的緩存单元数量 I为 1M个), 配额 比例放大系数 b为 120%, 配额比例缩小系数 s为 12%, 当另外一个域上运行有 4个镜像时, 每个镜像的最高配额为 1M 120%/4=307.2K, 最低配额为 1M 12%/4=30.72Κ。 在 Cache模块空间未占满的情况下, 釆用緩存替换算法如 LRU替换算法进 行緩存替换。 假设经过一段时间运行后, 每个镜像都分别占用了 1M/4=256K个緩存单 元, Cache模块中緩存了各个镜像中的热点数据。 此时, 即使某个镜像比较活 跃, 它也最多只能占用 307.2K个緩存单元。 当某个镜像达到这个最高配额时, 若再要向 Cache模块中加入来自该镜像的新的数据块, 就要用 LRU緩存队列中 该镜像的 LRU端緩存块进行替换,而不是用 LRU緩存队列的 LRU端緩存块进行 替换。 其中, LRU緩存队列中该镜像的 LRU端緩存块是指, LRU緩存队列中从 LRU端开始, 第一个指向该镜像的緩存块的緩存块信息指向的 Cache模块中的 緩存块。 LRU緩存队列的 LRU端緩存块是指, LRU緩存队列的 LUR端的緩存块 信息指向的 Cache模块中的緩存块。 这样, 即使某个镜像比较空闲, 它至少也能保证占用 30.72K个緩存单元来 保存它的热点数据,而这些緩存单元中的緩存块不会被其它镜像的数据块替换 出 Cache模块, 从而保障了这个镜像的性能。 当添加或删除镜像时, 配额范围进行动态变化。 以增加 1个镜像为例, 新 的镜像数量为 5 , 新的最高配额为 1M X 120%/5=245.76K, 最低配额为 1M χ 12%/5=24.576Κ, 此时再按新的最高配额和最低配额进行緩存替换。 緩存替换 的方法与图 2所示的实施例类似。 上述实施例以镜像为单位进行緩存配额管理, 类似地, 上述实施例提供的 技术方案还可扩展为以使用多个镜像的虚拟机为单位进行緩存配额管理。 上述实施例中, 现有替换算法也可以是 MRU緩存替换算法, 还可以是其 它高效的 Cache緩存替换算法。 本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤 可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取 存储介质中。 该程序在执行时, 执行包括上述各方法实施例的步骤; 而前述的 存储介质包括: ROM, RAM,磁碟或者光盘等各种可以存储程序代码的介质。 图 3为本发明实施例提供的一种用于替换緩存模块中数据的装置的结构示 意图。 本实施例提供的装置用于实现图 1所示实施例提供的方法, 如图 3所示, 该装置包括: 数据接收模块 31、 替换选择模块 32和替换模块 33。 数据接收模块 31用于接收新数据块或向緩存模块中写入新数据块的信息。 替换选择模块 32用于在緩存模块的空间被占满的情况下,根据配额在该緩存模 块中选择一个緩存块,作为预备替换块; 该緩存块为存储在该緩存模块中的数 据块。 替换模块 33用于用新数据块替换上述预备替换块。 可选地,替换选择模块 32具体用于: 当新数据块所属的镜像或虚拟机的緩 存块的数量达到最高配额 H时, 按照緩存替换算法, 将新数据块所属的镜像或 虚拟机的緩存块中预备最先被替换的緩存块作为预备替换块; 其中, 最高配额 H=N x b/I, N为緩存模块中的緩存单元的数量, 緩存单元为一个緩存块占用的 空间, b为配额比例放大系数, b>l , I为緩存模块服务的镜像或虚拟机的数量。 可选地,替换选择模块 32具体用于: 当新数据块所属的镜像或虚拟机的緩 存块的数量未达到最高配额 H时, 按照緩存替换算法, 将配额范围内的镜像或 虚拟机的緩存块中预备最先被替换的緩存块作为预备替换块;该配额范围内的 镜像或虚拟机为占用緩存模块的緩存单元的数量大于最低配额 L且小于最高配 额 H的镜像或虚拟机。 其中, 最高配额H=N χ b/I, 最低配额L=N χ s/I, N为緩 存模块中的緩存单元的数量, 緩存单元为一个緩存块占用的空间, b为配额比 例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为緩存模块服务的镜像或 虚拟机的数量。
可选地, 本发明实施例提供的用于替换緩存模块中数据的装置还包括: 第 一配额设置模块,用于在新数据块所属的镜像或虚拟机与緩存模块中的緩存块 所属的镜像或虚拟机不同的情况下,替换选择模块根据配额在存储模块中选择 一个緩存块,作为预备替换块之前,计算包括新数据块所属的镜像或虚拟机在 内的各镜像或虚拟机的最高配额 H和最低配额 L。 其中, 最高配额H=N χ b/I, 最低配额L=N χ s/I, N为緩存模块中的緩存单元的数量, 緩存单元为一个緩存 块占用的空间, b为配额比例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为緩存模块服务的镜像或虚拟机的数量。
可选地, 本发明实施例提供的用于替换緩存模块中数据的装置还包括: 命 令接收模块和第二配额设置模块。
命令接收模块用于在新数据块所属的镜像或虚拟机与緩存模块中的緩存 块所属的镜像或虚拟机不同的情况下,替换选择模块根据配额在存储模块中选 择一个緩存块, 作为预备替换块之前, 接收指示关闭镜像或虚拟机的命令。
第二配额设置模块用于根据命令接收模块接收的命令,清除该命令指示关 闭的镜像或虚拟机的緩存块, 并计算剩余镜像或虚拟机的最高配额 H和最低配 额 。 其中, 最高配额H=N χ b/I, 最低配额L=N χ s/I, N为緩存模块中的緩存 单元的数量, 该緩存单元为一个緩存块占用的空间, b为配额比例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为緩存模块服务的镜像或虚拟机的数量。 上述装置实施例通过替换选择模块进行緩存配额管理,如根据配额选择预 备替换块的方法, 减轻当某一个或几个镜像或虚拟机比较活跃时, 可能会较大 量地占用 Cache模块空间, 而导致其它镜像或虚拟机緩存的热点数据被替换出 Cache模块时引起的各镜像或虚拟机緩存空间不均衡的问题。 具体地, 对每一 个镜像或虚拟机设置配额范围, 限制每个镜像或虚拟机在 Cache模块中占用的 緩存块的数量, 使得不活跃镜像或虚拟机緩存的热点数据不被轻易地替换出 Cache模块, 从而有效地均衡了各镜像或虚拟机占用的緩存空间, 保证了各镜 像或虚拟机的性能。 图 4为本发明实施例提供的另一种用于替换緩存模块中数据的装置的结构 及应用示意图。 如图 4所示, 用于替换緩存模块中数据的装置包括緩存容量管 理模块 41、 配额设置模块 42、 数量管理模块 43、 緩存替换模块 44、 配额管理模 块 45和增删管理模块 46。 其中, 緩存模块可以是高速存储, 如存储速度和 IOPS远大于普通硬盘的 存储设备, 如不支持断电保护的内存, 或者如支持断电保护的非易失性随机访 问存 4诸器 (Non- Volatile Random Access Memory, NVRAM ) , 或者如高速固 态硬盘( Solid State Disk, SSD )等可以进行高速交互操作的存储设备。 该緩存模块为运行在桌面云 VDI场景中的镜像进行緩存服务。 当对桌面云 VDI场景中运行的镜像或虚拟机进行配额管理时, 各个模块之间将进行关联操 作, 关联关系如图 4中所示。 緩存容量管理模块 41用于从緩存模块获取该緩存模块中緩存单元的数量。 数量管理模块 43用于从桌面云 VDI场景中获取运行的镜像或虚拟机的数 量。 配额设置模块 42根据緩存容量管理模块 41获取的緩存模块中緩存单元的 数量以及数量管理模块 43获取的镜像或虚拟机的数量,设置各镜像或虚拟机的 配额范围。 假设緩存模块总容量大小为 M, 每个緩存单元大小为 K (则緩存单 元数量 Ν = Μ/Κ ) , 镜像数量为 I, 配额比例放大系数为 b, 配额比例缩小系数 为8。 当镜像数量 1>0, 则最高配额为 H=N x b/I, 最低配额数量为L=N χ s/I, 当 镜像数量 I发生变化时, 则最高配额 H和最低配额 L将随之变化。 若要固定配额 时, 可根据实际情况确定各镜像或虚拟机的最高配额和最低配额。 其中配额范围也可由外界提供给配额设置模块 42, 这种情况下, 配额设置 模块 42不需要进行配额计算。 緩存替换模块 44釆用緩存替换算法对緩存模块进行緩存替换。緩存替换算 法是指各种不同替换策略的緩存替换算法, 可以是 LRU緩存替换算法,也可以 是 MRU緩存替换算法, 还可以是其它高效的 Cache緩存替换算法。 在使用高速存储用作緩存模块的桌面云 VDI场景中, 緩存模块相对于普通 存储具有数据访问速度快的绝对优势,但由于容量有限, 当普通存储利用緩存 模块用于数据緩存时, 必然存在数据块替换的情况,在将块内容写入緩存模块 的过程中,緩存模块中有空闲緩存单元时,仅使用緩存替换模块 44进行緩存替 换即可。緩存模块中没有空闲緩存单元时, 配额管理模块 45根据配额设置模块 42设置的镜像或虚拟机的最高配额和最低配额, 对緩存块的替换策略进行调 整, 这个判定和调整过程是本发明实施例的关键部分。 增删管理模块 46用于获取关闭镜像或虚拟机的信息,或者判断镜像或虚拟 机是否增加了, 也即增删管理模块 46用来获知桌面云 VDI场景中运行的镜像或 虚拟机的数量是否有变化。 配额设置模块 42设置模块根据增删管理模块 46获知镜像或虚拟机的数量 发生变化时, 重新计算桌面云 VDI场景中运行的各镜像或虚拟机的配额范围。 这样, 当添加 /删除镜像或虚拟机时, 配额设置模块 42将会动态调整镜像或虚 拟机在緩存模块中的配额范围,然后根据该配额范围对镜像或虚拟机在緩存模 块中的緩存块进行緩存调度管理。 当桌面云 VDI场景下镜像或虚拟机进行添加 /删除时, 都会导致此桌面云 VDI场景下镜像数量的变化, 而引起镜像的数据块在緩存模块空间内配额数量 的变化, 当将数据块准备写入緩存模块中时, 不仅要釆用緩存替换算法, 还要 进行配额管理。 其中, 配额设置模块 42、 数量管理模块 43、 緩存替换模块 44和配额管理模 块 45实现的是上述替换选择模块和替换模块的功能 ,只是定义和功能划分不同 而已。 上述用于替换緩存模块中数据的装置可与緩存模块设置为一体, 如图 5所 示。 图 5为本发明实施例提供的用于替换緩存模块中数据的装置的应用场景示 意图。 如图 5所示, 緩存模块及替换装置 51包括緩存模块及用于替换该緩存模 块中的数据的装置, 也就是说, 本实施例中, 緩存模块及用于替换该緩存模块 中的数据的装置为一体设置。 緩存模块及替换装置 51由桌面云 VDI技术中的虚拟化软件系统在服务器 域 Domain 0上虚拟得到, 为 Domain U上运行的镜像或虚拟机提供緩存服务。 当将镜像的新数据块准备写入緩存模块时 ,緩存模块及替换装置 51的处理 流程如图 6所示, 包括: 步骤 61、 将数据块准备写入緩存模块中。 步骤 62、緩存模块及替换装置 51判断是否緩存模块剩余空间 >0 , 若是, 执 行步骤 63 , 否则, 执行步骤 65。 步骤 63、緩存模块及替换装置 51获取緩存单元, 用来存储准备写入緩存模 块的数据块。 判断获取緩存单元是否成功, 若是, 执行步骤 64, 否则, 写入数 据块失败。 步骤 64、在获取的緩存单元中存储步骤 61准备写入的数据块, 并更新緩存 信息, 写入数据块成功。 步骤 65、緩存模块及替换装置 51判断步骤 61准备写入的数据块所属的镜像 或虚拟机在緩存模块中的緩存块数量是否已达到最高配额,若是,执行步骤 66, 否则, 执行步骤 67。 步骤 66、緩存模块及替换装置 51按照緩存替换算法找到预备最先被替换的 緩存块 A, 緩存块 A来自步骤 61准备写入的数据块所属的镜像或虚拟机。 将緩 存块 A占用的存储单元作为准备存储步骤 61中数据块的存储空间, 然后执行步 骤 64。 步骤 67、緩存模块及替换装置 51按照緩存替换算法找到预备最先被替换的 緩存块 B。 步骤 68、 緩存模块及替换装置 51判断緩存块 B所属的镜像或虚拟机在緩存 模块中的緩存块数量是否大于最低配额, 若是, 执行步骤 69, 否则, 执行步骤 610。 步骤 69、 緩存模块及替换装置 51将緩存块 B占用的存储单元作为准备写入 步骤 61中数据块的存储空间, 然后执行步骤 64。 步骤 610、 緩存模块及替换装置 51从緩存替换算法的緩存队列中找到次于 緩存块 B预备被替换的緩存块 C信息, 然后对緩存块〇执行步骤 68, 即将步骤 68 中的緩存块 B替换为緩存块 C,依次类推,直到找到的緩存块如緩存块 D所属的 镜像或虚拟机在緩存模块中的緩存块数量大于最低配额, 将该緩存块 D占用的 存储单元作为准备存储步骤 61中数据块的存储空间, 然后执行步骤 64。 对应桌面云 VDI场景下, 多个活跃程度的不一样镜像或虚拟机, 上述实施 例根据配额进行緩存替换,减轻了部分活跃的镜像或虚拟机抢占大量緩存模块 空间的问题,让不活跃镜像或虚拟机緩存的热点数据不被轻易地替换出緩存模 块,从而有效地均衡了各镜像或虚拟机的緩存空间,保证了各镜像或虚拟机的 性能。
最后应说明的是: 以上各实施例仅用以说明本发明的技术方案, 而非对其 限制; 尽管参照前述各实施例对本发明进行了详细的说明, 本领域的普通技术 人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修改, 或者 对其中部分或者全部技术特征进行等同替换; 而这些修改或者替换, 并不使相 应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims

权 利 要 求
1、 一种用于替换緩存模块中数据的方法, 其特征在于, 包括: 接收新数据块或向緩存模块中写入新数据块的信息; 在緩存模块的空间被占满的情况下,根据配额在所述緩存模块中选择一个 緩存块, 作为预备替换块; 所述緩存块为存储在所述緩存模块中的数据块; 用所述新数据块替换所述预备替换块。
2、 根据权利要求 1所述方法, 其特征在于, 根据配额在所述存储模块中选 择一个緩存块, 作为预备替换块, 包括: 当所述新数据块所属的镜像或虚拟机的緩存块的数量达到最高配额 H时, 按照緩存替换算法,将所述新数据块所属的镜像或虚拟机的緩存块中预备最先 被替换的緩存块作为预备替换块; 其中, 所述最高配额 H=N x b/I, N为所述緩 存模块中的緩存单元的数量, 所述緩存单元为一个緩存块占用的空间, b为配 额比例放大系数, b>l , I为所述緩存模块服务的镜像或虚拟机的数量。
3、 根据权利要求 1所述方法, 其特征在于, 根据配额在所述存储模块中选 择一个緩存块, 作为预备替换块, 包括: 当所述新数据块所属的镜像或虚拟机的緩存块的数量未达到最高配额 H 时,按照緩存替换算法,将配额范围内的镜像或虚拟机的緩存块中预备最先被 替换的緩存块作为预备替换块;所述配额范围内的镜像或虚拟机为占用所述緩 存模块的緩存单元的数量大于最低配额 L且小于最高配额 H的镜像或虚拟机; 其中, 所述最高配额 H=N x b/I, 所述最低配额 L=N x s/I, N为所述緩存模块中 的緩存单元的数量, 所述緩存单元为一个緩存块占用的空间, b为配额比例放 大系数, b>l , s为配额比例缩小系数, 0<s<l , I为所述緩存模块服务的镜像或 虚拟机的数量。
4、 根据权利要求 1-3任一项所述方法, 其特征在于, 在所述新数据块所属 的镜像或虚拟机与所述緩存模块中的緩存块所属的镜像或虚拟机不同的情况 下, 根据配额在所述存储模块中选择一个緩存块, 作为预备替换块之前, 还包 括: 计算包括所述新数据块所属的镜像或虚拟机在内的各镜像或虚拟机的最 高配额 H和最低配额 L, 其中, 所述最高配额 H=N x b/I, 所述最低配额 L=N x s/I, N为所述緩存模块中的緩存单元的数量, 所述緩存单元为一个緩存块占用 的空间, b为配额比例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为所 述緩存模块服务的镜像或虚拟机的数量。
5、 根据权利要求 1-3任一项所述方法, 其特征在于, 在所述新数据块所属 的镜像或虚拟机与所述緩存模块中的緩存块所属的镜像或虚拟机不同的情况 下, 根据配额在所述存储模块中选择一个緩存块, 作为预备替换块之前, 还包 括: 接收指示关闭镜像或虚拟机的命令; 根据所述命令清除指示关闭的镜像或虚拟机的緩存块 ,并计算剩余镜像或 虚拟机的最高配额 H和最低配额 L, 其中, 所述最高配额 H=N x b/I, 所述最低 配额 L=N x s/I, N为所述緩存模块中的緩存单元的数量, 所述緩存单元为一个 緩存块占用的空间, b为配额比例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为所述緩存模块服务的镜像或虚拟机的数量。
6、 一种用于替换緩存模块中数据的装置, 其特征在于, 包括: 数据接收模块, 用于接收新数据块或向緩存模块中写入新数据块的信息; 替换选择模块, 用于在緩存模块的空间被占满的情况下,根据配额在所述 緩存模块中选择一个緩存块,作为预备替换块; 所述緩存块为存储在所述緩存 模块中的数据块; 替换模块, 用于用所述新数据块替换所述预备替换块。
7、 根据权利要求 6所述装置, 其特征在于, 所述替换选择模块具体用于: 当所述新数据块所属的镜像或虚拟机的緩存块的数量达到最高配额 H时, 按照 緩存替换算法,将所述新数据块所属的镜像或虚拟机的緩存块中预备最先被替 换的緩存块作为预备替换块; 其中, 所述最高配额 H=N x b/I, N为所述緩存模 块中的緩存单元的数量, 所述緩存单元为一个緩存块占用的空间, b为配额比 例放大系数, b>l , I为所述緩存模块服务的镜像或虚拟机的数量。
8、 根据权利要求 6所述装置, 其特征在于, 所述替换选择模块具体用于: 当所述新数据块所属的镜像或虚拟机的緩存块的数量未达到最高配额 H时, 按 照緩存替换算法,将配额范围内的镜像或虚拟机的緩存块中预备最先被替换的 緩存块作为预备替换块;所述配额范围内的镜像或虚拟机为占用所述緩存模块 的緩存单元的数量大于最低配额 L且小于最高配额 H的镜像或虚拟机; 其中, 所述最高配额 H=N x b/I, 所述最低配额 L=N x s/I, N为所述緩存模块中的緩存 单元的数量, 所述緩存单元为一个緩存块占用的空间, b为配额比例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为所述緩存模块服务的镜像或虚拟机的 数量。
9、 根据权利要求 6-8任一项所述装置, 其特征在于, 还包括:
第一配额设置模块,用于在所述新数据块所属的镜像或虚拟机与所述緩存 模块中的緩存块所属的镜像或虚拟机不同的情况下 ,所述替换选择模块根据配 额在所述存储模块中选择一个緩存块,作为预备替换块之前,计算包括所述新 数据块所属的镜像或虚拟机在内的各镜像或虚拟机的最高配额 H和最低配额 L, 其中, 所述最高配额 H=N x b/I, 所述最低配额 L=N x s/I, N为所述緩存模 块中的緩存单元的数量, 所述緩存单元为一个緩存块占用的空间, b为配额比 例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为所述緩存模块服务的镜 像或虚拟机的数量。
10、 根据权利要求 6-8任一项所述装置, 其特征在于, 还包括:
命令接收模块,用于在所述新数据块所属的镜像或虚拟机与所述緩存模块 中的緩存块所属的镜像或虚拟机不同的情况下,所述替换选择模块根据配额在 所述存储模块中选择一个緩存块,作为预备替换块之前,接收指示关闭镜像或 虚拟机的命令;
第二配额设置模块,用于根据所述命令清除指示关闭的镜像或虚拟机的緩 存块, 并计算剩余镜像或虚拟机的最高配额 H和最低配额 L, 其中, 所述最高 配额 H=N x b/I, 所述最低配额 L=N x s/I, N为所述緩存模块中的緩存单元的 数量, 所述緩存单元为一个緩存块占用的空间, b为配额比例放大系数, b>l , s为配额比例缩小系数, 0<s<l , I为所述緩存模块服务的镜像或虚拟机的数量。
PCT/CN2013/074843 2012-11-13 2013-04-27 一种用于替换缓存模块中数据的方法及装置 WO2014075428A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210453459.8 2012-11-13
CN2012104534598A CN102999444A (zh) 2012-11-13 2012-11-13 一种用于替换缓存模块中数据的方法及装置

Publications (1)

Publication Number Publication Date
WO2014075428A1 true WO2014075428A1 (zh) 2014-05-22

Family

ID=47928034

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/074843 WO2014075428A1 (zh) 2012-11-13 2013-04-27 一种用于替换缓存模块中数据的方法及装置

Country Status (2)

Country Link
CN (1) CN102999444A (zh)
WO (1) WO2014075428A1 (zh)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999444A (zh) * 2012-11-13 2013-03-27 华为技术有限公司 一种用于替换缓存模块中数据的方法及装置
CN104461928B (zh) * 2013-09-16 2018-11-16 华为技术有限公司 划分高速缓存的方法及装置
CN104331492B (zh) * 2014-11-14 2017-11-21 北京国双科技有限公司 一种缓存多实例数据的方法及装置
CN104503703B (zh) * 2014-12-16 2018-06-05 华为技术有限公司 缓存的处理方法和装置
GB2540761B (en) * 2015-07-23 2017-12-06 Advanced Risc Mach Ltd Cache usage estimation
CN108073527B (zh) * 2016-11-07 2020-02-14 华为技术有限公司 一种缓存替换的方法和设备
CN106897442A (zh) * 2017-02-28 2017-06-27 郑州云海信息技术有限公司 一种分布式文件系统用户配额预分配方法及分配系统
CN108932150B (zh) * 2017-05-24 2023-09-15 中兴通讯股份有限公司 基于ssd和磁盘混合存储的缓存方法、装置及介质
CN111625678A (zh) * 2019-02-28 2020-09-04 北京字节跳动网络技术有限公司 信息处理方法、装置和计算机可读存储介质
CN110096333B (zh) * 2019-04-18 2021-06-29 华中科技大学 一种基于非易失内存的容器性能加速方法
CN112667534B (zh) * 2020-12-31 2023-10-20 海光信息技术股份有限公司 缓冲存储装置、处理器及电子设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763226A (zh) * 2010-01-19 2010-06-30 北京航空航天大学 一种虚拟存储设备的缓存方法
CN102483718A (zh) * 2009-08-25 2012-05-30 国际商业机器公司 虚拟化环境中的高速缓存分区
CN102609362A (zh) * 2012-01-30 2012-07-25 复旦大学 一种共享高速缓存动态划分方法与电路
CN102999444A (zh) * 2012-11-13 2013-03-27 华为技术有限公司 一种用于替换缓存模块中数据的方法及装置

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003131946A (ja) * 2001-10-19 2003-05-09 Nec Corp キャッシュメモリ制御装置及び方法
US20110320720A1 (en) * 2010-06-23 2011-12-29 International Business Machines Corporation Cache Line Replacement In A Symmetric Multiprocessing Computer

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102483718A (zh) * 2009-08-25 2012-05-30 国际商业机器公司 虚拟化环境中的高速缓存分区
CN101763226A (zh) * 2010-01-19 2010-06-30 北京航空航天大学 一种虚拟存储设备的缓存方法
CN102609362A (zh) * 2012-01-30 2012-07-25 复旦大学 一种共享高速缓存动态划分方法与电路
CN102999444A (zh) * 2012-11-13 2013-03-27 华为技术有限公司 一种用于替换缓存模块中数据的方法及装置

Also Published As

Publication number Publication date
CN102999444A (zh) 2013-03-27

Similar Documents

Publication Publication Date Title
WO2014075428A1 (zh) 一种用于替换缓存模块中数据的方法及装置
US11531617B2 (en) Allocating and accessing memory pages with near and far memory blocks from heterogenous memories
CN110597451B (zh) 一种虚拟化缓存的实现方法及物理机
US9405476B2 (en) Systems and methods for a file-level cache
US8996807B2 (en) Systems and methods for a multi-level cache
US10310985B2 (en) Systems and methods for accessing and managing a computing system memory
JP6719027B2 (ja) 巨大ページをサポートするメモリ管理
JP4209906B2 (ja) 低消費電力メモリ管理方法及びその方法を用いた計算機
US8972661B2 (en) Dynamically adjusted threshold for population of secondary cache
JP5270801B2 (ja) デバイス・アダプタを介して、データをキャッシュから複数のストレージ・デバイスの各々にデステージするための方法、システム及びコンピュータ・プログラム
JP6106028B2 (ja) サーバ及びキャッシュ制御方法
US20080235477A1 (en) Coherent data mover
US20120110251A1 (en) Processor-bus-connected flash storage module
EP3857389B1 (en) Logging pages accessed from i/o devices
US9658957B2 (en) Systems and methods for managing data input/output operations
US10452300B2 (en) Storage system, node apparatus, cache control method and program
US10152422B1 (en) Page-based method for optimizing cache metadata updates
US8656119B2 (en) Storage system, control program and storage system control method
US20150095576A1 (en) Consistent and efficient mirroring of nonvolatile memory state in virtualized environments
US10747679B1 (en) Indexing a memory region
US10657069B2 (en) Fine-grained cache operations on data volumes
WO2012016783A1 (en) A method of managing computer memory, corresponding computer program product; and data storage device therefor
WO2013023090A2 (en) Systems and methods for a file-level cache
CN112988388A (zh) 一种内存页管理方法及计算设备
WO2013075627A1 (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: 13855274

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13855274

Country of ref document: EP

Kind code of ref document: A1