A micro application pruning method, system, device and medium
By combining static and dynamic analysis with a micro-application pruning method, redundant code is accurately identified and removed, solving the functional integrity and lightweight challenges caused by coarse granularity in existing technologies, and achieving efficient optimization and business continuity on resource-constrained devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG ELECTRIC POWER SCI RES INST ENERGY TECH CO LTD
- Filing Date
- 2026-04-14
- Publication Date
- 2026-07-10
AI Technical Summary
Existing micro-application pruning techniques suffer from coarse pruning granularity, making it difficult to achieve precise lightweight optimization on resource-constrained devices while ensuring the integrity of application functions. Furthermore, pruning decisions struggle to identify fine-grained units and their dependencies, leading to a high risk of functional failure.
We extract atomic functional code fragments through static analysis, filter the smallest functional units by combining dynamic analysis, obtain and score multi-dimensional running parameters, perform dependency conflict detection based on the unit dependency graph, generate a set of pruning units, and remove redundant code without restarting through dynamic linking and memory isolation technology.
It enables precise and lightweight optimization on resource-constrained devices while ensuring functional integrity, reducing operation and maintenance costs, ensuring business continuity and the reversibility of pruning operations, and avoiding the risk of functional failure.
Smart Images

Figure CN122364052A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of micro-application optimization technology, and in particular to a micro-application pruning method, system, device and medium. Background Technology
[0002] With the large-scale deployment and intelligent operation and maintenance of energy storage power stations, numerous micro-applications are deployed on embedded monitoring terminals at the edge to achieve key functions such as battery voltage / temperature acquisition, status alerts, and remote control. These terminals typically use ARM architecture processors, are equipped with limited memory and storage space, and operate in environments subject to dynamic changes such as network fluctuations and power constraints. Therefore, lightweight optimization of micro-applications while ensuring the integrity of core functions is a fundamental technical challenge in this field.
[0003] Currently, mainstream methods for micro-application pruning include coarse-grained pruning based on module / page granularity, static pruning, and single-dimensional dynamic pruning. Module / page-level pruning removes redundant code at the entire functional module level; static pruning determines the pruning strategy through offline analysis before application deployment and cannot be adjusted after deployment; single-dimensional dynamic pruning makes pruning decisions based on a single indicator such as network status or device load. While these existing methods achieve application lightweighting to some extent, they still suffer from excessively coarse pruning granularity when applied to resource-constrained and business-critical energy storage monitoring terminals. Existing technologies use "modules" or "pages" as the smallest operational unit, failing to identify fine-grained code snippets that implement single atomic functions, such as "voltage acquisition commands," "alarm push logic," and "data storage interfaces." When a module contains both redundant and core functional code, retaining the module results in redundant residue, while removing the module damages the core functionality. Due to the lack of ability to identify fine-grained units, existing technologies struggle to strike a balance between precise lightweighting and functional integrity. Furthermore, existing technologies lack sufficient understanding of inter-unit dependencies. Because fine-grained units and their calling relationships cannot be identified, pruning decisions struggle to predict whether removing a unit will cause functional failures due to dependencies. The pruning process is typically irreversible, and once functional anomalies occur, recovery is slow, increasing operational costs and system risks.
[0004] In summary, the core drawback of existing technologies lies in their coarse-grained pruning, making it difficult to achieve precise lightweight optimization on resource-constrained devices while ensuring the integrity of application functionality. Therefore, there is an urgent need for a micro-application pruning solution that can effectively remove redundant code, reduce resource consumption, and improve the accuracy of lightweight optimization while maintaining the integrity of core functions. Summary of the Invention
[0005] This application provides a micro-application pruning method, system, and medium, aiming to solve the technical problem that existing micro-application pruning technologies, due to their overly coarse pruning granularity, make it difficult to achieve precise and lightweight optimization on resource-constrained devices while ensuring the integrity of application functions. Firstly, this application provides a micro-application pruning method, including: Static analysis is performed on the source code of the micro-application to extract code segments that implement atomic functions as candidate units; dynamic analysis is performed on the candidate units to select the smallest functional units that can run independently, forming a set of smallest functional units. Obtain the operating parameters of each of the minimum functional units in multiple preset dimensions, and determine the importance score value of each of the minimum functional units based on the preset scoring model and the operating parameters. Based on the importance score, units to be pruned are selected from the set of minimum functional units, and dependency conflict detection is performed on the units to be pruned based on the unit dependency graph to generate the final set of units to be pruned; wherein, the unit dependency graph is constructed based on the calling relationship between each of the minimum functional units in the set of minimum functional units; Remove the code corresponding to the set of prunable units from the microapplication to generate an optimized microapplication.
[0006] This application combines static and dynamic analysis to decompose micro-applications into atomic-level minimum functional units, solving the coarse-grained problem caused by traditional methods that prune at the module level. This allows pruning operations to precisely locate independently removable code segments. By acquiring multi-dimensional runtime parameters and quantifying unit importance through a scoring model, pruning decisions can comprehensively balance resource efficiency and business value, ensuring that high-value core units are retained and low-value redundant units are removed. Furthermore, dependency conflict detection provides a global dependency view for pruning decisions, preventing functional failures caused by broken dependency chains due to unit removal. This achieves precise lightweight optimization while maintaining application functionality. Compared to existing coarse-grained pruning schemes, this application achieves precise lightweight optimization of micro-applications while ensuring application functionality and hardware execution efficiency.
[0007] Furthermore, the static analysis of the micro-application source code to extract code fragments implementing atomic functions as candidate units specifically includes: The source code of micro-applications is preprocessed to generate standardized source code; The standardized source code is parsed using an abstract syntax tree to obtain abstract syntax tree nodes; Code snippets that meet preset conditions are selected from the abstract syntax tree nodes as candidate units.
[0008] This application uses static analysis to precisely locate candidate units that implement atomic functions at the source code level, laying the foundation for subsequent fine-grained pruning. By parsing an abstract syntax tree to obtain syntactic structure nodes, code fragments that meet preset conditions (such as single atomic function, no functional dependencies or side effects, and independent execution) are selected as candidate units. This decomposes the micro-application into atomic-level code fragments, fundamentally solving the coarse-grained problem caused by traditional methods that prune at the module level. This allows subsequent runtime verification and pruning decisions to accurately target truly independent units, providing high-quality input for the entire pruning process.
[0009] Further, the step of selecting units to be pruned from the set of minimum functional units based on the importance score, and performing dependency conflict detection on the units to be pruned based on the unit dependency graph to generate the final set of pruneable units includes: From the set of minimum functional units, minimum functional units with importance scores below a preset threshold are selected as units to be pruned; all the units to be pruned constitute the set to be pruned. Based on the unit dependency graph, it is determined whether each unit to be pruned in the set to be pruned is dependent on by a core unit; wherein, the core unit is the smallest functional unit whose importance score is higher than the preset threshold. If the unit to be pruned is dependent on by a core unit, then the unit to be pruned is removed from the set to be pruned, or the dependency relationship of the core unit is optimized. Based on the adjusted set of branches to be pruned, determine the final set of units that can be pruned.
[0010] In this way, by setting preset thresholds to filter the smallest functional units, a clear quantitative standard is provided for pruning decisions. Units with importance scores below the threshold are identified as units to be pruned, ensuring that the pruning target accurately focuses on low-value redundant parts and avoids misjudging high-value core units. By relying on a conflict detection mechanism, the risk of functional failure is identified and avoided in advance during the pruning decision-making stage, fundamentally ensuring the functional integrity of the application after pruning, and upgrading the pruning operation from an uncontrollable risk attempt to predictable and precise control.
[0011] Furthermore, the step of obtaining the operating parameters of each of the minimum functional units in multiple preset dimensions, and determining the importance score value of each of the minimum functional units based on a preset scoring model and the operating parameters, specifically involves: The call frequency, resource consumption, fault impact, and business contribution of each of the minimum functional units are obtained as the operating parameters of the minimum functional units. The importance score of each minimum functional unit is obtained by multiplying its operating parameters by the corresponding weight coefficients and summing the results.
[0012] By comprehensively scoring multi-dimensional operating parameters, this application provides precise quantitative basis for pruning decisions, enabling pruning decisions to comprehensively balance resource efficiency and business value: call frequency reflects usage intensity, resource consumption identifies high-overhead units, fault impact assesses the scope of failure, and business contribution is linked to core business indicators. Compared to a crude evaluation relying solely on a single dimension, this application uses multi-dimensional quantitative modeling to accurately distinguish between "high-value core units" and "low-value redundant units," ensuring that pruning operations are precisely applied to low-value redundant units, achieving lightweighting while guaranteeing business continuity.
[0013] Furthermore, the dynamic analysis of the candidate units to select the smallest functional units that can operate independently, forming a set of smallest functional units, specifically involves: During the micro-application compilation phase, embedding code is injected into the candidate units; Based on the embedded code, track the call chain and functional side effects of the candidate unit during runtime; Based on the tracking results, units without functional side effects and meeting the independent execution conditions are selected from the candidate units and designated as the minimum functional unit. Based on each of the aforementioned minimum functional units, the set of minimum functional units is constituted.
[0014] This application uses runtime dynamic analysis to ensure that the selected smallest functional units truly meet the conditions for independent removal, thus overcoming the limitations of static analysis which can only judge based on code structure. It can identify and eliminate dynamic dependencies and hidden side effects missed in static analysis, fundamentally avoiding functional abnormalities after pruning due to misjudgment of unit independence, and providing a reliable operation object for subsequent precise pruning.
[0015] Furthermore, the step of removing the code corresponding to the set of prunable units from the micro-application to generate the optimized micro-application specifically involves: During the micro-application runtime, code segments corresponding to the set of pruning units are removed without restarting through dynamic linking and memory isolation technologies; metadata of the removed code segments is recorded; wherein, the metadata includes code content, dependencies and configuration parameters; The micro-application with the code snippets removed is compiled to generate an optimized micro-application.
[0016] This application achieves uninterrupted execution and traceability of the pruning process through a runtime-free removal mechanism, avoiding business interruptions caused by the need for downtime deployment in traditional pruning methods, and ensuring business continuity in scenarios with high real-time requirements such as energy storage monitoring. At the same time, metadata retention provides accurate evidence for subsequent reversible recovery, making the pruning operation recoverable and solving the operational risks caused by the irreversibility of traditional pruning methods.
[0017] Furthermore, after removing the code corresponding to the set of prunable units from the microapplication and generating the optimized microapplication, the process further includes: Collect and optimize hardware performance data and business metrics data for micro-applications; Calculate the performance improvement rate based on the hardware performance data, and calculate the business loss rate based on the business indicator data; When the performance improvement rate is lower than the first preset threshold or the business loss rate is higher than the second preset threshold, the weight coefficient of the scoring model is adjusted.
[0018] This application employs a closed-loop iterative optimization mechanism to enable pruning strategies to be continuously adjusted based on actual operational results. This allows pruning strategies to be dynamically optimized in response to changes in the operating environment, user behavior shifts, and business needs. This avoids the problem of resource optimization effectiveness declining and business loss risk increasing in the long term due to the inability of pruning strategies to adapt to dynamic changes.
[0019] Secondly, this application provides a micro-application pruning system, including: a unit identification module, a scoring module, a decision-making module, and a pruning execution module; The unit identification module is used to perform static analysis on the micro-application source code, extract code segments that implement atomic functions as candidate units, and perform dynamic analysis on the candidate units to select the smallest functional units that can run independently, forming a set of smallest functional units. The scoring module is used to obtain the operating parameters of each of the minimum functional units in multiple preset dimensions, and to determine the importance score value of each of the minimum functional units according to the preset scoring model and the operating parameters. The decision module is used to select units to be pruned from the set of minimum functional units based on the importance score, and to perform dependency conflict detection on the units to be pruned based on the unit dependency graph to generate the final set of units that can be pruned; wherein, the unit dependency graph is constructed based on the calling relationship between each of the minimum functional units in the set of minimum functional units; The pruning execution module is used to remove the code corresponding to the set of pruneable units from the microapplication and generate an optimized microapplication.
[0020] This application, through a modular system architecture design, achieves standardized processing and efficient collaboration across the entire micro-application pruning process, providing a complete engineering solution for achieving precise lightweighting while ensuring functional integrity on resource-constrained devices. Each module has clearly defined responsibilities and interfaces, and the data flow between modules is standardized and orderly, avoiding debugging and maintenance difficulties caused by functional coupling. This ensures the efficiency and stability of the data processing flow, improving the overall processing efficiency, system reliability, and engineering application feasibility of the pruning task.
[0021] Thirdly, this application provides a terminal device including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the micro-application pruning method provided in the first aspect above.
[0022] Fourthly, this application provides a computer-readable storage medium, comprising: a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to execute the micro-application pruning method provided in the first aspect. Attached Figure Description
[0023] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0024] Figure 1 This is a flowchart illustrating an embodiment of the micro-application pruning method provided in this application; Figure 2 This is a schematic diagram of the structure of one embodiment of the micro-application pruning system provided in this application.
[0025] Labeling Explanation: 100, Unit Identification Module; 200, Scoring Module; 300, Decision Module; 400, Pruning Execution Module. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0028] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0029] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0030] In the large-scale deployment and intelligent operation and maintenance of energy storage power stations, a large number of micro-applications are deployed on resource-constrained embedded monitoring terminals, which urgently need to achieve lightweight optimization while ensuring the integrity of core functions. Existing micro-application pruning technologies (including coarse pruning based on modules / pages, static pruning, and single-dimensional dynamic pruning) generally suffer from the core pain point of excessively coarse pruning granularity: using "modules" or "pages" as the smallest operating unit, they cannot identify fine-grained atomic functional codes such as "voltage acquisition commands" and "alarm push logic," resulting in redundant residues or accidental deletion of core functions; at the same time, due to the lack of understanding of the dependencies between fine-grained units, pruning decisions are difficult to predict the risk of functional failure, thus failing to balance functional integrity and precise lightweighting.
[0031] To address this, this application proposes a micro-application pruning method. Please refer to [link / reference]. Figure 1 , Figure 1 This is a flowchart of an embodiment of the micro-application pruning method provided in this application. To address the technical problem in the prior art where excessively coarse pruning granularity makes it difficult to balance functional integrity and precise lightweight design, an embodiment of this application provides a micro-application pruning method, including steps S1 to S5, each step as follows: Step S1: Perform static analysis on the micro-application source code and extract code snippets that implement atomic functions as candidate units; Step S2: Perform dynamic analysis on the candidate units, select the smallest functional units that can operate independently, and form a set of smallest functional units; Step S3: Obtain the operating parameters of each minimum functional unit in multiple preset dimensions, and determine the importance score value of each minimum functional unit based on the preset scoring model and each operating parameter. Step S4: Based on the importance score, select units to be pruned from the set of minimum functional units, and perform dependency conflict detection on the units to be pruned based on the unit dependency graph to generate the final set of units to be pruned; wherein, the unit dependency graph is constructed based on the calling relationship between each minimum functional unit in the set of minimum functional units. Step S5: Remove the code corresponding to the set of pruning units from the microapplication to generate the optimized microapplication.
[0032] The smallest functional unit refers to a code segment in the micro-application source code that can independently complete a single atomic function, such as "voltage acquisition instruction", "alarm push logic", "data storage interface", etc., which is the smallest unit of granularity for pruning operations.
[0033] The unit dependency graph describes the graph structure of the calling relationships between the smallest functional units, including the dependency pointers and dependency strengths between units, and is used to analyze the chain effects that may be caused by removing a unit.
[0034] Specifically, in some embodiments, in step S1, static analysis is performed on the micro-application source code to extract code segments that implement atomic functions as candidate units, specifically: The source code of micro-applications is preprocessed to generate standardized source code; The standardized source code is parsed using an abstract syntax tree to obtain abstract syntax tree nodes; The code snippets that meet the preset conditions are selected from the nodes of the abstract syntax tree as candidate units.
[0035] In this context, an abstract syntax tree (AST) node refers to the basic unit in the tree structure generated after the source code has been parsed using an abstract syntax tree. Each node corresponds to a syntactic structure in the source code, such as a function definition, variable declaration, statement block, or expression. By traversing these nodes, the structured information of the code can be accessed and understood.
[0036] Preprocessing refers to the formatting operations performed before the source code is formally parsed. These operations include removing comments, blank lines, and other distracting elements, standardizing code format, fixing syntax errors, and converting non-standard syntax into standard syntax nodes that can be recognized by the abstract syntax tree.
[0037] Preset conditions refer to the set of rules used to filter candidate units, which include at least: the code snippet implements only one atomic function, has no external side effect dependencies, can be executed independently, and the functional semantics can be clearly marked.
[0038] In one embodiment, taking the source code of a certain energy storage monitoring micro-application as an example, it includes functional modules such as battery voltage acquisition, local data storage, historical log cleaning, and alarm push notifications. First, the source code is preprocessed: all comments and blank lines are removed, indentation and code formatting are standardized, syntax errors (such as unclosed parentheses and undefined variables) are checked and corrected, and non-standard syntax is converted into standard syntax nodes recognizable by the abstract syntax tree parser. After preprocessing, a standardized source code file is generated as input for subsequent abstract syntax tree parsing.
[0039] The standardized source code is parsed using an abstract syntax tree (AST), which is broken down hierarchically into "file-function-statement block" levels to obtain AST nodes. Each node carries rich metadata, including node type, position range (start line, end line), and code content. After parsing the AST, corresponding function declaration nodes are generated, whose child nodes include variable declaration nodes, expression nodes, return statement nodes, etc.
[0040] Code snippets that meet preset conditions are selected as candidate units from the abstract syntax tree nodes. The preset conditions include: Rule 1: Code snippets should implement only one atomic function. For example, "reading ADC channel value", "converting ADC value to voltage", and "returning voltage value" are each atomic functions, but the entire function contains a combination of multiple atomic functions, which does not comply with this rule.
[0041] Rule 2: No external side-effect dependencies. Code snippets should not modify global variables, should not call functions not defined externally, and should not depend on external context state. For example, if a code snippet calls a global variable that is not defined locally, then the snippet has a side-effect dependency and does not comply with this rule.
[0042] Rule 3: Code snippets should be executable independently. Input parameters required by a code snippet should be passed through local variables or parameters, without relying on an external context.
[0043] Rule 4: Functional semantics should be clearly labeled. Code snippets should have clear business functional semantics, excluding code with no specific business function, such as "general utility functions" or "empty functions".
[0044] Each candidate unit also comes with detailed metadata, including code snippets, location ranges, functional semantics, input / output parameter definitions, and a list of dependent variables. This metadata serves as crucial input for subsequent runtime dynamic analysis, verifying the candidate unit's actual independence and pruning potential. Specifically, the code snippet is the original code text corresponding to the candidate unit, the specific object of subsequent pruning operations; the functional semantics is a natural language description of the function implemented by the code snippet, facilitating understanding of the unit's business value; the location range refers to the start and end lines of the code snippet in the source file, used for precise location and subsequent code removal operations. Input parameters are the external input values that the candidate unit needs to receive during execution; input parameters can be constants or variables; output parameters refer to the result values returned after the candidate unit completes execution; output parameters can be basic data types (such as integers, floating-point numbers, and booleans) or complex objects.
[0045] Specifically, in some embodiments, in step S4, units to be pruned are selected from the set of minimum functional units based on importance scores, and dependency conflict detection is performed on the units to be pruned based on the unit dependency graph to generate the final set of units to be pruned. This specifically includes steps S41 to S44, each step as follows: Step S41: Select the smallest functional units with importance scores lower than a preset threshold from the set of smallest functional units as units to be pruned; all units to be pruned constitute the set to be pruned. Step S42: Based on the unit dependency graph, determine whether each unit to be pruned in the set to be pruned is dependent on by the core unit; wherein, the core unit is the smallest functional unit whose importance score is higher than a preset threshold. Step S43: If the unit to be pruned is dependent on by the core unit, then remove the unit to be pruned from the set to be pruned, or optimize the dependency relationship of the core unit. Step S44: Determine the final set of pruning units based on the adjusted set of units to be pruned.
[0046] Among them, units to be pruned refer to the smallest functional units whose importance score is below a preset threshold and are initially determined to be removable. These units are candidate objects for pruning operations, but they must undergo dependency conflict detection before being finalized. Core units refer to the smallest functional units whose importance score is above a preset threshold. These units play a crucial role in the functional integrity or business value of the application and should be retained in the pruning decision, serving as the judgment criterion for dependency conflict detection.
[0047] Synchronous optimization refers to the process of removing the core unit's dependency on the unit to be pruned by refactoring the code and modifying the dependency relationship when a dependency conflict is detected, so that the unit to be pruned can be safely removed.
[0048] It should be noted that before performing step S4, complete decision input data needs to be constructed, including scene feature vectors, unit dependency graphs, and calibrated thresholds.
[0049] First, the multi-dimensional data acquisition module collects four types of data in real time to construct scene feature vectors. As input for pruning decisions: The first category is hardware characteristic data, which collects information such as the device's CPU architecture, instruction set support, memory bandwidth, cache level, and GPU acceleration capabilities to generate a hardware capability profile. ,in For hardware characteristics, each dimension has a value of 1 indicating support and 0 indicating no support.
[0050] The second category is runtime environment data, which collects network status (bandwidth, latency, jitter), device status (CPU utilization, memory usage, battery level), and user operation scenarios (foreground / background / floating screen) at millisecond-level frequency to generate an environment state vector. ,in For the environmental dimension.
[0051] The third category is user behavior data, which collects user operation sequences, page dwell time, and operation intervals. User behavior labels are obtained through K-means clustering, generating user behavior vectors. ,in This is a user behavior dimension.
[0052] The fourth category is business metric data, which collects business data such as conversion rate, retention rate, and conversion rate to construct a business metric vector. ,in For business metrics.
[0053] Profile hardware capabilities , environment state vector User behavior vectors Business indicator vector Fusion to generate scene feature vectors .
[0054] Secondly, constructing the unit dependency graph is a crucial step in avoiding "functional anomalies caused by pruning" before pruning. Based on the tracking code injected in the runtime dynamic analysis above, firstly, complete call chain data of the smallest functional unit across the entire scenario is collected to provide a data source for dependency analysis. Then, time-series analysis and correlation analysis are performed on the collected chain data; time-series analysis is used to reconstruct the order in which calls occur, and correlation analysis is used to identify implicit dependencies across links. Through the above analysis, direct and indirect dependencies between the smallest functional units are identified, and dependency strength (such as call frequency, call path length, etc.) is quantified. Finally, the quantified dependencies are transformed into a unit dependency graph, which in this embodiment is represented digitally using a dependency matrix D, where... Representation unit Dependent on unit , This indicates no dependency relationship. The matrix constructs MFU dependencies from two dimensions: "graphical dependency graph" and "digital dependency matrix". The core objective is to accurately identify "who depends, the strength of the dependency, and whether it is a core dependency" for rapid calculation and decision-making at the terminal.
[0055] In addition, before selecting units to be pruned, the software and hardware collaborative decision engine also calculates the hardware adaptability of each smallest functional unit based on the hardware capability profile H. The formula for calculating the fit is as follows: , in, As the smallest functional unit For the The compatibility coefficient for a hardware feature, with a value of 0 or 1. 1 indicates that the unit is compatible with the hardware feature, and 0 indicates that it is not compatible.
[0056] The preset thresholds T and A0 are determined through A / B testing calibration. Specifically, multiple candidate thresholds are selected in the test environment for pruning experiments. The performance improvement rate and business indicator loss rate of the application after pruning are statistically analyzed, and the optimal threshold combination that satisfies "performance improvement rate ≥ 30% and business indicator loss rate ≤ 5%" is selected.
[0057] After completing the above data preparation, in step S41, the minimum functional unit importance score value calculated in step S3 is used. The system then filters functional units based on a preset threshold T. The smallest functional units with importance scores below the preset threshold T are designated as units to be pruned, forming a pruning set P. Simultaneously, the smallest functional units with importance scores above the preset threshold T are defined as core units, forming a core set C.
[0058] In step S42, for each unit to be pruned in the set P to be pruned Based on the unit dependency graph D, determine whether it is depended upon by the core unit. The detection rule is as follows: If a core unit exists satisfy Then the unit to be pruned If a unit is depended upon by a core unit, a dependency conflict exists; otherwise, there is no dependency conflict. If the unit to be pruned is directly or indirectly depended upon by a core unit, removing it directly will cause the core unit that depends on it to malfunction due to the missing dependency.
[0059] In step S43, the set P to be pruned is adjusted based on the conflict detection results. For units to be pruned that have dependency conflicts, there are two processing methods: Direct retention: Remove the conflicting unit from the pruning set P and allow it to continue running in the application. This approach is suitable for scenarios where refactoring costs are high or the conflicting unit itself consumes very few resources.
[0060] Synchronous optimization: Analyze the specific implementation of dependencies and remove the core unit's dependency on conflicting units through code refactoring. For example, inline the functional code of the conflicting unit into the core unit, or change the original direct call to pass the required data through parameter passing, thereby removing the code-level dependency of the core unit on the conflicting unit. Re-matrix the dependency matrix after optimization. This makes conflicting units safe to remove, and they can then be retained in the set to be pruned.
[0061] In the conflict resolution process, hardware compatibility can also be considered for a comprehensive judgment. For units with excessively low hardware compatibility (i.e., Even without dependency conflicts, the decision to retain a value can be made based on the actual situation. (Preset threshold) With threshold Simultaneous optimization ensures that the pruning strategy strikes a balance between performance improvement and business assurance.
[0062] For units to be pruned that have no dependencies or conflicts, they are directly retained in the pruning set without special processing. After the above adjustments, a new pruning set is obtained. .
[0063] In step S44, the adjusted set of branches to be pruned is... Determined as the final set of pruning units . Each unit in the dataset meets the following condition: its importance score is below a preset threshold. ( ); No core unit dependencies (i.e. All have At this point, the final set of pruning units is generated. The units in this set are all low-value redundant units that can be safely removed, and their removal will not affect the functionality of any core unit.
[0064] Specifically, in some embodiments, in step S3, the operating parameters of each minimum functional unit in multiple preset dimensions are obtained, and the importance score value of each minimum functional unit is determined according to the preset scoring model and each operating parameter, specifically as follows: Obtain the call frequency, resource consumption, fault impact, and business contribution of each minimum functional unit as the operating parameters of the minimum functional unit; The importance score of each minimum functional unit is obtained by multiplying the operating parameters of each minimum functional unit by their corresponding weight coefficients and then summing them.
[0065] In its implementation, the scoring model quantifies the contribution of each minimum functional unit to the functional completeness and business value, providing a quantitative basis for subsequent pruning decisions. First, it is necessary to obtain the operational parameters of each minimum functional unit across four key dimensions. These parameters reflect the unit's value and impact from different perspectives: The first dimension is the frequency of use. This parameter is based on the data collected during runtime in step S2, which counts the number of times each smallest functional unit is called within a preset period, and maps it to a normalized value. The higher the call frequency, the more active and frequently used the unit is in the application. For example, a voltage acquisition unit might be called once per second in an energy storage monitoring application, while a log cleanup unit might only be called once per hour.
[0066] The second dimension is the resource consumption coefficient. This parameter comprehensively evaluates the resource consumption of the smallest functional unit during operation, including sub-dimensions such as memory usage, CPU usage, and network traffic. A resource consumption coefficient is obtained through weighted calculation, and it is also mapped to... The range. The higher the resource consumption coefficient, the greater the resource consumption of the unit.
[0067] The third dimension is the impact of the failure. This parameter is analyzed based on the unit dependency graph constructed in step S3 to assess the scope of impact of removing the unit on the functionality of other units. The larger the scope of impact, the higher the failure impact. For example, the failure impact of a basic utility function that is depended on by multiple core units is close to 1; while the failure impact of a completely independent log cleaning unit is close to 0.
[0068] The fourth dimension is business contribution. This parameter is calculated using a business metric mapping model and reflects the contribution of the smallest functional unit to core business objectives. Business contribution is also mapped to... In the range, the contribution of core business modules (such as marketing push and data reporting) is close to 1, while the contribution of peripheral functional modules is relatively low.
[0069] After obtaining the operating parameters for the above four dimensions, an importance score for each minimum functional unit is calculated using a weighted summation method. The calculation formula is as follows: , in, For the weighting coefficients, satisfying The weighting coefficients can be dynamically adjusted according to the application scenario to adapt to different optimization objectives. For example, in resource-constrained edge computing scenarios, the weighting coefficient corresponding to the resource consumption value can be appropriately increased. In business-critical applications, the weighting coefficient corresponding to the business contribution can be increased. In scenarios with high functional safety requirements, the weighting coefficient corresponding to the impact of failures can be increased. The adjustment of weight coefficients can be automatically completed through the effect evaluation and iterative optimization module in step S5. When the performance improvement rate or business loss rate after pruning does not reach the expected indicators, the system will automatically adjust the weight coefficients and re-execute the pruning decision.
[0070] Specifically, in some embodiments, in step S2, the candidate units are dynamically analyzed to select the smallest functional units that can operate independently, forming a set of smallest functional units, specifically: During the micro-application compilation phase, inject tracking code into candidate units; Based on the embedded code, trace the call chain and functional side effects of the candidate unit at runtime; Based on the tracking results, units without functional side effects and meeting the independent execution conditions are selected from the candidate units and used as the smallest functional units. Based on each minimum functional unit, a set of minimum functional units is formed.
[0071] Among them, the instrumentation code refers to the lightweight monitoring code injected into the candidate unit during the compilation stage. It is used to record the unit's call status, execution path, and possible side effects at runtime without modifying the original business logic.
[0072] The call chain refers to the complete path in which a candidate unit is invoked at runtime, including information such as the caller, the callee, the call order, and the call frequency, which is used to analyze the dependencies between units.
[0073] Functional side effects refer to the observable impacts that candidate units have on the external environment during execution, including but not limited to modifying global variables, writing to files, sending network requests, and calling uncontrollable external interfaces. Units with side effects typically do not have the conditions for independent pruning.
[0074] Independent execution condition refers to the ability of a candidate unit to execute independently without its original context and to behave as expected. Specific requirements include: no errors, no logical exceptions, and return values that meet expectations.
[0075] In practice, during the micro-application compilation phase, a non-intrusive instrumentation technique is employed to inject lightweight tracking code into candidate units selected through static analysis. "Non-intrusive" means that monitoring logic is implanted through compile-time bytecode manipulation or source code enhancement without modifying the original code logic of the candidate units.
[0076] Throughout the full-scenario operation of the micro-application, the calling behavior of candidate units is continuously tracked through embedded code. The tracking scope covers all possible runtime scenarios, including but not limited to: scheduled task scenarios; event-triggered scenarios; user operation scenarios; network communication scenarios; and exception scenarios. Simultaneously, the tracking system also detects functional side effects generated during the execution of candidate units; this side effect information is recorded and used for subsequent independence verification. Based on the runtime tracking results, units that simultaneously meet the following conditions are selected from the candidate units as the final minimum functional unit: No functional side effects: During execution, the candidate unit does not modify global variables, does not call external uncontrollable interfaces, and does not have any unexpected impact on the system state; Controllable dependencies: The number of direct dependent units of a candidate unit does not exceed one, and the dependent units belong to predefined core basic units (such as constant definitions and general utility functions), ensuring that the dependency relationship is simple and manageable; Independently executable: The candidate unit can be executed independently without its original context, without errors or logical exceptions during execution, and the return value is as expected.
[0077] The above screening criteria ensure that each unit entering the minimum functional unit set is feasible to be removed independently, laying the foundation for subsequent dependency analysis and precise pruning.
[0078] Specifically, in some embodiments, in step S5, the code corresponding to the set of prunable units is removed from the microapplication to generate an optimized microapplication, specifically as follows: During the micro-application runtime, code snippets corresponding to the set of pruning units are removed without restarting through dynamic linking and memory isolation technologies; the metadata of the removed code snippets is recorded, including code content, dependencies, and configuration parameters; The micro-application with the code snippets removed is compiled to generate an optimized micro-application.
[0079] Dynamic linking technology refers to compiling the code modules of a micro-application into dynamic link libraries (such as shared object .so files in Linux or DLLs in Windows), so that each functional unit is loaded and linked at runtime. This technology allows for the dynamic unloading of unnecessary code modules at runtime without affecting the normal operation of other loaded modules.
[0080] Memory isolation technology ensures that the memory space occupied by removed code modules can be safely reclaimed, while avoiding memory access conflicts caused by module unloading. In specific implementations, process-level isolation or memory partitioning techniques can be used to place the code and data of different functional units in independent virtual memory areas. When a unit is removed, the operating system can reclaim its corresponding memory pages and update the memory mapping table to ensure that other units cannot access the freed memory area.
[0081] In practice, the process of removing the code corresponding to the set of pruning units from a microapplication and generating an optimized microapplication can adopt a "hot-pluggable pruning" mechanism. Through dynamic linking technology and memory isolation technology, the code fragments corresponding to the set of pruning units R can be removed without restarting.
[0082] When removing a code snippet, the system automatically records the metadata of the removed code snippet. This metadata forms the basis for subsequent reversible recovery and includes at least the following: Code content: The complete source code or intermediate code (such as bytecode) of the removed unit, used to rebuild the unit if recovery is required.
[0083] Dependencies: Information on the dependencies between the removed unit and other units, including which units it depends on (callers) and which units it depends on (callees). This information is obtained from the unit dependency graph to ensure that dependency connections can be correctly rebuilt during recovery.
[0084] Configuration parameters: Configuration parameters that the removed unit depends on during runtime, such as initialization parameters, environment variables, threshold settings, etc., to ensure that the restored unit can run in its original state.
[0085] Metadata can be stored on local storage (such as a flash partition on an embedded device) or a cloud server, depending on the specific application scenario. For resource-constrained edge devices, lightweight local storage is usually the preferred choice; for scenarios requiring centralized management, it can be uploaded to the cloud for unified backup, and a structured format can be used for storage to facilitate subsequent parsing.
[0086] In this specific embodiment, taking an energy storage monitoring micro-application as an example, it is assumed that the final set of pruningable units R = { This refers to the historical log cleanup unit, which is built as a separate dynamic link library module at compile time. At runtime, when a pruning decision is triggered, the system calls the dynamic link library's unload interface to remove the logs. The corresponding code module is unloaded from the process address space, and its occupied memory resources are reclaimed through a memory isolation mechanism. Throughout this process, other functional units of the micro-application (such as voltage acquisition and alarm push notifications) continue to operate normally, without the user's awareness. When removed... During (historical log cleanup), the system records its code content (including file operation logic) and dependencies. It does not depend on any unit, nor do any other units depend on it, and it has configuration parameters (such as the log retention period of 7 days). This metadata is encapsulated as a JSON object and stored in a local flash memory reservation partition.
[0087] After removing code snippets, the modified micro-application needs to be recompiled to generate an optimized executable version. The compilation process can employ either a full compilation or an incremental compilation: Full compilation recompiles all removed source code to generate a complete micro-application image, suitable for scenarios with large-scale pruning or high code integrity requirements. Incremental compilation only recompiles the modified parts (i.e., the modules affected by the removal of related code) and then links them with the unmodified parts to generate the final application. This method is faster and suitable for scenarios requiring rapid response.
[0088] The optimized micro-application generated after compilation can be an executable file, an installation package, or a runtime image, depending on the target platform and deployment method. In energy storage monitoring terminals, an executable file or container image under embedded Linux is typically generated, and the original application is replaced through a hot upgrade mechanism.
[0089] Optionally, in some embodiments, the above pruning steps can be performed in conjunction with model quantization and knowledge distillation to further achieve deep optimization of the micro-application. Specifically, for micro-applications containing artificial intelligence modules, after removing the code corresponding to the set of pruneable units, the artificial intelligence modules are further quantized. The quantization process converts the original 32-bit floating-point parameters into low-width integer parameters, and the conversion formula is as follows: , in, As the smallest functional unit The original parameters, The scaling factor is determined based on the range of parameter distribution. Zero point These are the quantized parameters. Quantization significantly reduces model size and improves computational efficiency, making it particularly suitable for resource-constrained embedded devices.
[0090] Preferably, knowledge distillation technology can be used to transfer knowledge from the original complex model to a simplified, lightweight model. In specific implementation, the original, complete minimum functional unit is used as the teacher model, and the simplified unit after pruning and quantization is used as the student model. The output results of the teacher and student models are compared for consistency using preset test cases. Distillation is considered complete when the output difference is less than a preset threshold and the resource consumption of the student model meets the expected requirements. Furthermore, logical verification ensures that the student model strictly adheres to the original business rules. If the consistency verification fails, a "knowledge completion" operation is performed to restore the simplified model parameters, ensuring the functional integrity of the final model.
[0091] The aforementioned pruning-quantification-distillation collaborative execution process can achieve deep slimming and performance optimization of micro-applications without affecting functional integrity, further improving the operating efficiency of micro-applications on resource-constrained devices.
[0092] Optionally, in some embodiments, after generating the optimized micro-application, reversible recovery and cross-platform adaptation steps may be included to further improve the reliability and applicability of the system.
[0093] Specifically, the system continuously monitors the operational status of optimized micro-applications, focusing on collecting application crash rates and lag rates. When a crash rate or lag rate exceeds a preset threshold, the system automatically restores removed code snippets based on stored metadata. The restoration process reloads the corresponding code modules using dynamic linking technology, rebuilds connections based on dependencies in the metadata, and restores original configuration parameters, achieving one-click rapid recovery. Furthermore, the system also supports manual triggering of the recovery process by operations and maintenance personnel to handle unexpected anomalies.
[0094] Meanwhile, to address the differences in Application Programming Interfaces (APIs) across different host platforms (such as WeChat Mini Programs, Alipay Mini Programs, and standalone Apps), the system automatically generates adaptation layer code. This adaptation layer encapsulates platform-specific API calls, providing a unified interface for upper-layer business logic. Integrating this adaptation layer code into the optimized micro-application allows the same set of business code to run compatiblely on multiple host platforms, significantly reducing the development and maintenance costs of multi-platform deployment. Through the aforementioned reversible recovery and cross-platform adaptation mechanism, the micro-application is provided with complete fault tolerance and self-healing capabilities after pruning, further enhancing the system's reliability and engineering application value.
[0095] Specifically, in some embodiments, after removing the code corresponding to the set of prunable units from the microapplication in step S5 and generating the optimized microapplication, the process further includes: Collect and optimize hardware performance data and business metrics data for micro-applications; Calculate the performance improvement rate based on hardware performance data, and calculate the business loss rate based on business indicator data. When the performance improvement rate is lower than the first preset threshold or the business loss rate is higher than the second preset threshold, the weight coefficients of the scoring model are adjusted.
[0096] Specifically, in one embodiment, to further improve the adaptability and long-term effectiveness of the pruning strategy, the effect evaluation and iteration module evaluates the pruning effect from multiple dimensions, and dynamically adjusts the weight coefficients of the scoring model and the pruning threshold according to the evaluation results to form a closed-loop optimization.
[0097] In this embodiment, two types of data are collected during the operation of the optimized micro-application: Hardware performance data: Low-level hardware metrics such as cache hit rate and instruction execution cycle are collected through hardware performance counters to evaluate the impact of pruning on hardware execution efficiency.
[0098] Business metrics data: Compare key business metrics before and after pruning, such as conversion rate, retention rate, and alarm success rate, to assess the impact of pruning on core business value.
[0099] Based on the collected data, three quantitative indicators were calculated: Performance improvement rate This reflects the degree to which pruning improves hardware execution efficiency; the calculation formula is as follows: , The execution cycle before and after pruning can be obtained by collecting the number of instruction cycles from the hardware performance counter. The larger the value, the more significant the improvement in hardware execution efficiency.
[0100] Business loss rate : Reflects the degree of negative impact of pruning on core business indicators; the calculation formula is: , For energy storage monitoring scenarios, "alarm success rate" and "data reporting success rate" can be used as business metrics. The smaller the value, the less impact pruning has on the business.
[0101] The preset first threshold (performance improvement rate threshold) is: The second threshold (business loss rate threshold) is .when or When this occurs, it indicates that the current pruning strategy has not achieved the expected results and needs to be optimized and adjusted.
[0102] When optimization conditions are triggered, the system dynamically adjusts the weight coefficients and pruning thresholds of the scoring model. The initial weights of the scoring model can be set to... The initial pruning threshold can be set to Adjustment strategies can be designed according to actual needs, for example: If the performance improvement rate is insufficient ( This indicates that the current pruning is too conservative, and the resource consumption weight can be appropriately reduced. And lower the threshold To increase pruning intensity. If the business loss rate exceeds the standard ( This indicates that the current pruning has inadvertently harmed core business operations, and the weighting of business contribution can be increased. And increase the threshold This is to enhance the protection of the core unit.
[0103] The adjustment method can be a preset step value (such as adjusting each time). Alternatively, optimization algorithms such as gradient descent can be used for automatic optimization. The adjusted weights and thresholds will be used for the next round of pruning decisions. After adjustment, the system re-executes steps S3 and S4 to generate a new set of pruningable units and perform pruning, followed by another evaluation of the results. This process is repeated iteratively until... and Alternatively, the maximum number of iterations can be reached to obtain the optimal pruning strategy that meets both performance and business requirements.
[0104] It should be noted that the above basic embodiment only uses hardware performance data and business indicator data as evaluation criteria. In other optional embodiments, application runtime data (such as startup time, memory usage, lag rate, etc.) can be further collected, and resource saving rate can be calculated. The resource saving rate reflects the degree to which pruning reduces the resource consumption of the application. The calculation formula is: , Memory usage can be measured as the average value during stable operation, or other resource metrics such as CPU usage and network traffic can be considered depending on the specific scenario. The larger the value, the better the resource saving effect. Based on this, P can be... As an additional evaluation metric, for example, adding a third threshold. ,when The same optimization adjustment is triggered at the same time, or according to P. The value of β helps adjust the resource consumption weight. These additional features can be selectively enabled depending on the specific application scenario (such as edge devices that are extremely sensitive to memory).
[0105] Please refer to Figure 2 , Figure 2This is a schematic diagram of the structure of a micro-application pruning system in some embodiments of this application. The system includes: a unit identification module 100, a scoring module 200, a decision module 300, and a pruning execution module 400. The unit identification module 100 is used to perform static analysis on the micro-application source code, extract code segments that implement atomic functions as candidate units, and perform dynamic analysis on the candidate units to select the smallest functional units that can run independently, forming a set of smallest functional units. The scoring module 200 is used to obtain the operating parameters of each minimum functional unit in multiple preset dimensions, and to determine the importance score value of each minimum functional unit based on the preset scoring model and each operating parameter. The decision module 300 is used to select units to be pruned from the set of minimum functional units based on importance scores, and to perform dependency conflict detection on the units to be pruned based on the unit dependency graph to generate the final set of units that can be pruned; wherein, the unit dependency graph is constructed based on the calling relationships between the minimum functional units in the set of minimum functional units; The pruning execution module 400 is used to remove the code corresponding to the set of pruneable units from the microapplication and generate an optimized microapplication.
[0106] It is understood that the above system embodiments correspond to the method embodiments of this application, and can implement the micro-application pruning method provided by any of the above method embodiments of this application.
[0107] It should be noted that the system embodiments described above are merely illustrative, and some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the system embodiments provided in this application, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0108] For ease of description and brevity, the system implementation embodiments of this application include all the implementation methods described in the above micro-application pruning method embodiments, and will not be repeated here.
[0109] Based on the above embodiments of the micro-application pruning method, another embodiment of this application provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the micro-application pruning method provided in any of the above-described method embodiments of this application.
[0110] For example, in this embodiment, the computer program can be divided into one or more modules, which are stored in the memory and executed by the processor to complete this application. The one or more module units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the terminal device.
[0111] Based on the above-described method embodiments, another embodiment of this application provides a computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to execute the micro-application pruning method provided in any of the above-described method embodiments of this application.
[0112] The above description is the preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications are also considered to be within the scope of protection of this application.
Claims
1. A micro-application pruning method, characterized in that, include: Static analysis is performed on the source code of the micro-application to extract code snippets that implement atomic functions as candidate units; The candidate units are dynamically analyzed to select the smallest functional units that can operate independently, thus forming a set of smallest functional units; Obtain the operating parameters of each of the minimum functional units in multiple preset dimensions, and determine the importance score value of each of the minimum functional units based on the preset scoring model and the operating parameters. Based on the importance score, units to be pruned are selected from the set of minimum functional units, and dependency conflict detection is performed on the units to be pruned based on the unit dependency graph to generate the final set of units to be pruned; wherein, the unit dependency graph is constructed based on the calling relationship between each of the minimum functional units in the set of minimum functional units; Remove the code corresponding to the set of prunable units from the microapplication to generate an optimized microapplication.
2. The micro-application pruning method according to claim 1, characterized in that, The static analysis of the micro-application source code, extracting code snippets that implement atomic functions as candidate units, specifically involves: The source code of micro-applications is preprocessed to generate standardized source code; The standardized source code is parsed using an abstract syntax tree to obtain abstract syntax tree nodes; Code snippets that meet preset conditions are selected from the abstract syntax tree nodes as candidate units.
3. The micro-application pruning method according to claim 1, characterized in that, The process of selecting units to be pruned from the set of minimum functional units based on the importance score, and performing dependency conflict detection on the units to be pruned based on the unit dependency graph to generate the final set of pruneable units includes: From the set of minimum functional units, minimum functional units with importance scores below a preset threshold are selected as units to be pruned; all the units to be pruned constitute the set to be pruned. Based on the unit dependency graph, it is determined whether each unit to be pruned in the set to be pruned is dependent on by a core unit; wherein, the core unit is the smallest functional unit whose importance score is higher than the preset threshold. If the unit to be pruned is dependent on by a core unit, then the unit to be pruned is removed from the set to be pruned, or the dependency relationship of the core unit is optimized. Based on the adjusted set of branches to be pruned, determine the final set of units that can be pruned.
4. The micro-application pruning method according to claim 1, characterized in that, The process involves obtaining the operating parameters of each of the minimum functional units across multiple preset dimensions, and determining the importance score of each minimum functional unit based on a preset scoring model and the operating parameters. Specifically: The call frequency, resource consumption, fault impact, and business contribution of each of the minimum functional units are obtained as the operating parameters of the minimum functional units. The importance score of each minimum functional unit is obtained by multiplying its operating parameters by the corresponding weight coefficients and summing the results.
5. The micro-application pruning method according to claim 1, characterized in that, The process of dynamically analyzing the candidate units to select the smallest functional units that can operate independently, forming a set of smallest functional units, specifically involves: During the micro-application compilation phase, embedding code is injected into the candidate units; Based on the embedded code, track the call chain and functional side effects of the candidate unit during runtime; Based on the tracking results, units without functional side effects and meeting the independent execution conditions are selected from the candidate units and designated as the minimum functional unit. Based on each of the aforementioned minimum functional units, the set of minimum functional units is constituted.
6. The micro-application pruning method according to claim 1, characterized in that, The step of removing the code corresponding to the set of prunable units from the microapplication to generate the optimized microapplication specifically involves: During the micro-application runtime, code segments corresponding to the set of pruning units are removed without restarting through dynamic linking and memory isolation technologies; metadata of the removed code segments is recorded; wherein, the metadata includes code content, dependencies and configuration parameters; The micro-application with the code snippets removed is compiled to generate an optimized micro-application.
7. The micro-application pruning method according to claim 1, characterized in that, After removing the code corresponding to the set of prunable units from the microapplication and generating the optimized microapplication, the process further includes: Collect and optimize hardware performance data and business metrics data for micro-applications; Calculate the performance improvement rate based on the hardware performance data, and calculate the business loss rate based on the business indicator data; When the performance improvement rate is lower than the first preset threshold or the business loss rate is higher than the second preset threshold, the weight coefficient of the scoring model is adjusted.
8. A micro-application pruning system, characterized in that, include: Unit identification module, scoring module, decision-making module, and pruning execution module; The unit identification module is used to perform static analysis on the micro-application source code, extract code segments that implement atomic functions as candidate units, and perform dynamic analysis on the candidate units to select the smallest functional units that can run independently, forming a set of smallest functional units. The scoring module is used to obtain the operating parameters of each of the minimum functional units in multiple preset dimensions, and to determine the importance score value of each of the minimum functional units according to the preset scoring model and the operating parameters. The decision module is used to select units to be pruned from the set of minimum functional units based on the importance score, and to perform dependency conflict detection on the units to be pruned based on the unit dependency graph to generate the final set of units that can be pruned; wherein, the unit dependency graph is constructed based on the calling relationship between each of the minimum functional units in the set of minimum functional units; The pruning execution module is used to remove the code corresponding to the set of pruneable units from the microapplication and generate an optimized microapplication.
9. A terminal device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, it implements the microapplication pruning method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, include: A stored computer program, wherein, when the computer program is executed, it controls the device containing the computer-readable storage medium to perform the microapplication pruning method as described in any one of claims 1-7.