Memory cache management method, multimedia server and computer storage medium

By directly replacing the target page in the multimedia server to achieve cache recycling, the delay problem caused by frequent memory cache recycling is solved, the consumption of cache swap out on the operating system is reduced, and the user experience and server performance is improved.

CN110895515BActive Publication Date: 2024-11-05NANJING ZHONGXING XIN SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201811062577.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-09-12
Publication Date
2024-11-05
Estimated Expiration
2038-12-27

AI Technical Summary

Technical Problem

When playing audio and video files, frequent memory cache recycling leads to an increase in delay, affecting user experience. Especially in scenarios where synchronous cache recycling requires high latency when memory is insufficient, the existing technology unified cache recycling algorithm cannot effectively reduce cache Swap out the consumption of the operating system.

Method used

By receiving memory requests, obtaining the target page of the set size before the current access location, directly replace and store new file data, avoiding system calls, realizing cache recycle usage, and reducing the consumption of cache swap out on the operating system.

Benefits of technology

It significantly reduces cache recycling consumption and file reading delay, improves the performance of multimedia servers, especially in scenarios with large bandwidth and large traffic, cache recycling greatly reduces the burden on the operating system and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110895515B_ABST
    Figure CN110895515B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a memory cache management method, a multimedia server and a computer storage medium, the method comprising: receiving a memory application request; obtaining a target page of a set size before a current access position according to the memory application request; when it is determined that the target page is obtained, using the target page to store data corresponding to the memory application request, and inserting the target page after the current access position.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a memory cache management method, a multimedia server and a computer storage medium. Background Art

[0002] Currently, when playing audio and video files, the audio and video files are usually read from the disk into the memory. After reading, these memories are not released immediately. When a cache miss occurs, the old cache needs to be swapped out, and then the swapped out memory is used for new file reading and writing.

[0003] However, the growth of memory capacity is often much smaller than the growth of hard disk capacity, which results in cache replacement happening all the time. Video reading and writing have very high latency requirements. When memory is insufficient, it is often necessary to trigger synchronous cache recycling to release memory. This synchronous waiting is fatal for scenarios with high latency requirements. For the current implementations of various operating systems, cache recycling is a unified action, regardless of whether it is the Least Frequently Used (LFU) algorithm or the Least Recently Used (LRU) algorithm. Anyway, they are all unified management ideas, which leads to the problem of insufficient memory triggering cache recycling and affecting user experience, which is particularly serious in multimedia servers. Summary of the invention

[0004] To solve the existing technical problems, the embodiments of the present invention provide a memory cache management method, a multimedia server and a computer storage medium which can reduce cache recovery consumption and file reading delay.

[0005] To achieve the above object, the technical solution of the embodiment of the present invention is implemented as follows:

[0006] A memory cache management method includes: receiving a memory application request; obtaining a target page of a set size before a current access position according to the memory application request; when it is determined that the target page is obtained, using the target page to store data corresponding to the memory application request, and inserting the target page after the current access position.

[0007] Among them, after obtaining the target page of the set size before the current access position according to the memory application request, it also includes: when it is determined that the target page is not obtained, obtaining the cache corresponding to the memory application request according to the set memory recovery algorithm through the operating system OS.

[0008] The receiving of the memory application request includes: receiving a file pre-read request, the file pre-read request carries size information of a memory block to be sent to the hard disk; or receiving a file read request, the file read request carries set page size information.

[0009] After using the target page to store the data corresponding to the memory application request, the method further includes: updating a reference count of the target page.

[0010] Among them, before obtaining the target page of the set size before the current access position according to the memory application request, it also includes: judging whether the memory application request is a memory application request for audio and video files, and determining whether the current heat value of the audio and video files is less than the set heat range; obtaining the target page of the set size before the current access position according to the memory application request includes: corresponding to the memory application request being a memory application request for audio and video files, and determining that the current heat value of the audio and video files is less than the set heat range, obtaining the target page of the set size before the current access position according to the memory application request.

[0011] Among them, after determining whether the memory application request is a memory application request for an audio or video file, it also includes: corresponding to the memory application request being a memory application request for an audio or video file, and when it is determined that the current heat value of the audio or video file meets the set heat range, obtaining the cache corresponding to the memory application request through the OS according to the set memory recovery algorithm.

