CN-115269517-B - File management method, device, storage medium and terminal
Abstract
The embodiment of the application discloses a file management method, a device, a storage medium and a terminal. According to the scheme, an arbitration control module with a precompression function is newly added in the mirror image formatting process of the EROFS system, the file compression ratio of the file to be compressed is calculated through the arbitration control module, the file compression ratio is compared with the optimal file compression ratio, a target file with a larger file compression ratio is screened out from the file to be compressed based on a comparison result, compression processing is not carried out on the target file, and therefore the problem of negative optimization of file compression in the EROFS system can be solved, and the sequential read-write performance of EROFS is improved.
Inventors
- ZOU PENG
- ZHONG BIN
Assignees
- 深圳TCL新技术有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20220711
Claims (9)
- 1. A method of file management, the method comprising: Acquiring at least one file to be compressed; Predicting the size of a target cache occupied by each file to be compressed after being compressed by a compression algorithm of a specified file system based on file index information of each file to be compressed; Determining the file compression ratio of each file to be compressed according to the initial file size of each file to be compressed and the target cache size; determining a target file with a file compression ratio greater than a reference compression ratio of the specified file system from the at least one file to be compressed; removing the target file from the at least one file to be compressed so that the target file is not compressed through the compression algorithm; the method for predicting the target cache size occupied by each file to be compressed after being compressed by a compression algorithm of a specified file system based on the file index information of each file to be compressed comprises the following steps: Determining file data of the file to be compressed according to the file index information; Determining a buffer area applied to file compression processing in the specified file system; The file data is transmitted into the buffer area for compression processing, and the number of blocks of a buffer block occupied by the compression processing in the buffer area is determined; and determining the target cache size based on the cache size of the buffer block and the block number.
- 2. The method of claim 1, wherein said transferring the file data into the buffer for compression processing, determining the number of blocks of the buffer block occupied by the compression processing in the buffer, comprises: Acquiring an initial buffer block number of the buffer area; invoking the compression algorithm to execute compression processing on the file data to obtain a target buffer block number corresponding to the compressed file data; and calculating the block number based on the initial buffer block number and the target buffer block number.
- 3. The method of claim 1, wherein determining the file compression ratio of each file to be compressed based on the initial file size of each file to be compressed and the target cache size comprises: And calculating the ratio of the target cache size to the initial file size to obtain the file compression ratio.
- 4. The method of claim 1, wherein the determining, from the files to be compressed, a target file having a file compression ratio greater than a reference compression ratio of the specified file system comprises: Determining a reference compression ratio of the specified file system; And comparing the file compression ratio of each file to be compressed with the reference compression ratio, and determining the file to be compressed with the file compression ratio larger than the reference compression ratio to obtain the target file.
- 5. The method of claim 4, wherein said determining a reference compression ratio for the specified file system comprises: acquiring the actual file compression ratio of each file in a target file partition of a specified file system; Sorting the actual file compression ratio of each file according to a preset rule to obtain the sorted actual file compression ratio; Acquiring first read-write performance of each file in the target partition in the specified file system and second read-write performance of each file in other file systems; comparing the first read-write performance with the second read-write performance to obtain a comparison result; The reference compression ratio is determined from the sorted actual file compression ratios based on the comparison result.
- 6. The method according to claim 1, wherein the method further comprises: and compressing files except the target file in the at least one file to be compressed through the compression algorithm.
- 7. A document management apparatus, the apparatus comprising: the acquisition unit is used for acquiring at least one file to be compressed; The prediction unit is used for predicting the size of the target cache occupied by each file to be compressed after being compressed by a compression algorithm of a specified file system based on the file index information of each file to be compressed; the first determining unit is used for determining the file compression ratio of each file to be compressed according to the initial file size of each file to be compressed and the target cache size; a second determining unit configured to determine, from the at least one file to be compressed, a target file having a file compression ratio greater than a reference compression ratio of the specified file system; The rejecting unit is used for rejecting the target file from the at least one file to be compressed so that the target file is not compressed through the compression algorithm; Wherein the prediction unit includes: A first determining subunit, configured to determine file data of the file to be compressed according to the file index information; a first obtaining subunit, configured to determine a buffer area applied to file compression processing in the specified file system; The processing subunit is used for transmitting the file data into the buffer area for compression processing and determining the number of blocks of a buffer block occupied by the compression processing in the buffer area; and the second determining subunit is used for determining the target cache size based on the cache size of the buffer block and the block number.
- 8. A storage medium storing a plurality of instructions adapted to be loaded by a processor to perform the file management method of any one of claims 1 to 6.
- 9. A terminal comprising a processor and a memory, the memory storing a plurality of instructions, the processor loading the instructions to perform the file management method of any one of claims 1 to 6.
Description
File management method, device, storage medium and terminal Technical Field The present application relates to the field of computer technologies, and in particular, to a method and apparatus for file management, a storage medium, and a terminal. Background Currently, an extensible read-only file system (extendable read-only FILE SYSTEM, EROFS) is often employed in terminals. EROFS are compressed and stored, so that the occupied space of the data can be reduced, and the random reading performance can be improved. In the related art, the default processing of the formatting tool of EROFS for the image file is that a 'violent' compression strategy method for all compression is selected for various types of files which can be compressed in the image file, the compression strategy can improve the overall compression rate of the image file, but the performance effects of different files after compression are different, in EROFS, the sequential reading performance is related to the good or bad file compression effect, and when the compression effect of part of files is poor, the sequential reading and writing performance of EROFS can be influenced by adopting the compression strategy for all compression. Disclosure of Invention The embodiment of the application provides a file management method, a file management device, a storage medium and a terminal, which can improve the sequential reading performance of a file system. The embodiment of the application provides a file management method, which comprises the following steps: Acquiring at least one file to be compressed; Predicting the size of a target cache occupied by each file to be compressed after being compressed by a compression algorithm of a specified file system based on file index information of each file to be compressed; Determining the file compression ratio of each file to be compressed according to the initial file size of each file to be compressed and the target cache size; determining a target file with a file compression ratio greater than a reference compression ratio of the specified file system from the at least one file to be compressed; And rejecting the target file from the at least one file to be compressed so that the target file is not compressed through the specified compression algorithm. Correspondingly, the embodiment of the application also provides a file management device, which comprises: the acquisition unit is used for acquiring at least one file to be compressed; The prediction unit is used for predicting the size of the target cache occupied by each file to be compressed after being compressed by a compression algorithm of a specified file system based on the file index information of each file to be compressed; the first determining unit is used for determining the file compression ratio of each file to be compressed according to the initial file size of each file to be compressed and the target cache size; a second determining unit configured to determine, from the at least one file to be compressed, a target file having a file compression ratio greater than a reference compression ratio of the specified file system; And the rejecting unit is used for rejecting the target file from the at least one file to be compressed so as not to compress the target file through the appointed compression algorithm. In some embodiments, the prediction unit comprises: A first determining subunit, configured to determine file data of the file to be compressed according to the file index information; a first obtaining subunit, configured to determine a buffer area applied to file compression processing in the specified file system; The processing subunit is used for transmitting the file data into the buffer area for compression processing and determining the number of blocks of a buffer block occupied by the compression processing in the buffer area; and the second determining subunit is used for determining the target cache size based on the cache size of the buffer block and the block number. In some embodiments, the processing subunit is specifically configured to: Acquiring an initial buffer block number of the buffer area; Invoking the appointed compression algorithm to execute compression processing on the file data to obtain a target buffer block number corresponding to the compressed file data; and calculating the block number based on the initial buffer block number and the target buffer block number. In some embodiments, the first determining unit comprises: And the calculating subunit is used for calculating the ratio of the target cache size to the initial file size to obtain the file compression ratio. In some embodiments, the second determining unit comprises: A third determination subunit configured to determine a reference compression ratio of the specified file system; and a fourth determining subunit, configured to compare the file compression ratio of each file to be compressed with the reference compression ratio, de