A Microservice Concern Overload Odor Refactoring Method Based on Genetic Algorithm

By combining topic modeling and genetic algorithms, we can identify concern overload in microservice systems and generate high-quality refactoring solutions. This solves the problems of functional ambiguity and high operation and maintenance costs caused by concern overload in microservice architecture, and improves the modularity quality and refactoring efficiency of the system.

CN115469880BActive Publication Date: 2026-07-03NANJING UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NANJING UNIV
Filing Date
2022-09-24
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In microservice-based software systems, concern overload leads to unclear service function responsibilities, high system deployment and maintenance costs, and a lack of effective automated refactoring methods to eliminate concern overload odors at the architectural level.

Method used

Topic modeling and mining techniques are used to detect overload of concerns. Combined with genetic algorithms to search for reconstruction schemes, overloaded services are identified by generating code file dependency matrices and topic models. Multi-objective genetic algorithms are used to optimize the set of reconstruction units and generate high-quality reconstruction schemes.

Benefits of technology

Automated identification of concerns overload improves the efficiency of microservice system refactoring and optimization, reduces system maintenance costs, and enhances the modular quality and functional architecture design of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115469880B_ABST
    Figure CN115469880B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of software automated refactoring technology, specifically involving a method and system for detecting concern overload odors using topic modeling and mining, and for searching refactoring solutions using genetic algorithms. The method includes: parsing and preprocessing the source code of a microservice system to obtain a code dependency matrix for quality assessment; using topic modeling techniques to mine concerns in the system and detect concern overload odors, while converting overloaded services into a set of refactoring units; and using a multi-objective genetic algorithm to search a list of refactoring solutions and using Euclidean distance to select the optimal refactoring solution. This invention discovers microservices with concern overload odors by mining semantic topics in the software system and provides a modular decomposition and refactoring method for overloaded services, thereby helping architects quickly discover and refactor concern overload odors within the system, improving the efficiency of software maintenance and evolution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of software automated refactoring technology, specifically involving a method and system for detecting odors caused by interest overload using topic modeling and mining, and for searching refactoring schemes using genetic algorithms. Background Technology

[0002] In microservice-based software systems, inappropriate modular design of architectural components can easily lead to an unreasonable distribution of concerns among services, resulting in an architectural smell known as concern overload. This smell indicates that services implement too many functional concerns, and the granularity of service division within the system is insufficient. This can make the functional responsibilities of services bloated and ambiguous, while increasing deployment and maintenance costs and reducing overall system availability.

[0003] When researching the elimination of large-granularity related odors in software, researchers typically design methods to decompose system components and eliminate these odors through automated refactoring. Software odors can be categorized into three levels based on granularity: code, design, and architecture. Overload of concern, as a large-granularity odor at the architectural level, can be eliminated by decomposing the overloaded services. To apply odor elimination methods to software systems, researchers commonly employ automated refactoring techniques. Compared to traditional manual refactoring by developers, automated refactoring techniques can modify the internal structure of the system more efficiently and at a lower cost, while preserving the system's external behavioral characteristics, thus improving system quality.

[0004] However, current research on automated refactoring for smells focuses more on code-level smells. Research on architecture-level smell refactoring is still in the exploratory stage due to the lack of universal architecture definition standards, smell detection methods, and the implementation of architecture refactoring operations. Therefore, there is a lack of an effective refactoring method for smells that overload concerns. Summary of the Invention

[0005] The purpose of this invention is to provide a method and system for detecting concern overload odors using topic modeling and mining, and for searching refactoring solutions using genetic algorithms, addressing existing research on automated refactoring for architectural odors. This helps developers and architects quickly identify concern overload odors within microservice systems, obtain refactoring solution references, and improve the efficiency of software maintenance and evolution.

[0006] To achieve the above objectives, the technical solution of the present invention is: to provide a method for detecting odors due to overload of interest by utilizing topic modeling and mining, and for searching for reconstruction schemes using a genetic algorithm, comprising the following steps:

[0007] S1: Extract the code file dependency matrix of the microservice system to evaluate the cohesion of the topic, the cluster similarity of the refactoring units, and the structural modularity quality of the refactoring scheme;

[0008] S2: Perform topic modeling on the microservice system, mine the concern information under each service, and detect services with overloaded concerns based on concern thresholds;

[0009] S3: Convert services with overloaded concerns into a set of refactoring units according to a certain granularity, and describe the process of refactoring them as a modular decomposition process of the set of refactoring units;

[0010] S4: Use a multi-objective genetic algorithm to search for a list of high-quality reconstruction schemes and select the optimal scheme based on the Euclidean distance of the optimization objective.

[0011] Preferably, the specific steps for extracting the code file dependency matrix of a microservice system include:

[0012] S1-1: Set a file filter to limit the scope of code files and exclude interference from other types of files such as configuration files, test files, and data files;

[0013] S1-2: Recursively read the list of all source code files of the target microservice system based on the file filter;

[0014] S1-3: Define the target dependency types to be extracted, including but not limited to: method calls, package imports, subclass inheritance, interface implementations, property calls, as parameters, as return values, type conversions, aggregate inclusion, and instantiation;

[0015] S1-4: Use the Antlr syntax processing tool to read the specified dependencies of all code files;

[0016] S1-5: Generate a 0-1 dependency matrix based on the dependencies of the code files, which is used to calculate the topic cohesion;

[0017] S1-6: Generate a weighted dependency matrix based on the dependencies of the code files, which is used to calculate the structural modularity quality index.

[0018] Preferably, the specific steps for performing topic modeling and detecting concern overload odors in a microservice system include:

[0019] S2-1: Based on the list of code files obtained by the file filter, read the text content of all code files;

[0020] S2-2: Perform the following operations on the text content of the code file in sequence: word segmentation, camelCase splitting, lowercase conversion, removal of stop words, removal of extraneous words, importance filtering, and stemming, to obtain the semantic vocabulary corresponding to each code file.

[0021] S2--3: Set initial parameters and use the LDA algorithm to perform topic modeling on the vocabulary of all code files in the microservice system;

[0022] S2--4: Based on the perplexity feedback of the topic model, continuously adjust the LDA parameters to the ideal parameter combination;

[0023] S2--5: Calculate the association probability between each topic word and each service, and filter out the set of services that are highly related to the topic based on the association probability threshold between topic words and files, the association probability threshold between topic words and services, and the cohesion threshold of the topic itself.

[0024] S2--6: From the set of services highly related to each keyword, deduce the keywords highly related to each service, as the focus information for each service;

[0025] S2--7: Based on the attention threshold parameter, services with more than the threshold number of attention points are considered as attention overloaded services, i.e., the appearance of attention overload odor.

[0026] Preferably, the specific steps for converting services with overloaded concerns into a set of refactoring units include:

[0027] S3-1: Use a file filter to read all code files under the overload service;