[0012] Among them, after determining whether the memory application request is a memory application request for an audio or video file, it also includes: when it is determined that the memory application request is a memory application request for a non-audio or video file, obtaining a cache corresponding to the memory application request according to a set memory recovery algorithm through the OS.

[0013] Among them, when it is determined that the memory application request is a memory application request for an audio or video file, a target page of a set size before the current access position is obtained according to the memory application request, including: when it is determined that the memory application request is a memory application request for an audio or video file of a first clarity, a target page of a first set size before the current access position is obtained according to the memory application request; when it is determined that the memory application request is a memory application request for an audio or video file of a second clarity, a target page of a second set size before the current access position is obtained according to the memory application request, the first clarity is higher than the second clarity, and the first set size is larger than the second set size.

[0014] A multimedia server comprises a processor and a memory for storing a computer program that can be run on the processor; wherein the processor, when being used to run the computer program, executes the memory cache management method described in any embodiment of the present application.

[0015] A computer storage medium stores a computer program, and when the computer program is executed by a processor, the memory cache management method described in any embodiment of the present application is implemented.

[0016] The memory cache management method provided in the above embodiment receives a memory application request, obtains a target page of a set size before the current access position according to the memory application request, and when it is determined that the target page is obtained, uses the target page to store data corresponding to the memory application request, and inserts the target page after the current access position. In this way, when it is determined that memory needs to be applied for, the target page of the set size before the current access position can be directly replaced. Compared with the known method of obtaining the cache by using a unified cache recovery algorithm to recycle and release old cache pages through the operating system, by using a directly replaced target page to store new file data, cache recycling can be achieved without the need for system calls, which greatly reduces the consumption of the cache swap on the operating system and also reduces the problem of poor user experience caused by latency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is an architecture diagram of an operating system of a memory cache management method in one embodiment of the present invention;

[0018] Figure 2 A flowchart of a memory cache management method according to an embodiment of the present invention;

[0019] Figure 3 A flowchart of a memory cache management method in another embodiment of the present invention;

[0020] Figure 4 A flowchart of a memory cache management method in another embodiment of the present invention;

[0021] Figure 5 A flowchart of a memory cache management method in a specific example of the present invention;

[0022] Figure 6 is a timing diagram of the interaction between the client and the OS in one embodiment of the present invention;

[0023] Figure 7 FIG. 1 is a schematic diagram of the structure of a multimedia server in an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The technical solution of the present invention is further elaborated in detail below in conjunction with the accompanying drawings and specific embodiments of the specification. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the technical field of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items.

[0025] Before further describing the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are described. The nouns and terms involved in the embodiments of the present invention are subject to the following explanations.

[0026] 1) Page. In memory management, memory is generally divided into certain units, referred to as pages.

[0027] 2) Page cache. In the operating system, file reading and writing usually reads and writes the cache in the memory first, and then synchronizes with the hard disk through a certain mechanism. Because the memory read and write efficiency is higher than the hard disk, the read and write performance is guaranteed. The memory used for caching is generally called page cache. Since the memory is generally managed in units of pages, for example, it is called pagecache in Linux.

[0028] 3) Pre-reading. When reading a file, pre-reading is generally used to ensure that the media blocks submitted to the hard disk are large blocks. Pre-reading is to read the hard disk data in advance and put it into the page cache, so that the next read will hit the cache.

[0029] 4) Zero copy (sendfile). When sending files over the network, they no longer go through a copy from kernel state to user state. Instead, they are sent directly from kernel state to the network card, and then the network card sends them to the peer device.

[0030] 5) Cache recycling: When the operating system performs page caching, for servers that mainly read files, as the cache grows, there is a cache recycling mechanism due to memory space limitations.

[0031] 6) Least Recently Used (LRU) and Least Frequently Used (LFU) both refer to memory recycling algorithms, which are used for cache management and recycling. They are a linked list method to manage and age the cache from the perspective of pages.

[0032] 7) One shot mode. According to statistics, most of the time when accessing files, the sequential playback method is used. However, according to the characteristics of video playback, there will be a long tail effect, that is, a small number of popular videos occupy less cache but serve a large number of people. However, most files are accessed only once in a period of time, serving a small number of people but occupying a large cache. This is the one shot mode.

