File arrangement method and device, electronic equipment and storage medium
By judging and marking hot files in the terminal device and fragmenting them, the system performance degradation caused by file fragmentation is solved, and the read and write performance of files and the user experience of terminal devices is improved.
Patent Information
- Application Number
- CN202510032119.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-05-13
AI Technical Summary
During the long-term use of terminal devices, due to frequent file read and write operations, files are fragmented, affecting the system's read and write performance, and thus affecting the user's user experience.
By determining whether the file is a hot file based on the preset judgment strategy, and marking it in the file system, the hot file is fragmented and sorted in response to the preset conditions.
It realizes the distinction and identification of hot files in the file system, and only fragmentation of hot files is carried out, thereby improving the sequential read and write performance of hot files and improving the usage performance of terminal devices.
Smart Images

Figure CN119988330A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a file organization method, device, electronic device, and computer-readable storage medium. Background Art
[0002] With the development of terminal devices, users have higher and higher requirements for the performance of terminal devices. For a system, there will be a large number of file read and write operations during the system operation. The repeated reading and writing caused by long-term use will cause file fragmentation, affecting the system's read and write performance, and thus affecting the user's experience. In addition, there are many files in the disk file system, and the number is huge.
[0003] Therefore, how to process files to improve the system's reading and writing performance of files is a problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present disclosure provide a file organization method, device, electronic device, and computer-readable storage medium, which aim to solve one of the technical problems in the related art at least to a certain extent.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for organizing files, the method comprising:
[0006] Based on the preset judgment strategy, determine whether each file is a hot file;
[0007] Based on the judgment result corresponding to each file, marking the file in the file system;
[0008] In response to satisfying a preset condition, hot files in the file system are defragmented.
[0009] In a second aspect, an embodiment of the present disclosure further provides a file arrangement device, the device comprising:
[0010] A judgment module, used to judge whether each file is a hot file based on a preset judgment strategy;
[0011] A marking module, used for marking files in the file system based on the judgment result corresponding to each file;
[0012] The arrangement module is used to arrange the hot files in the file system into fragments in response to meeting a preset condition.
[0013] In a third aspect, an embodiment of the present disclosure further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and which implements the steps in the above-mentioned file organization method when the computer program is executed by the processor.
[0014] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above-mentioned file organization method are implemented.
[0015] In a fifth aspect, the embodiments of the present disclosure further provide a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in various optional implementations of the embodiments of the present disclosure.
[0016] In the disclosed embodiment, firstly, based on a preset judgment strategy, it is judged whether each file is a hot file, then based on the judgment result corresponding to each file, the file is marked in the file system, and then in response to meeting the preset conditions, the hot files in the file system are fragmented. Thus, hot files can be distinguished and identified at the file system level, and only hot files in the file system can be fragmented, so that hot files can be accurately read and written in sequence, thereby improving the performance of the terminal device.
[0017] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 is a flowchart of a method for organizing files provided by the first embodiment of the present disclosure;
[0020] Figure 2 is a flowchart of a method for organizing files provided in the second embodiment of the present disclosure;
[0021] Figure 3 is a flowchart of a method for organizing files provided in the third embodiment of the present disclosure;
[0022] Figure 4 is a flowchart of a method for organizing files provided in a fourth embodiment of the present disclosure;
[0023] Figure 5is a schematic diagram of the structure of a file arrangement device provided by an embodiment of the present disclosure;
[0024] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] Some embodiments of the present disclosure will be described in detail here, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. Various changes, modifications and equivalents of the methods, devices and / or systems described herein will become apparent after understanding the present disclosure. For example, the order of operations described herein is merely an example and is not limited to those orders set forth herein, but can be changed as becomes apparent after understanding the present disclosure, except for operations that must be performed in a specific order. In addition, for clarity and brevity, descriptions of features known in the art may be omitted.
[0026] The embodiments described in some embodiments of the present disclosure below do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0027] It should be noted that the execution subject of the file organization method of this embodiment may be a file organization device, and the device may be configured in any type of electronic device, which is not limited here.
[0028] In the embodiments of the present disclosure, the "file system" is used as the execution subject to illustrate the file organization method, which is not limited here. It should be noted that the description order of the following embodiments is not used as a limitation on the priority order of the embodiments.
[0029] Figure 1 It is a flowchart of a method for organizing files provided according to the first embodiment of the present disclosure.
[0030] like Figure 1 As shown, the method includes:
[0031] Step 101, based on a preset judgment strategy, determine whether each file is a hot file.
[0032] Among them, the preset judgment strategy is a preset judgment method for judging whether a file is a hot file.
[0033] The hot files may be files with a high access frequency (eg, the number of times they are read or modified), or may be some key files, such as database files, which are not limited here.
[0034] It should be noted that files that meet certain specific conditions can be used as hot files, and hot files can be defined in different ways. In the disclosed embodiment, there can be multiple judgment strategies. For example, if file 1 meets specific condition A, file 1 can be marked as a hot file. If file 2 meets specific condition B, file 2 can also be marked as a hot file. Among them, judging whether a file meets specific condition A or specific condition B is the judgment strategy.
[0035] Optionally, when any file is a file required during the cold start process of the application, the any file is determined to be a hot file.
[0036] It should be noted that during the cold start process of an application, any file that is accessed or used is very critical, so it can be used as a hot file. The files required by different applications during the cold start process may be the same or different. For example, application A needs to rely on file x1 during the cold start process, and application B needs to rely on file x2 during the cold start process.
[0037] A cold start refers to the first start of an application from a completely non-running state to an interactive state. During this process, the application may need to load configuration files, read databases, load resource files, etc.
[0038] For example, for application A, file x1 is a file required during its cold start process, which means that file x1 is more critical, and thus it can be used as a hot file.
[0039] Optionally, when any file is a file required during the cold start process of the application and the file size of any file is greater than a first threshold, it is determined that any file is a hot file.
[0040] The first threshold may be a threshold of the file size. As an example, the first threshold may be 10M, which is not limited here.
[0041] It should be noted that if any file is a file required by the application during the cold start process, and the file is relatively large (larger than the first threshold), the file can be used as a hot file.
[0042] Optionally, when any file is a database file used by an application, any file is determined to be a hotspot file.
[0043] The database files used by applications are files used by specific applications to store, manage, and retrieve data. These files usually contain the data structures, records, and possible indexes and relationships required by the application, and are the bridge between the application and the data. The specific form and characteristics of the database files depend on the type of database management system used.
[0044] The types of database files may include relational database files, embedded database files, memory database files, etc., which are not limited here.
[0045] It should be noted that if the file system determines that any file is a database file used by an application, it can be determined as a hot file. Alternatively, the number of file accesses and access frequency can be counted by monitoring the file access log or using the monitoring tool provided by the file system. If the access frequency of a database file is much higher than that of other files, then it can be determined that the database file is a hot file.
[0046] Optionally, when any file is a file that the system depends on for startup, any file is determined to be a hot file.
[0047] Among them, the files that the system depends on for startup are those that are loaded and executed by the boot program when the computer system starts, and are essential for the normal startup and operation of the system. These files are usually located on the system's boot volume, and their integrity and correctness are essential for the stable operation of the system.
[0048] It should be noted that if the file system determines that any file is a file that the system startup depends on, it can be determined as a hot file.
[0049] Optionally, when the access frequency corresponding to any file is greater than a second threshold, any file is determined to be a hot file.
[0050] The second threshold may be a threshold of access frequency.
[0051] It should be noted that if the system's access frequency to any file is greater than the second threshold, it means that the file is of great interest, that is, files that are frequently accessed or have a high access frequency can be regarded as hot files.
[0052] Step 102: based on the judgment result corresponding to each file, mark the file in the file system.
[0053] Optionally, when the judgment result is that any file is a hot file, the target attribute of any file is marked as a hot attribute in the index node of the file system.
[0054] The target attribute may be an attribute indicating whether the file is a hot file. For example, if the target attribute is a hot attribute, it indicates that the file is a hot file. If the target attribute is a cold attribute, it indicates that the file is not a hot file.
[0055] Among them, the English equivalent of the index node is inode, which is the full name of Index Node. It is a data structure in the file system that is used to store metadata for files and directories. The inode structure provides a unique identifier for each file and directory in the file system, and stores key information related to these files and directories, such as file size, permissions, owner, timestamp, etc. It can be understood that the metadata and actual data block location of the file can be quickly found through the inode identifier of each file, thereby achieving access and operation of the file. In the file system, all inodes are stored in a continuous storage area called the inode table. The size of the inode table and the number of inodes are determined when the file system is formatted and remain unchanged during the life cycle of the file system.
[0056] The index node may record the target attributes of each file.
[0057] Optionally, when the judgment result shows that any file is not a hot file, the target attribute of any file is marked as a cold attribute in the index node of the file system.
[0058] It should be noted that the file system can set the target attribute of the file in the index node based on the judgment result of each file, that is, whether it is a hot file, that is, hot files can be set to hot attributes, and non-hot files can be set to cold attributes.
[0059] Optionally, the file system may update the target attribute according to the access frequency corresponding to each file.
[0060] Specifically, the file system can dynamically update the target attributes according to the access frequency corresponding to each file. In the disclosed embodiment, the file system can track the access of the file and determine whether the file should be marked as a hot file or a cold file based on a preset threshold or algorithm. In order to ensure the accuracy of the file attributes, the file system can scan regularly, check the access records of the file, and update the file attributes according to the latest access frequency. This regular scanning can help the file system identify files whose access patterns have changed and adjust their attribute tags in a timely manner.
[0061] For example, if the access frequency corresponding to the file was originally less than the second threshold and then becomes greater than the second threshold, its target attribute may be modified from a cold attribute to a hot attribute, which is not limited here.
[0062] Step 103: In response to satisfying a preset condition, defragment the hot files in the file system.
[0063] Among them, defragmentation, also known as defragmentation, is an important operation in computer storage management. It refers to reorganizing the scattered file fragments on the disk so that the various parts of the file are stored continuously on the disk, thereby improving the access speed and efficiency of the disk. During the file storage process, due to frequent operations such as creating, deleting, and modifying files, the storage of files on the disk may become discontinuous, forming file fragments. These fragments will be scattered in various corners of the disk, so that the disk needs to move the read-write head frequently when reading files, which increases the access time and reduces the system performance. Through defragmentation, these scattered file fragments can be reorganized into continuous files, thereby reducing the number of times the read-write head moves and improving the access speed of the disk.
[0064] The preset condition may be a preset condition for starting defragmentation. The preset condition may be one or more. If there are more than one preset condition, defragmentation of hot files in the file system may begin when any of the preset conditions is met.
[0065] As a possible implementation method, when the file system is in an idle state, it can be determined that a preset condition is met, and then the hot files in the file system are defragmented.
[0066] It should be noted that the idle state of a file system refers to a state in which there are no or few read and write operations for a period of time. In this state, the file system does not process or processes few file requests, the disk read and write heads are stationary or move at a low speed, and system resources are relatively idle.
[0067] Optionally, whether the file system is in an idle state can be determined by monitoring the I / O activities of the file system. Specifically, the number of read and write operations and the amount of read and write data of the file system within a certain period of time can be counted. When these indicators are lower than a preset threshold, the file system can be considered to be in an idle state.
[0068] In the embodiment of the present disclosure, in the defragmentation operation, the file system idle state can be used for defragmentation to reduce the impact on system performance. Fragmentation defragmentation may occupy system resources and affect the execution of other tasks. Therefore, it is necessary to perform the defragmentation operation when the system load is low.
[0069] In the disclosed embodiment, the file system first determines whether each file is a hot file based on a preset judgment strategy, and then marks the file in the file system based on the judgment result corresponding to each file, and then responds to meeting the preset conditions to defragment the hot files in the file system. Thus, hot files can be distinguished and identified at the file system level, and hot files in the file system can be defragmented, so that hot files can be accurately read and written in sequence, thereby improving the performance of the terminal device.
[0070] It should be noted that in the related art, when identifying hot files, it is usually implemented by the kernel, or a business module above the kernel. Since the embodiment of the present disclosure is executed by the file system, it has the ability to distinguish between hot and cold files at the file system level, and the file system can independently determine the timing and mechanism of file defragmentation. The file system can be completely isolated from the upper-level business and separated from the business. In the related art, since the hot files are identified and defragmented by the kernel or other upper-level business modules, the degree of coupling is relatively high.
[0071] As an example, F2FS (Flash Friendly File System) is a file system designed for modern flash memory devices, one of its core design goals is to optimize the performance and durability of flash memory. In the F2FS file system, garbage collection (GC) is an important mechanism for reclaiming invalid data blocks and organizing disk space to reduce fragmentation.
[0072] When the GC inside the F2FS file system performs necessary cleanup (i.e., regular garbage collection and disk space cleanup), it can adopt a strategy to lower the priority of hot file cleanup. The data blocks of hot files may be distributed relatively discretely in the flash memory, but due to their frequent access characteristics, the impact on performance is particularly significant. During the GC process, the file system can give priority to processing data blocks of files that have less impact on performance or are not accessed so frequently. The advantage of doing this is that it can reduce interference with hot files and avoid performance degradation caused by frequent reading and writing of hot files during the cleanup process. At the same time, since the distribution of hot file data blocks in the flash memory may be relatively complex, lowering their cleanup priority can also reduce the complexity and time consumption of the GC process.
[0073] Therefore, the F2FS file system can manage the storage space of flash memory devices more effectively and reduce the degree of fragmentation by reducing the priority of hot file defragmentation and other optimization strategies, thereby improving the performance and durability of the file system. These optimization strategies make F2FS perform better on modern flash memory devices.
[0074] Figure 2 It is a flowchart of a method for organizing files provided according to the second embodiment of the present disclosure.
[0075] like Figure 2 As shown, the method includes:
[0076] Step 201, based on a preset judgment strategy, determine whether each file is a hot file.
[0077] Step 202: based on the judgment result corresponding to each file, mark the file in the file system.
[0078] It should be noted that the specific implementation of steps 201 and 202 can refer to the above embodiment and will not be described in detail here.
[0079] Step 203: when the file system is in an idle state and any application is not started, determine that a first preset condition is met, and defragment a first hot spot file corresponding to any application.
[0080] The first hotspot file is a hotspot file required during the cold start process of the application.
[0081] Among them, the first preset condition may be that the file system is in an idle state and any application is not started, and at this time, the condition for defragmenting the first hot spot file corresponding to any application is met.
[0082] The file system is in an idle state, which means that the file system is not currently performing any read or write operations, or the frequency of read and write operations is extremely low, so the system can be considered to be in an idle state. Application not started means that no specific application is currently running or in the background, and the specific application is closed or inactive.
[0083] It should be noted that if an application is completely closed (or has never been run), the user starts the application again. Since there is no process information of the application in the system at this time, the cold start process is usually slower than a hot start (the application is still running in the background) or a warm start (the application process has been terminated, but some data is still retained in the memory). When the file system is idle and the application is not started, the system will check whether the first preset condition is met.
[0084] If the conditions are met, the system will defragment the specified hotspot files. For example, if the file system is not started and the application M is completely closed, it can be considered that the first preset condition is met, and the hotspot files (first hotspot files) required during the cold start of the application M are defragmented.
[0085] In the disclosed embodiment, firstly, based on a preset judgment strategy, it is judged whether each file is a hot file, and then based on the judgment result corresponding to each file, the file is marked in the file system, and then when the file system is in an idle state and any application is not started, it is determined that the first preset condition is met, and the first hot file corresponding to any application is defragmented, wherein the first hot file is the hot file required in the cold start process of the application. Thus, by defragmenting the hot files required in the cold start process, the seek time and delay time when reading the file can be reduced, thereby improving the startup speed of the application. Defragmentation helps to optimize the overall performance of the file system, reduce the delay and error rate of read and write operations, and improve the stability and reliability of the system. By reducing unnecessary read and write operations and wear, fragmentation can also extend the service life of the flash memory device and the entire system.
[0086] Figure 3 It is a flowchart of a method for organizing files provided according to the third embodiment of the present disclosure.
[0087] like Figure 3 As shown, the method includes:
[0088] Step 301, based on a preset judgment strategy, determine whether each file is a hot file.
[0089] Step 302: based on the judgment result corresponding to each file, mark the file in the file system.
[0090] It should be noted that the specific implementation of steps 301 and 302 can refer to the above embodiment and will not be described in detail here.
[0091] Step 303: when the file system is in an idle state and the second hot file of any application is not accessed, it is determined that the second preset condition is met, and the second hot file of any application is defragmented.
[0092] Among them, the second hot file is a database file used by the application.
[0093] The second preset condition may be that the file system is in an idle state and the second hotspot file of any application is not accessed, and at this time, the condition for defragmenting the second hotspot file corresponding to any application is met.
[0094] The file system being in an idle state means that the file system is not currently performing any read or write operations, or the frequency of read and write operations is extremely low, and the system can be considered to be in an idle state.
[0095] Among them, the second hot file that is not accessed by any application means that at the current moment, no application is accessing or requesting to read its database file (i.e., the second hot file). The second hot file refers to the database file used by the application. These files usually contain a large amount of data and are often affected by read and write operations, so they are prone to fragmentation. Defragmentation is a process that aims to reorganize data blocks in the file system to reduce or eliminate fragmentation. For database files, it can include rearranging data records, merging free data blocks, optimizing index structures, etc.
[0096] In the disclosed embodiment, firstly, based on a preset judgment strategy, it is judged whether each file is a hot file, and then based on the judgment result corresponding to each file, the file is marked in the file system, and then when the file system is in an idle state and the second hot file of any application is not accessed, it is determined that the second preset condition is met, and the second hot file of any application is defragmented, wherein the second hot file is a database file used by the application. Thus, by reducing fragmentation, the system can speed up the read and write speed of the database, improve query performance, and reduce data access delays. Fragmentation helps to optimize the overall performance of the file system, reduce unnecessary read and write operations, and improve the utilization of storage space. By reducing frequent read and write operations and data movement, fragmentation can also reduce wear on storage devices, thereby extending their service life.
[0097] Figure 4 It is a flowchart of a method for organizing files provided according to the fourth embodiment of the present disclosure.
[0098] like Figure 4 As shown, the method includes:
[0099] Step 401, based on a preset judgment strategy, determine whether each file is a hot file.
[0100] Step 402: based on the determination result corresponding to each file, mark the file in the file system.
[0101] It should be noted that the specific implementation of steps 401 and 402 can refer to the above embodiment and will not be described in detail here.
[0102] Step 403: When the file system is in an idle state and the third hotspot file is not currently accessed, determine that the third preset condition is met, and defragment the third hotspot file.
[0103] Among them, the third hot file is the file that the system startup depends on.
[0104] Among them, the third preset condition may be that the file system is in an idle state and the third hot spot file is not currently accessed, and at this time, the condition for defragmenting the third hot spot file is met.
[0105] It should be noted that if the file system is currently in a non-busy state, that is, there are no large number of read and write operations in progress, and there is no significant performance bottleneck or resource contention. And the third hotspot file that the system depends on for startup is not currently accessed by any process or application, this ensures that the defragmentation process will not interfere with the running system services or applications.
[0106] Specifically, the file system first detects whether the file system is in an idle state and confirms that the third hotspot file is not currently accessed. When confirming that the file system is idle and the third hotspot file is not currently accessed, the system further checks whether the third preset condition is met. If the third preset condition is met, the system will start to defragment the third hotspot file. This process may involve operations such as reading files, rearranging and writing data blocks to ensure the continuity and efficiency of files in physical storage.
[0107] In the disclosed embodiment, firstly, based on a preset judgment strategy, it is judged whether each file is a hot file, and then based on the judgment result corresponding to each file, the file is marked in the file system, and then when the file system is in an idle state and the third hot file is not currently accessed, it is determined that the third preset condition is met, and the third hot file is defragmented, wherein the third hot file is a file that the system depends on for startup. Thus, by reducing fragmentation, the system can access and load files that startup depends on more quickly, thereby shortening the system startup time. Fragmentation defragmentation helps to optimize the overall performance of the file system, improve file access speed and system responsiveness. By ensuring the continuity and integrity of key files, fragmentation defragmentation can enhance the stability and reliability of the system and reduce the risk of system crashes or performance degradation due to file fragmentation.
[0108] In order to better implement the document arrangement method of the present disclosure, the present disclosure also provides a document arrangement device based on the document arrangement method. The meanings of the terms are the same as those in the document arrangement method, and the specific implementation details can refer to the description in the method embodiment.
[0109] See also Figure 5 , Figure 5 : is a schematic diagram of the structure of a file arrangement device provided by an embodiment of the present disclosure, wherein the file arrangement device 500 comprises:
[0110] The judgment module 510 is used to judge whether each file is a hot file based on a preset judgment strategy;
[0111] A marking module 520, configured to mark the file in the file system based on the judgment result corresponding to each file;
[0112] The sorting module 530 is used to sort the hot files in the file system into fragments in response to meeting a preset condition.
[0113] Optionally, the judging module 510 is specifically configured to:
[0114] In the case where any file is a file required during the cold start process of the application, determining the any file as a hot file;
[0115] or,
[0116] If any file is a file required in a cold start process of an application and the file size of any file is greater than a first threshold, determining that any file is a hot file;
[0117] or,
[0118] In the case where any file is a database file used by an application, determining the any file as a hotspot file;
[0119] or,
[0120] In the case where any file is a file that the system depends on for startup, determining the any file as a hotspot file;
[0121] or,
[0122] When the access frequency corresponding to any file is greater than the second threshold, the any file is determined to be a hot file.
[0123] Optionally, the sorting module 530 is specifically used for:
[0124] When the file system is in an idle state, determining that the preset condition is satisfied;
[0125] Hot files in the file system are defragmented.
[0126] Optionally, the sorting module 530 is specifically used for:
[0127] When the file system is in an idle state and any application is not started, determining that a first preset condition is met, and defragmenting a first hotspot file corresponding to any application, wherein the first hotspot file is a hotspot file required in a cold start process of the application;
[0128] or,
[0129] When the file system is in an idle state and a second hot file of any application is not accessed, determining that a second preset condition is met, and defragmenting the second hot file of any application, wherein the second hot file is a database file used by the application;
[0130] or,
[0131] When the file system is in an idle state and the third hotspot file is not currently accessed, it is determined that a third preset condition is met, and the third hotspot file is defragmented, wherein the third hotspot file is a file that the system startup depends on.
[0132] Optionally, the marking module 520 is specifically used for:
[0133] If the judgment result is that any file is a hot file, marking the target attribute of any file as a hot attribute in the index node of the file system;
[0134] or,
[0135] When the judgment result is that any file is not a hot file, the target attribute of any file is marked as a cold attribute in the index node of the file system.
[0136] Optionally, the tag module is also used to:
[0137] The target attribute is updated according to the access frequency corresponding to each file.
[0138] Optional, finishing module, specifically used for:
[0139] Determining hot files to be sorted in the file system;
[0140] Determine a fragmentation value corresponding to the hot file to be sorted, wherein the fragmentation value is used to characterize the degree of fragmentation of the file;
[0141] When the fragmentation value is greater than a third threshold, the hot file to be sorted is defragmented based on the logical block addressing LBA of the hot file to be sorted.
[0142] In the disclosed embodiment, the file sorting device first determines whether each file is a hot file based on a preset judgment strategy, and then marks the file in the file system based on the judgment result corresponding to each file, and then responds to meeting the preset conditions to perform fragmentation sorting on the hot files in the file system. Thus, hot files can be distinguished and identified at the file system level, and hot files in the file system can be fragmented, so that hot files can be accurately read and written in sequence, thereby improving the performance of the terminal device.
[0143] In addition, the present disclosure also provides an electronic device, such as Figure 6 As shown, it shows a schematic diagram of the structure of the electronic device involved in the present disclosure, specifically:
[0144] The electronic device may include components such as a processor 601 with one or more processing cores, a memory 602 with one or more computer-readable storage media, a power supply 603, and an input unit 604. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0145] The processor 601 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 602, and calling data stored in the memory 602, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 601 may include one or more processing cores; preferably, the processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 601.
[0146] The memory 602 can be used to store software programs and modules. The processor 601 executes various functional applications and data processing by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 602 may also include a memory controller to provide the processor 601 with access to the memory 602.
[0147] The electronic device also includes a power supply 603 for supplying power to various components. Preferably, the power supply 603 can be logically connected to the processor 601 through a power management system, so as to manage charging, discharging, power consumption management and other functions through the power management system. The power supply 603 can also include one or more DC or AC power supplies, recharging systems, power supply device debugging circuits, power converters or inverters, power status indicators and other arbitrary components.
[0148] The electronic device may further include an input unit 604, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0149] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 601 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 602 according to the following instructions, and the processor 601 will run the application programs stored in the memory 602, thereby implementing the steps in any file organization method provided in the embodiments of the present disclosure.
[0150] In the disclosed embodiment, firstly, based on a preset judgment strategy, it is judged whether each file is a hot file, then based on the judgment result corresponding to each file, the file is marked in the file system, and then in response to meeting the preset conditions, the hot files in the file system are fragmented. Thus, the hot files can be distinguished and identified at the file system level, and the hot files in the file system can be fragmented, so that the hot files can be accurately read and written in sequence, thereby improving the performance of the terminal device.
[0151] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0152] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0153] To this end, the present disclosure provides a computer-readable storage medium, on which a computer program is stored. The computer program can be loaded by a processor to execute the steps in any file organization method provided by the present disclosure.
[0154] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0155] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0156] Since the instructions stored in the computer-readable storage medium can execute the steps in any file organization method provided by the present disclosure, the beneficial effects that can be achieved by any file organization method provided by the present disclosure can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0157] The above is a detailed introduction to a file organization method, device, electronic device and computer-readable storage medium provided by the present disclosure. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for organizing files, characterized in that: Performed by the file system, including: Based on the preset judgment strategy, determine whether each file is a hot file; Based on the judgment result corresponding to each file, marking the file in the file system; In response to satisfying a preset condition, hot files in the file system are defragmented.
2. The method according to claim 1, characterized in that The step of judging whether each file is a hotspot file based on a preset judgment strategy includes: In the case where any file is a file required during the cold start process of the application, determining the any file as a hot file; or, If any file is a file required in a cold start process of an application and the file size of any file is greater than a first threshold, determining that any file is a hot file; or, In the case where any file is a database file used by an application, determining the any file as a hotspot file; or, In the case where any file is a file that the system depends on for startup, determining the any file as a hotspot file; or, When the access frequency corresponding to any file is greater than the second threshold, the any file is determined to be a hot file.
3. The method according to claim 1, characterized in that: In response to satisfying a preset condition, defragmenting the hot files in the file system includes: When the file system is in an idle state, determining that the preset condition is satisfied; Hot files in the file system are defragmented.
4. The method according to claim 1, characterized in that: In response to satisfying a preset condition, defragmenting the hot files in the file system includes: When the file system is in an idle state and any application is not started, determining that a first preset condition is met, and defragmenting a first hotspot file corresponding to any application, wherein the first hotspot file is a hotspot file required in a cold start process of the application; or, When the file system is in an idle state and a second hot file of any application is not accessed, determining that a second preset condition is met, and defragmenting the second hot file of any application, wherein the second hot file is a database file used by the application; or, When the file system is in an idle state and the third hotspot file is not currently accessed, it is determined that a third preset condition is met, and the third hotspot file is defragmented, wherein the third hotspot file is a file that the system startup depends on.
5. The method according to claim 1, characterized in that The marking of the file in the file system based on the judgment result corresponding to each file includes: If the judgment result is that any file is a hot file, marking the target attribute of any file as a hot attribute in the index node of the file system; or, When the judgment result is that any file is not a hot file, the target attribute of any file is marked as a cold attribute in the index node of the file system.
6. The method according to claim 5, characterized in that Also includes: The target attribute is updated according to the access frequency corresponding to each file.
7. The method according to any one of claims 1 to 6, characterized in that: The fragmentation of hot files in the file system includes: Determining hot files to be sorted in the file system; Determine a fragmentation value corresponding to the hot file to be sorted, wherein the fragmentation value is used to characterize the degree of fragmentation of the file; When the fragmentation value is greater than a third threshold, the hot file to be sorted is defragmented based on the logical block addressing LBA of the hot file to be sorted.
8. A file arrangement device, characterized in that: include: A judgment module, used to judge whether each file is a hot file based on a preset judgment strategy; A marking module, used for marking files in the file system based on the judgment result corresponding to each file; The arrangement module is used to arrange the hot files in the file system into fragments in response to meeting a preset condition.
9. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
File sorting method and apparatus, and electronic device and storage medium
WO2026149063A1