[0028] S3-2: Based on the specified refactoring unit granularity settings, the weighted dependency matrix of the code files is used to calculate similarity, and the k-centroid clustering algorithm is applied to generate a set of refactoring units under the overloaded service.

[0029] Preferably, the specific steps for using a genetic algorithm to obtain a reconstruction scheme include:

[0030] S4--1: Encode the individuals of the genetic algorithm into a tag array of the overload service corresponding reconstruction unit set;

[0031] S4--2: Set the parameters of the genetic algorithm, including but not limited to: maximum number of generations, maximum population size, crossover probability, mutation probability, and maximum number of different genotypes.

[0032] S4--3: Set the fitness objectives of the genetic algorithm, including: structural modularity quality, semantic modularity quality, and reconstruction cost;

[0033] S4--4: The NSGA-II algorithm is applied to complete the multi-objective search. The first frontier solution set obtained is filtered by the overload detection of the focus and then output as a list of reconstruction schemes.

[0034] S4--5: Select the optimal reconstruction scheme based on the Euclidean distance of the three fitness optimization objectives.

[0035] To complete the search for high-quality reconstruction schemes, this invention designs a multi-objective genetic algorithm for modular search and applies it to search for reconstruction schemes that maximize structural modularity quality, maximize semantic modularity quality, and minimize reconstruction scheme cost.

[0036] Preferably, the length of the label array encoding the individuals in the genetic algorithm is equal to the number of reconstruction units. Each label in the label array corresponds to a different reconstruction unit under the overloaded service, and the value of each label represents the service ID to which the corresponding reconstruction unit belongs in the modular scheme. Therefore, the value of each label in the original overloaded service's label array is the ID of the overloaded service. By using the label array to map different modular results of reconstruction units, this invention transforms the reconstruction of the overloaded service of concern into a process of modular decomposition of its reconstruction unit set, that is, decomposing the overloaded service into multiple sub-services of concern that are not overloaded.

[0037] Preferably, the genetic algorithm uses three optimization objectives: structural modularity quality, semantic modularity quality, and reconstruction cost. The formula for calculating structural modularity quality is as follows:

[0038]

[0039] Where N represents the number of services, scoh i Scop represents the structural cohesion value of service i. i,j This represents the coupling value between services i and j. The formula for calculating cohesion within a service and coupling between services is as follows:

[0040]

[0041]

[0042] Where, μ i σ represents the number of dependencies between code files within service i. i,j This represents the number of dependencies between the code files of services i and j. i N j These represent the number of code files for services i and j, respectively.

[0043] This metric measures the structural cohesion and structural coupling of overloaded service decomposition by calculating the tightness of dependencies between sub-services and their counterparts, driving the genetic algorithm to search for service decomposition schemes with high cohesion and low coupling.

[0044] The formula for calculating the quality of semantic modularity is as follows:

[0045]

[0046] Where N represents the number of services, sim i sim represents the semantic similarity between code files under service i. i,j This represents the semantic similarity between the code files of services i and j. The semantic similarity is calculated using cosine similarity based on TF-IDF vectors, as shown in the following formula:

[0047]

[0048]

[0049] This metric calculates the similarity of code files inside and outside a sub-service from a semantic perspective, measuring semantic cohesion and semantic coupling. Higher semantic cohesion means cohesion of concern information within a sub-service, while lower semantic coupling means that the concern design between different sub-services conforms to the principle of separation. This metric drives a genetic algorithm to search for service decomposition schemes with high semantic cohesion and low semantic coupling.

[0050] The formula for calculating reconstruction cost is as follows:

[0051]

[0052] Where mno(A,B) represents the modularity distance between refactoring scheme A and the target system B in terms of modularity results. This represents the maximum modularity distance between any modularization result and the target system B. The smaller the modularity distance between the refactoring scheme A and the target system B, the fewer move and merge operations are required to transform the target system into the refactoring scheme, and therefore the higher the similarity between the two, and the lower the refactoring cost.

[0053] Preferably, the genetic algorithm sets the initial population to a modular scheme for the original overloaded service. During each generation of evolution, the population first selects parent individuals to generate crossover and mutation based on crossover and mutation probabilities. Then, it performs crossover and mutation operations to obtain offspring individuals. After identifying duplicate individuals, the NSGA-II algorithm is used to calculate the target fitness value and crowding distance of each individual. Finally, a non-dominated sorting process is used to select the set of individuals to be retained for the next generation, completing the population evolution. The genetic algorithm stops running only when the number of generations reaches a threshold or the number of different individual genotypes found reaches a threshold.

[0054] Preferably, when selecting the optimal reconstruction scheme, the fitness function values ​​of the reconstruction scheme on the three optimization objectives are used to calculate the target distance, specifically using Euclidean distance. The calculation formula is as follows:

[0055]

[0056] Where s represents a single reconstruction scheme output by the algorithm, and PF represents a list of output reconstruction schemes, i.e., a set of Pareto front solutions. StMQ, SeMQ, and RC represent structural modularity quality, semantic modularity quality, and reconstruction cost objective, respectively.

[0057] Based on the above calculation method, the solution with the smallest target distance will be selected as the optimal reconstruction solution. The quantitative quality index for the optimal reconstruction solution is calculated as follows:

[0058]

[0059] Where Dis is the target distance of the reconstruction scheme. This metric represents the proportion of the average value of the target distance of the reconstruction scheme across the three optimization objectives to the theoretical maximum value of the objective. Therefore, the larger this metric is, the higher the average objective quality of the reconstruction scheme.

[0060] This invention also provides a microservice concern overload odor refactoring system based on genetic algorithm, the system including a dependency extraction module, a concern identification module, a refactoring unit generation module, a refactoring search module, and a visualization query module;

[0061] The dependency extraction module extracts specified static code dependencies from the target microservice system and generates two dependency matrices: a 0-1 dependency matrix and a weighted dependency matrix. These are used for processes such as focus selection, refactoring unit generation, and genetic algorithm calculation of structural modularity quality. The 0-1 dependency matrix represents a Boolean dependency matrix between code files, where 0 indicates no dependency between code files and 1 indicates direct or indirect dependency between them; it is used to calculate the cohesion of a topic. The weighted dependency matrix represents the degree of dependency between code files, with weights representing the number of dependencies between two code files; it is used in the genetic algorithm to calculate structural modularity quality metrics.

[0062] The concern identification module is used to generate a topic model of the target microservice system, detect concern overload anomalies within the system, and identify concern overload services that need to be refactored. The parameters that need to be set for this module include: the number of LDA-related clustered topics k, hyperparameter α, hyperparameter β, number of sampling iterations i, concern cohesion threshold, concern-code file association probability threshold, concern-service association threshold, and concern overload threshold.