[0033] 8) Radix tree, a data structure, is currently widely used to manage the cache of a certain file, that is, to manage the cache from the perspective of a single file.

[0034] like Figure 1 As shown, in one embodiment, an architecture diagram of an application scenario using the memory cache management method provided by an embodiment of the present invention is provided, and the architecture includes a client 100 and a multimedia server 200. The client 100 is connected to the multimedia server 200 through a network. The client 100 sends a file play instruction. After receiving the file play instruction, the multimedia server 200 reads the slice file of the corresponding file into the memory, and sends the data that hits the memory cache according to the access request of the client 100 to the network card, and the network card sends it to the client device according to the specified network transmission protocol. In the embodiment of the present invention, this type of business is collectively referred to as a model combining disk reading and packet sending. The memory cache management method provided by an embodiment of the present invention can be applied to the model combining disk reading and packet sending, wherein the multimedia server 200 reads the slice file into the memory, and when it is determined that the memory is insufficient, the file cache management structure radix tree is used to obtain the page before the current access position for subsequent access, and then through pre-reading, this part of the memory page is used to store the data read from the hard disk. Since the pages before the current access position are cached pages that have been accessed and are unlikely to be accessed again in a short period of time, the multimedia server 200 directly recycles the memory pages that will not be accessed again in a short period of time based on the locations before the current access position, thereby ensuring that only a very small amount of memory, such as 2-5M, is occupied after playing a large file of several GB. In a media server with large bandwidth and large traffic, the consumption of the operating system by cache swapping is greatly reduced.

[0035] In one embodiment, the multimedia server 200 refers to a CDN server supporting RTSP on-demand service scenarios. In the Internet IPTV television service, it is necessary to support RTSP on-demand service. The basic service model is to read the film source stored on the CDN server, package it into an RTP packet and carry it on UDP or TCP, and send it out from the network port of the CDN server device. The RTSP on-demand service is a typical model combining disk reading and packet sending. By adopting the memory cache management method provided by the embodiment of the present invention, the memory pages that will not be accessed again in a short time before the current access position are directly recycled and applied to the sendfile packet sending mechanism of the Linux system, the overall performance of the CDN server is greatly improved.

[0036] In another embodiment, the multimedia server 200 refers to a CDN server supporting the HLS on-demand service scenario, and supports the HLS on-demand service on the Internet OTT service. The multimedia file source stored on the CDN is read out according to the HLS segmentation format requirements, downloaded in HTTP mode, and sent to the requesting terminal on TCP. Therefore, the HLS on-demand service is also a typical model combining disk reading and packet sending. By adopting the memory cache management method provided in an embodiment of the present invention, the memory pages that will not be accessed again in a short time before the current access position are directly recycled and applied to the sendfile packet sending mechanism of the Linux system, thereby greatly improving the overall performance of the CDN server.

[0037] In another embodiment, the multimedia server 200 refers to a CDN server supporting a DASH on-demand service scenario, and supports the DASH on-demand service on the Internet OTT service. The multimedia file sources stored on the CDN are read out according to the DASH segment format requirements to support HTTP download, and are carried on TCP and sent to the requesting terminal. Therefore, the DASH on-demand service is also a typical model combining disk reading and packet sending. By adopting the memory cache management method provided in an embodiment of the present invention, the memory pages that will not be accessed again in a short time before the current access position are directly recycled and applied to the sendfile packet sending mechanism of the Linux system, thereby greatly improving the overall performance of the CDN server.

[0038] In another embodiment, the multimedia server 200 refers to a CDN server supporting an HPD on-demand service scenario, and supports an HPD large file download on-demand service on the Internet OTT service. The multimedia file source stored on the CDN is read out to support HTTP download, and is carried on TCP and sent to the requesting terminal. The HPD on-demand service is also a typical model combining disk reading and packet sending. By adopting the memory cache management method provided in an embodiment of the present invention, the memory pages that will not be accessed again in a short period of time are directly recycled based on the current access position, and are applied to the sendfile packet sending mechanism of the Linux system, the overall performance of the CDN server is greatly improved.

[0039] See also Figure 2 , is a flow chart of a memory cache management method provided by an embodiment of the present invention, the memory cache management method comprising the following steps:

[0040] Step 101, receiving a memory application request;

[0041] Step 103, obtaining a target page of a set size before the current access position according to the memory application request;

