Cache resource adjustment method and related products
By dynamically adjusting the cache resources of computer equipment, and based on the used and allocated cache resources and the attributes and scenario information of the data to be cached, the problem of cache resources is solved and the smoothness of the system is improved.
Patent Information
- Application Number
- CN202211114943.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-14
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2042-09-14
AI Technical Summary
In the prior art, due to the switching of video application scenarios, especially for large-resolution videos, excessive cache resources are allocated to lead to memory waste.
By responding to resource adjustment instructions, we determine the used cache resources in the computer device and allocate cache resources, obtain the target information of the data to be cached, and dynamic adjustment of cache resources is performed based on the target information, including scene switching and attribute changes, so as to reasonably allocate cache resources.
It effectively avoids waste of cache resources, saves memory space, and improves the smoothness of system operation.
Smart Images

Figure CN115421916B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a cache resource adjustment method and related products. Background Art
[0002] The management and allocation of cache resources are widely used in fields such as computer programming and network communications. This is because data caching is often necessary, such as in video scenarios. In the mobile internet era, a large number of video playback and interactive activities are involved. However, for different video application scenarios, the transmission and caching of video streams are subject to significant uncertainty.
[0003] In the prior art, in order to cover more video application scenarios, more buffer resources are usually allocated. However, in actual applications, due to the switching of video application scenarios, especially for high-resolution videos, the allocation of more buffer resources will occupy too much memory, resulting in resource waste. Summary of the Invention
[0004] The technical problem to be solved by the embodiments of the present application is to provide a cache resource adjustment method and related products that can reduce the problem of resource waste existing in the prior art.
[0005] In a first aspect, embodiments of the present application disclose a cache resource adjustment method, the method comprising:
[0006] In response to a resource adjustment instruction, determining used cache resources in the computer device and allocating cache resources;
[0007] When the used cache resources are less than the allocated cache resources, acquiring target information of the data to be cached, the target information being used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached;
[0008] The cache resources of the computer device are allocated and adjusted according to the target information.
[0009] In a second aspect, an embodiment of the present application further discloses a cache resource adjustment device, comprising: a determination module, an acquisition module, and an adjustment module, wherein:
[0010] The determining module is configured to determine used cache resources and allocated cache resources in the computer device in response to a resource adjustment instruction;
[0011] The acquisition module is configured to acquire target information of the data to be cached when the used cache resources are less than the allocated cache resources, wherein the target information is used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached;
[0012] The adjustment module is used to allocate and adjust the cache resources of the computer device according to the target information.
[0013] According to a third aspect, a computer device is provided, comprising: a processor, a memory, a communication interface and a bus; the processor, the memory and the communication interface are connected via the bus and communicate with each other; the memory stores executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute all or part of the implementation steps of the method described above.
[0014] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program executed by a computer device, wherein the computer program enables the computer device to execute all or part of the implementation steps of the method described above.
[0015] Compared with the prior art, this application has the following beneficial effects:
[0016] In an embodiment of the present application, a computer device responds to a resource adjustment instruction to determine the used cache resources and allocated cache resources in the computer device; when the used cache resources are less than the allocated cache resources, target information of the data to be cached is obtained, the target information being used to indicate the attributes of the data to be cached and / or the scenario associated with the data to be cached; and the cache resources of the computer device are allocated and adjusted according to the target information. By adopting an embodiment of the present application, the cache resources within the device can be dynamically adjusted according to actual cache requirements based on the used cache resources and allocated cache resources in the computer device, thereby avoiding the problem of resource waste in the prior art, thereby saving the memory space occupied by cache resources and facilitating the smoothness of system operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 This is a schematic diagram of a video decoding process provided by the prior art.
[0019] Figure 2 This is a flow chart of a cache resource adjustment method provided in an embodiment of the present application.
[0020] Figure 3 This is a flow chart of another cache resource adjustment method provided in an embodiment of the present application.
[0021] Figure 4 This is a flow chart of another cache resource adjustment method provided in an embodiment of the present application.
[0022] Figure 5 This is a flow chart of another cache resource adjustment method provided in an embodiment of the present application.
[0023] Figure 6 This is a flow chart of another cache resource adjustment method provided in an embodiment of the present application.
[0024] Figure 7 This is a structural diagram of a cache resource adjustment device provided in an embodiment of the present application.
[0025] Figure 8 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0027] The terms "first," "second," and "third" (if any) in the specification and claims of this application and the accompanying drawings are used to distinguish different objects, not to describe a specific order. In addition, the terms "comprises" and "comprising" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to the process, method, product, or apparatus.
[0028] In the process of filing this application, the applicant also found that: Figure 1 This is a flow chart of video decoding provided by the prior art. Figure 1 After obtaining the video stream, the computer device allocates cache resources (buffer) to the hardware / software decoder, then sends the video stream to the hardware / software decoder to start decoding, and finally outputs the decoded data to a file or transmits it to the screen for display.
[0029] The video encoding process is similar. Specifically, after obtaining raw video data (e.g., color-encoded YUV data), the computer allocates cache resources to the hardware / software decoder, then sends the raw video data to the hardware / software encoder for encoding. Finally, the encoded data is output to a file or sent to another device.
[0030] In the mobile Internet era, a large number of video playback and video interaction activities are involved, and complex video application scenarios, video stream transmission and caching are subject to great uncertainty. In the existing technology, in order to cover as many application scenarios as possible, more cache resources tend to be allocated when allocating cache resources. However, in actual applications, due to changes in scenarios, especially for high-resolution videos, too many cache resources will occupy a lot of memory due to allocation, resulting in resource waste. For example, when playing a 4K movie, a computer device can allocate 10 cache resources, and the cache space of each cache resource is approximately 12M. However, in actual use, the computer device detects that 4 cache resources are used, which can meet the application scenario, so the other 6 cache resources can be released, thereby saving 72M of memory space.
[0031] Please refer to Table 1 below, which shows the correspondence between some video resolutions and the cache resources used by frame videos.
[0032] Table 1
[0033]
[0034] Table 1 shows that as video resolution increases from the standard image format (352×288) to 8K, the pixels increase from 352×288 to 7680×4320, and the cache resources occupied by each video frame increase from 152KB to 50MB. This shows that for higher-resolution videos, the memory waste caused by redundant cache resources is more severe, and accordingly, the benefits of cache resource adjustment are greater.
[0035] Based on this, this application proposes a cache resource adjustment method and related products. By dynamically adjusting cache resources, memory space can be saved, thereby improving the smoothness of system operation. The following first introduces several application scenarios applicable to this application.
[0036] First, the encoding scenario. The cache resource adjustment scheme involved in this application can be applied to encoding scenarios, which may include but are not limited to scenarios such as image encoding, voice encoding, or video encoding. Accordingly, the cache data involved in this application in this scenario includes but is not limited to image data, voice data, video data, or other data that supports encoding.
[0037] Second, decoding scenarios. The cache resource adjustment scheme involved in this application can be applied to decoding scenarios, which may include but are not limited to scenarios such as image decoding, voice decoding, or video decoding. Accordingly, in this scenario, the cache data involved in this application includes but is not limited to image data, voice data, video data, or other data that supports decoding.
[0038] Third, other application scenarios. The cache resource adjustment scheme involved in this application can be applied to scenarios other than encoding and decoding scenarios, that is, non-encoding and decoding scenarios. Accordingly, the cache data involved in this application in this scenario includes but is not limited to image data, voice data, video data, text data or other data to be cached.
[0039] Next, several method embodiments provided by this application are introduced. Figure 2 , is a flow chart of a cache resource adjustment method provided by an embodiment of the present application. Figure 2 The method is applied to a computer device, including but not limited to a smartphone (e.g., an Android phone, an iOS phone, etc.), a personal computer, a tablet computer, a PDA, a mobile internet device (MID), or a wearable smart device. The method includes the following steps:
[0040] S201 : In response to a resource adjustment instruction, determine used cache resources and allocate cache resources in the computer device.
[0041] The resource adjustment instructions described in this application can be generated by developers based on actual needs, or they can be received from other devices (such as servers or terminal devices). The resource adjustment instructions are used to indicate support for dynamic adjustment of cache resources in the computer device. The cache resources involved in this application can refer to the size of the cache resources, that is, the size of the memory space occupied; it can also refer to the number of cache resources, that is, the number of buffers, which is not limited in this application.
[0042] The used cache resources are the cache resources that have been used in the computer device, that is, data has been cached in the cache resources. The allocated cache resources are the cache resources allocated by the computer device for the current cache scenario, which are usually pre-allocated maximum cache resources that can support the cache scenario. For example, in an encoding scenario, the allocated cache resources can be allocated according to the level of the encoder used in the encoding scenario, and its encoding level will limit the maximum cache resources for different cached data. Correspondingly, in a decoding scenario, the allocated cache resources can be allocated according to the level of the decoder used in the decoding scenario, and its decoding level will limit the maximum cache resources for different cached data, such as the number of decoded picture buffers (DPBs), etc.
[0043] S202: When the used cache resources are less than the allocated cache resources, obtain target information of the data to be cached, where the target information is used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached.
[0044] This application does not limit the type of data to be cached. It is related to the application scenario corresponding to the cache (referred to as the cache scenario). For example, in the encoding scenario, the data to be cached may be image data, voice data, or video data, etc.; in the non-encoding and decoding scenario, the data to be cached may be video data or text data, etc., which can be found in the previous introduction to the cache data, which will not be repeated here.
[0045] The target information includes but is not limited to at least one of the following: attribute information of the data to be cached, scene information corresponding to the data to be cached, or other information that affects resource regulation, etc. The attribute information is information used to describe the attributes of the data to be cached, which may include but is not limited to the size of the data to be cached. When the data to be cached is video data or image data, the attribute information may also include the resolution of the data to be cached, etc. The scene information is used to indicate the current scene of the data to be cached, and can also be used directly to indicate whether the current scene of the data to be cached has been switched, such as whether the user has changed channels (changed TV channels), or whether the display resolution has been switched, such as from standard display to ultra-high-definition display, etc.
[0046] S203: Allocate and adjust cache resources of the computer device according to the target information.
[0047] By implementing the embodiment of the present application, the computer device responds to the resource adjustment instruction and determines the used cache resources and allocated cache resources in the computer device; when the used cache resources are less than the allocated cache resources, the target information of the data to be cached is obtained, and the target information is used to indicate the attributes of the data to be cached and / or the scenario associated with the data to be cached; and the cache resources of the computer device are allocated and adjusted according to the target information. By adopting the embodiment of the present application, the cache resources in the device can be dynamically adjusted according to the actual cache requirements based on the used cache resources and allocated cache resources in the computer device, thereby avoiding the problem of cache resource waste, thereby saving the memory space occupied by the cache resources, and helping to improve the smoothness of system operation.
[0048] See Figure 3 , is a flow chart of another cache resource adjustment method provided by an embodiment of the present application. Figure 3 The method shown is applied to a computer device, and the method includes the following implementation steps:
[0049] S301. In response to a resource adjustment instruction, register a cache monitoring service in the computer device, where the cache monitoring service is used to monitor and mark the usage status of cache resources in the computer device.
[0050] After determining to start the resource adjustment function, the present application may first register a cache monitoring service in the computer device, such as a cache quantity monitoring service (buffer_count service). The cache monitoring service is used to monitor all cache resources in the computer device and mark the usage status of each cache resource. For example, monitor the number of cache resources actually used, mark the usage status of the used cache resources as used (USED) status, mark the usage status of the unused cache resources as unused (UNUSED) status, etc. The usage status of each cache resource can be adjusted and changed according to the actual usage conditions. This application does not elaborate on the registration implementation of the cache monitoring service, for example, it can be implemented by responding to the registration request of the cache monitoring service.
[0051] S302: Call the cache monitoring service to determine the used cache resources and allocate cache resources in the computer device.
[0052] S303: Determine whether the used cache resources are less than the allocated cache resources.
[0053] The present application can first determine the used cache resources and allocated cache resources in the computer device through the cache monitoring service. Then, it can determine whether the used cache resources are less than the allocated cache resources. When it is determined that the used cache resources are less than the allocated cache resources, step S304 can be continued. Otherwise, the cache resources can be dynamically adjusted according to actual needs, specifically, for example, the corresponding cache resources can be reallocated according to the cache space required for the data to be cached. Furthermore, the present application can incorporate the reallocated cache resources into the dynamic adjustment.
[0054] S304: Acquire target information of the data to be cached, where the target information is used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached.
[0055] The target information described in this application is used to adjust the cache resources in the computer device, and the target information includes but is not limited to at least one of the following: attribute information of the data to be cached, scene information corresponding to the data to be cached, or other information that affects resource adjustment. Figure 2 The relevant introduction in the embodiments will not be repeated here.
[0056] S305: Allocate and adjust the cache resources of the computer device according to the target information.
[0057] After obtaining the target information, the present application can allocate and adjust the cache resources in the computer device according to the target information. The implementation method of the allocation and adjustment can be found in Figure 4 As shown, Figure 4 The cache resource adjustment method shown includes the following implementation steps:
[0058] S401: If the target information includes scene information corresponding to the data to be cached, determine whether a scene switch occurs in the cached data in the computer device according to the scene information.
[0059] This application does not limit the implementation method for determining the scene switch. For example, this application may perform a consistency comparison based on the scene information of the current data to be cached and the scene information of the last cached data stored in the system to determine whether a scene switch has occurred. Alternatively, this application may directly determine whether a scene switch has occurred based on the indication of the scene information. In this case, the scene information is directly used to indicate whether a scene switch has occurred in the data to be cached.
[0060] Accordingly, if it is determined that no scene switching occurs in the cache resources in the computer device, step S402 is continued to be executed; otherwise, the process can be terminated, or step S403 is continued to be executed.
[0061] It should be noted that scene switching in video data may include, but is not limited to, switching from a single scene to a complex scene, or switching from a static scene to a moving scene. Each scene switching will cause changes in cache resources. Therefore, this application needs to dynamically allocate and adjust cache resources based on the scene switching of the data to maximize the rational use of cache resources, improve cache resource utilization, and avoid resource waste.
[0062] S402: After a preset time period is reached, the redundant cache resources in the computer device are released.
[0063] When the present application determines that no scene switching has occurred in the cache resources in the computer device, after a preset period of time, that is, after the cache resources occupied by the system have reached stability, the present application may first determine the maximum cache resources occupied in actual use. Then, based on the allocated cache resources and the maximum cache resources, the redundant cache resources in this scenario are determined, and finally the redundant cache resources are released. The size of the redundant cache resources described here is the difference between the allocated cache resources and the maximum cache resources, and the usage status of the redundant cache resources is all unused (UNSED). The preset duration is a system-customized duration, which is used to characterize the duration required for the computer device to enter a stable data cache. The duration can be an empirical value set based on user experience, or a numerical value obtained based on a series of experimental data statistics.
[0064] S403: If the target information includes attribute information of the data to be cached, determine whether the attribute of the cached data in the computer device has changed according to the attribute information.
[0065] This application does not limit the implementation method for determining the attribute change. For example, this application can directly determine whether an attribute change has occurred based on the indication of the attribute information. In this case, the attribute information is used to directly indicate whether the attribute of the data to be cached has changed. Alternatively, this application can perform a consistency comparison between the attribute information of the data to be cached and the attribute information of the last cached data stored in the system to determine whether an attribute change has occurred.
[0066] For example, taking the data to be cached as video data, the attribute information of the data to be cached is the resolution of the video data. Accordingly, after determining that a scene switch has occurred, the present application can further determine whether a resolution change has occurred. Specifically, the present application can parse the width field pic_width_in_luma_sample and the length field pic_height_in_luma_sample in the parameter setting (sequence parameter set) in the video data, and compare them with the width field and length field in the previous frame of video data for consistency, thereby determining whether a resolution change, that is, an attribute change, has occurred.
[0067] When it is determined that the attribute of the cache resource in the computer device has changed, step S404 may be continued to be executed; otherwise, step S405 may be executed.
[0068] S404: Allocate new cache resources for the data to be cached according to the attribute information.
[0069] This application can first release all cache resources in the computer device, and then allocate new cache resources to the data to be cached based on the attribute information of the data to be cached. For example, new cache resources can be re-allocated to the data to be cached based on the size or resolution of the data to be cached to meet the current cache requirements of the system. It can also increase or release cache resources based on cache resource requirements when cache resource attributes change.
[0070] S405: Allocate and adjust cache resources in the computer device according to the scenario information corresponding to the data to be cached.
[0071] In a possible implementation, when the required cache resources corresponding to the scenario information are greater than the allocated cache resources, new cache resources may be allocated for the data to be cached based on the required cache resources. At this time, the size of the new cache resources may be the difference between the required cache resources and the allocated cache resources.
[0072] In another possible implementation, when the required cache resources corresponding to the scenario information are less than the allocated cache resources, redundant cache resources in the computer device may be determined based on the required cache resources and the allocated cache resources, where the size of the redundant cache resources is the difference between the allocated cache resources and the required cache resources. Furthermore, the present application may release the redundant cache resources in the computer device.
[0073] It should be noted that the two solutions involved in steps S401-S402 and steps S403-S405 of the present application can be implemented separately or in combination. For example, when the target information described in the present application only includes the scene information corresponding to the data to be cached, the solution of steps S401-S402 can be implemented separately; when the target information includes the attribute information of the data to be cached, the solution of steps S403-S405 can be implemented separately; when the target information includes both the scene information corresponding to the data to be cached and the attribute information of the data to be cached, the solution of steps S401-S405 can be implemented in combination, etc.
[0074] By implementing the embodiment of the present application, the computer device responds to the resource adjustment instruction, registers the cache monitoring service in the computer device in response to the resource adjustment instruction; calls the cache monitoring service to determine the used cache resources and allocated cache resources in the computer device; when the used cache resources are less than the allocated cache resources, obtains the target information of the data to be cached, the target information is used to indicate the attributes of the data to be cached, and / or the scenario associated with the data to be cached; and allocates and adjusts the cache resources of the computer device according to the target information. By adopting the embodiment of the present application, the cache resources in the device can be dynamically adjusted according to the actual cache requirements based on the used cache resources and allocated cache resources in the computer device, thereby avoiding the problem of cache resource waste, thereby saving the memory space occupied by the cache resources, and helping to improve the smoothness of system operation.
[0075] See Figure 5 , is a flow chart of another cache resource adjustment method provided by an embodiment of the present application. Figure 5 The method shown is applied to a computer device, and the method includes the following implementation steps:
[0076] S501. In response to a resource adjustment instruction, register a cache monitoring service in the computer device, where the cache monitoring service is used to monitor and mark the usage status of cache resources in the computer device.
[0077] This application monitors the usage of cache resources in a computer device by a video communication server (VCS) by registering a buffer_count service, and updates the usage status of the cache resources in real time.
[0078] S502: Call the cache monitoring service to determine the used cache resources and allocate cache resources in the computer device.
[0079] S503: Determine whether the used cache resources are less than the allocated cache resources.
[0080] When the application determines that the used cache resources are less than the allocated cache resources, the application may continue to execute step S504; otherwise, the process may end. Figure 3 The introduction of steps S301-S303 in the embodiment will not be repeated here.
[0081] S504: Determine current redundant resources in the computer device according to the used cache resources and the allocated cache resources.
[0082] The present application can determine the current redundant resources in the computer device through the cache monitoring service. The current redundant resources can be determined based on the used cache resources and the allocated cache resources, or can be obtained by multiplying the redundant resources occupied by each cache data by the number of redundant cache data. For example, the current redundant resources can be obtained by multiplying the redundant resources occupied by each frame of video data by the number of redundant frame videos, etc.
[0083] S505: Determine whether the current redundant resources are greater than a preset redundant threshold.
[0084] After obtaining the current redundant resources, the present application may determine whether the current redundant resources are greater than a preset redundant threshold. If so, the process proceeds to step S506. Otherwise, the process may terminate and the cache resource usage status may no longer be monitored through the cache monitoring service. The preset redundant threshold may be a system-defined value, such as an empirical value set based on user experience.
[0085] It is understandable that for smaller cache data, such as video data with a smaller resolution (below 720P), since the originally applied allocated cache resources are not large, the redundant resources are also relatively small. At this time, there is no need to dynamically adjust the cache resources, that is, the dynamic adjustment of cache resources does not bring much benefit. On the contrary, dynamic adjustment of cache resources in this case may cause problems such as reduced cache efficiency due to frequent allocation and release of memory. Therefore, in this case, the present application can set a preset redundancy threshold. When the redundant resources in the computer device are less than the preset redundancy threshold, there is no need to dynamically adjust the cache resources.
[0086] S506: Acquire target information of the data to be cached, where the target information is used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached.
[0087] In an optional embodiment, before obtaining the target information of the data to be cached, the present application may further determine whether the current cache scenario is stable, specifically determining whether the used cache resources used in the computer device are constant (do not change) after reaching a preset time period. If so, the target information of the data to be cached is obtained; otherwise, the process may be terminated. The used cache resources may be the cache resources used in the computer device after reaching a preset time period, such as the maximum cache resources used in the computer device during the preset time period. The preset time period may be a time period customized by the system, for which details can be found in the relevant description of the aforementioned embodiment.
[0088] S507: Allocate and adjust the cache resources of the computer device according to the target information.
[0089] For the introduction of steps S506-S507 in the embodiment of the present application, please refer to the aforementioned Figure 3 and Figure 4 The relevant introduction in the embodiments will not be repeated here.
[0090] By implementing the embodiment of the present application, the computer device responds to the resource adjustment instruction, registers the cache monitoring service in the computer device in response to the resource adjustment instruction; calls the cache monitoring service to determine the used cache resources and allocated cache resources in the computer device; when the used cache resources are less than the allocated cache resources, obtains the target information of the data to be cached, the target information is used to indicate the attributes of the data to be cached, and / or the scenario associated with the data to be cached; and allocates and adjusts the cache resources of the computer device according to the target information. By adopting the embodiment of the present application, the cache resources in the device can be dynamically adjusted according to the actual cache requirements based on the used cache resources and allocated cache resources in the computer device, thereby avoiding the problem of cache resource waste, thereby saving the memory space occupied by the cache resources, and helping to improve the smoothness of system operation.
[0091] See Figure 6 , is a flow chart of another cache resource adjustment method provided by an embodiment of the present application. Figure 6 The method shown is applied to a computer device, and the method includes the following implementation steps:
[0092] S601: Determine a cache scenario of the computer device.
[0093] The method for determining the caching scene described in this application is not limited. For example, this application can determine it by analyzing the type of data to be cached, or by parsing specific fields in the data to be cached, such as parsing the width field pic_width_in_luma_sample and the length field pic_height_in_luma_sample in the sequence parameter set in the video data to determine the corresponding resolution size scene, etc.
[0094] The cache scenario involved in this application is used to describe the scenario where the cached data is located, which may include but is not limited to decoding scenarios, encoding scenarios, frequent switching scenarios, non-frequent switching scenarios, resolution size scenarios, high-definition scenarios, standard picture quality scenarios, ultra-high-definition scenarios, or other custom classification scenarios.
[0095] S602: Determine whether the cached scene is a preset scene.
[0096] The preset scenario described in this application is a scenario customized by the system. In this embodiment, for example, it is an infrequent switching scenario, that is, the switching frequency of the scenario is less than a preset frequency threshold.
[0097] When the present application determines that the cache scene is a preset scene, step S603 may be continued; otherwise, if it is determined that the current cache scene is in a frequently switched scene, that is, the scene switches frequently, there is no need to dynamically adjust the cache resources, and the process may be ended.
[0098] It should be noted that an alternative implementation of steps S601-S602 of the present application may be to determine the scene switching frequency of the computer device, and then proceed to step S603 if the scene switching frequency is less than a preset frequency threshold; otherwise, the process may terminate. The implementation method for determining the scene switching frequency is not limited. For example, the present application may determine the scene switching frequency by parsing specific fields in the cached data or based on the type of data to be cached, etc., which is not limited by the present application.
[0099] S603: In response to the resource adjustment instruction, determine the used cache resources and allocate cache resources in the computer device.
[0100] S604: Determine whether the used cache resources are less than the allocated cache resources.
[0101] S605: Acquire target information of the data to be cached, where the target information is used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached.
[0102] S606: Allocate and adjust the cache resources of the computer device according to the target information.
[0103] For the description of steps S603-S606 in the embodiment of the present application, please refer to the aforementioned Figure 2-Figure 5 The relevant introduction in the embodiments will not be repeated here.
[0104] By implementing the embodiment of the present application, the computer device determines the cache scenario of the computer device; when it is determined that the cache scenario is a preset scenario, in response to the resource adjustment instruction, the used cache resources and allocated cache resources in the computer device are determined; when the used cache resources are less than the allocated cache resources, the target information of the data to be cached is obtained, and the target information is used to indicate the attributes of the data to be cached and / or the scenario associated with the data to be cached; according to the target information, the cache resources of the computer device are allocated and adjusted. By adopting the embodiment of the present application, the cache resources in the device can be dynamically adjusted according to the actual cache requirements based on the used cache resources and allocated cache resources in the computer device, thereby avoiding the problem of cache resource waste, thereby saving the memory space occupied by the cache resources, and helping to improve the smoothness of system operation.
[0105] Based on the above embodiments, the following describes the device and equipment embodiments involved in this application. Figure 7 , is a structural embodiment of a cache resource adjustment device provided in an embodiment of the present application. Figure 7 The device shown includes a determination module 701, an acquisition module 702, and an adjustment module 703, wherein:
[0106] The determining module 701 is configured to determine used cache resources and allocated cache resources in the computer device in response to a resource adjustment instruction;
[0107] The acquisition module 702 is configured to acquire target information of the data to be cached when the used cache resources are less than the allocated cache resources, wherein the target information indicates attributes of the data to be cached and / or a scenario associated with the data to be cached;
[0108] The adjustment module 703 is configured to allocate and adjust the cache resources of the computer device according to the target information.
[0109] In some embodiments, the target information includes scene information corresponding to the data to be cached, and the adjustment module 703 is specifically used to: determine whether a scene switch has occurred in the cached data in the computer device based on the scene information; if not, release the redundant cache resources in the computer device after reaching a preset time.
[0110] In some embodiments, the target information includes attribute information of the data to be cached, and the adjustment module 703 is specifically used to: determine whether the attributes of the cached data in the computer device have changed based on the attribute information; if so, allocate new cache resources to the data to be cached based on the attribute information.
[0111] In some embodiments, the adjustment module 703 is further configured to: when it is determined that no attribute change has occurred, allocate and adjust cache resources in the computer device according to scenario information corresponding to the data to be cached.
[0112] In some embodiments, the adjustment module 703 is specifically used to: when the demand cache resources corresponding to the scenario information are greater than the allocated cache resources, allocate new cache resources to the data to be cached according to the demand cache resources; or, when the demand cache resources corresponding to the scenario information are less than the allocated cache resources, release the redundant cache resources in the computer device according to the demand cache resources.
[0113] In some embodiments, before determining the used cache resources in the computer device and allocating cache resources, the apparatus further includes a registration module (not shown), the registration module being configured to: register a cache monitoring service in the computer device, the cache monitoring service being configured to monitor and mark the usage status of the cache resources in the computer device;
[0114] The determining module 701 is specifically configured to: call the cache monitoring service, determine the used cache resources in the computer device, and allocate cache resources.
[0115] In some embodiments, before obtaining the target information of the data to be cached, the determining module 701 is further configured to: determine current redundant resources in the computer device based on the used cache resources and the allocated cache resources;
[0116] The acquisition module 702 is specifically configured to acquire target information of the data to be cached when the current redundant resource is greater than a preset redundant threshold.
[0117] In some implementations, the used cache resource is the maximum cache resource used in the computer device after a preset time period is reached.
[0118] In some embodiments, before determining the used cache resources in the computer device and allocating cache resources in response to the resource adjustment instruction, the determining module 701 is further configured to: determine a cache scenario of the computer device;
[0119] The determining module 701 is specifically configured to: when the cache scenario is a preset scenario, determine the used cache resources and allocate cache resources in the computer device in response to a resource adjustment instruction.
[0120] It should be noted that the specific implementation of each module involved in the embodiment of this application can refer to Figures 2 to 6 The description of the corresponding implementation steps in the corresponding embodiments will not be repeated here.
[0121] By implementing the embodiment of the present application, the computer device determines the cache scenario of the computer device; when it is determined that the cache scenario is a preset scenario, in response to the resource adjustment instruction, the used cache resources and allocated cache resources in the computer device are determined; when the used cache resources are less than the allocated cache resources, the target information of the data to be cached is obtained, and the target information is used to indicate the attributes of the data to be cached and / or the scenario associated with the data to be cached; according to the target information, the cache resources of the computer device are allocated and adjusted. By adopting the embodiment of the present application, the cache resources in the device can be dynamically adjusted according to the actual cache requirements based on the used cache resources and allocated cache resources in the computer device, thereby avoiding the problem of cache resource waste, thereby saving the memory space occupied by the cache resources, and helping to improve the smoothness of system operation.
[0122] See Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device disclosed in an embodiment of the present application. The terminal of this embodiment includes: at least one processor 801, a communication interface 802, a user interface 803 and a memory 804. The processor 801, the communication interface 802, the user interface 803 and the memory 804 can be connected via a bus or other means. The embodiment of the present application takes the connection via bus 805 as an example.
[0123] The processor 801 may be a general-purpose processor, such as a central processing unit (CPU).
[0124] The communication interface 802 may be a wired interface (e.g., an Ethernet interface) or a wireless interface (e.g., a cellular network interface or a wireless local area network interface) for communicating with other terminals or websites. In the embodiment of the present application, the communication interface 802 is specifically used to obtain data, such as obtaining data to be cached.
[0125] The user interface 803 may be a touch panel, including a touch screen and a touch screen, for detecting operation instructions on the touch panel, or a physical button or mouse. The user interface 803 may also be a display screen for outputting and displaying images or data.
[0126] Memory 804 may include volatile memory, such as random access memory (RAM); non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the aforementioned types of memory. Memory 804 is used to store a set of program codes, and processor 801 is used to call the program codes stored in memory 804 to perform the following operations:
[0127] In response to a resource adjustment instruction, determining used cache resources in the computer device and allocating cache resources;
[0128] When the used cache resources are less than the allocated cache resources, acquiring target information of the data to be cached, the target information being used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached;
[0129] The cache resources of the computer device are allocated and adjusted according to the target information.
[0130] In some embodiments, the target information includes scenario information corresponding to the data to be cached, and allocating and adjusting cache resources of the computer device according to the target information includes:
[0131] determining, based on the scene information, whether a scene switch occurs in the cached data in the computer device;
[0132] If not, the redundant cache resources in the computer device are released after a preset time period is reached.
[0133] In some embodiments, the target information includes attribute information of the data to be cached, and allocating and adjusting cache resources of the computer device according to the target information includes:
[0134] Determining, based on the attribute information, whether an attribute change occurs to the cached data in the computer device;
[0135] If so, new cache resources are allocated to the data to be cached according to the attribute information.
[0136] In some embodiments, the processor 801 is further configured to: when it is determined that no attribute change has occurred, allocate and adjust cache resources in the computer device according to scenario information corresponding to the data to be cached.
[0137] In some embodiments, allocating and adjusting cache resources in the computer device according to the scenario information corresponding to the data to be cached includes:
[0138] When the required cache resources corresponding to the scenario information are greater than the allocated cache resources, allocating new cache resources for the data to be cached according to the required cache resources; or
[0139] When the required cache resources corresponding to the scenario information are less than the allocated cache resources, the redundant cache resources in the computer device are released according to the required cache resources.
[0140] In some embodiments, before determining the used cache resources in the computer device and allocating cache resources, the processor 801 is further configured to register a cache monitoring service in the computer device, the cache monitoring service being configured to monitor and mark a usage status of the cache resources in the computer device;
[0141] The determining of used cache resources in the computer device and the allocating of cache resources include:
[0142] The cache monitoring service is called to determine used cache resources in the computer device and allocate cache resources.
[0143] In some embodiments, before obtaining the target information of the data to be cached, the processor 801 is further configured to determine current redundant resources in the computer device based on the used cache resources and the allocated cache resources;
[0144] The target information of obtaining the data to be cached includes:
[0145] When the current redundant resource is greater than a preset redundancy threshold, target information of the data to be cached is obtained.
[0146] In some implementations, the used cache resource is the maximum cache resource used in the computer device after a preset time period is reached.
[0147] In some embodiments, before determining the used cache resources in the computer device and allocating cache resources in response to the resource adjustment instruction, the processor 801 is further configured to determine a cache scenario of the computer device;
[0148] The determining, in response to the resource adjustment instruction, used cache resources in the computer device and allocating cache resources comprises:
[0149] When the cache scenario is a preset scenario, in response to a resource adjustment instruction, used cache resources and allocated cache resources in the computer device are determined.
[0150] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program includes part or all of the steps of any of the above methods recorded in the above method embodiments.
[0151] By implementing the embodiment of the present application, the computer device responds to the resource adjustment instruction and determines the used cache resources and allocated cache resources in the computer device; when the used cache resources are less than the allocated cache resources, the target information of the data to be cached is obtained, and the target information is used to indicate the attributes of the data to be cached and / or the scenario associated with the data to be cached; and the cache resources of the computer device are allocated and adjusted according to the target information. By adopting the embodiment of the present application, the cache resources in the device can be dynamically adjusted according to the actual cache requirements based on the used cache resources and allocated cache resources in the computer device, thereby avoiding the problem of cache resource waste, thereby saving the memory space occupied by the cache resources, and helping to improve the smoothness of system operation.
[0152] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0153] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0154] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0155] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0156] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0157] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0158] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A cache resource adjustment method, characterized in that: Applied to a computer device, the method comprises: In response to a resource adjustment instruction, determining used cache resources in the computer device and allocating cache resources; When the used cache resources are less than the allocated cache resources, acquiring target information of the data to be cached, the target information being used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached; Based on the target information, cache resources of the computer device are allocated and adjusted, wherein cache resources are increased or released when the attributes of the data to be cached indicated by the target information change and / or when the scene associated with the data to be cached undergoes a scene switch.
2. The method according to claim 1, characterized in that The target information includes scenario information corresponding to the data to be cached, and allocating and adjusting cache resources of the computer device according to the target information includes: determining, based on the scene information, whether a scene switch occurs in the cached data in the computer device; If not, the redundant cache resources in the computer device are released after a preset time period is reached.
3. The method according to claim 1, characterized in that The target information includes attribute information of the data to be cached, and allocating and adjusting cache resources of the computer device according to the target information includes: Determining, based on the attribute information, whether an attribute change occurs to the cached data in the computer device; If so, new cache resources are allocated to the data to be cached according to the attribute information.
4. The method according to claim 3, characterized in that The method further comprises: When it is determined that no attribute change occurs, the cache resources in the computer device are allocated and adjusted according to the scene information corresponding to the data to be cached.
5. The method according to claim 4, characterized in that The allocating and adjusting the cache resources in the computer device according to the scenario information corresponding to the data to be cached includes: When the required cache resources corresponding to the scenario information are greater than the allocated cache resources, allocating new cache resources for the data to be cached according to the required cache resources; or When the required cache resources corresponding to the scenario information are less than the allocated cache resources, the redundant cache resources in the computer device are released according to the required cache resources.
6. The method according to claim 1, characterized in that Before determining the used cache resources in the computer device and allocating the cache resources, the method further includes: Registering a cache monitoring service in the computer device, wherein the cache monitoring service is used to monitor and mark the usage status of cache resources in the computer device; The determining of used cache resources in the computer device and the allocating of cache resources include: The cache monitoring service is called to determine used cache resources in the computer device and allocate cache resources.
7. The method according to claim 1, characterized in that Before obtaining the target information of the data to be cached, the method further includes: determining current redundant resources in the computer device based on the used cache resources and the allocated cache resources; The target information of obtaining the data to be cached includes: When the current redundant resource is greater than a preset redundancy threshold, target information of the data to be cached is obtained.
8. The method according to claim 7, characterized in that The used cache resources are the maximum cache resources used in the computer device after a preset time period is reached.
9. The method according to claim 1, characterized in that Before determining the used cache resources in the computer device and allocating the cache resources in response to the resource adjustment instruction, the method further includes: Determining a scene switching frequency of the computer device; The determining, in response to the resource adjustment instruction, used cache resources in the computer device and allocating cache resources comprises: When the scene switching frequency is less than a preset frequency threshold, in response to a resource adjustment instruction, used cache resources in the computer device are determined and cache resources are allocated.
10. A cache resource adjustment device, characterized in that: include: Determination module, acquisition module and adjustment module, where: The determining module is configured to determine used cache resources and allocated cache resources in the computer device in response to the resource adjustment instruction; The acquisition module is configured to acquire target information of the data to be cached when the used cache resources are less than the allocated cache resources, wherein the target information is used to indicate attributes of the data to be cached and / or a scenario associated with the data to be cached; The adjustment module is used to allocate and adjust the cache resources of the computer device according to the target information, wherein the cache resources are increased or released when the attributes of the data to be cached indicated by the target information change and / or the scene associated with the data to be cached undergoes a scene switch.
11. A computer device, characterized in that: include: processors, memories, communication interfaces, and buses; The processor, the memory and the communication interface are connected via the bus and communicate with each other; The memory stores executable program code; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the cache resource adjustment method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program enables a computer device to execute the cache resource adjustment method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Virtual scene rendering resource processing method, device and equipment and storage medium
CN112052097A
Data transmission method, device and equipment, receiver and storage medium
CN114490459A