[0063] The refactoring unit generation module generates a set of refactoring units of a specified granularity based on the dependency tightness of code files under overloaded service through clustering. This module uses the k-centroid clustering algorithm to generate refactoring units; therefore, a refactoring unit is actually composed of one or a group of code files. The specific clustering process is as follows: First, the 0-1 dependency matrix between code files under overloaded service is recorded, representing the direct dependencies between code files. Then, the Floyd algorithm is used to find all indirect dependencies between code files and add them to the dependency matrix. At this point, the 0-1 matrix is ​​upgraded to a weighted matrix, where the weight represents the number of dependency levels between two code files, where 1 represents a direct dependency and n represents an indirect dependency through n levels. The larger n is, the lower the cluster similarity between code files. Before clustering, the number of clusters k needs to be specified; the size of k directly affects the granularity of the refactoring unit and the search performance of the genetic algorithm.

[0064] The reconstruction search module encodes the overloaded service individually according to the specified optimization objective and uses the NSGA-II algorithm to search for the set of individuals with the highest target fitness value, which serves as a list of reconstruction schemes. Finally, the scheme with the smallest target distance is selected as the optimal reconstruction scheme using Euclidean distance. The input of this module is the initial modularization result of the overloaded service, which requires setting parameters including: maximum number of generations, maximum population size, crossover and mutation probability, and maximum number of genotypes. Driven by the three optimization objectives of maximizing structural modularization quality, maximizing semantic modularization quality, and minimizing reconstruction cost, the algorithm eventually outputs the Pareto front solution set with the highest dominance level as a list of reconstruction schemes after multiple iterations. By calculating the target distance of the reconstruction schemes, the optimal reconstruction scheme can be selected from the list of reconstruction schemes.

[0065] The visualization query module can query a list of reconstruction schemes and the optimal reconstruction scheme information for overloaded services with specified concerns. The reconstruction scheme will be displayed in the form of a web page, showing the optimization objective function value, target distance, and detailed modular reconstruction result diagrams.

[0066] The beneficial effects of this invention are as follows: By performing topic modeling and filtering on the semantic information of the source code of a microservice system, microservices with overloaded concerns within the system can be automatically identified. Driven by three optimization objectives—maximizing structural modularity quality, maximizing semantic modularity quality, and minimizing refactoring costs—the genetic algorithm can provide the optimal modular decomposition scheme for the set of refactoring units of overloaded services, i.e., the optimal refactoring scheme. Developers only need to fill out relevant forms in the system operation interface to automatically complete the anomaly detection of concern overload and obtain a reference refactoring scheme, which can greatly improve the efficiency of microservice system refactoring and optimization, reduce system maintenance costs, and effectively improve the modularity quality of the system and optimize the functional architecture design by applying the provided optimal refactoring scheme.

[0067] This invention still has some areas for improvement: the identification scheme for the odor of interest relies on a large number of parameter settings, and the influence of multi-dimensional parameters will make algorithm debugging more difficult and reduce the traceability of results; the dependency matrix used to generate the reconstruction unit only uses the call dependencies between code files, and it is possible to consider using indicators such as dependency distribution matrix and abstract syntax tree to enrich the dependency data and improve the applicability of the algorithm. Attached Figure Description

[0068] Figure 1 This is a flowchart of a method for detecting odors due to overload of interest using topic modeling and mining, and for searching for reconstruction schemes using a genetic algorithm, according to Embodiment 1 of the present invention.

[0069] Figure 2 This is a diagram illustrating the code file dependency matrix extraction process of Embodiment 1 of the present invention.

[0070] Figure 3 This is a diagram of the semantic preprocessing process of the code file in Embodiment 1 of the present invention.

[0071] Figure 4 This is a trend chart of k-perplexity for adjusting the theme modeling parameters in Embodiment 1 of the present invention.

[0072] Figure 5 This is a structural diagram of the subject terms in Embodiment 1 of the present invention.

[0073] Figure 6 This is a diagram illustrating the topic modeling and focus selection process in Embodiment 1 of the present invention.

[0074] Figure 7 This is the tag array encoding diagram of the original overload service in Embodiment 1 of the present invention.

[0075] Figure 8 This is a flowchart of the multi-objective genetic algorithm of Embodiment 1 of the present invention.

[0076] Figure 9This is a structural diagram of a microservice-oriented concern overload odor reconfiguration device according to Embodiment 3 of the present invention. Detailed Implementation

[0077] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.

[0078] This invention provides a method for detecting odors due to overload of interest by utilizing topic modeling and mining, and for searching for reconstruction schemes using genetic algorithms, comprising the following steps:

[0079] S1: Extract the code file dependency matrix of the microservice system to evaluate the cohesion of the topic, the cluster similarity of the refactoring units, and the structural modularity quality of the refactoring scheme;

[0080] S2: Perform topic modeling on the microservice system, mine the concern information under each service, and detect services with overloaded concerns based on concern thresholds;

[0081] S3: Convert services with overloaded concerns into a set of refactoring units according to a certain granularity, and describe the process of refactoring them as a modular decomposition process of the set of refactoring units;

[0082] S4: Use a multi-objective genetic algorithm to search for a list of high-quality reconstruction schemes and select the optimal scheme based on the Euclidean distance of the optimization objective.

[0083] Preferably, the specific steps for extracting the code file dependency matrix of a microservice system include:

[0084] S1-1: Set a file filter to limit the scope of code files and exclude interference from other types of files such as configuration files, test files, and data files;

[0085] S1-2: Recursively read the list of all source code files of the target microservice system based on the file filter;

[0086] S1-3: Define the target dependency types to be extracted, including but not limited to: method calls, package imports, subclass inheritance, interface implementations, property calls, as parameters, as return values, type conversions, aggregate inclusion, and instantiation;

[0087] S1-4: Use the Antlr syntax processing tool to read the specified dependencies of all code files;

[0088] S1-5: Generate a 0-1 dependency matrix based on the dependencies of the code files, which is used to calculate the topic cohesion;

[0089] S1-6: Generate a weighted dependency matrix based on the dependencies of the code files, which is used to calculate the structural modularity quality index.

[0090] Preferably, the specific steps for performing topic modeling and detecting concern overload odors in a microservice system include:

[0091] S2-1: Based on the list of code files obtained by the file filter, read the text content of all code files;

[0092] S2-2: Perform the following operations on the text content of the code file in sequence: word segmentation, camelCase splitting, lowercase conversion, removal of stop words, removal of extraneous words, importance filtering, and stemming, to obtain the semantic vocabulary corresponding to each code file.

[0093] S2--3: Set initial parameters and use the LDA algorithm to perform topic modeling on the vocabulary of all code files in the microservice system;

[0094] S2--4: Based on the perplexity feedback of the topic model, continuously adjust the LDA parameters to the ideal parameter combination;