[0042] Step 105: when it is determined that the target page is acquired, the target page is used to store data corresponding to the memory application request, and the target page is inserted after the current access position.

[0043] Here, the multimedia server receiving the memory application request may be that the multimedia server reads the corresponding slice file from the hard disk into the memory based on the multimedia file playback instruction sent by the client, and receives the memory application request when it is determined that the memory is insufficient. In a specific application, the multimedia server receiving the memory application request may also be that the multimedia server sets an interface for file access heat, and the multimedia server reads the corresponding slice file from the hard disk into the memory based on the multimedia file playback instruction sent by the client, and receives the memory application request when the interface for calling the file access heat predicts that the current heat of the corresponding multimedia file is a non-hot file.

[0044] The multimedia server obtains the target page of a set size before the current access position according to the memory application request. This can be done by, at the offset position of the current access file, using the file cache management structure, such as the page in the radix tree used by Linux, to determine the target page before the corresponding page for acquisition. When the multimedia server determines that the target page has been acquired, it uses this part of the target page to store the slice data corresponding to the memory application request read from the hard disk, and inserts the target page after the current access position. When the data of the target page is new, the input and output (IO) can be initiated to read directly. In this way, it is equivalent to directly obtaining the target page before the current access position for replacement. By modifying some position parameters related to the target page, it can be inserted into the cache of the corresponding file. The direct replacement of memory avoids the operation of the linked list in the radix tree and reduces the consumption of the CPU.

[0045] In the above embodiment of the present invention, when the multimedia server determines that it needs to apply for memory, it can directly recycle the target page of the set size before the current access position, instead of using the operating system to obtain the required memory according to a unified cache recovery method. By using the directly recovered target page to store data, it is equivalent to realizing the recycling of the page cache. Compared with the known method of obtaining the cache by using a unified cache recovery algorithm to recycle and release the old cache page through the operating system, by using the directly replaced target page to store the new file data, the cache recycling can be realized without the need for a system call, which greatly reduces the consumption of the operating system by the cache page swap out, and also reduces the problem of poor user experience caused by latency.

[0046] See also Figure 3 In one embodiment, in the memory cache management method provided by the embodiment of the present invention, after obtaining the target page of the set size before the current access position according to the memory application request, it also includes:

[0047] Step 107 : when it is determined that the target page has not been obtained, the operating system OS obtains the cache corresponding to the memory application request according to a set memory recycling algorithm.

[0048] Here, the set memory recycling algorithm refers to a linked list method for managing aged cache from the perspective of the page, and an LRU or LFU algorithm for cache management and recycling. The OS obtains the cache corresponding to the memory application request according to the set memory recycling algorithm, which means that when the operating system reads a file from the disk into the memory, when a cache hit request occurs, a unified LRU or LFU algorithm is used to swap out the old cache, and then the swapped out memory is used for reading and writing new files.

[0049] In the above embodiment of the present invention, when the direct recycling method fails to apply for memory and the target page cannot be obtained, the memory can be obtained from the cache of the corresponding CPU through the OS, while ensuring the high efficiency and success rate of memory acquisition.

[0050] In one embodiment, step 101, receiving a memory application request, includes:

[0051] A file pre-reading request is received, the file pre-reading request carrying size information of a memory block to be sent to a hard disk; or a file reading request is received, the file reading request carrying set page size information.

[0052] When reading a file, there are two main entries for applying for memory: a pre-read interface, which can increase the block size sent to the hard disk and ensure IO performance; and a normal read interface, which can be applied according to the page size. For example, the default for Linux is 4k.

[0053] In the above embodiment of the present invention, whether through the pre-read interface or the common read interface, the target page between the current access position can be directly recovered for replacement. Compared with the currently known use of a unified memory recovery algorithm to calculate the memory that needs to be swapped out, if the LRU algorithm is used to calculate the memory that needs to be swapped out, it is necessary to traverse the LRU linked list to release it, and in order to speed up the traversal, the LRU linked list is split into an acte linked list and an inactive link, so that for a media server with a memory of tens to hundreds of GB, the linked list will be relatively long, and the performance consumption is very large when traversing and obtaining. When the memory is insufficient, the time to trigger the memory recovery algorithm to apply for memory is uncontrollable. The embodiment of the present invention can configure a memory application mode for directly replacing a target page of a set size obtained before the current access position when applying for a large block of memory in a pre-reading manner or a small block of memory in a normal reading manner, and swap out from the cache before the file. When swapping out, there is no need to modify the position of the target page in the linked list. By modifying the position parameter of the page, the target page storing new data is inserted into the cache corresponding to the file, which can avoid linked list operations and reduce system consumption; batch caching can be performed when swapping out, and when applying for memory again, it can be applied from the swapped out memory, thereby realizing direct recycling of the memory. After playing a large file of several GB, only a very small part of the memory, such as 2-5M, can be occupied, thereby greatly reducing the consumption when the cache is swapped out, and the time for applying for memory is more controllable.

