WO2016090985A1 - 缓存的读取、读取处理方法及装置 - Google Patents

缓存的读取、读取处理方法及装置 Download PDF

Info

Publication number
WO2016090985A1
WO2016090985A1 PCT/CN2015/090030 CN2015090030W WO2016090985A1 WO 2016090985 A1 WO2016090985 A1 WO 2016090985A1 CN 2015090030 W CN2015090030 W CN 2015090030W WO 2016090985 A1 WO2016090985 A1 WO 2016090985A1
Authority
WO
WIPO (PCT)
Prior art keywords
data blocks
cache
data block
file system
read
Prior art date
Application number
PCT/CN2015/090030
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 WO2016090985A1 publication Critical patent/WO2016090985A1/zh

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

Definitions

  • the present invention relates to the field of communications, and in particular to a method and apparatus for reading and reading a cache.
  • the local file user mode caching method in the distributed streaming media service proposed by the patent can not only improve the storage efficiency of the streaming media file, but also can be well applied in the distributed storage system based on the block storage, for example, Taobao File System (TFS), Distributed File System (HDFS) and other systems.
  • TFS Taobao File System
  • HDFS Distributed File System
  • the storage system usually divides the video file into fixed-size block files (for example, block files that are divided into 64MB size) and stores them in the background distributed storage system.
  • the traditional file system has the following problems in the block file storage: the traditional file system cache is managed by page_cache (paged cache), the hotspot data of the streaming media file is low, the spatial locality is poor, and the data is sequentially accessed.
  • page_cache paged cache
  • the way to access prone to cache pollution problems, so that the memory resources can not be used reasonably, and the pre-fetch granularity of the general file system is not high.
  • an embodiment of the present invention provides a method and apparatus for reading and reading stored.
  • a method for reading a cache including: transmitting a read request for a plurality of data blocks in a local file system; determining that the plurality of data blocks are located in the local file system And in a cache, when a size of the read portion of the specified data block of the plurality of data blocks exceeds a preset ratio of the specified data block size, reading a next one of the plurality of data blocks.
  • the preset ratio is 1/2.
  • the method further includes: when the plurality of data blocks requested by the read request are located in the cache of the local file system, Receiving an identifier ID of the shared memory in the local file system; determining a correspondence between the ID and the cache.
  • reading the next one of the plurality of data blocks includes: determining, according to the correspondence, a shared memory corresponding to the cache; and reading the next through the shared memory A block of data.
  • the dirty data block generated after the specified file in the cache is changed is synchronized to the hard disk.
  • the method includes: updating the dirty data; and marking the updated dirty data block for indicating the location The identifier that the dirty data block has completed the update.
  • a cache read processing method comprising: acquiring a read request of a plurality of data blocks in a local file system; and monitoring that the plurality of data blocks are located in the local Transmitting the next data of the plurality of data blocks in a cache of the file system, and a size of the read portion of the specified data block of the plurality of data blocks exceeds a preset ratio of the specified data block size Block to the client.
  • a cache reading apparatus comprising: a sending module configured to send a read request for a plurality of data blocks in a local file system; and a reading module configured to determine The plurality of data blocks are located in a cache of the local file system, and when a size of a read portion of the specified data block of the plurality of data blocks exceeds a preset ratio of the specified data block size, the read The next one of the plurality of data blocks.
  • a cache reading processing apparatus comprising: an obtaining module configured to acquire a read request of a plurality of data blocks in a local file system; and a sending module configured to monitor The plurality of data blocks are located in a cache of the local file system, and when a size of a read portion of the specified data block of the plurality of data blocks exceeds a preset ratio of the specified data block size, the sending station The next data block of the plurality of data blocks is described to the client.
  • the technical means of the next data block process solves the problem that the memory resources cannot be reasonably utilized due to the access mode of the data block in the form of sequential access flow, and the process of asynchronously acquiring multiple data blocks is realized. In turn, the speed of acquiring data blocks can be quickly increased, and memory resources can be reasonably used.
  • FIG. 1 is a flow chart of a method of reading a cache according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a data reading policy of a cache management system according to an embodiment of the present invention
  • FIG. 3 is a structural block diagram of a cache reading device according to an embodiment of the present invention.
  • FIG. 4 is a flowchart of a method for reading a cache according to an embodiment of the present invention.
  • FIG. 5 is a structural block diagram of a cache read processing apparatus according to an embodiment of the present invention.
  • FIG. 6 is a flow chart of a cache read strategy in accordance with a preferred embodiment of the present invention.
  • FIG. 7 is a flowchart of data block state processing in a read strategy according to a preferred embodiment of the present invention.
  • FIG. 8 is a schematic diagram of a cache write strategy in accordance with a preferred embodiment of the present invention.
  • FIG. 1 is a flowchart of a method for reading a cache according to an embodiment of the present invention. As shown in FIG. 1, the method includes the following steps:
  • Step S102 sending a read request for multiple data blocks in the local file system
  • Step S104 when it is determined that the plurality of data blocks are located in the cache of the local file system, and the size of the read portion of the specified data block in the plurality of data blocks exceeds a preset ratio of the specified data block size, read Taking the next one of the plurality of data blocks.
  • the preset ratio is 1/2.
  • the setting of the preset ratio may be completely set according to actual needs of the user, for example, the part of the specified data block may be read.
  • the process of asynchronously acquiring the next data block is performed.
  • Step S200 it is determined whether the request is located 1/2 after the data block, if yes, then go to step S204, if no, go to step 202;
  • Step S202 ending the process
  • Step S204 it is determined whether the next data block is being prefetched, if yes, then go to step S202, if no, go to step S206;
  • Step S206 the Transcend asynchronously reads the request of the data block and submits it to the asynchronous IO queue.
  • step S102 after performing the technical solution of step S102, the following technical solution may also be implemented: receiving the local file when multiple data blocks requested by the read request are located in a cache of the local file system
  • the identification ID of the shared memory in the system determining the corresponding relationship between the ID and the cache, and the technical solution of the foregoing step S104 is implemented in various manners according to the technical solution provided above.
  • a further improvement of the foregoing technical solution in the embodiment of the present invention is that the process of writing the cache may be implemented by synchronizing the dirty data block generated by the change of the specified file in the cache to the hard disk, and after performing the foregoing steps. And updating the dirty data; marking the updated dirty data block to indicate that the dirty data block has been updated.
  • Step 1.1 Cache system initialization, each cached block size is 1MB or larger (default is 1MB). All data is read in block units.
  • Step 2.1 When a read request occurs, first, locate the data block where the data page is located, and if the data block is in the cache system (corresponding to the local file system of the above embodiment), pass the ID of the shared memory to The user completes the ID to cache conversion by the client's library function. If the location of the data page access is the last 1/2 of the data block, the cache management system will asynchronously prefetch the next adjacent data block.
  • Step 3.1 If the data block is not in memory, the entire data block is read into the cache, where the cache is organized in read-only shared memory and can be accessed by multiple processes.
  • Step 4.1 After the reading is completed, the function that releases the reference is called to notify the file system that the reference to the read data block is decremented by 1.
  • Step 1.2 The file system receives a write request from the user.
  • Step 2.2 Determine whether the data block accessed by the write request is in the cache, and if not in the cache, write the data to the cache.
  • Step 3.2 The metadata of the file is not updated during the entire process of writing until the file metadata synchronization function provided by the cache management system is called, and the metadata about the file on the disk is updated.
  • the embodiment of the present invention provides a user-mode cache management method suitable for large-scale streaming media files, which can improve file writing and improve file system high concurrent read performance.
  • Embodiment of the present invention The proposed technical solution is directed to a Raw Cache Management (RCM) method for streaming media files.
  • RCM Raw Cache Management
  • the technical solution provided by the foregoing embodiments of the present invention not only manages data by means of shared memory, but also prefetches data blocks to be accessed.
  • the above technical solution can effectively reduce the problem of cache pollution.
  • FIG. 3 is a structural block diagram of a cache reading apparatus according to an embodiment of the present invention. As shown in Figure 3, the device comprises:
  • the sending module 30 is configured to send a read request for multiple data blocks in the local file system
  • the reading module 32 is connected to the sending module 30, and is configured to determine that the plurality of data blocks are located in a cache of the local file system, and a size of the read portion of the specified data block in the plurality of data blocks exceeds the foregoing designation When the preset ratio of the data block size is read, the next one of the plurality of data blocks is read.
  • FIG. 4 is a flowchart of a cache read processing method according to an embodiment of the present invention, as shown in FIG. 4 . As shown, the following steps are included:
  • Step S402 acquiring a read request of multiple data blocks in the local file system
  • Step S404 when it is detected that the plurality of data blocks are located in the cache of the local file system, and the size of the read portion of the specified data block in the plurality of data blocks exceeds a preset ratio of the specified data block size, Sending the next one of the plurality of data blocks to the client.
  • the technical means of the read and send to the client process of the specified data block in the plurality of data blocks is adopted, which solves the related art, because the access mode of the data block is in the form of sequentially accessing the flow.
  • the problem that memory resources cannot be reasonably utilized realizes the process of asynchronously acquiring multiple data blocks, thereby rapidly increasing the speed of acquiring data blocks and rationally using memory resources.
  • the plurality of data blocks requested by the read request are not located in the cache of the local file system, the plurality of data blocks are obtained from the hard disk of the local file system by using the cache.
  • FIG. 5 is a structural block diagram of a cache read processing apparatus according to an embodiment of the present invention. As shown in Figure 5, the device includes:
  • the obtaining module 50 is configured to obtain a read request of multiple data blocks in the local file system
  • the sending module 52 is connected to the obtaining module 50, and configured to monitor that the plurality of data blocks are located in a cache of the local file system, and that the size of the read portion of the specified data block in the plurality of data blocks exceeds the foregoing designation When the data block size is preset, the next data block of the plurality of data blocks is sent to the client.
  • the technical means of the read and send to the client process of the specified data block in the plurality of data blocks is adopted, and the related art is used to sequentially access the flow form due to the access mode of the data block.
  • the problem that the memory resources cannot be reasonably utilized realizes the process of asynchronously acquiring multiple data blocks, thereby rapidly increasing the speed of acquiring the data blocks and rationally using the memory resources.
  • the above cache management method includes the following steps:
  • FIG. 6 is a flowchart of a cache read policy according to a preferred embodiment of the present invention. As shown in FIG. 6, the method includes the following steps:
  • Step S602 dividing the read request into a data block, determining whether the read request spans multiple data blocks, if the read request does not span multiple data blocks, directly jumps to step S604; otherwise, step S606;
  • Step S604 After receiving the read request, the file system first calculates the data block information of the request, generates a corresponding hash value, and searches the hash list for the data block in the cache. At this time, two cases occur: the data If the block is not in the cache, go to step S608, the data block is in the cache, then go to step S610;
  • Step S606 dividing the read request into multiple sub-requests according to the data block size, and sequentially sending the sub-requests to the file system;
  • Step S608 the data block needs to be loaded into the memory from the hard disk
  • Step S610 whether the I/O request is to release the shared memory reference, but the state of the data block is diverse at this time, and there are three states: OP_READING, OP_PREFETCH, OP_FINISHED, and FIG. 7 shows in detail how to according to the above three states.
  • a flowchart for processing a data block, as shown in FIG. 7, includes the following steps:
  • Step S702 determining the state of the data block here
  • Step S704 when the foregoing state is OP_READING, check whether the information of the data block is legal;
  • the status OP_READING indicates that the user has read the data block before, but the block data is being read, the page is not ready, and the read request is suspended in the waiting queue.
  • Step S706 when the foregoing state is OP_PREFETCH, updating the prefetched statistical information
  • the status OP_PREFETCH indicates that the block data was not previously accessed, but due to prefetching, the block data is being read from the disk, and the read request is suspended in the wait queue.
  • Step S708 when the foregoing state is OP_FINISHED, directly returning the read request;
  • the status is OP_FINISHED, which indicates that the data block has been read intact.
  • the file system calls the corresponding callback function, deletes the read request that has waited for the block data from the wait queue, and returns the read result to the user.
  • step S710 the request is put into the waiting queue.
  • Step S612 calling the state processing module, finding the cache, and returning the shared memory id number to the user.
  • the shared memory reference of the data block is incremented by one;
  • Step S614 the shared memory reference of the data block is decremented by one
  • the usual file system practice in the related art is to write the data in the memory and the metadata to the hard disk every 5 seconds, which ensures the consistency of the data, but the meta The update of the data is still slightly frequent.
  • the preferred embodiment of the present invention provides the following technical solutions to solve the above technical problems.
  • the read request is divided into data blocks to determine whether the read request spans multiple data blocks. If the read request does not span multiple data blocks, jump directly to step 2.2; otherwise, divide the write request by data block size. For multiple sub-requests, and send these sub-requests to the file system in turn; secondly: the metadata is not updated, and the data is directly written back to the cache;
  • FIG. 8 is a schematic diagram of a cache write strategy according to a preferred embodiment of the present invention. As shown in FIG. 8, the method includes the following steps:
  • Step S802 When the user executes a call of the metadata of the synchronization file RFS_SYNC(). There are three stages in total: First, the dirty data block related to the file in the cache is synchronized to the hard disk, and each time a data block is updated, the data block is marked as Clean, so as to avoid affecting the data block in the next synchronization. ;
  • Step S804 At this time, the system metadata about the file is updated first;
  • Step S806 After the metadata update of the system ends, the metadata of the file is updated, including the size of the file, the access time, and the block pointer of the file.
  • the dirty data is written to the disk using asynchronous I/O.
  • the system metadata is started to be synchronized.
  • the embodiment of the present invention provides a local file user state cache method in a distributed streaming media service that provides two strategies for reading and writing cache.
  • the corresponding synchronous metadata interface is directly provided, which reduces the frequent update of the metadata and improves the performance of the system.
  • the read strategy reduces the secondary copy of the data by sharing the memory, and provides a coarser-grained prefetch for the read request, improving the sequential access performance of the system.
  • the technical solution of the embodiment of the present invention has a significant improvement on the performance index of the I/O bandwidth compared with the traditional file system.
  • the embodiment of the present invention achieves the following technical effects: the prefetching mechanism of the cache system can pre-read the corresponding data block in advance, and optimizes the performance of sequential access files; how much memory is occupied by a certain file system instance It can be set, it will not occupy all memory, affecting the memory of other applications using the system; the write strategy not only improves the efficiency of data writing, but also ensures the consistency of data.
  • a storage medium is further provided, wherein the software includes the above-mentioned software, including but not limited to: an optical disk, a floppy disk, a hard disk, an erasable memory, and the like.
  • modules or steps of the present invention described above can be implemented by a general-purpose computing device that can be centralized on a single computing device or distributed across a network of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein.
  • the steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps thereof are fabricated as a single integrated circuit module.
  • the invention is not limited to any specific combination of hardware and software.
  • the foregoing technical solution provided by the present invention can be applied to a cache read process, when a size of a read portion of a specified data block in a plurality of data blocks exceeds a preset ratio of the specified data block size,
  • the technical means for performing the process of "reading the next data block in the plurality of data blocks" solves the problem that the memory resources cannot be reasonably utilized in the related art due to the access mode of the data blocks in the form of sequentially accessing the flow.
  • the problem is that the process of asynchronously acquiring multiple data blocks is realized, thereby quickly increasing the speed of acquiring data blocks and rationally using memory resources.