[0095] S2--5: Calculate the association probability between each topic word and each service, and filter out the set of services that are highly related to the topic based on the association probability threshold between topic words and files, the association probability threshold between topic words and services, and the cohesion threshold of the topic itself.

[0096] S2--6: From the set of services highly related to each keyword, deduce the keywords highly related to each service, as the focus information for each service;

[0097] S2--7: Based on the attention threshold parameter, services with more than the threshold number of attention points are considered as attention overloaded services, i.e., the appearance of attention overload odor.

[0098] Preferably, the specific steps for converting services with overloaded concerns into a set of refactoring units include:

[0099] S3-1: Use a file filter to read all code files under the overload service;

[0100] S3-2: Based on the specified refactoring unit granularity settings, the weighted dependency matrix of the code files is used to calculate similarity, and the k-centroid clustering algorithm is applied to generate a set of refactoring units under the overloaded service.

[0101] Preferably, the specific steps for using a genetic algorithm to obtain a reconstruction scheme include:

[0102] S4--1: Encode the individuals of the genetic algorithm into a tag array of the overload service corresponding reconstruction unit set;

[0103] S4--2: Set the parameters of the genetic algorithm, including but not limited to: maximum number of generations, maximum population size, crossover probability, mutation probability, and maximum number of different genotypes.

[0104] S4--3: Set the fitness objectives of the genetic algorithm, including: structural modularity quality, semantic modularity quality, and reconstruction cost;

[0105] S4--4: The NSGA-II algorithm is applied to complete the multi-objective search. The first frontier solution set obtained is filtered by the overload detection of the focus and then output as a list of reconstruction schemes.

[0106] S4--5: Select the optimal reconstruction scheme based on the Euclidean distance of the three fitness optimization objectives.

[0107] To complete the search for high-quality reconstruction schemes, this invention designs a multi-objective genetic algorithm for modular search and applies it to search for reconstruction schemes that maximize structural modularity quality, maximize semantic modularity quality, and minimize reconstruction scheme cost.

[0108] Preferably, the length of the label array encoding the individuals in the genetic algorithm is equal to the number of reconstruction units. Each label in the label array corresponds to a different reconstruction unit under the overloaded service, and the value of each label represents the service ID to which the corresponding reconstruction unit belongs in the modular scheme. Therefore, the value of each label in the original overloaded service's label array is the ID of the overloaded service. By using the label array to map different modular results of reconstruction units, this invention transforms the reconstruction of the overloaded service of concern into a process of modular decomposition of its reconstruction unit set, that is, decomposing the overloaded service into multiple sub-services of concern that are not overloaded.

[0109] Preferably, the genetic algorithm uses three optimization objectives: structural modularity quality, semantic modularity quality, and reconstruction cost. The formula for calculating structural modularity quality is as follows:

[0110]

[0111] Where N represents the number of services, scoh i Scop represents the structural cohesion value of service i. i,j This represents the coupling value between services i and j. The formula for calculating cohesion within a service and coupling between services is as follows:

[0112]

[0113]

[0114] Where, μ i σ represents the number of dependencies between code files within service i. i,jThis represents the number of dependencies between the code files of services i and j. i N j These represent the number of code files for services i and j, respectively.

[0115] This metric measures the structural cohesion and structural coupling of overloaded service decomposition by calculating the tightness of dependencies between sub-services and their counterparts, driving the genetic algorithm to search for service decomposition schemes with high cohesion and low coupling.

[0116] The formula for calculating the quality of semantic modularity is as follows:

[0117]

[0118] Where N represents the number of services, sim i sim represents the semantic similarity between code files under service i. i,j This represents the semantic similarity between the code files of services i and j. The semantic similarity is calculated using cosine similarity based on TF-IDF vectors, as shown in the following formula:

[0119]

[0120]

[0121] This metric calculates the similarity of code files inside and outside a sub-service from a semantic perspective, measuring semantic cohesion and semantic coupling. Higher semantic cohesion means cohesion of concern information within a sub-service, while lower semantic coupling means that the concern design between different sub-services conforms to the principle of separation. This metric drives a genetic algorithm to search for service decomposition schemes with high semantic cohesion and low semantic coupling.

[0122] The formula for calculating reconstruction cost is as follows:

[0123]

[0124] Where mno(A,B) represents the modularity distance between refactoring scheme A and the target system B in terms of modularity results. This represents the maximum modularity distance between any modularization result and the target system B. The smaller the modularity distance between the refactoring scheme A and the target system B, the fewer move and merge operations are required to transform the target system into the refactoring scheme, and therefore the higher the similarity between the two, and the lower the refactoring cost.

[0125] Preferably, the genetic algorithm sets the initial population to a modular scheme for the original overloaded service. During each generation of evolution, the population first selects parent individuals to generate crossover and mutation based on crossover and mutation probabilities. Then, it performs crossover and mutation operations to obtain offspring individuals. After identifying duplicate individuals, the NSGA-II algorithm is used to calculate the target fitness value and crowding distance of each individual. Finally, a non-dominated sorting process is used to select the set of individuals to be retained for the next generation, completing the population evolution. The genetic algorithm stops running only when the number of generations reaches a threshold or the number of different individual genotypes found reaches a threshold.

[0126] Preferably, when selecting the optimal reconstruction scheme, the fitness function values ​​of the reconstruction scheme on the three optimization objectives are used to calculate the target distance, specifically using Euclidean distance. The calculation formula is as follows:

[0127]

[0128] Where s represents a single reconstruction scheme output by the algorithm, and PF represents a list of output reconstruction schemes, i.e., a set of Pareto front solutions. StMQ, SeMQ, and RC represent structural modularity quality, semantic modularity quality, and reconstruction cost objective, respectively.

[0129] Based on the above calculation method, the solution with the smallest target distance will be selected as the optimal reconstruction solution. The quantitative quality index for the optimal reconstruction solution is calculated as follows:

[0130]

[0131] Where Dis is the target distance of the reconstruction scheme. This metric represents the proportion of the average value of the target distance of the reconstruction scheme across the three optimization objectives to the theoretical maximum value of the objective. Therefore, the larger this metric is, the higher the average objective quality of the reconstruction scheme.

[0132] This invention also provides a microservice concern overload odor refactoring system based on genetic algorithm, the system including a dependency extraction module, a concern identification module, a refactoring unit generation module, a refactoring search module, and a visualization query module;

[0133] The dependency extraction module extracts specified static code dependencies from the target microservice system and generates two dependency matrices: a 0-1 dependency matrix and a weighted dependency matrix. These are used for processes such as focus selection, refactoring unit generation, and genetic algorithm calculation of structural modularity quality. The 0-1 dependency matrix represents a Boolean dependency matrix between code files, where 0 indicates no dependency between code files and 1 indicates direct or indirect dependency between them; it is used to calculate the cohesion of a topic. The weighted dependency matrix represents the degree of dependency between code files, with weights representing the number of dependencies between two code files; it is used in the genetic algorithm to calculate structural modularity quality metrics.