[0054] In one embodiment, in the memory cache management method, after using the target page to store the data corresponding to the memory application request, the method further includes:

[0055] Update the reference count of the target page.

[0056] In the embodiment of the present invention, the cache recovery mechanism of the system has not changed, that is, the mechanism of the OS to release the cache according to the set memory recovery algorithm has not changed. When adopting a memory application mode based on obtaining a target page of a set size before the current access position for direct replacement, after using the replaced target page to store new data, by updating the reference count of the target page, it is possible to avoid the target page in the radix tree being recycled by the system's cache recovery mechanism when it is reused. Here, updating the reference count of the target page can be to increase the reference count of the corresponding target page, which can avoid locking and reducing performance. After initiating IO to read the target page, the reference count is reduced, and the location of the file pointed to by the page is already the latest. Here, after updating the reference count of the target page, it can also include updating other related data for managing cache pages such as page identifiers.

[0057] In one embodiment, see Figure 4 In the memory cache management method, before obtaining the target page of the set size before the current access position according to the memory application request, it also includes:

[0058] Step 102, determining whether the memory application request is a memory application request for an audio or video file, and determining whether a current heat value of the audio or video file is less than a set heat range;

[0059] The step of obtaining a target page of a set size before a current access position according to the memory application request includes:

[0060] Step 1051, corresponding to the memory application request being a memory application request for an audio or video file, and when it is determined that the current heat value of the audio or video file is less than a set heat range, a target page of a set size before the current access position is obtained according to the memory application request.

[0061] Further, after determining whether the memory application request is a memory application request for an audio or video file, the method further includes:

[0062] Step 1052, corresponding to the memory application request being a memory application request for an audio or video file, and when it is determined that the current heat value of the audio or video file meets the set heat range, the cache corresponding to the memory application request is obtained through the OS according to the set memory recovery algorithm.

[0063] Here, the media server can choose to adopt a memory application mode of directly replacing a target page of a set size obtained before the current access position or a memory recovery mode of obtaining a cache through the OS according to a set memory recovery algorithm, based on whether the read file corresponding to the memory application request is an audio or video file and the current popularity of the audio or video file. The multimedia server can set an interface for file access popularity. For files whose popularity can be predicted, such as TV series, movies, and ball games that are hot based on on-demand records and the home page display of the Electronic Program Guide (EPG), the predicted popularity calculation and the corresponding time attribute are placed in the slice file. For audio and video files whose current popularity values ​​meet the set popularity range, the memory recovery mode of obtaining a cache through the OS according to a set memory recovery algorithm is used to obtain memory; otherwise, the memory application mode of directly replacing a target page of a set size obtained before the current access position is used to obtain memory. For audio and video files whose heat values ​​meet the set heat range, since audio and video files with high heat values ​​are accessed by many people in the corresponding time period, the memory recycling mode of the cache is obtained by the OS according to the set memory recycling algorithm, so that the cache of files with many access times can be kept in the memory as much as possible, reducing the replacement of the cache. Here, determining whether the current heat value of the audio and video file meets the set heat range can be based on the relevant information of the heat value carried in the switching file corresponding to the audio and video file. Determine whether the current heat value of the audio and video file meets the set heat range.

[0064] It should be noted that the popularity of files is within a certain time range. For example, an episode of a new TV series will be almost unaccessed after a certain period of time. Here, through the file access popularity interface, the popularity of the slice file corresponding to the corresponding file is calculated and updated in real time based on the set popularity calculation rules, and the popularity value and the corresponding time attribute are saved in the switching file. For sudden hot files, as the number of accesses increases rapidly, you can also switch from using the set memory recovery algorithm to obtain the cache memory recovery mode to obtain memory, and switch to the memory application mode that uses the target page of the set size obtained before the current access position for direct replacement to obtain memory, to ensure that the cache is in memory as much as possible.

