Mobile terminal file defragmentation method and system based on context awareness and machine learning

CN122654084APending Publication Date: 2026-08-28NANJING UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611142913.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-30
Publication Date
2026-08-28

AI Technical Summary

Technical Problem

[0006]本发明的目的在于提供一种基于上下文感知与机器学习的移动终端文件碎片整理方法,解决现有方法仅依据热度或碎片程度迁移数据,忽视交互场景以及前台应用使用模式,导致迁移开销大且关键文件整理不及时的问题

Benefits of technology

[0015] (1) This invention does not simply determine migration priority based on file popularity or fragmentation, but constructs a multi-dimensional evaluation system that integrates contextual value perception and front-end application usage pattern modeling. On the one hand, it uses a lightweight neural network to predict the scenario value weight of user interaction scenarios in real time; on the other hand, it comprehensively considers user habit characteristics such as application usage frequency, active days ratio, and average single usage duration, and through the synergistic effect of scenario value weight and application usage pattern score, it ensures that fragmented files generated by frequently used applications in latency-sensitive scenarios are promptly organized, truly determining the organization priority from the perspective of user-perceptible experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122654084A_ABST
    Figure CN122654084A_ABST
Patent Text Reader

Abstract

The application discloses a mobile terminal file fragmentation arrangement method and system based on context awareness and machine learning. The method comprises forming a lightweight neural network model and a machine learning regression model which can be deployed to a mobile terminal and completing the deployment; recording context and file access information when a foreground application runs, and calling the deployed lightweight neural network model and machine learning regression model to respectively perform context value awareness and comprehensive file value evaluation, and screening and migrating high-value fragmented files during a system idle period. The application significantly reduces migration overhead while improving application response performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention pertains to storage optimization technology, specifically a method and system for defragmenting mobile terminal files based on context awareness and machine learning. Background Technology

[0002] With the widespread adoption of mobile devices, flash-based storage has become the mainstream storage medium for smartphones. To adapt to the physical characteristics of flash memory, flash-friendly file systems and other journal-structured file systems are widely used in mobile devices. When storage utilization is below a preset threshold (e.g., 70%), flash-friendly file systems default to an off-site update strategy. This means that when file data is modified, the system writes the updated data to a newly allocated data block instead of overwriting it in the original location; the original data block is marked as invalid for subsequent garbage collection. In daily use of mobile devices, applications and system upgrades frequently modify critical files. Under the off-site update mechanism, the updated data is written to a new logical block address, disrupting the original continuity of the file and causing file fragmentation to accumulate continuously over time.

[0003] File fragmentation degrades the I / O performance of storage systems and harms the user experience at multiple levels. At the operating system level, when an application initiates a read request, if the target file data is not contiguous in the logical address space, the operating system's block layer will split the request into multiple discrete block I / O (bio) structures for separate processing, introducing additional software stack scheduling and processing overhead. At the storage device level, modern mobile storage devices rely on multi-chip architectures to achieve chip-level parallelism and channel-level interleaving. Their internal flash translation layers typically employ data striping strategies, mapping contiguous logical addresses to physical pages distributed across multiple chips to maximize I / O parallelism and throughput. However, file fragmentation disrupts this hardware-level parallelism: scattered and disordered logical blocks prevent the controller from efficiently allocating requests to multiple chips, resulting in I / O traffic concentrating on a few chips while the rest remain idle. The resulting serialization overhead and head-of-line blocking significantly increase I / O tail latency.

[0004] To alleviate file fragmentation, existing defragmentation solutions mainly fall into the following categories: The first category is traditional file system-level defragmentation tools, which perform a full migration indiscriminately on fragmented files. The second category is selective migration schemes based on a combination of fragmentation level and access frequency, determining migration priority by combining the file's fragmentation level (defined as the ratio of the currently allocated number of segments to the ideal minimum number of segments) with the file's access frequency. The third category is fragmentation suppression schemes based on pre-allocation, which use decision trees to identify frequently updated files and pre-allocate storage space for them to support in-situ updates, but this consumes a significant amount of storage space.

