Method and apparatus for managing cache files
By acquiring feature information and classifying cached files using machine learning models, and managing cached files by different types, the problem of inflexible cached file management is solved, system performance and I/O performance are improved, storage device lifespan is extended, and user experience is enhanced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2021-06-30
- Publication Date
- 2026-07-03
AI Technical Summary
In existing technologies, cache file management methods fail to effectively distinguish between cache files and regular files, leading to unnecessary write-back operations that affect I/O performance and the lifespan of storage devices.
By acquiring the feature information of cached files, machine learning models are used to classify cached files into types that can be deleted, temporary storage, and long-term storage. Corresponding management operations are then performed based on the type, including deletion, temporary storage in memory, or writing back to flash memory, thereby reducing unnecessary write-back operations.
It improves system performance and I/O performance, extends the lifespan of storage devices, reduces the re-download rate of cached files, and enhances the user experience.
Smart Images

Figure CN115617255B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer storage, and more particularly to a method and apparatus for managing cached files. Background Technology
[0002] Most mobile applications need to download cache files from the internet. In order to improve the speed of retrieving cache files, the phone will temporarily store the cache files locally.
[0003] Currently, the system manages cached files and regular files in the same way. For example, the Android system writes cached files to memory and then writes them back to flash memory. However, cached files are different from regular files; they are time-sensitive. Many cached files will not be used again after a period of time, so there is no need to write them back to flash memory for long-term storage. Furthermore, as network speeds increase, online data increases, and application complexity increases, the number of cached files downloaded per unit of time is increasing. Writing these cached files back to flash memory would cause many unnecessary write-back operations, and a large number of write-backs to flash memory would conflict with normal input / output (I / O), affecting I / O performance.
[0004] Alternatively, cached files can be accessed directly from memory for better performance. However, if the cached files are not frequently used, it reduces the available memory space for other files, decreases memory efficiency, and consequently reduces performance.
[0005] Therefore, there is an urgent need for a cache file management method to solve the above-mentioned problem of inflexible cache file storage and improve system performance. Summary of the Invention
[0006] This application provides a method for managing cache files, which enables flexible storage of cache files and improves system performance.
[0007] In a first aspect, a method for managing cached files is provided, comprising: obtaining characteristic information of the cached files, wherein the characteristic information includes at least one of read / write information, size information, or active time information of the cached files; determining the file type of the cached files based on the characteristic information, wherein the file type includes at least two of deletable type, temporary storage type, or long-term storage type; and managing the cached files based on the file type of the cached files.
[0008] In this embodiment, the storage device can classify cached files by acquiring their characteristic information and perform different management operations based on different file types. For cached files whose loss has no impact on the application, the storage device can directly delete them to free up storage space, providing more available memory for other files, improving memory efficiency, and thus improving system performance. For cached files requiring temporary storage, the storage device can temporarily store them in memory without writing them back to flash memory. For cached files requiring long-term storage, the storage device can write them back from memory to flash memory to reduce unnecessary write-back operations. This helps avoid conflicts between a large number of cached file write-back operations and normal I / O, thereby improving I / O performance. This application, while ensuring a low cached file re-download rate, only writes cached files requiring long-term storage back to flash memory, which is beneficial for improving storage device performance and lifespan.
[0009] In conjunction with the first aspect, in one implementation of the first aspect, determining the file type of the cached file based on the aforementioned feature information includes: inputting the aforementioned feature information into a machine learning model to obtain the file type of the cached file, wherein the aforementioned machine learning model is trained using the feature information and file type of historical cached files.
[0010] In this embodiment, the storage device can achieve the above-mentioned classification of cached files within 20 microseconds through a machine learning model, and can reduce memory overhead to 82KB, resulting in a better user experience.
[0011] In conjunction with the first aspect, in one implementation of the first aspect, the above machine learning model employs any of the following algorithms: dimensionality reduction algorithm, clustering algorithm, neural network algorithm, or reinforcement learning algorithm.
[0012] In conjunction with the first aspect, in one implementation of the first aspect, before obtaining the characteristic information of the cached file, the method further includes: detecting an access instruction from an application, the access instruction being used to instruct the application to access the cached file; and, if the cached file is not to be stored, downloading the cached file to memory based on the access instruction.
[0013] In conjunction with the first aspect, in one implementation of the first aspect, managing the cache file according to the file type of the cache file includes: if the file type of the cache file is a deletable type, determining whether the memory is less than a first preset threshold and / or whether the cache file has not been accessed within a first preset time period; if the memory is less than the first preset threshold and / or the cache file has not been accessed within the first preset time period, deleting the file page and file identifier of the cache file.
[0014] In this embodiment of the application, for cache files of the deletable type after use, if there is sufficient memory space, the storage device can first store them in memory. When memory space is tight, the cache files of this type are deleted first, which reduces the re-download rate of such files and improves the access speed of such files.
[0015] In conjunction with the first aspect, in one implementation of the first aspect, managing the cache file according to the file type of the cache file includes: if the file type of the cache file is temporary storage type, placing the file page in the non-removable list in the memory, and placing the file identifier in the LRU list or in the memory file management system.
[0016] In this embodiment of the application, since the cache files of this type of temporary storage only account for about 1% of the total memory, the amount of data written back to flash memory is reduced, the read and write conflicts with ordinary files are reduced, and the overall I / O performance is improved.
[0017] In conjunction with the first aspect, in one implementation of the first aspect, the method further includes: deleting the file page and file identifier of the cache file when the memory is less than a second preset threshold and / or the cache file is not accessed within a second preset time period.
[0018] In conjunction with the first aspect, in one implementation of the first aspect, managing the cache file according to the file type of the cache file includes: if the file type of the cache file is a long-term storage type, storing the file page and file identifier of the cache file in flash memory.
[0019] In this embodiment, the re-downloading of the aforementioned cached files is avoided, thereby improving the access speed of the cached files.
[0020] In conjunction with the first aspect, in one implementation of the first aspect, the method further includes: determining whether the cached file has not been accessed within a third preset time period; and deleting the file page and file identifier of the cached file if the cached file has not been accessed within the third preset time period.
[0021] Secondly, a cache file management device is provided, comprising: an acquisition module and a processing module, wherein the acquisition module is configured to acquire characteristic information of the cache file, the characteristic information including at least one of read / write information, size information, or active time information of the cache file; the processing module is configured to determine the file type of the cache file based on the characteristic information, the file type including at least two of a deletable type, a temporary storage type, or a long-term storage type; and manage the cache file based on the file type of the cache file.
[0022] In conjunction with the second aspect, in one implementation of the second aspect, the above processing module is used to: input the above feature information into a machine learning model to obtain the file type of the above cached file, wherein the above machine learning model is trained using the feature information and file type of historical cached files.
[0023] In conjunction with the second aspect, in one implementation of the second aspect, the above machine learning model employs any of the following algorithms: dimensionality reduction algorithm, clustering algorithm, neural network algorithm, or reinforcement learning algorithm.
[0024] In conjunction with the second aspect, in one implementation of the second aspect, the above-mentioned processing module is used to: detect an access instruction from an application, the access instruction being used to instruct the application to access the cache file; and, if the cache file is not stored, download the cache file to memory based on the access instruction.
[0025] In conjunction with the second aspect, in one implementation of the second aspect, the above processing module is used to: if the file type of the above cached file is a deletable type, determine whether the above memory is less than a first preset threshold and / or whether the above cached file has not been accessed within a first preset time period; if the above memory is less than the first preset threshold and / or the above cached file has not been accessed within the first preset time period, delete the file page and file identifier of the above cached file.
[0026] In conjunction with the second aspect, in one implementation of the second aspect, the above processing module is used to: if the file type of the above cached file is temporary storage type, place the above file page in the non-removable list in the above memory, and place the above file identifier in the LRU list or in the memory file management system.
[0027] In conjunction with the second aspect, in one implementation of the second aspect, the above-mentioned processing module is used to: delete the file page and file identifier of the cache file when the memory is less than the second preset threshold and / or the cache file is not accessed within the second preset time period.
[0028] In conjunction with the second aspect, in one implementation of the second aspect, the above processing module is used to: if the file type of the above cached file is a long-term storage type, store the file page and file identifier of the above cached file in flash memory.
[0029] In conjunction with the second aspect, in one implementation of the second aspect, the above processing module is used to: determine whether the above cached file has not been accessed within a third preset time period; if the above cached file has not been accessed within the third preset time period, delete the file page and file identifier of the above cached file.
[0030] Thirdly, another cache file management device is provided, including a processor coupled to memory, which can be used to execute instructions in memory to implement the methods in any possible implementation of any of the above aspects. Optionally, the device also includes memory. Optionally, the device also includes a communication interface, to which the processor is coupled.
[0031] Fourthly, a processor is provided, comprising: an input circuit, an output circuit, and a processing circuit. The processing circuit is used to receive signals through the input circuit and transmit signals through the output circuit, causing the processor to execute the method in any possible implementation of the first aspect described above.
[0032] In specific implementation, the processor can be a chip, the input circuit can be an input pin, the output circuit can be an output pin, and the processing circuit can be a transistor, gate circuit, flip-flop, and various logic circuits. The input signal received by the input circuit can be received and input by, for example, but not limited to, a receiver, and the signal output by the output circuit can be output to, for example, but not limited to, a transmitter and transmitted by the transmitter. Furthermore, the input circuit and the output circuit can be the same circuit, which is used as the input circuit and the output circuit at different times. This application does not limit the specific implementation of the processor and various circuits.
[0033] Fifthly, a processing apparatus is provided, including a processor and a memory. The processor is used to read instructions stored in the memory and to receive signals via a receiver and transmit signals via a transmitter to execute the method in any of the possible implementations of the first aspect described above.
[0034] Optionally, there may be one or more processors and one or more memories.
[0035] Alternatively, the memory can be integrated with the processor, or the memory can be set up separately from the processor.
[0036] In specific implementation, the memory can be a non-transitory memory, such as read-only memory (ROM), which can be integrated with the processor on the same chip or set on different chips. The embodiments of this application do not limit the type of memory or the way the memory and processor are set.
[0037] The processing device in the fifth aspect above can be a chip. The processor can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. The memory can be integrated into the processor or located outside the processor and exist independently.
[0038] In a sixth aspect, a computer program product is provided, comprising: a computer program (also referred to as code or instructions) that, when executed, causes a computer to perform the method in any of the possible implementations of the first aspect described above.
[0039] In a seventh aspect, a computer-readable storage medium is provided that stores a computer program (also referred to as code or instructions) that, when executed on a computer, causes the computer to perform the methods in any of the possible implementations of the first aspect described above. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of the storage device provided in an embodiment of this application;
[0041] Figure 2 This is a schematic diagram of a cache file management method provided in an embodiment of this application;
[0042] Figure 3 This is a schematic flowchart illustrating the management of cached files using an LRU list, as provided in an embodiment of this application.
[0043] Figure 4 This is a schematic diagram of yet another cache file management method provided in an embodiment of this application;
[0044] Figure 5 This is a schematic block diagram of a cache file management device provided in an embodiment of this application;
[0045] Figure 6 This is a schematic block diagram of another cache file management device provided in the embodiments of this application. Detailed Implementation
[0046] The technical solutions in this application will now be described with reference to the accompanying drawings.
[0047] 1. Variational auto-encoder (VAE) model
[0048] The model consists of two networks: an encoder network that maps high-dimensional inputs to low-dimensional latent variables, and a decoder network that maps the low-dimensional latent variables back to high-dimensional inputs.
[0049] 2. K-means machine learning algorithm
[0050] This algorithm belongs to the unsupervised learning class, also known as clustering. It refers to a method that classifies data based on relevant characteristics without providing a correct answer. The goal of learning is to find the most relevant characteristics.
[0051] Most mobile applications download cache files from the internet. To improve the speed of retrieving cache files, applications temporarily store them locally. Current systems manage cache files and regular files in the same way, writing the files to memory and then back to flash memory. However, cache files differ from regular files; they are time-sensitive. Many cache files will not be used again after a period of time, so it is unnecessary to write them all back to flash memory, thus avoiding excessive storage space consumption.
[0052] In the first implementation, cache files can be managed uniformly by temporarily writing all cache files to memory and then writing them back to flash memory when memory is insufficient. However, with increasing network speeds, more online data, and growing application complexity, the number of cache files downloaded per unit of time is increasing. Writing multiple cache files back to flash memory uniformly would result in many unnecessary write operations, and a large number of write-back operations might conflict with normal I / O, affecting I / O performance. In addition, writing too many cache files back to flash memory and then deleting them after a period of time would also shorten the lifespan of the flash memory.
[0053] In the second implementation, users mount specific cache file paths to memory file systems such as ramfs or tmpfs, thereby accessing cache files from memory for better performance. Managing cache files through ramfs and tmpfs reduces the total amount of write-back to flash memory, but it consumes a significant amount of memory. Furthermore, if the selected cache files are not frequently used, it reduces the available memory space for other files, decreasing memory efficiency and ultimately performance.
[0054] In view of this, embodiments of this application provide a method and apparatus for managing cached files. The cached files can be categorized into different types based on their read / write information and size. These different types of cached files have different storage characteristics. This application can differentiate and store cached files according to their type. While ensuring a low re-download rate, only cached files requiring long-term storage are written back, effectively avoiding unnecessary write-back operations and storage space occupation, thus improving storage space efficiency and device performance and lifespan.
[0055] Before introducing the methods and apparatus provided in the embodiments of this application, the following points should be made first.
[0056] First, in the embodiments shown below, the terms and English abbreviations, such as baseline data or differential data, are merely exemplary examples given for ease of description and should not constitute any limitation on this application. This application does not preclude the possibility of defining other terms that can achieve the same or similar functions in existing or future agreements.
[0057] Second, in the embodiments shown below, the terms "first," "second," and various numerical designations are merely for descriptive convenience and are not intended to limit the scope of the embodiments of this application. For example, "first preset threshold" and "second preset threshold" are simply used to distinguish different preset thresholds, etc.
[0058] Third, "at least one" means one or more, while "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b, and c, where a, b, and c can be single or multiple.
[0059] To make the objectives and technical solutions of this application clearer and more intuitive, the methods and apparatus provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0060] It should be understood that the methods in the embodiments of this application can be executed by a storage device with read and write capabilities, which is referred to as a storage device in the embodiments of this application.
[0061] Figure 1 The storage device 100 provided in an embodiment of this application is shown, such as Figure 1 As shown, the storage device 100 is equipped with an application and file management system. Applications can download cached files over the network. These cached files can be categorized within the kernel, and the file management system can manage them according to their specific categories. For example, it can directly delete the cached files, store them in memory, or write them back to flash memory.
[0062] Figure 2 This is a schematic flowchart of the cache file management method 200 in an embodiment of this application. Figure 2 As shown, method 200 includes the following steps:
[0063] S201, Obtain the characteristic information of the cached file, which may include at least one of the following: file read / write information, size information, or active time information.
[0064] For example, the storage device can record and obtain characteristic information of a K-second cache file, wherein the read / write information in the aforementioned characteristic information may include at least one of the following: the number of read / write operations per second for the cache file within K seconds, the total number of read / write operations for the cache file within K seconds, the total number of read / write operations for the cache file within K seconds, or the last read / write time of the cache file. The aforementioned active time information is used to indicate the duration for which the cache file has been read and written. For example, if the cache file has not been read or written for K seconds after its creation, then the active time of the cache file is K seconds.
[0065] It should be understood that in S201 above, before obtaining the characteristic information of the cache file, the storage device may, after detecting the application's access instruction and determining that the cache file is not in memory or flash memory, download the cache file to memory based on the access instruction. The access instruction may be an instruction initiated by the application during startup or operation if it needs to perform read or write operations on a certain file.
[0066] S202, Based on the characteristic information of the cached files, determine the file type of the cached files.
[0067] For example, the above file types may include at least two of the following:
[0068] The deleteable type is used to indicate cached files that will no longer be used after being accessed.
[0069] Temporary storage type, used to indicate cached files that will be used again shortly after being accessed.
[0070] Long-term storage type indicates cached files that will be used again long after the initial access.
[0071] It should be understood that the file types of the aforementioned cached files are not limited to the three types mentioned above, and this application embodiment does not limit them.
[0072] S203, manage the cache files according to the file types of the cache files mentioned above.
[0073] It should be understood that the management operations performed on the storage device will differ depending on the file type of the cached files mentioned above.
[0074] For example, if the cached file is of a removable type, the terminal device can directly delete the cached file from memory after the application accesses it.
[0075] If the cached file is of temporary storage type, the terminal device can determine to continue storing the cached file in memory and not write it back to flash memory after the application accesses the cached file.
[0076] If the cached file is a file type that needs to be stored long-term, the terminal device can write the cached file back to flash memory after the application accesses it.
[0077] In this embodiment, the storage device can classify cached files by acquiring their characteristic information and perform different management operations based on different file types. For cached files whose loss has no impact on the application, the storage device can directly delete them to free up storage space, providing more available memory for other files, improving memory efficiency, and thus improving system performance. For cached files requiring temporary storage, the storage device can temporarily store them in memory without writing them back to flash memory. For cached files requiring long-term storage, the storage device can write them back from memory to flash memory to reduce unnecessary write-back operations. This helps avoid conflicts between a large number of cached file write-back operations and normal I / O, thereby improving I / O performance. This application, while ensuring a low cached file re-download rate, writes cached files requiring long-term storage back to flash memory, which is beneficial for improving the performance and lifespan of the storage device.
[0078] Corresponding to S202 above, the storage device can input the above feature information into the machine learning model to obtain the file type of the above cached file. The machine learning model is trained using the feature information and file type of historical cached files.
[0079] For example, the storage device can use this feature information as input to the VAE+Kmeans machine learning model and output the file type of the cached file. Because this machine learning algorithm is lightweight, it can achieve the above classification of cached files within 20 microseconds and reduce memory overhead to 82KB, resulting in a better user experience.
[0080] Specifically, the feature information is input into VAE to obtain the dimensionality-reduced features, and the output of VAE is used as the input of Kmeans to obtain the type of the cache file mentioned above.
[0081] It should be understood that the above machine learning model may employ dimensionality reduction algorithms, clustering algorithms, neural network algorithms, or reinforcement learning algorithms, etc., and this application does not limit it in this regard.
[0082] Taking the three file types provided above as examples, the method for managing cached files provided in this application embodiment can be described in detail in three cases.
[0083] In the first scenario, if the cached file is of a removable type, the storage device can directly delete the file page and file identifier of the cached file, freeing up the corresponding storage space and providing more available memory space for other files.
[0084] It should be understood that when such removable cache files are accessed again, the storage device needs to download the cache file from the network again because its file pages and file identifiers have been deleted.
[0085] In the second scenario, if the cached file is of temporary storage type, the storage device can store the file pages of the cached file in a non-removable list in memory using a quasi-memory file system to ensure that the cached file is not removed from memory. The file identifier of the cached file can be managed using a least recently used (LRU) list provided in this application. Figure 3 This application illustrates a method for managing cache files using an LRU list, as provided in an embodiment. Figure 3 As shown, looking from right to left, a cached file is first inserted into the active list after being categorized. When the threshold time is reached, the cached file in the active list is moved to the idle list. When the space pressure increases until there is not enough space, and the cached file is a file generated by the background application, then the cached file will be preferentially reclaimed, i.e. deleted. Then the cached file is no longer linked to the list. If the storage device uses the cached file in the idle list again, then the cached file will be inserted back into the head of the active list.
[0086] When memory is sufficient, these files are stored in memory. When memory is insufficient, i.e. when the memory space is less than the second threshold, the storage device will delete the cached files. Since these temporary cached files only account for about 1% of the total memory, the amount of data written back to flash memory is reduced, the read / write conflicts with ordinary files are reduced, and the overall I / O performance is improved.
[0087] It should be understood that the aforementioned second preset threshold can be equal to the aforementioned first preset threshold.
[0088] In the third scenario, if the cached file is a long-term storage type, the storage device can write the file pages and file identifiers of the cached file back to the flash memory through the flash file system, avoiding the re-downloading of the cached file and improving access speed.
[0089] It should be understood that for this type of cached file that needs to be stored for a long time, when it is accessed again, because its file pages and file identifiers are stored for a long time, the storage device does not need to download the cached file from the network again, and can access it directly in the flash memory.
[0090] Optionally, in the first case described above, before deleting the cache file of the deletable type, the storage device may also delete the cache file of the deletable type in memory if the memory space is less than a first preset threshold and / or the cache file has not been accessed within a first preset time period.
[0091] It should be understood that the first preset duration can be used to indicate the maximum duration for which the cache file of the above-mentioned deletable type has not been accessed in memory. If the cache file is not accessed within the first preset duration, it indicates that the probability of the cache file being accessed is low. In order to avoid the invalid occupation of memory space, the storage device may choose to delete the cache file from memory.
[0092] Optionally, in the second case described above, the storage device may also delete the cache file of the temporary storage type in memory if the memory space is less than the second threshold and / or the cache file is not accessed within the second preset time period.
[0093] It should be understood that the aforementioned second preset duration can be used to indicate the maximum duration for which the aforementioned temporary storage type of cache file has not been accessed in memory. If the aforementioned cache file is not accessed within the second preset duration, it indicates that the probability of the cache file being accessed is low. In order to avoid the invalid occupation of memory space, the storage device may choose to delete the cache file from memory.
[0094] It should be understood that the first preset duration can be less than the second preset duration.
[0095] For example, since the probability of deletable cache files being accessed again after this access is very small, the first preset duration can be set to one day. If the cache file of this type is not accessed again within one day, it can be deleted directly to free up the corresponding memory space. However, the probability of temporary storage cache files being accessed again in the short term is relatively high, so the second preset duration can be longer than the first preset duration, such as one week. This can improve access efficiency and reduce the download rate of the cache file of this type, thereby reducing overhead.
[0096] Alternatively, when the storage device determines that there is insufficient memory space, the storage device can delete different types of cache files in memory.
[0097] In the first scenario, if there are cached files in memory that are of the deletable type and cached files that are of the time storage type, the terminal device can prioritize deleting the cached files of the deletable type.
[0098] In the second scenario, if only temporary storage cache files exist in memory, the terminal device can directly delete these cache files to free up storage space.
[0099] For example, the storage device may select from a number of cache files of temporary storage type that have not been accessed within the second preset time period, or select the cache files of the background program for priority deletion.
[0100] Optionally, when the storage device determines that the flash memory space is less than a third preset threshold and / or the cache file of this type has not been accessed within a third preset time period, the storage device may delete the cache file that is a long-term storage type stored in the flash memory.
[0101] It should be understood that the aforementioned third preset duration is used to indicate the maximum duration for which the aforementioned long-term storage type cache file is stored in the flash memory. If the aforementioned long-term storage type cache file is not accessed within the third preset duration, it indicates that the probability of the cache file being accessed is low, and the storage device can choose to delete the file to free up the corresponding flash memory space.
[0102] For example, when space is insufficient, the storage device may select from multiple cache files of the long-term storage type that have not been accessed within the aforementioned third preset time period, or select the aforementioned cache files of the background program for priority deletion, in order to free up the corresponding flash memory space.
[0103] It should be understood that the second preset duration can be less than the third preset duration.
[0104] For example, since deleting the cache files of the long-term storage type will affect the application, that is, the probability of such cache files being accessed is extremely high over a long period of time, the third preset duration can be greater than the second preset duration, such as one month. This can improve the access efficiency of such files and reduce the overhead of re-downloading such cache files without affecting the application.
[0105] The following section provides a detailed description of the proposed solution in the scenario where the cached file is accessed again.
[0106] Figure 4 This application provides another method 400 for managing cached files, as shown in Figure 4. Subsequent access can be described in several scenarios:
[0107] In the first scenario, when an application accesses the aforementioned cached file, it can first determine whether the cached file exists in memory or flash memory. If the cached file does not exist in either memory or flash memory, it can be determined that the cached file was a deleteable or temporary storage type when it was last accessed. In this case, the storage device needs to download the cached file again for application access. The downloaded cached file will be temporarily stored in memory awaiting classification. The storage device can then use a machine learning model to reclassify the cached file within 30 seconds and manage its storage based on the latest file type. The specific steps are the same as described above. Figure 2 Similarly, to avoid repetition, the embodiments in this application will not be described in detail.
[0108] It should be understood that the absence of the aforementioned cache file in both memory and flash memory could indicate that the cache file was previously classified as a deleteable type, and was therefore deleted directly after the last access. Alternatively, it could indicate that the cache file was previously classified as a deleteable type, and was temporarily stored in memory after the last access due to sufficient memory space, without being deleted until the storage device detects insufficient memory and deletes it first. It could also indicate that the cache file was previously classified as a temporary storage type, and was temporarily stored in memory after the last access, but was deleted by the storage device due to insufficient memory space. All of these scenarios would result in the storage device needing to re-download the cache file for this access.
[0109] In the second scenario, if the application accesses the cached file again and determines that the cached file is cached in memory, it can be determined that the cached file was previously classified as a deletable type or a temporary storage type. In this case, the storage device does not need to download the cached file again, and the application can directly access the cached file in memory, effectively improving access efficiency.
[0110] It should be understood that the existence of the aforementioned cache file in memory indicates that the cache file was previously classified as a deleteable type, and that after its last access, due to ample memory space, the storage device temporarily stored it in memory instead of deleting it. It also indicates that the cache file was previously classified as a temporary storage type, and after its last access, it was temporarily stored in memory. Therefore, the storage device does not need to re-download the cache file, and the application can directly access the file from memory.
[0111] In the third scenario, if the application accesses the cached file again and determines that the cached file is stored in flash memory, the storage device does not need to download the cached file again. The application can directly access the cached file from flash memory, thus improving access efficiency.
[0112] It should be understood that the existence of the aforementioned cached files in the flash memory indicates that the cached files were previously classified as long-term storage and were written back to the flash memory after being accessed. Therefore, applications can directly access the aforementioned files in memory without having to download the cached files again.
[0113] Optionally, to avoid the original file types becoming inapplicable when user behavior changes, this application can also reclassify cached files according to changes in user behavior, thereby changing the file types. Table 1 shows the changes between cached file types, the operations required for these changes, and the beneficial effects of these changes.
[0114] Table 1
[0115]
[0116]
[0117] For example, if the cached file was previously a deletable file type, it would be deleted immediately after being accessed. When the cached file is downloaded and accessed multiple times from the network, it will be reclassified as a temporary storage file type due to the increased access rate after subsequent downloads. This changes the file type, effectively reducing the download rate of the cached file and improving access efficiency.
[0118] For example, if the cached file was previously a temporary storage file, the storage device can delete the cached file when it is not accessed for a long time. When the cached file is accessed again, it can be reclassified as a deletable file, effectively avoiding the problem of the cached file occupying memory space due to long-term inaccessibility.
[0119] For example, if the cached file was previously a long-term storage type, and if the cached file is not accessed for a long time, the storage device can also delete it from the flash memory to free up the corresponding space. When the cached file is accessed again, it can be reclassified as a deleteable type or a temporary storage type, thus avoiding the problem of the cached file occupying flash memory space for a long time and being deleted after being occupied, which reduces the lifespan of the flash memory.
[0120] This application embodiment can classify cached files by acquiring their characteristic information and perform differentiated management based on different file types. While ensuring a low re-download rate for cached files, unused cached files are deleted, freeing up corresponding memory space for other files, improving memory efficiency and thus system performance. Cached files needed in the short term are temporarily stored in memory, while only those needed long-term are written back to flash memory, reducing unnecessary write-back operations and avoiding conflicts between numerous write-back operations and normal I / O, thereby improving I / O performance and extending the performance and lifespan of the storage device. Furthermore, the classification of cached files in this application can change according to changes in user behavior, improving the flexibility of storage device management of cached files and effectively enhancing the user experience.
[0121] It should be understood that the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0122] The methods provided in the embodiments of this application above are described from the perspective of the storage device as the execution subject. To implement the functions of the methods provided in the embodiments of this application above, the storage may include hardware structures and / or software modules, and may implement the above functions in the form of hardware structures, software modules, or a combination of hardware structures and software modules. Whether a particular function is executed in the form of hardware structures, software modules, or a combination of hardware structures and software modules depends on the specific application and design constraints of the technical solution.
[0123] The following will combine Figure 5 and Figure 6 This application describes in detail the cache file management device provided in the embodiments of this application.
[0124] Figure 5 The present application illustrates a cache file management device 500, which includes an acquisition module 501 and a processing module 502.
[0125] The acquisition module 501 is used to: acquire characteristic information of the cached file, the characteristic information including at least one of the read / write information, size information or active time information of the cached file; the processing module 502 is used to: determine the file type of the cached file according to the characteristic information, the file type including at least two of the deletable type, temporary storage type or long-term storage type; and manage the cached file according to the file type of the cached file.
[0126] Optionally, the processing module 502 is used to: input the above feature information into a machine learning model to obtain the file type of the above cached file, wherein the machine learning model is trained using the feature information and file type of historical cached files.
[0127] Optionally, the above machine learning model may employ any of the following algorithms: dimensionality reduction algorithm, clustering algorithm, neural network algorithm, or reinforcement learning algorithm.
[0128] Optionally, the processing module 502 is configured to: detect an access instruction from an application, the access instruction being used to instruct the application to access the cache file; and, if the cache file is not stored, download the cache file to memory based on the access instruction.
[0129] Optionally, the processing module 502 is configured to: if the file type of the cached file is a deletable type, determine whether the memory is less than a first preset threshold and / or whether the cached file has not been accessed within a first preset time period; if the memory is less than the first preset threshold and / or the cached file has not been accessed within the first preset time period, delete the file page and file identifier of the cached file.
[0130] Optionally, the processing module 502 is configured to: if the file type of the cached file is temporary storage, place the file page in the non-removable list in the memory, and place the file identifier in the LRU list or the memory file management system.
[0131] Optionally, the processing module 502 is configured to: delete the file pages and file identifiers of the cached files when the memory is less than a second preset threshold and / or the cached files are not accessed within a second preset time period.
[0132] Optionally, the processing module 502 is used to: if the file type of the above-mentioned cached file is a long-term storage type, store the file page and file identifier of the above-mentioned cached file to flash memory.
[0133] Optionally, the processing module 502 is configured to: determine whether the cached file has not been accessed within a third preset time period; and if the cached file has not been accessed within the third preset time period, delete the file page and file identifier of the cached file.
[0134] It should be understood that the device 500 here is embodied in the form of a functional module. The term "module" here can refer to application-specific integrated circuits (ASICs), electronic circuits, processors (e.g., shared processors, proprietary processors, or group processors, etc.) and memories for executing one or more software or firmware programs, integrated logic circuits, and / or other suitable components supporting the described functions. In an alternative example, those skilled in the art will understand that the device 500 may specifically be the storage device in the above embodiments, or the functions of the storage device in the above embodiments may be integrated into the device 500. The device 500 may be used to execute the various processes and / or steps corresponding to the storage device in the above method embodiments; to avoid repetition, these will not be described further here.
[0135] The aforementioned device 500 has the function of implementing the corresponding steps performed by the storage device in the aforementioned method; the aforementioned function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the aforementioned function.
[0136] In the embodiments of this application, Figure 5 The device 500 in the text can also be a chip or a chip system, such as a system on chip (SoC).
[0137] Figure 6 Another cache file management device 600 provided in this application embodiment is illustrated. The device 600 includes a processor 601, a memory 602, a communication interface 603, and a bus 604. The memory 602 is used to store instructions, and the processor 601 is used to execute the instructions stored in the memory 602. The processor 601, memory 602, and communication interface 603 are interconnected via the bus 604.
[0138] The processor 601 is configured to: acquire characteristic information of a cached file, the characteristic information including at least one of read / write information, size information, or active time information of the cached file; determine the file type of the cached file based on the characteristic information, the file type including at least two of a deletable type, a temporary storage type, or a long-term storage type; and manage the cached file based on the file type of the cached file.
[0139] Optionally, the processor 601 is used to: input the aforementioned feature information into a machine learning model to obtain the file type of the aforementioned cached file, wherein the aforementioned machine learning model is trained using the feature information and file type of historical cached files.
[0140] Optionally, the above machine learning model may employ any of the following algorithms: dimensionality reduction algorithm, clustering algorithm, neural network algorithm, or reinforcement learning algorithm.
[0141] Optionally, the processor 601 is configured to: detect an access instruction from an application, the access instruction being used to instruct the application to access the cache file; and, if the cache file is not stored, download the cache file to memory based on the access instruction.
[0142] Optionally, the processor 601 is configured to: if the file type of the cached file is a deletable type, determine whether the memory is less than a first preset threshold and / or whether the cached file has not been accessed within a first preset time period; if the memory is less than the first preset threshold and / or the cached file has not been accessed within the first preset time period, delete the file page and file identifier of the cached file.
[0143] Optionally, the processor 601 is configured to: if the file type of the cached file is temporary storage, place the file identifier in the LRU list or the memory file management system.
[0144] Optionally, the processor 601 is configured to: delete the file pages and file identifiers of the cached files when the memory is less than a second preset threshold and / or the cached files are not accessed within a second preset time period.
[0145] Optionally, the processor 601 is configured to: if the file type of the cached file is a long-term storage type, store the file pages and file identifier of the cached file to flash memory.
[0146] Optionally, the processor 601 is configured to: determine whether the cached file has not been accessed within a third preset time period; and if the cached file has not been accessed within the third preset time period, delete the file page and file identifier of the cached file.
[0147] It should be understood that device 600 may specifically be the storage device in the above embodiments, or the functions of the storage device in the above embodiments may be integrated into device 600. Device 600 may be used to execute the various steps and / or processes corresponding to the storage device in the above method embodiments. Optionally, the memory 602 may include read-only memory and random access memory, and provide instructions and data to the processor. A portion of the memory may also include non-volatile random access memory. For example, the memory may also store device type information. The processor 601 may be used to execute instructions stored in the memory, and when the processor executes the instructions, the processor may execute the various steps and / or processes corresponding to the storage device in the above method embodiments.
[0148] It should be understood that, in the embodiments of this application, the processor may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0149] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or as a combination of hardware and software modules within the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor executes the instructions in the memory, combining them with its hardware to complete the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0150] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0151] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0152] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0153] The units described as separate components may or may not be physically separate. 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 the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0154] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0155] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0156] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A management method of a cache file, characterized by, include: Obtain the characteristic information of the cached file, wherein the characteristic information includes at least one of the cached file's read / write information, size information, or active time information; Based on the feature information, the file type of the cached file is determined, and the file type includes at least two of the following: deletable type, temporary storage type, and long-term storage type. Manage the cache files according to their file types; Managing the cache files according to their file types includes: If the cached file is a deletable type, determine whether the memory is less than a first preset threshold and / or whether the cached file has not been accessed within a first preset time period; If the memory is less than the first preset threshold and / or the cached file is not accessed within the first preset time period, delete the file page and file identifier of the cached file; If the cached file is a temporary storage type, the file page is placed in the non-removable list in the memory, and the file identifier is placed in the Least Recently Used (LRU) list or the memory file management system. If the memory is less than a second preset threshold and / or the cached file is not accessed within a second preset time period, delete the file page and file identifier of the cached file; If the cached file is of long-term storage type, store the file pages and file identifier of the cached file in flash memory; Determine whether the cached file has not been accessed within a third preset time period; If the cached file is not accessed within the third preset time period, delete the file page and file identifier of the cached file.
2. The management method according to claim 1, characterized in that, Determining the file type of the cached file based on the feature information includes: The feature information is input into a machine learning model to obtain the file type of the cached file. The machine learning model is trained using the feature information and file type of historical cached files.
3. The management method according to claim 2, characterized in that, The machine learning model employs any of the following algorithms: Dimensionality reduction algorithms, clustering algorithms, neural network algorithms, or reinforcement learning algorithms.
4. The management method according to any one of claims 1 to 3, characterized in that, Before obtaining the feature information of the cached file, the method further includes: The application receives an access instruction, which instructs the application to access the cache file; If the cache file is not stored, the cache file is downloaded to memory based on the access instruction.
5. A management apparatus of a cache file characterized by comprising: include: The acquisition module is used to acquire the characteristic information of the cached file, the characteristic information including at least one of the cached file's read / write information, size information, or active time information; The processing module is configured to determine the file type of the cached file based on the feature information, wherein the file type includes at least two of the following: a deletable type, a temporary storage type, or a long-term storage type; and to manage the cached file based on the file type of the cached file. The processing module is used for: If the cached file is a deletable type, determine whether the memory is less than a first preset threshold and / or whether the cached file has not been accessed within a first preset time period; If the memory is less than a first preset threshold and / or the cache file is not accessed within a first preset time period, delete the file page and file identifier of the cache file; If the cached file is of temporary storage type, the file page is placed in the non-removable list in the memory, and the file identifier is placed in the LRU list or the memory file management system; If the memory is less than a second preset threshold and / or the cached file is not accessed within a second preset time period, delete the file page and file identifier of the cached file; If the cached file is of long-term storage type, store the file pages and file identifier of the cached file in flash memory; Determine whether the cached file has not been accessed within a third preset time period; If the cached file is not accessed within the third preset time period, delete the file page and file identifier of the cached file.
6. The management device according to claim 5, wherein The processing module is used for: The feature information is input into a machine learning model to obtain the file type of the cached file. The machine learning model is trained using the feature information and file type of historical cached files.
7. The management device according to claim 6, characterized by The machine learning model employs any of the following algorithms: Dimensionality reduction algorithms, clustering algorithms, neural network algorithms, or reinforcement learning algorithms.
8. The management device according to any one of claims 5 to 7, characterized by, The processing module is used for: An access instruction from the application was detected, the access instruction being used to instruct the application to access the cache file; If the cache file is not to be stored, the cache file is downloaded to memory based on the access instruction.
9. A management apparatus of a cache file characterized by comprising: include: A processor coupled to a memory for storing a computer program, wherein when the processor invokes the computer program, the device performs the management method as described in any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that, Used to store computer programs, the computer programs including instructions for implementing the management method as described in any one of claims 1 to 4.
11. A computer program product comprising computer program code in said computer program product, characterised in that, When the computer program code is run on a computer, it causes the computer to implement the management method as described in any one of claims 1 to 4.