Abstract

一种缓存的读取、读取处理方法及装置,其中,所述读取方法包括:发送对本地文件系统中多个数据块的读取请求(S102);在判定所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,读取所述多个数据块中的下一个数据块(S104)。采用上述技术方案,解决了相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,实现了异步获取多个数据块的过程,进而快速提升获取数据块的速度,合理使用内存资源。

Description

缓存的读取、读取处理方法及装置 技术领域
本发明涉及通信领域,具体而言,涉及一种缓存的读取、读取处理方法及装置。
背景技术
随着计算、存储、通信等技术的发展,大规模流媒体服务已经广泛的应用到娱乐、教育、商业等各个领域,如何实现大规模流媒体文件的高效存储,同时支持高并发的用户是一个非常关键的问题。本专利提出的分布式流媒体服务中的本地文件用户态缓存方法不仅可以很好的提高流媒体文件的存储效率,同时也可以很好的应用在基于分块存储的分布式存储系统中,例如淘宝文件系统(Taobao File System,简称为TFS),分布式文件系统(Hadoop Distributed File System,简称为HDFS)等系统中。
由于视频文件较大,所以存储系统通常会将视频文件切分成固定大小的块文件(例如,切分成64MB大小的块文件)存储在后台分布式存储系统中。传统的文件系统在块文件存储上存在如下问题:传统的文件系统的缓存采用page_cache(分页缓存)的方式管理,流媒体文件的热点数据较低,空间局部性较差,数据多以顺序访问流的方式访问,容易出现缓存污染的问题,从而内存的资源无法得到合理的利用,并且通用文件系统的预取粒度并不高。
针对相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,尚未提出有效的解决方案。
发明内容
为了解决上述技术问题,本发明实施例提供了一种存的读取、读取处理方法及装置。
根据本发明的一个实施例,提供了一种缓存的读取方法,包括:发送对本地文件系统中多个数据块的读取请求;在判定所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,读取所述多个数据块中的下一个数据块。
在本发明实施例中,所述预设比例取值为1/2。
在本发明实施例中,发送对本地文件系统中多个数据块的读取请求之后,还包括:在所述读取请求所请求的多个数据块位于所述本地文件系统的缓存中时,接收所述本地文件系统中共享内存的标识ID;确定所述ID与所述缓存的对应关系。
在本发明实施例中,读取所述多个数据块中的下一个数据块,包括:根据所述对应关系确定所述缓存所对应的共享内存;通过所述共享内存中读取所述下一个数据块。
在本发明实施例中,将所述缓存中指定文件发生变化后产生的脏数据块同步到硬盘中。
在本发明实施例中,将所述缓存中指定文件发生变化后产生的脏数据块同步到硬盘中之后,包括:对所述脏数据进行更新;对更新后的脏数据块标记用于指示所述脏数据块已完成更新的标识。
根据本发明的另一个实施例,还提供了一种缓存的读取处理方法,包括:获取本地文件系统中多个数据块的读取请求;在监测到所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,发送所述多个数据块中的下一个数据块至客户端。
在本发明实施例中,在判断所述读取请求所请求的多个数据块未位于所述本地文件系统的缓存中时,通过所述缓存从所述本地文件系统的硬盘中获取所述多个数据块。
根据本发明的另一个实施例,还提供了一种缓存的读取装置,包括:发送模块,设置为发送对本地文件系统中多个数据块的读取请求;读取模块,设置为在判定所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,读取所述多个数据块中的下一个数据块。
根据本发明的另一个实施例,还提供了一种缓存的读取处理装置,包括:获取模块,设置为获取本地文件系统中多个数据块的读取请求;发送模块,设置为在监测到所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,发送所述多个数据块中的下一个数据块至客户端。
通过本发明实施例,采用在多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,就执行“读取所述多个数据块中的下一个数据块”过程的技术手段,解决了相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,实现了异步获取多个数据块的过程,进而快速提升获取数据块的速度,合理使用内存资源。
附图说明
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:
图1是根据本发明实施例的缓存的读取方法的流程图;
图2是根据本发明实施例的缓存管理系统的数据读取策略的流程图;
图3为根据本发明实施例的缓存的读取装置的结构框图;
图4为根据本发明实施例的缓存的读取处理方法的流程图;
图5为根据本发明实施例的缓存的读取处理装置的结构框图;
图6为根据本发明优选实施例的缓存的读取策略的流程图;
图7为根据本发明优选实施例的读取策略中的数据块状态处理流程图;
图8为根据本发明优选实施例的缓存写入策略示意图。
具体实施方式
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。
本发明的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点可通过在所写的说明书、权利要求书、以及附图中所特别指出的结构来实现和获得。
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。
为了解决上述技术问题,在本实施例中提供了一种缓存的读取方法,图1是根据本发明实施例的缓存的读取方法的流程图,如图1所示,包括以下步骤:
步骤S102,发送对本地文件系统中多个数据块的读取请求;
步骤S104,在判定上述多个数据块位于上述本地文件系统的缓存中,且上述多个数据块中的指定数据块的已读取部分的大小超过上述指定数据块大小的预设比例时,读取上述多个数据块中的下一个数据块。
通过上述各个步骤,采用在多个数据块中的指定数据块的已读取部分的大小超过上述指定数据块大小的预设比例时,就执行“读取上述多个数据块中的下一个数据块”过程的技术手段,解决了相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,实现了异步获取多个数据块的过程,进而快速提升获取数据块的速度,合理使用内存资源。
可选地,上述预设比例取值为1/2,当然,对于上述预设比例的设定,完全是可以根据用户实际的需求进行设定的,例如,可以在读取指定数据块的部分超过指定数据块的3/4的大小时,执行异步获取下一个数据块的过程。
上述技术方案可以结合图2的流程进行更加详细的说明:
步骤S200,判断请求是否位于数据块后的1/2,如果是,则转步骤S204,如果否,则转步骤202;
步骤S202,结束进程;
步骤S204,判断是否正在预取下一个数据块,如果是,则转步骤S202,如果否,则转步骤S206;
步骤S206,创见异步读取数据块的请求,并提交到异步IO队列中。
在本发明实施例中,在执行完步骤S102的技术方案之后,还可以执行以下技术方案:在上述读取请求所请求的多个数据块位于上述本地文件系统的缓存中时,接收上述本地文件系统中共享内存的标识ID;确定上述ID与上述缓存的对应关系,基于上述提供的技术方案,对于上述步骤S104的技术方案有多种实现形式,在本发明实施例的一个可选示例中,根据上述对应关系确定上述缓存所对应的共享内存;通过上述共享内存中读取上述下一个数据块。
本发明实施例对上述技术方案的进一步改进在于,缓存的写入过程可以通过以下技术方案实现:将上述缓存中指定文件发生变化后产生的脏数据块同步到硬盘中,并在执行上述步骤之后,对上述脏数据进行更新;对更新后的脏数据块标记用于指示上述脏数据块已完成更新的标识。
以下结合以下两个过程对上述实施例提供的技术方案进行解释说明:
对于上述缓存的读取策略,可以通过以下流程进行详细说明:
步骤1.1:缓存系统初始化,每个缓存的块大小为1MB或者更大(默认为1MB)。所有的数据的读取均以块单位做读取。
步骤2.1:当有读取请求发生的时候,首先,定位该数据页所在的数据块,如果该数据块在缓存系统(相当于上述实施例的本地文件系统)中,将共享内存的ID传递给用户,由客户端的库函数完成ID到缓存的转换。如果数据页访问的位置为数据块的后1/2,那么缓存管理系统将会异步预取相邻的下一个数据块。
步骤3.1:如果该数据块不在内存中,将整个数据块读入到缓存中,这里的缓存是以只读的共享内存的形式组织,可以被多进程访问。
步骤4.1:读取结束后,调用释放引用的函数,通知文件系统,被读取的数据块的引用减1。
对于上述缓存的写入策略,可以通过以下流程进行详细说明:
步骤1.2:文件系统接收来自用户的写请求。
步骤2.2:判断写请求所访问的数据块是否在缓存中,如果不在缓存中,将数据写入到缓存中。
步骤3.2:在写入的整个过程中并不更新文件的元数据,直到调用了缓存管理系统所提供的文件元数据同步函数,磁盘上的有关该文件的元数据才会得到更新。
综上所述,本发明实施例提供了一个用户态的适用于大规模流媒体文件的缓存管理方法,该方法既能提高文件的写,同时又能提高文件系统的高并发读性能,可选地,本发明实施例 提出的技术方案针对流媒体文件的原缓存管理(Raw Cache Management,简称为RCM)方法。
也就是说,本发明实施例上述提供的技术方案不仅采用共享内存的方式管理数据,还能够对即将访问到的数据块进行预取,上述技术方案可以有效减少缓存污染的问题。
在本实施例中还提供了一种缓存的读取装置,用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述,下面对该装置中涉及到的模块进行说明。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。图3为根据本发明实施例的缓存的读取装置的结构框图。如图3所示,该装置包括:
发送模块30,设置为发送对本地文件系统中多个数据块的读取请求;
读取模块32,与发送模块30连接,设置为在判定上述多个数据块位于上述本地文件系统的缓存中,且上述多个数据块中的指定数据块的已读取部分的大小超过上述指定数据块大小的预设比例时,读取上述多个数据块中的下一个数据块。
通过上述各个模块的综合作用,采用在多个数据块中的指定数据块的已读取部分的大小超过上述指定数据块大小的预设比例时,就执行“读取上述多个数据块中的下一个数据块”过程的技术手段,解决了相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,实现了异步获取多个数据块的过程,进而快速提升获取数据块的速度,合理使用内存资源。
为了更加晚上上述缓存的读取过程,在本发明实施例中还提供了一种缓存的读取处理方法,图4为根据本发明实施例的缓存的读取处理方法的流程图,如图4所示,包括以下步骤:
步骤S402,获取本地文件系统中多个数据块的读取请求;
步骤S404,在监测到上述多个数据块位于上述本地文件系统的缓存中,且上述多个数据块中的指定数据块的已读取部分的大小超过上述指定数据块大小的预设比例时,发送上述多个数据块中的下一个数据块至客户端。
通过上述各个步骤,采用在多个数据块中的指定数据块的已读取发送至客户端过程的技术手段,解决了相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,实现了异步获取多个数据块的过程,进而快速提升获取数据块的速度,合理使用内存资源。
可选地,当判断上述读取请求所请求的多个数据块未位于上述本地文件系统的缓存中时,通过上述缓存从上述本地文件系统的硬盘中获取上述多个数据块。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本发明所必需的。
在本实施例中还提供了一种缓存的读取处理装置,用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述,下面对该装置中涉及到的模块进行说明。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。图5为根据本发明实施例的缓存的读取处理装置的结构框图。如图5所示,该装置包括:
获取模块50,设置为获取本地文件系统中多个数据块的读取请求;
发送模块52,与获取模块50连接,设置为在监测到上述多个数据块位于上述本地文件系统的缓存中,且上述多个数据块中的指定数据块的已读取部分的大小超过上述指定数据块大小的预设比例时,发送上述多个数据块中的下一个数据块至客户端。
通过上述各个模块的综合作用,采用在多个数据块中的指定数据块的已读取发送至客户端过程的技术手段,解决了相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,实现了异步获取多个数据块的过程,进而快速提升获取数据块的速度,合理使用内存资源。
为了更好的理解上述缓存的读取处理、读取流程,以下结合优选实施例进行说明,但不用于限定本发明实施例的技术方案:
可选地,以下技术方案在有Linux环境的阵列功能的主机或阵列系统上依次按以下步骤实现的,而对于分布式流媒体服务中的本地文件用户态缓存方法适用于所有在用户态实现的文件系统。上述的缓存管理方法包含有以下步骤:
对于上述读取策略,图6为根据本发明优选实施例的缓存的读取策略的流程图,如图6所示,包括以下步骤:
步骤S602:将读取请求划分数据块,判断该读请求是否跨越了多个数据块,如果读请求并没有跨越多个数据块,直接跳转到步骤S604;否则转步骤S606;
步骤S604;文件系统接受到读请求后,首先计算该请求的数据块信息,生成相应的哈希值,并在哈希链表中查找缓存中的数据块,此时会出现两种情况:该数据块不在缓存中,则转步骤S608,该数据块在缓存中,则转步骤S610;
步骤S606:按数据块大小将该读请求划分为多个子请求,并将这些子请求依次发送给文件系统;
步骤S608;需要从硬盘上将该数据块调入到内存中;
步骤S610;该I/O请求是否为释放共享内存引用,但是此时数据块的状态却是多样的,共有三种状态:OP_READING,OP_PREFETCH,OP_FINISHED,图7详细示出了如何根据上述三种状态对数据块进行处理的流程图,如图7所示,包括以下步骤:
步骤S702,判断此处数据块的状态;
步骤S704,当上述状态为OP_READING时,检查该数据块的信息是否合法;
状态为OP_READING表示之前有用户读取该数据块,但是该块数据正在读取中,该页没有就绪,此时将该读请求挂起到等待队列中。
步骤S706,当上述状态为OP_PREFETCH时,更新预取的统计信息;
状态为OP_PREFETCH表示该块数据之前并未被访问,但是由于预取,因此该块数据正在从磁盘上读取,此时将该读请求挂起到等待队列中。
步骤S708,当上述状态为OP_FINISHED时,直接返回该读取请求;
状态为OP_FINISHED,此时标志该数据块已经读取完整。当该读请求已经完成时,文件系统调用相应的回调函数,将曾经等待该块数据的读请求从等待队列中删除,并将读取的结果返回给用户。
需要说明的是,这个部分只对状态为OP_FINISHED有效。当该读请求访问的部分超过了整个块大小的1/2。那么将相邻的下一个数据块以异步的方式预取出来。
步骤S710,将该请求放入到等待队列中。
步骤S612,调用状态处理模块,找到该缓存,并将共享内存id号返回给用户。该数据块的共享内存引用加1;
步骤S614,将该数据块的共享内存引用减1;
步骤S616,预取数据块;
对于缓存写入策略,实际上,相关技术中通常的文件系统的做法是,每隔5秒将内存中的数据以及元数据写入到硬盘上,这样做虽然保证了数据的一致性,但是元数据的更新仍然略显频繁,本发明优选实施例提供了以下技术方案解决上述技术问题。
首先,将该读请求划分数据块,判断该读请求是否跨越了多个数据块,如果读请求并没有跨越多个数据块,直接跳转到步骤2.2;否则按数据块大小将该写请求划分为多个子请求,并将这些子请求依次发送给文件系统;其次:元数据不被更新,直接将数据写入到缓存就返回;
图8为根据本发明优选实施例的缓存写入策略示意图,如图8所示,包括以下步骤:
步骤S802:当用户执行了一个同步文件的元数据的调用RFS_SYNC()。总共分为三个阶段:首先,将缓存中与该文件有关的脏数据块同步到硬盘上,每更新一个数据块,将该数据块标记为Clean,这样避免下次同步时影响到该数据块;
步骤S804:此时先更新有关该文件的系统元数据;
步骤S806:当系统的元数据更新结束后,开始更新该文件的元数据,包括该文件的大小,访问时间,以及文件的块指针等信息。
此时将脏数据写入到磁盘采用异步I/O的方式,当该文件所有的脏数据都同步到硬盘上时,才开始同步系统元数据。
综上所述,本发明实施例提供了一种分布式流媒体服务中的本地文件用户态缓存方法提供了读取,写入缓存的两种策略。在执行写操作时,根据流媒体文件写入的特征,直接提供相应的同步元数据接口,减少了元数据的频繁更新,提高了系统的性能。读取策略通过共享内存的方式减少了数据的二次拷贝,同时为读请求提供了更粗粒度的预取,提高了系统的顺序访问性能。实验表明,在多种顺序写负载下,本发明实施例的技术方案比传统文件系统在I/O带宽的性能指标上有非常显著的提高。
综上所述,本发明实施例达到了以下技术效果:缓存系统的预取机制可以提前预读出相应的数据块,优化了顺序访问文件的性能;某一文件系统实例所占用的内存的多少是可以设定的,不会全部占用内存,影响其他应用使用系统的内存;写入策略既提高了数据写入的效率,同时也保证了数据的一致性。
在另外一个实施例中,还提供了一种软件,该软件用于执行上述实施例及优选实施方式中描述的技术方案。
在另外一个实施例中,还提供了一种存储介质,该存储介质中存储有上述软件,该存储介质包括但不限于:光盘、软盘、硬盘、可擦写存储器等。
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的对象在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。
工业实用性
本发明提供的上述技术方案,可以应用于缓存的读取处理过程中,采用在多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,就执行“读取所述多个数据块中的下一个数据块”过程的技术手段,解决了相关技术中,由于数据块的访问方式以顺序访问流的形式而导致的内存资源无法合理利用的问题,实现了异步获取多个数据块的过程,进而快速提升获取数据块的速度,合理使用内存资源。