[0065] In one embodiment, in the memory cache management method, when determining that the memory application request is a memory application request for an audio or video file, obtaining a target page of a set size before a current access position according to the memory application request includes:

[0066] When it is determined that the memory application request is a memory application request for an audio or video file of a first definition, obtaining a target page of a first set size before a current access position according to the memory application request;

[0067] When it is determined that the memory application request is a memory application request for an audio or video file of a second definition, a target page of a second set size before a current access position is obtained according to the memory application request, the first definition is higher than the second definition, and the first set size is larger than the second set size.

[0068] Here, when applying for memory, the available cache can be found based on the cache search position passed in by the user state, such as the first few MB of the current access position. For playback requests of audio and video files of different resolutions, the transmission efficiency of the data packets that read data from the hard disk to the memory and then send them is different, that is, the number of pages that need to be sent within a certain period of time is also very different. In an embodiment of the present invention, in response to the client's playback request for audio and video files of different resolutions, when acquiring memory based on a memory application mode of directly replacing a target page of a set size before the current access position, the application position of the target page of the set size is correspondingly different, that is, the position that needs to be recovered can be adjusted according to the bit rate of the audio and video file. Taking the first definition as HD as an example, the number of pages sent within a certain period of time is large, such as 20M / s, then it is necessary to apply for the target page at a relatively farther place before the current access position, such as 20M before the current access position, to avoid the cached page that has not been released by the network card when the distance is close. Taking the second definition as SD as an example, the number of pages sent within a certain period of time is relatively small, so the target page can be applied for at a relatively closer place before the current access position, such as 2M before the current access position, which must have been sent by the network card, and the page can be used with a high probability. It should be noted that here, the memory application request for the audio and video file of the first definition and the memory application request for the audio and video file of the second definition can refer to the memory application request for different audio and video files of different definitions, or the memory application request for the file segments of different definitions of the same audio and video file. The audio and video files of the first definition and the second definition correspond to different bit rates of the audio and video files respectively. Taking the first definition as HD and the second definition as SD as an example, they correspond to different definition ranges respectively, rather than a specific definition value.

[0069] In order to further understand the implementation principle of the memory cache management method provided by the embodiment of the present invention, the following specifically takes the media server of the Linux system as an example to illustrate the process of the memory cache management method. Figure 5, where the Linux system uses a radix tree to manage the cache page of a single file view. The pointer page* of the cache page is stored in the radix node. Each file has a separate inode. The inode finds the corresponding cache radix tree through address_space. When the user requests to obtain a page from the cache, it is obtained from the radix tree. The memory cache management method includes the following steps:

[0070] Step S11, obtaining a file read request, and when it is determined that the memory is insufficient, receiving a memory application request;

[0071] Step S12, determining whether the currently requested file is a hot file; if not, executing steps S13 to S15; if yes, executing step S16;

[0072] Step S13, setting the memory application mode to a replacement mode, in which, according to the memory application request, a target page of a set size before the current access position is obtained; wherein, the replacement mode is an abbreviation for a memory mode of directly replacing a target page of a set size before the current access position by using a memory application mode to obtain a memory mode;

[0073] Step S14, determining whether the target page is obtained;

[0074] Step S15, when it is determined that the target page is obtained, the target page is used to store the data corresponding to the memory application request, and after the target page is inserted into the current access position, the reference count of the target page is increased; when it is determined that the target page is not obtained, step S16 is executed;

[0075] Step S16, setting the memory application mode to the recycling mode. In the recycling mode, the operating system OS obtains the cache corresponding to the memory application request according to the set memory recycling algorithm; wherein the recycling mode refers to the abbreviation of the memory recycling mode of obtaining the cache using the set memory recycling algorithm.

[0076] Step S17, pre-reading the cache acquired through the replacement mode or the recycling mode, and returning the file reading result to the client.