[0134] The concern identification module is used to generate a topic model of the target microservice system, detect concern overload anomalies within the system, and identify concern overload services that need to be refactored. The parameters that need to be set for this module include: the number of LDA-related clustered topics k, hyperparameter α, hyperparameter β, number of sampling iterations i, concern cohesion threshold, concern-code file association probability threshold, concern-service association threshold, and concern overload threshold.

[0135] The refactoring unit generation module generates a set of refactoring units of a specified granularity based on the dependency tightness of code files under overloaded service through clustering. This module uses the k-centroid clustering algorithm to generate refactoring units; therefore, a refactoring unit is actually composed of one or a group of code files. The specific clustering process is as follows: First, the 0-1 dependency matrix between code files under overloaded service is recorded, representing the direct dependencies between code files. Then, the Floyd algorithm is used to find all indirect dependencies between code files and add them to the dependency matrix. At this point, the 0-1 matrix is ​​upgraded to a weighted matrix, where the weight represents the number of dependency levels between two code files, where 1 represents a direct dependency and n represents an indirect dependency through n levels. The larger n is, the lower the cluster similarity between code files. Before clustering, the number of clusters k needs to be specified; the size of k directly affects the granularity of the refactoring unit and the search performance of the genetic algorithm.

[0136] The reconstruction search module encodes the overloaded service individually according to the specified optimization objective and uses the NSGA-II algorithm to search for the set of individuals with the highest target fitness value, which serves as a list of reconstruction schemes. Finally, the scheme with the smallest target distance is selected as the optimal reconstruction scheme using Euclidean distance. The input of this module is the initial modularization result of the overloaded service, which requires setting parameters including: maximum number of generations, maximum population size, crossover and mutation probability, and maximum number of genotypes. Driven by the three optimization objectives of maximizing structural modularization quality, maximizing semantic modularization quality, and minimizing reconstruction cost, the algorithm eventually outputs the Pareto front solution set with the highest dominance level as a list of reconstruction schemes after multiple iterations. By calculating the target distance of the reconstruction schemes, the optimal reconstruction scheme can be selected from the list of reconstruction schemes.

[0137] The visualization query module can query a list of reconstruction schemes and the optimal reconstruction scheme information for overloaded services with specified concerns. The reconstruction scheme will be displayed in the form of a web page, showing the optimization objective function value, target distance, and detailed modular reconstruction result diagrams.

[0138] The technical solution of the present invention will be described in detail below with reference to specific embodiments.

[0139] Example 1

[0140] Figure 1 This is a flowchart of a method for detecting concern overload odors using topic modeling and mining, and for searching refactoring solutions using a genetic algorithm, according to Embodiment 1 of the present invention. The application scenario of this method is: software systems based on microservice architecture exhibit problems such as poor maintainability, chaotic system architecture, and low availability due to concern overload odors, requiring architectural refactoring. Specifically, it includes the following steps:

[0141] Step 110: Extract the code file dependency matrix of the microservice system to evaluate the cohesion of the topic, the cluster similarity of the refactoring units, and the structural modularity quality of the refactoring scheme.

[0142] Before extracting the code file dependency matrix, set a file filter to limit the target source code file type to files whose filenames end with ".java" and do not contain the "Test" suffix. Also, set the dependency type of the code files to be extracted to be: method call dependencies between classes --- Call.

[0143] Figure 2The process of extracting the code file dependency matrix involves inputting the root directory of the target system's source code. A file filter is then used to recursively scan all folders to obtain a complete list of code files. Next, the Antlr syntax processing tool is used to parse the abstract syntax tree of the source code files in the specified programming language, generating a complete code file dependency matrix. Finally, formal processing is used to generate a 0-1 dependency matrix and a weighted dependency matrix, which will be used to calculate topic cohesion and structural modularity quality metrics, respectively.

[0144] In this embodiment, the microservice system was scanned, resulting in a total of 542 source code files. 242 files were filtered and retained, and a 242*242 original dependency matrix was generated based on this. A total of 1081 different types of dependencies were captured from the abstract syntax tree, of which 319 were target dependencies.

[0145] Step 120: Perform topic modeling on the microservice system, mine the concern information under each service, and detect services with concern overload based on concern thresholds.

[0146] Topic modeling is based on abstract entities of documents, words, and topics. Therefore, before performing topic modeling, semantic extraction and preprocessing of the source code information of the microservice system are required. Figure 3 This paper describes the detailed process of processing source code text into source code documentation. After reading the text information of the source code file, all words in the text are obtained through word segmentation. Then, common camelCase word combinations in the code are broken down and standardized to lowercase. To improve the accuracy of identifying points of interest, stop word and extraneous word filtering are performed on the standardized words, removing low-relevance terms of common words and programming-related terms, respectively. Since words in the source code have different word frequencies, TF-IDF is used to filter words by importance, retaining the top 80% of words. Finally, due to the limitations of English grammar, stemming technology is used to unify the different forms of individual words.

[0147] This invention uses LDA, a well-established topic clustering method in the field of topic modeling, to perform topic modeling on source code documents. When using LDA for clustering, the following settings need to be configured: the number of cluster topics k, hyperparameter α, hyperparameter β, and the number of sampling iterations i. In this embodiment, the values ​​of β and i are kept constant at 0.01 and 1200, respectively. The values ​​of k and α are obtained through the perplexity metric after multiple experiments. Figure 4 In this embodiment, the values ​​of the perplexity index under different k values ​​are considered. Taking into account both perplexity and the number of topics, k=30 is selected as the number of clustering topics.

[0148] The topic information obtained from topic modeling, such as Figure 5 As shown, each topic consists of a set of words and their associated probabilities, representing different topic semantics. To obtain high-quality attention information for each service, it is necessary to further filter these 30 topics by combining the association probability between topic words and code files, the association probability between topic words and services, and the cohesion of the topic words themselves.

[0149] Figure 6 This paper describes the detailed process from topic modeling to the selection of points of interest. The topic model data obtained by topic modeling and clustering using the LDA algorithm includes semantic association probability matrices between all topics and vocabularies, as well as semantic association probability matrices between all code files and all topics. Using these two sets of data, combined with a file association probability threshold, the association probability between all services and topics can be obtained. Subsequently, to select points of interest from these topics, each topic needs to be traversed, and two rounds of topic-service association search are performed on each topic. In the first round of iteration, for each current topic, services with higher association probabilities are selected first. For the selected services, combined with the file association probability threshold, code files within those services with high relevance to the current topic are added to the topic file set. This selection process is repeated until the association probability between candidate services and the current topic is higher than the threshold, or the topic file set is expanded to make the topic cohesion lower than the threshold. The first round of iteration is mainly to search for associated services without knowing the initial value of the current topic's cohesion. In the second round of iteration, the current topic already has a certain set of topic files, associated services, and a current state of cohesion. The same operation as the first iteration is repeated, but the termination condition is changed to the topic's cohesion value being higher than a threshold. This is because after the first iteration, the current topic has already obtained a set of associated services and topic files, and has an initial cohesion value. Therefore, the second iteration aims to expand the set of associated services and topic files as much as possible while maintaining high topic cohesion, in order to discover all topic-service relationships. In this embodiment, the threshold for concern overload is set to 7, and the services with concern overload contain a total of 10 concerns.