Claims (10)

  1. 一种缓存的读取方法,包括:
    发送对本地文件系统中多个数据块的读取请求;
    在判定所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,读取所述多个数据块中的下一个数据块。
  2. 根据权利要求1所述的方法,其中,所述预设比例取值为1/2。
  3. 根据权利要求1所述的方法,其中,发送对本地文件系统中多个数据块的读取请求之后,还包括:
    在所述读取请求所请求的多个数据块位于所述本地文件系统的缓存中时,接收所述本地文件系统中共享内存的标识ID;
    确定所述ID与所述缓存的对应关系。
  4. 根据权利要求3所述的方法,其中,读取所述多个数据块中的下一个数据块,包括:
    根据所述对应关系确定所述缓存所对应的共享内存;
    通过所述共享内存中读取所述下一个数据块。
  5. 根据权利要求1所述的方法,其中,
    将所述缓存中指定文件发生变化后产生的脏数据块同步到硬盘中。
  6. 根据权利要求5所述的方法,其中,将所述缓存中指定文件发生变化后产生的脏数据块同步到硬盘中之后,包括:
    对所述脏数据进行更新;对更新后的脏数据块标记用于指示所述脏数据块已完成更新的标识。
  7. 一种缓存的读取处理方法,包括:
    获取本地文件系统中多个数据块的读取请求;
    在监测到所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,发送所述多个数据块中的下一个数据块至客户端。
  8. 根据权利要求7所述的方法,其中,
    在判断所述读取请求所请求的多个数据块未位于所述本地文件系统的缓存中时,通过所述缓存从所述本地文件系统的硬盘中获取所述多个数据块。
  9. 一种缓存的读取装置,包括:
    发送模块,设置为发送对本地文件系统中多个数据块的读取请求;
    读取模块,设置为在判定所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,读取所述多个数据块中的下一个数据块。
  10. 一种缓存的读取处理装置,包括:
    获取模块,设置为获取本地文件系统中多个数据块的读取请求;
    发送模块,设置为在监测到所述多个数据块位于所述本地文件系统的缓存中,且所述多个数据块中的指定数据块的已读取部分的大小超过所述指定数据块大小的预设比例时,发送所述多个数据块中的下一个数据块至客户端。