[0077] Among them, the memory cache management method can configure the behavior of the OS in applying for memory by setting an interface call, such as a / proc or / sys interface. At the same time, for each file, due to the different memory search locations, an interface for setting the search location can be provided for user mode use, or a default search range can be used. By calling the interface, the adaptability of the memory cache management method can be increased. Similar interfaces can be implemented for open source Unix or other Unix-like OSs, including closed source OSs such as Windows, to achieve corresponding functions. It can be implemented in the OS as a kernel feature, or as a kernel module loaded into the kernel.

[0078] Please refer to Figure 6 , is a timing diagram of the interaction between the client and the operating system OS of the multimedia server. The OS returns a file handle based on the file read request of the client. The client queries the file temperature through the interface of the set file access temperature according to the file handle. The OS sets the memory mode according to the file temperature. When the file temperature is less than the set temperature range, the memory mode is set to a memory application mode that uses a target page of a set size obtained before the current access position for direct replacement. The OS receives the client's request to read or send a file, directly obtains the target page before the current access position for replacement and recycling, and returns the reading or sending result to the client. When the file temperature value is greater than the set temperature range or the target page is not obtained, the memory mode is set to a memory recycling mode that uses the set memory recycling algorithm to obtain the cache. The OS releases the cache through the LRU or LFU algorithm and swaps out the old cache for new file reading and writing.

[0079] Taking the application of the memory cache management method to the CDN server supporting the RTSP on-demand service as an example, when the memory cache management method is used to read the disk and send packets for the file playback request issued by the client, the performance comparison data of the CDN server is shown in Table 1 and Table 2 below:

[0080] Table 1

[0081]

[0082]

[0083] Table 2

[0084]

[0085]

[0086] By comparing Table 1 and Table 2, it can be seen that Table 1 indicates that the memory cache management method provided by the embodiment of the present invention is loaded. Under the performance flow of 93G, the CPU system occupancy is only about 25%, the idle is above 45%, and it is relatively stable; Table 2 indicates that the memory cache management method provided by the embodiment of the present invention is not loaded. Also under the performance flow of 93G, the CPU system occupancy is only about 57%-61%, the idle is below 15%, and often fluctuates below 10%.

[0087] In one embodiment, a memory cache management device is provided. The memory cache management device can be, for example, an interface for setting a memory mode, which is used to receive a memory application request; obtain a target page of a set size before a current access position according to the memory application request; when it is determined that the target page is obtained, use the target page to store data corresponding to the memory application request, and insert the target page after the current access position.

[0088] The memory cache management device is further used to obtain the cache corresponding to the memory application request through the operating system OS according to a set memory recycling algorithm when it is determined that the target page has not been obtained.

[0089] Among them, the memory cache management device is used to receive memory application requests, which may include: receiving a file pre-read request, the file pre-read request carries the size information of the memory block that needs to be sent to the hard disk; or, receiving a file read request, the file read request carries the set page size information.

[0090] Wherein, the memory cache management device is further used to update the reference count of the target page after the target page is used to store the data corresponding to the memory application request.

[0091] Among them, the memory cache management device is also used to determine whether the memory application request is a memory application request for an audio or video file, and determine whether the current heat value of the audio or video file is less than the set heat range before obtaining the target page of the set size before the current access position according to the memory application request; the obtaining the target page of the set size before the current access position according to the memory application request includes: corresponding to the memory application request being a memory application request for an audio or video file, and determining that the current heat value of the audio or video file is less than the set heat range, obtaining the target page of the set size before the current access position according to the memory application request.

[0092] Among them, the memory cache management device is also used to obtain the cache corresponding to the memory application request through the OS according to the set memory recovery algorithm after judging whether the memory application request is a memory application request for an audio or video file, corresponding to the memory application request being a memory application request for an audio or video file, and determining that the current heat value of the audio or video file meets the set heat range.

[0093] Among them, the memory cache management device is also used to obtain the cache corresponding to the memory application request through the OS according to the set memory recovery algorithm after determining whether the memory application request is a memory application request for an audio or video file and determining that the memory application request is a memory application request for a non-audio or video file.

[0094] Among them, the memory cache management device is used to obtain a target page of a set size before the current access position according to the memory application request, which may include: when it is determined that the memory application request is a memory application request for an audio or video file of a first definition, obtaining a target page of a first set size before the current access position according to the memory application request; when it is determined that the memory application request is a memory application request for an audio or video file of a second definition, obtaining a target page of a second set size before the current access position according to the memory application request, the first definition is higher than the second definition, and the first set size is larger than the second set size.