[0150] Step 130: Convert the service with overloaded concerns into a set of refactoring units according to a certain granularity. Describe the refactoring process as a modular decomposition of the set of refactoring units. According to Step 120, the service with overloaded concerns to be refactored contains 10 concerns, and the number of code files is 89. To describe it as a set of decomposable refactoring units, it is necessary to cluster these 89 code files using the weighted dependency matrix generated in Step 110. This embodiment adopts the smallest granularity refactoring unit, i.e., the code file granularity, and selects k=89 for k-centroid clustering. This actually forms 89 clusters corresponding to the 89 code files, with each code file representing a refactoring unit. In this way, the overloaded service can be described as a set of 89 refactoring units. The refactoring scheme considers how to decompose these 89 refactoring units from a modular perspective to generate high-quality subsets.

[0151] Step 140: Use a multi-objective genetic algorithm to search for a list of high-quality reconstruction schemes, and select the optimal scheme based on the Euclidean distance of the optimization objective. For example... Figure 7 As shown, the original overloaded services in the genetic algorithm are encoded as an 89-bit tag array, where each bit represents the sub-service ID to which the corresponding reconstruction unit belongs. Before reconstruction decomposition, they all represent the original service ID. The parameter settings for the genetic algorithm in this embodiment are shown in the table below:

[0152] Table 1

[0153]

[0154]

[0155] Figure 8 This embodiment describes the process of using a multi-objective genetic algorithm to search for and generate a list of reconstruction schemes. The algorithm starts with a single individual for population initialization. In each subsequent generation, variant individuals are selected from the parent population for crossover and mutation. The number of variant individuals is determined by the crossover and mutation probabilities. After single-point crossover and mutation, offspring individuals equal to the number of variant individuals from the parent generation are generated. These individuals are then filtered for duplicate genotypes to obtain the offspring population. During population updates, the parent and offspring populations are mixed, and some overloaded individuals are randomly eliminated based on a maximum overload threshold. A non-dominated sort is then performed on the mixed population to obtain different front subsets. Fronts with high dominance relationships are preferentially selected from these subsets to form the parent population for the next generation, ensuring that the population size never exceeds the maximum population size threshold. The algorithm terminates when the number of genetic iterations reaches a threshold or the total number of individuals with different genotypes reaches a threshold.

[0156] To reduce the impact of randomness in the genetic algorithm, this embodiment executed the genetic algorithm with the same parameter configuration 30 times. On average, each execution of the genetic algorithm searched for 474k different reconstruction schemes. Among them, 287k schemes had no concern overload, meaning that the number of concerns contained in the sub-services generated from the decomposition of the overloaded service was within the concern threshold, and there were no new concern overload anomalies. However, 187k schemes had concern overload, meaning that the sub-services generated from the decomposition still contained concern overload anomalies. Therefore, it can be considered that this embodiment can obtain a relatively large number of effective reconstruction schemes.

[0157] Regarding the quality of the reconstruction schemes, in all 30 runs, the average target distance of the effective reconstruction schemes was 1.0778, and the corresponding maximum quality percentage was 37.77%. To illustrate comparability, this embodiment also statistically analyzed the average target distance and maximum quality percentage of the reconstruction schemes obtained by the random search algorithm under the same parameter configuration, which were 1.5653 and 9.62%, respectively. Therefore, the effective reconstruction schemes output by the genetic algorithm show a significant improvement in the optimization objective.

[0158] Regarding specific optimization goals, in all 30 runs, the average structural modularity quality of the effective refactoring scheme was 0.0718, a 5026% improvement compared to the original overloaded service's 0.0014; the average semantic modularity quality was 0.4808, an 81.5% improvement compared to the original overloaded service's 0.2649; and the average refactoring cost was 0.8632, indicating that the overall refactoring scheme and the original service have a high degree of similarity in modularity results, thus the refactoring cost is relatively low.

[0159] Example 2

[0160] This embodiment, based on the above embodiments, uses larger-granularity reconstruction units for reconstruction scheme search. The preliminary steps, such as code file dependency matrix extraction, topic modeling, and overload detection of concerns, are the same as in Embodiment 1. When generating reconstruction units, a smaller number of clusters, k, is chosen for k-centroid clustering. Specifically, k is set to the number of code files / 5. This significantly increases the granularity of the reconstruction units, shrinking the number of clusters to one-fifth of the original. An overload service is described as a set of 18 reconstruction units, where each reconstruction unit consists of 1 to 18 code files.

[0161] Compared to the 89 code file-level reconstruction units in Example 1, this example significantly reduces the number of reconstruction units, thus greatly reducing the number of modular decomposition combination schemes. As a result, the genetic algorithm no longer requires higher parameter constraints to search for high-quality reconstruction schemes within a limited time. The parameter settings for the genetic algorithm in this example are shown in the table below:

[0162] Table 2

[0163]

[0164] By reducing the parameter settings for maximum number of generations, maximum population size, and maximum number of genotypes, the genetic algorithm can converge and output a reconstruction scheme more quickly. Parameters such as crossover probability and mutation probability remain unchanged. Similar to Example 1, the genetic algorithm with this parameter configuration was executed 30 times to reduce the impact of algorithmic randomness.

[0165] Due to the reduction in the modular search space, this embodiment generates an average of only 77k different reconstruction schemes per search in 30 searches. Of these, 72k are effective reconstruction schemes, and only 5k of them rely on overload smells related to concerns. This demonstrates that increasing the granularity of the reconstruction unit can still generate a significant number of effective reconstruction schemes.

[0166] Regarding the overall quality of the reconstruction schemes, the average target distance of the schemes obtained from 30 searches was 1.2153, with a corresponding average maximum quality ratio of 29.83%. To illustrate comparability, this embodiment also statistically analyzed the average target distance and maximum quality ratio of the reconstruction schemes obtained by the random search algorithm under the same parameter configuration, which were 1.3534 and 21.86%, respectively. It can be observed that the reconstruction schemes output by the genetic algorithm still have higher overall quality, but the increased granularity of the reconstruction units reduces the difference between them and the results of the random search algorithm.