[0005] The aforementioned existing technologies have significant limitations in practical applications on mobile terminals. The core problem lies in the fact that the migration decisions of existing solutions mainly rely on underlying input / output access statistics (such as file read / write frequency) or physical fragmentation status. There is a serious disconnect between these underlying statistical indicators and the actual impact of files on the foreground user experience. Due to the lack of awareness and consideration of user interaction context (such as latency-sensitive scenarios like application cold starts) and application usage patterns (such as users' high-frequency application preferences), existing solutions cannot accurately assess the true "experience value" of fragmented files. This bias in value assessment leads to two problems in actual operation: First, fragmented files that are crucial to user experience (such as databases or dynamic link library files accessed by frequently used applications during cold starts) may be given a lower defragmentation priority due to their low overall underlying read / write frequency, resulting in increased critical path latency; second, unimportant fragmented files (such as logs and temporary caches frequently written in the background) are over-defragmented due to their high underlying input / output activity and fragmentation level, thereby generating unnecessary migration overhead and exacerbating flash memory wear. Summary of the Invention

[0006] The purpose of this invention is to provide a mobile terminal file fragmentation method based on context awareness and machine learning, which solves the problem that existing methods migrate data only based on popularity or fragmentation level, ignoring interaction scenarios and front-end application usage patterns, resulting in high migration costs and untimely organization of critical files.

[0007] The technical solution to achieve the purpose of this invention is: a method for defragmenting mobile terminal files based on context awareness and machine learning, comprising:

[0008] Develop and deploy lightweight neural network models and machine learning regression models that can be deployed to mobile terminals;

[0009] The system records context and file access information during foreground application runtime, and calls deployed lightweight neural network models and machine learning regression models to perform context value perception and comprehensive file value assessment, respectively. It also filters and migrates high-value fragmented files during system idle periods.

[0010] This invention also proposes a mobile terminal file fragmentation system based on context awareness and machine learning, including: a context value awareness module, a fragmentation decision module, and an action execution module;

[0011] The context value perception module is used to collect and analyze user interaction behavior and underlying input and output features in real time, and predict the value weight of the current usage scenario through a preset lightweight neural network.

[0012] The fragmentation decision module is used to integrate application usage patterns, scenario value weights, file status characteristics, and system space utilization. It calculates the comprehensive file value through a preset machine learning regression model and filters out high-value fragmented files based on the comprehensive file value.

[0013] The action execution module is used to detect the idle state of the mobile terminal system and perform selective physical migration on the hot segments of the selected high-value fragmented files during the system idle period.

[0014] Compared with the prior art, the significant advantages of this invention are:

[0015] (1) This invention does not simply determine migration priority based on file popularity or fragmentation, but constructs a multi-dimensional evaluation system that integrates contextual value perception and front-end application usage pattern modeling. On the one hand, it uses a lightweight neural network to predict the scenario value weight of user interaction scenarios in real time; on the other hand, it comprehensively considers user habit characteristics such as application usage frequency, active days ratio, and average single usage duration, and through the synergistic effect of scenario value weight and application usage pattern score, it ensures that fragmented files generated by frequently used applications in latency-sensitive scenarios are promptly organized, truly determining the organization priority from the perspective of user-perceptible experience.

[0016] (2) This invention does not necessarily migrate the entire file, but identifies the hot sections within the file that are frequently read and severely fragmented, and performs selective migration only on the hot sections, thus avoiding unnecessary input / output overhead and additional flash memory wear caused by full file migration.

[0017] (3) This invention does not rely on manually labeled training samples, but automatically generates continuous file value labels through grading quantization, normalization and heuristic weighting formulas for training machine learning regression models, thus solving the problem of lack of manually labeled true values ​​for fragment sorting benefits.

[0018] The present invention will now be described in further detail with reference to the accompanying drawings. Attached Figure Description

[0019] Figure 1 This is a deployment architecture diagram of the present invention.

[0020] Figure 2 This is a workflow diagram for the present invention. Detailed Implementation

[0021] like Figure 1 , 2As shown, a mobile terminal file defragmentation method based on context awareness and machine learning includes a model preparation stage and a terminal execution stage. The model preparation stage is used to form a lightweight neural network model in the context value awareness module that can be deployed to the mobile terminal, and a machine learning regression model in the defragmentation decision module. The terminal execution stage is used to record context and file access information during the runtime of the foreground application, and to call the deployed lightweight neural network model and machine learning regression model to perform context value awareness and comprehensive file value evaluation, respectively. Then, during system idle periods, high-value fragmented files are screened and migrated.

[0022] The first stage is the model preparation stage, which specifically includes:

[0023] Step 1: Train a lightweight neural network model for the context value perception module. The context value perception module uses a lightweight neural network model to perceive context value. User interaction scenarios are pre-divided into four categories, and different Context Value Weights (SVWs) are set for each category. Input / output trajectories and user interface actions of the foreground application are collected under different predefined scenarios, and context value perception features are constructed within a 1-second sliding window. These context value perception features include underlying input / output frequency, average input / output size, sequential access ratio, read request ratio, total input / output data volume, and user interface actions. The lightweight neural network model is trained using these context value perception features, enabling it to learn a non-linear evaluation relationship between real-time input / output features and user interface actions and context value weights within the range of 0 to 1. The interaction scenarios include:

[0024] (1) Interactive loading scenario: triggered by explicit user interface interaction, manifested as a sudden large block read request, such as loading dynamic library files when the application starts. This scenario is sensitive to input and output delays, and its scenario value weight is 1.0;

[0025] (2) Continuous browsing scenario: sequential prefetching is triggered by frequent swiping, such as browsing social media feeds or image galleries. This scenario requires stable input and output throughput, and its scenario value weight is 0.8.

[0026] (3) Multimedia playback scenario: This is characterized by continuous large-block sequential reading for real-time media decoding. This scenario emphasizes continuous data supply, and its scenario value weight is 0.6.

[0027] (4) Other scenarios: including background synchronization, low-frequency input / output operations and write-dominant tasks. This scenario is considered a low-priority defragmentation scenario, and its scenario value weight is 0.1.

[0028] Step 2: Collect training samples for the defragmentation decision module. The defragmentation decision module uses a machine learning regression model. Sample feature vectors are collected to train the machine learning regression model. The construction process of the sample feature vectors is as follows: First, collect the original features of application usage patterns, original features of file status, original features of system status, and the scene value perception features described in Step 1; then, input the scene value perception features into the lightweight neural network model trained in Step 1 to infer the scene value weights (SVW); finally, combine the above original features with the inferred scene value weights to construct the sample feature vectors used for model training. Among them, the original features of application usage patterns include application usage frequency, active days ratio, and average single usage duration; the original features of file status include file type, file popularity, fragmentation degree, and average fragment size of actively accessed hot segments; the original features of system status include system space utilization.

[0029] Step 3: Generate continuous file value labels and train the machine learning regression model in the defragmentation decision module. Since defragmentation benefits lack manually labeled ground truth values, during the model training phase, all original features from Step 2 (i.e., application usage pattern features, file status features, and system status features) are categorized, quantized, normalized, and heuristically weighted to automatically generate continuous file value labels for training the machine learning regression model. This label generation process specifically includes: weighting the quantified application usage pattern features (including application usage frequency, active days ratio, and average single usage duration) to obtain labels related to application usage patterns; weighting the quantified file status features (including file type, file popularity, fragmentation degree, and average fragment size in hot segments) to obtain labels related to file status; and finally, merging these two label components with the scenario value weight and the quantified system space utilization rate to generate the final file value labels.

[0030] In a specific embodiment of training label generation, the original features obtained in step 2 (i.e., application usage pattern features, file status features, and system status features) are first quantized and converted into base scores ranging from 0 to 1. Taking the "average fragment size of hot segments" in the file status features as an example, its quantization rules are shown in Table 1 (KB represents kilobytes): For example, when the average fragment size of a hot segment is greater than 16KB and not greater than 32KB, the feature is quantized to 0.9 (indicating that fragments in this range have a significant impact on system input / output performance and have high sorting value); while when the average fragment size is greater than 512KB, its base score is reduced to 0.1 (indicating that large fragments have good continuity and have a lower sorting priority). The base score conversion methods for other features are similar.

[0031] Table 1. Classification and Quantification Rules for Average Fragment Size in Hot Zones

[0032] Greater than 0 and not greater than 16 1.0 Greater than 16 and not greater than 32 0.9 Greater than 32 and not greater than 64 0.8 Greater than 64 and not greater than 128 0.6 Greater than 128 and not greater than 256 0.4 Greater than 256 and not greater than 512 0.2 Greater than 512 0.1

[0033] In one training label generation embodiment, the scores related to file status, the scores related to application usage patterns, and the final file value label can be generated as follows:

[0034]

[0035]

[0036]

[0037] In the formula: This represents a comprehensive score related to the file's status; This represents a comprehensive score related to application usage patterns; This represents the value tag of the final generated file; , , , These represent the quantified base scores for file popularity, fragmentation, file type, and average fragment size in hot zones, respectively. , , These represent the base score for application usage frequency, the base score for the proportion of active days, and the base score for average single usage time, respectively. This represents the value weight of the scenario; This represents the quantified base score for system space utilization. , , , The first set of heuristic weight coefficients for the file state dimension; , , The second set of heuristic weight coefficients for the application usage pattern dimension; , , , The third set of heuristic weight coefficients is used to integrate features from various dimensions to generate the final label.

[0038] The base scores and weight coefficients in the tiered quantization, normalization, and heuristic weighting processes are only used for automatically generating labels during the training phase. They are not used as model inputs during the terminal execution phase, nor as fixed parameters for directly calculating the comprehensive document value (CFV) during terminal execution. The continuous document value labels (serving as the training ground values ​​for the comprehensive document value (CFV)) are used to train a machine learning regression model, enabling the model to learn the non-linear evaluation relationship from multi-dimensional raw features to the comprehensive document value (CFV). After training, the lightweight neural network model and the machine learning regression model are deployed to the corresponding modules on the mobile terminal.

[0039] The second stage is the terminal operation stage, which specifically includes:

[0040] Step 4: Record foreground access context. During application operation, the mobile terminal collects real-time input / output trajectories and user interface actions of the foreground application, and constructs scene value-aware features within a 1-second sliding window. The context value-aware module inputs these scene value-aware features into a trained lightweight neural network model, outputs the current scene value weight (SVW) within the range of 0 to 1, and saves this scene value weight along with the corresponding foreground file access record.

[0041] Step 5: The mobile terminal records the application's historical usage, foreground file access records, file metadata, file fragmentation status, and system space utilization to obtain historical operation records. Specifically, based on the application's historical usage, aggregated statistics are used to obtain the application's usage frequency, active days ratio, and average single usage duration; based on file metadata, file types are extracted through parsing; based on foreground file access records, file popularity is statistically determined; and based on file fragmentation status, the average fragment size of actively accessed hot segments is calculated.

[0042] Step 6: Filter high-value fragmented files during system idle periods. The fragmentation decision module does not need to run in real time. Instead, it reads the historical running records saved in Step 5 during system idle periods, such as at night. It aggregates these historical running records according to application and file inodes (Inodes) to construct original features of application usage patterns, file status, and system status. Simultaneously, it reads the scene value weights saved in the foreground file access records. The fragmentation decision module forms a feature vector from the above original features and scene value weights and inputs it into a trained machine learning regression model. The model directly outputs the comprehensive file value. For files whose comprehensive file value exceeds a preset threshold, the fragmentation decision module identifies them as high-value fragmented files and outputs the file metadata of the high-value fragmented files and the hotspot boundaries of the selected hotspot segments. The file metadata includes the file path.

[0043] Step 7: Generate Hot Segment Migration Tasks. The action execution module receives candidate file metadata, hot segment boundaries, and overall file value from the fragmentation decision module, and maintains a priority task queue sorted in descending order of overall file value. Based on the file paths in the file metadata, the action execution module locates the target file requiring data migration, and determines the range of hot segments requiring migration within that target file based on the hot segment boundaries. This ensures that migration tasks are generated only for actively accessed and severely fragmented hot segments within high-value files, avoiding indiscriminate migration of the entire file.

[0044] Step 8: Perform selective physical migration during system idle periods. The action execution module retrieves migration tasks from the head of the priority task queue according to the overall file value, from high to low, generates a defragmentation list for the current idle time, and performs physical migration on the hot segments of files in the list. The migration process only occurs during system idle periods to minimize interference with foreground interactive input and output.

[0045] A mobile terminal file defragmentation system based on context awareness and machine learning includes: a context value awareness module, a defragmentation decision module, and an action execution module. The context value awareness module analyzes user interaction behavior and underlying output characteristics in real time and uses a lightweight neural network to predict the value weight of the current scenario. The defragmentation decision module integrates application usage patterns, scenario value weights, file status characteristics, and system space utilization, and uses a machine learning regression model to calculate the comprehensive file value (CFV) to filter out high-value fragmented files that have a significant impact on user experience. The action execution module performs selective physical migration of hot sections of high-value files during system idle periods, rather than full file migration, thereby maximizing user-perceived performance gains while significantly reducing migration overhead.

Claims

1. A method for defragmenting file fragments on mobile terminals based on context awareness and machine learning, characterized in that, include: Develop and deploy lightweight neural network models and machine learning regression models that can be deployed to mobile terminals; The system records context and file access information during foreground application runtime, and calls deployed lightweight neural network models and machine learning regression models to perform context value perception and comprehensive file value assessment, respectively. It also filters and migrates high-value fragmented files during system idle periods.

2. The mobile terminal file defragmentation method based on context awareness and machine learning according to claim 1, characterized in that, Forming a lightweight neural network model that can be deployed on mobile devices includes: User interaction scenarios are pre-divided into four categories, and different scenario value weights are set for each category. Collect the input / output trajectories and user interface actions of the foreground application under different predefined scenarios, and construct scene value perception features within a set sliding window; A lightweight neural network model is trained using scene value perception features, enabling the lightweight neural network model to learn the nonlinear evaluation relationship between real-time input / output features and user interface actions and scene value weights in the range of 0 to 1.

3. The mobile terminal file defragmentation method based on context awareness and machine learning according to claim 2, characterized in that, The scene value perception features include the underlying input / output frequency, average input / output size, sequential access ratio, read request ratio, total input / output data volume, and user interface actions.

4. The mobile terminal file defragmentation method based on context awareness and machine learning according to claim 1, characterized in that, Forming machine learning regression models that can be deployed on mobile devices includes: Collect original characteristics of application usage patterns, original characteristics of file status, original characteristics of system status, and characteristics of perceived value in the scenario; The scene value perception features are input into a lightweight neural network model to infer the scene value weights. The original features of application usage patterns, original features of file status, original features of system status, and the scene value weights obtained through inference are combined to construct a sample feature vector for model training. The original characteristics of application usage patterns, file status, and system status are classified, quantified, normalized, and heuristically weighted to automatically generate continuous file value tags. The machine learning regression model is trained using sample feature vectors and continuous file value labels.

5. The mobile terminal file defragmentation method based on context awareness and machine learning according to claim 4, characterized in that, The specific process for generating value tags for continuous documents is as follows: The original features of the quantified application usage patterns are weighted to obtain the label part related to the application usage patterns; the original features of the quantified file status are weighted to obtain the label part related to the file status; finally, the weighted application usage pattern original feature labels and file status original feature labels are combined with the scenario value weight and the quantified system space utilization to generate the final file value label.

6. The mobile terminal file defragmentation method based on context awareness and machine learning according to claim 4, characterized in that, The original characteristics of the application usage pattern include application usage frequency, active days ratio, and average single usage duration; The original characteristics of a file's status include file type, file popularity, degree of fragmentation, and average fragment size of the most actively accessed hot segments; The original characteristics of the system state include the system space utilization rate.

7. The mobile terminal file defragmentation method based on context awareness and machine learning according to claim 1, characterized in that, The specific steps for recording context and file access information during foreground application runtime, and calling the deployed lightweight neural network model and machine learning regression model to perform context value perception and comprehensive file value assessment respectively are as follows: During application operation, the mobile terminal collects the real-time input and output trajectories and user interface actions of the foreground application, and constructs scene value perception features within a set sliding window; The scene value perception features are input into the deployed lightweight neural network model, which outputs the current scene value weight in the range of 0 to 1, and saves the scene value weight along with the corresponding front-end file access record. The mobile terminal records the application's historical usage, foreground file access records, file metadata, file fragmentation status, and system space utilization to obtain historical running records; During system idle periods, the machine learning regression model reads historical running records and aggregates them according to application and file index nodes to construct original features of application usage patterns, original features of file status, and original features of system status. At the same time, it reads the scene value weights saved in the foreground file access records. The original features of application usage patterns, original features of file status, original features of system status, and scenario value weights are combined to form a feature vector, which is then input into the deployed machine learning regression model to obtain the comprehensive file value. Files with a comprehensive file value exceeding a preset threshold are identified as high-value fragmented files, and the file metadata of high-value fragmented files and the hot segment boundaries of the selected hot segments are output.

8. The mobile terminal file defragmentation method based on context awareness and machine learning according to claim 7, characterized in that, The specific method for filtering and migrating high-value fragmented files during system idle periods is as follows: It receives high-value fragmented file metadata, hot segment boundaries, and comprehensive file value from the output of a machine learning regression model, and maintains a priority task queue sorted in descending order of comprehensive file value. Migration tasks are retrieved from the head of the priority task queue in descending order of overall file value. A defragmentation list is generated for the current idle time, and physical migration is performed on the hot segments in the list.

9. A mobile terminal file defragmentation system based on context awareness and machine learning, characterized in that, include: Contextual value perception module, fragment organization decision-making module, and action execution module; The context value perception module is used to collect and analyze user interaction behavior and underlying input and output features in real time, and predict the value weight of the current usage scenario through a preset lightweight neural network. The fragmentation decision module is used to integrate application usage patterns, scenario value weights, file status characteristics, and system space utilization. It calculates the comprehensive file value through a preset machine learning regression model and filters out high-value fragmented files based on the comprehensive file value. The action execution module is used to detect the idle state of the mobile terminal system and perform selective physical migration on the hot segments of the selected high-value fragmented files during the system idle period.