[0095] It should be noted that the memory cache management device and the memory cache management method provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0096] The embodiment of the present invention also provides a multimedia server, see Figure 7, the multimedia server includes a processor 201 and a storage medium 202 for storing a computer program that can be run on the processor 201, wherein the processor 201 is used to execute the steps of the memory cache management method provided in any embodiment of the present application when running the computer program. Here, the processor 201 and the storage medium 202 do not refer to the corresponding quantity as one, but can be one or more. Among them, the multimedia server also includes a memory 203, a network interface 204, and a system bus 205 that connects the processor 201, the memory 203, the network interface 204 and the storage medium 202. The storage medium 202 stores an operating system and a memory cache management device for implementing the memory cache management method provided in an embodiment of the present invention. The processor 201 is used to improve computing and control capabilities and support the operation of the entire multimedia server. The memory 203 is used to provide an environment for the operation of the memory cache management method in the storage medium 202, and the network interface 204 is used to communicate with the client over the network, receive or send data, for example, receive a file read request sent by the client, return a file read result to the client, etc.

[0097] The embodiment of the present invention also provides a computer storage medium, for example, including a memory storing a computer program, and the computer program can be executed by a processor to complete the steps of the memory cache management method provided in any embodiment of the present application. The computer storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disk, or CD-ROM; it can also be various devices including one or any combination of the above memories.

[0098] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. The protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A memory cache management method, characterized in that: include: Receive memory application request; Acquire a target page of a set size before a current access position according to the memory application request; When it is determined that the target page has not been obtained, obtaining the cache corresponding to the memory application request according to a set memory recycling algorithm through the operating system OS; When it is determined that the target page is acquired, the target page is used to store data corresponding to the memory application request, and the target page is inserted after the current access position.

2. The memory cache management method according to claim 1, characterized in that: The receiving of the memory application request comprises: receiving a file pre-reading request, wherein the file pre-reading request carries size information of a memory block to be sent to a hard disk; or, A file read request is received, where the file read request carries set page size information.

3. The memory cache management method according to claim 1, characterized in that: After using the target page to store the data corresponding to the memory application request, the method further includes: Update the reference count of the target page.

4. The memory cache management method according to claim 1, characterized in that: Before obtaining the target page of the set size before the current access position according to the memory application request, the method further includes: Determine whether the memory application request is a memory application request for an audio or video file, and determine whether a current heat value of the audio or video file is less than a set heat range; The step of obtaining a target page of a set size before a current access position according to the memory application request includes: Corresponding to the memory application request being a memory application request for an audio or video file, and when it is determined that the current heat value of the audio or video file is less than a set heat range, a target page of a set size before a current access position is obtained according to the memory application request.

5. The memory cache management method according to claim 4, characterized in that: After determining whether the memory application request is a memory application request for an audio or video file, the method further includes: Corresponding to the memory application request being a memory application request for an audio or video file, and when it is determined that the current heat value of the audio or video file meets the set heat range, the cache corresponding to the memory application request is obtained through the OS according to the set memory recovery algorithm.

6. The memory cache management method according to claim 4, characterized in that: After determining whether the memory application request is a memory application request for an audio or video file, the method further includes: When it is determined that the memory application request is a memory application request for non-audio and video files, a cache corresponding to the memory application request is obtained through the OS according to a set memory recycling algorithm.

7. The memory cache management method according to claim 4, characterized in that: When determining that the memory application request is a memory application request for an audio or video file, obtaining a target page of a set size before a current access position according to the memory application request includes: When it is determined that the memory application request is a memory application request for an audio or video file of a first definition, obtaining a target page of a first set size before a current access position according to the memory application request; When it is determined that the memory application request is a memory application request for an audio or video file of a second definition, a target page of a second set size before a current access position is obtained according to the memory application request, the first definition is higher than the second definition, and the first set size is larger than the second set size.

8. A multimedia server comprising a processor and a memory for storing a computer program that can be run on the processor; wherein: When the processor is used to run the computer program, it executes the memory cache management method according to any one of claims 1 to 7.

9. A computer storage medium, characterized in that The computer storage medium stores a computer program, and when the computer program is executed by a processor, the memory cache management method according to any one of claims 1 to 7 is implemented.