PCT/CN2015/090030 2014-12-11 2015-09-18 缓存的读取、读取处理方法及装置 WO2016090985A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410766329.9 2014-12-11
CN201410766329.9A CN105740166B (zh) 2014-12-11 2014-12-11 缓存的读取、读取处理方法及装置

Publications (1)

Publication Number Publication Date
WO2016090985A1 true WO2016090985A1 (zh) 2016-06-16

Family

ID=56106627

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/090030 WO2016090985A1 (zh) 2014-12-11 2015-09-18 缓存的读取、读取处理方法及装置

Country Status (2)

Country Link
CN (1) CN105740166B (zh)
WO (1) WO2016090985A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108897495A (zh) * 2018-06-28 2018-11-27 北京五八信息技术有限公司 缓存更新方法、装置、缓存设备及存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108132757B (zh) * 2016-12-01 2021-10-19 阿里巴巴集团控股有限公司 数据的存储方法、装置及电子设备
CN108345546B (zh) * 2017-05-09 2019-09-20 清华大学 用于确定处理器操作的方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101382948A (zh) * 2008-10-14 2009-03-11 成都市华为赛门铁克科技有限公司 一种文件存储方法、装置和系统
US20100281221A1 (en) * 2009-04-30 2010-11-04 International Business Machines Corporation Shared Data Prefetching with Memory Region Cache Line Monitoring
CN102841778A (zh) * 2011-06-22 2012-12-26 索尼公司 存储器管理设备和方法、控制程序和记录介质
CN103645863A (zh) * 2013-12-12 2014-03-19 北京奇虎科技有限公司 共享内存的数据读取方法和系统、写入方法和系统
CN103984640A (zh) * 2014-05-14 2014-08-13 华为技术有限公司 实现数据预取方法及装置

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853218B (zh) * 2010-05-12 2015-05-20 中兴通讯股份有限公司 用于磁盘阵列的读取方法和系统
CN102111448B (zh) * 2011-01-13 2013-04-24 华为技术有限公司 分布式哈希表dht存储系统的数据预取方法、节点和系统
CN102521349A (zh) * 2011-12-12 2012-06-27 深圳市创新科信息技术有限公司 一种文件预读方法
US9390155B2 (en) * 2012-08-22 2016-07-12 Adobe Systems Incorporated Accessing content in a content-aware mesh
CN102945207A (zh) * 2012-10-26 2013-02-27 浪潮(北京)电子信息产业有限公司 一种块级数据的缓存管理方法及系统
CN103916465A (zh) * 2014-03-21 2014-07-09 中国科学院计算技术研究所 一种基于分布式文件系统的数据预读装置及其方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101382948A (zh) * 2008-10-14 2009-03-11 成都市华为赛门铁克科技有限公司 一种文件存储方法、装置和系统
US20100281221A1 (en) * 2009-04-30 2010-11-04 International Business Machines Corporation Shared Data Prefetching with Memory Region Cache Line Monitoring
CN102841778A (zh) * 2011-06-22 2012-12-26 索尼公司 存储器管理设备和方法、控制程序和记录介质
CN103645863A (zh) * 2013-12-12 2014-03-19 北京奇虎科技有限公司 共享内存的数据读取方法和系统、写入方法和系统
CN103984640A (zh) * 2014-05-14 2014-08-13 华为技术有限公司 实现数据预取方法及装置

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
WU, FENGGUANG: "Prefetching Algorithms in Linux Kerne", ELECTRONIC TECHNOLOGY & INFORMATION SCIENCE , CHINA DOCTORAL DISSERTATIONS FULL-TEXT DATABASE, no. 9, 15 September 2009 (2009-09-15) *
YAO, WEI: "A Disk Energy Saving of Perfecting Algorithms in Linux", COMPUTER SYSTEMS & APPLICATIONS, vol. 19, no. 7, 31 December 2010 (2010-12-31) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108897495A (zh) * 2018-06-28 2018-11-27 北京五八信息技术有限公司 缓存更新方法、装置、缓存设备及存储介质
CN108897495B (zh) * 2018-06-28 2023-10-03 北京五八信息技术有限公司 缓存更新方法、装置、缓存设备及存储介质