[0167] Regarding the specific optimization goals, in all 30 runs, the average structural modularity quality of the effective refactoring scheme was 0.0091, a 553% improvement compared to the original overloaded service's 0.0014; the average semantic modularity quality was 0.3163, a 19.4% improvement compared to the original overloaded service's 0.2649; and the average refactoring cost was 0.8516. It can be observed that the refactoring scheme still brings significant improvements to the structural and semantic modularity quality of the target system, and the refactoring cost remains low. However, compared to the results in Example 1, while increasing the granularity of the refactoring units reduces the search space, it also clearly limits the improvement effect on the optimization goals.

[0168] Regarding the average execution time per algorithm, in Example 1, when searching at the code file granularity, the average execution time of the genetic algorithm was 446.4 seconds; while in this example, the average execution time of the genetic algorithm was only 117.4 seconds, a reduction of 349 seconds. Similarly, in this example, the average total number of genotypes generated by the genetic algorithm per run was reduced by 397k compared to the previous example, which means that the memory constraint required for algorithm execution was also greatly reduced. Therefore, for larger granularity reconstruction units, the search performance of the genetic algorithm can often be greatly improved and memory consumption reduced, but the improvement effect on the optimization objective will be lower than that of smaller granularity reconstruction units.

[0169] Example 3

[0170] Figure 9 This is a schematic diagram of a concern overload odor refactoring device for microservices provided by the present invention. The refactoring device includes: a dependency extraction module 310, a concern identification module 320, a refactoring unit generation module 330, a refactoring search module 340, and a visualization query module 350.

[0171] The dependency extraction module 310 is mainly used to extract the target dependencies of code files, and provides two conversion interfaces for 0-1 dependency matrices and weighted dependency matrices, respectively, depending on the application scenario. The two dependency matrices are used to calculate topic cohesion and structural modularity quality indicators, respectively.

[0172] The concern identification module 320 is responsible for performing topic modeling on the microservice system and identifying services with concern overload or odor based on concern thresholds. This mainly includes: code semantic preprocessing, topic modeling, concern filtering, and odor detection.

[0173] The code semantic preprocessing process requires extracting document and vocabulary information for topic modeling from the source code text information of the microservice system. Specifically, it uses NLP processing methods such as word segmentation, stemming, and stop word removal.

[0174] The topic modeling process uses the LDA algorithm to cluster topics in the source code documents, obtaining topic information within the documents. Simultaneously, the topic model will also output the association probability matrix between topic terms and code files, and the association probability matrix between topic terms and the vocabulary.

[0175] The process of focusing on key concerns and detecting anomalies first filters topics in the topic model based on topic cohesion, the probability of association between a topic and code files, and the probability of association between a topic and services to identify key concerns. Then, by combining these key concern thresholds, services with excessive key concerns are identified, i.e., those requiring refactoring.

[0176] The reconstruction unit generation module 330 performs a modular transformation of the reconstruction object in a modular search scenario, thereby better adapting it to the encoding method of the genetic algorithm and using it to describe the various reconstruction schemes found. Considering different reconstruction scenarios, this module can also define different rules to obtain reconstruction units of different granularities, thereby realizing diverse reconstruction search needs.

[0177] The reconstruction search module 340 encodes overloaded services individually according to the specified optimization objective and uses a genetic algorithm to search for the set of individuals with the highest target fitness value, which serves as a list of reconstruction schemes. The algorithm takes (1) maximizing structural modularity quality, (2) maximizing semantic modularity quality, and (3) minimizing reconstruction cost as fitness objectives, and extends new individual encoding methods, crossover and mutation operators, population change logic, and individual constraints. Based on the comprehensive quality index of target distance and maximum quality ratio, the algorithm can select an optimal reconstruction scheme.

[0178] The visualization query module 350 mainly converts the reconstruction scheme data used for display into a specific data format required by the interface.

[0179] It should be noted that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A microservice concern overload odor refactoring method based on genetic algorithm, characterized in that, Includes the following steps: S1: Extract the code file dependency matrix of the microservice system to evaluate the cohesion of the topic, the cluster similarity of the refactoring units, and the structural modularity quality of the refactoring scheme; S2: Perform topic modeling on the microservice system, mine the concern information under each service, and detect services with overloaded concerns based on concern thresholds; S3: Convert services with overloaded concerns into a set of refactoring units according to a certain granularity, and describe the process of refactoring them as a modular decomposition process of the set of refactoring units; S4: Use a multi-objective genetic algorithm to search for a list of high-quality reconstruction schemes and select the optimal scheme based on the Euclidean distance of the optimization objective; The specific steps for using a genetic algorithm to obtain a reconstruction scheme include: S4--1: Encode the individuals of the genetic algorithm into a tag array of the overload service corresponding reconstruction unit set; S4--2: Set the parameters of the genetic algorithm, including: maximum number of generations, maximum population size, crossover probability, mutation probability, and maximum number of different genotypes; S4--3: Set the fitness objectives of the genetic algorithm, including: structural modularity quality, semantic modularity quality, and reconstruction cost; S4--4: The NSGA-II algorithm is applied to complete the multi-objective search. The first frontier solution set obtained is filtered by the overload detection of the focus and then output as a list of reconstruction schemes. S4--5: Select the optimal reconstruction scheme based on the Euclidean distance of the three fitness optimization objectives; The multi-objective genetic algorithm in S4 uses three optimization objectives: structural modularity quality, semantic modularity quality, and reconstruction cost. The formula for calculating structural modularity quality is as follows: Where N represents the number of services. This represents the structural cohesion value of service i. The coupling value between services i and j is represented by the following formula: (This formula represents the coupling value between services i and j.) in, This indicates the number of dependencies between the internal code files of service i. This indicates the number of dependencies between the code files of services i and j. , These represent the number of code files for services i and j, respectively. This metric measures the structural cohesion and structural coupling of overloaded service decomposition by calculating the tightness of dependencies between sub-services and their internal and external components, and drives the genetic algorithm to search for service decomposition schemes with high cohesion and low coupling. The formula for calculating the quality of semantic modularity is as follows: Where N represents the number of services. This represents the semantic similarity between code files under service i. This represents the semantic similarity between the code files of services i and j. The semantic similarity is calculated using cosine similarity based on TF-IDF vectors, as shown in the following formula: This metric, from a semantic perspective, calculates the similarity of code files inside and outside a sub-service to measure semantic cohesion and semantic coupling. Higher semantic cohesion indicates cohesion of concern information within a sub-service, while lower semantic coupling indicates that the concern design between different sub-services conforms to the principle of separation. This metric drives a genetic algorithm to search for service decomposition schemes with high semantic cohesion and low semantic coupling. The formula for calculating reconstruction cost is as follows: in, This represents the modularity distance between refactoring scheme A and the target system B in terms of modularity results. This represents the maximum modular distance between any modularized result and the target system B. The smaller the modular distance between the reconstruction scheme A and the target system B, the fewer the number of move and merge operations required to transform the target system into the reconstruction scheme. Therefore, the higher the similarity between the two, the lower the reconstruction cost.

2. The microservice concern overload odor refactoring method based on genetic algorithm according to claim 1, characterized in that, In step S1, the specific steps for extracting the code file dependency matrix of the microservice system include: S1-1: Set a file filter to limit the scope of code files and exclude interference from configuration files, test files, and data files; S1-2: Recursively read the list of all source code files of the target microservice system based on the file filter; S1-3: Define the target dependency types to be extracted, including: method call, package import, subclass inheritance, interface implementation, property call, as parameter, as return value, type conversion, aggregate inclusion, and instantiation; S1-4: Use the Antlr syntax processing tool to read the specified dependencies of all code files; S1-5: Generate a 0-1 dependency matrix based on the dependencies of the code files, which is used to calculate the topic cohesion; S1-6: Generate a weighted dependency matrix based on the dependency relationships of the code files, which is used for clustering to generate refactoring units.

3. The microservice concern overload odor refactoring method based on genetic algorithm according to claim 1, characterized in that, The specific steps for performing topic modeling and detecting concern overload odors in a microservice system include: S2-1: Based on the list of code files obtained by the file filter, read the text content of all code files; S2-2: Perform the following operations on the text content of the code file in sequence: word segmentation, camelCase splitting, lowercase conversion, stop word removal, impurity word removal, importance filtering, and stemming to obtain the semantic vocabulary for each code file; S2--3: Set initial parameters and use the LDA algorithm to perform topic modeling on the vocabulary of all code files in the microservice system; S2--4: Based on the perplexity feedback of the topic model, continuously adjust the LDA parameters to the ideal parameter combination; S2--5: Calculate the association probability between each topic word and each service, and filter out the set of services that are highly related to the topic based on the association probability threshold between topic words and files, the association probability threshold between topic words and services, and the cohesion threshold of the topic itself. S2--6: From the set of services highly related to each keyword, deduce the keywords highly related to each service, as the focus information for each service; S2--7: Based on the attention threshold parameter, services with more than the threshold number of attention points are considered as attention overloaded services, i.e., the appearance of attention overload odor.

4. The microservice concern overload odor refactoring method based on genetic algorithm according to claim 1, characterized in that, The specific steps to transform overloaded services into a set of refactored units include: S3-1: Use a file filter to read all code files under the overload service; S3-2: Based on the specified refactoring unit granularity settings, the weighted dependency matrix of the code files is used to calculate similarity, and the k-centroid clustering algorithm is applied to generate a set of refactoring units under the overloaded service.

5. The microservice concern overload odor refactoring method based on genetic algorithm according to claim 1, characterized in that, In the multi-objective genetic algorithm of S4, the fitness function values ​​of the reconstruction scheme on the three optimization objectives are used to calculate the objective distance, specifically using Euclidean distance, and the calculation formula is as follows: Where s represents a single reconstruction scheme output by the algorithm, PF represents a list of output reconstruction schemes, i.e. a set of Pareto front solutions, and StMQ, SeMQ, and RC represent structural modularity quality, semantic modularity quality, and reconstruction cost objective, respectively. Based on the above calculation method, the scheme with the smallest target distance will be selected as the optimal reconstruction scheme. The quantitative quality index of the optimal reconstruction scheme will be calculated as follows: Where Dis is the target distance of the reconstruction scheme. This index represents the proportion of the average value of the target distance of the reconstruction scheme on the three optimization objectives to the theoretical maximum value of the objective. Therefore, the larger the index is, the higher the average objective quality of the reconstruction scheme.

6. A microservice concern overload odor refactoring system based on genetic algorithm, characterized in that, The system includes a dependency extraction module, a concern identification module, a reconstruction unit generation module, a reconstruction search module, and a visualization query module; The dependency extraction module is used to extract the specified static code dependencies of the target microservice system and generate two types of dependency matrices: 0-1 dependency matrix and weighted dependency matrix. These are used for the process of selecting concerns, generating refactoring units, and calculating the structural modularity quality in the genetic algorithm. The 0-1 dependency matrix represents the Boolean dependency matrix between code files, where 0 indicates that there is no dependency between code files and 1 indicates that there is a direct or indirect dependency between code files. It is used to calculate the cohesion of the topic. The weighted dependency matrix represents the degree of dependency between code files, and the weights represent the number of dependencies between two code files. It is used to calculate the structural modularity quality index in the genetic algorithm. The concern identification module is used to generate a topic model of the target microservice system and detect concern overload anomalies within the system, and discover concern overload services that need to be refactored. The parameters that need to be set for this module include: the number of clustered topics k related to LDA, hyperparameter α, hyperparameter β, number of sampling iterations i, concern cohesion threshold, concern-code file association probability threshold, concern-service association threshold, and concern overload threshold. The refactoring unit generation module generates a set of refactoring units of a specified granularity based on the dependency tightness of code files under overloaded service through clustering. This module uses the k-centroid clustering algorithm to generate refactoring units. Therefore, a refactoring unit is actually composed of one or a group of code files. The specific clustering process is as follows: First, the 0-1 dependency matrix between code files under overloaded service is recorded. At this time, the dependency matrix represents the direct dependencies between code files. Then, the indirect dependencies between all code files are found through the Floyd algorithm and added to the dependency matrix. At this time, the 0-1 matrix is ​​upgraded to a weighted matrix. The weight represents the number of dependency levels between two code files, where 1 represents a direct dependency and n represents an indirect dependency through n levels. The larger n is, the lower the cluster similarity between code files. Before clustering, the number of clusters k needs to be specified. The size of k will directly affect the granularity of the refactoring unit and the search performance of the genetic algorithm. The reconstruction search module encodes the overloaded service individually according to the specified optimization objective and uses the NSGA-II algorithm to search for the set of individuals with the highest target fitness value as a list of reconstruction schemes. Finally, it uses Euclidean distance to select the scheme with the smallest target distance as the optimal reconstruction scheme. The input of this module is the initial modularization result of the overloaded service, which needs to be set with parameters including: maximum number of generations, maximum population size, crossover mutation probability, and maximum number of genotypes. Driven by the three optimization objectives of maximizing structural modularization quality, maximizing semantic modularization quality, and minimizing reconstruction cost, the algorithm will eventually output the Pareto front solution set with the highest dominance level as a list of reconstruction schemes after multiple iterations. By calculating the target distance of the reconstruction schemes, the optimal reconstruction scheme can be selected from the list of reconstruction schemes. The visualization query module can query a list of reconstruction schemes and the optimal reconstruction scheme information for overloaded services with specified concerns. The reconstruction scheme will be displayed in the form of a web page, showing the optimization objective function value, target distance, and detailed modular reconstruction result graph information.