Also Published As

Publication number Publication date
CN105740166B (zh) 2020-05-19
CN105740166A (zh) 2016-07-06

Similar Documents

Publication Publication Date Title
US11558487B2 (en) Methods and systems for stream-processing of biomedical data
KR101994021B1 (ko) 파일 조작 방법 및 장치
US10715622B2 (en) Systems and methods for accelerating object stores with distributed caching
US8782323B2 (en) Data storage management using a distributed cache scheme
US11593272B2 (en) Method, apparatus and computer program product for managing data access
CN107197359B (zh) 视频文件缓存方法及装置
US8897573B2 (en) Virtual machine image access de-duplication
US20200081867A1 (en) Independent evictions from datastore accelerator fleet nodes
US9424314B2 (en) Method and apparatus for joining read requests
WO2011144175A1 (zh) 分布式哈希表dht存储系统的数据预取方法、节点和系统
WO2013078583A1 (zh) 优化数据访问的方法及装置、优化数据存储的方法及装置
CN108540510B (zh) 一种云主机创建方法、装置及云服务系统
CN111124270B (zh) 缓存管理的方法、设备和计算机程序产品
CN111857539B (zh) 用于管理存储系统的方法、设备和计算机可读介质
US10146437B2 (en) Tier aware caching solution to increase application performance
US11226778B2 (en) Method, apparatus and computer program product for managing metadata migration
WO2016090985A1 (zh) 缓存的读取、读取处理方法及装置
US10936499B2 (en) Method, device and computer programme product for storage management
US20090327303A1 (en) Intelligent allocation of file server resources
CN110162395B (zh) 一种内存分配的方法及装置
CN116955219B (zh) 一种数据镜像方法、装置、主机及存储介质
WO2012171363A1 (zh) 分布式缓存系统中的数据操作方法和装置
CN114265814B (zh) 一种基于对象存储的数据湖文件系统
US10235293B2 (en) Tracking access pattern of inodes and pre-fetching inodes
CN110209343B (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: 15868055

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

Country of ref document: EP

Kind code of ref document: A1