Method and device for determining JVM tuning scheme and readable storage medium
By using the preset JVM tuning model to process the performance data of the target Java application, and automatically generate the JVM tuning solution, the problem of low efficiency and poor accuracy of JVM tuning solution determination in the prior art is solved, and efficient and accurate JVM tuning is achieved.
Patent Information
- Application Number
- CN202311173872.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-11
- Publication Date
- 2025-03-11
AI Technical Summary
In the prior art, the JVM tuning scheme is less efficient, prone to errors, and has a high labor cost.
By obtaining multiple sets of performance data continuously collected by the target Java application during the target time period, input it into the preset JVM tuning model for processing, and generating a JVM tuning solution for the target Java application. This model is a processed large language model that can automatically analyze performance data and provide JVM tuning suggestions.
It improves the determination efficiency of JVM tuning solutions, reduces the need for manual analysis and adjustment, improves the accuracy of the solutions, and reduces labor costs.
Smart Images

Figure CN119597393A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device and readable storage medium for determining a JVM tuning solution. Background Art
[0002] JVM stands for Java Virtual Machine. It is a virtual machine that runs Java applications on an operating system. JVM tuning is an important means to optimize the performance of Java applications and can effectively improve the operating efficiency and stability of Java applications.
[0003] However, determining the JVM tuning solution is a complex task. In the process of determining the JVM tuning solution, multiple factors need to be considered, such as memory management, garbage collection strategy, and program execution efficiency. Traditional JVM tuning solutions usually rely on technicians to combine multiple factors and determine based on experience. The current method of determining JVM tuning solutions heavily relies on the experience of technicians, so there are technical problems such as low efficiency, easy errors, and high labor costs. Summary of the invention
[0004] The embodiments of the present application provide a method, device and readable storage medium for determining a JVM tuning solution, which can solve the technical problems in the prior art that the method for determining a JVM tuning solution is inefficient, prone to errors and has high labor costs.
[0005] In a first aspect, an embodiment of the present application provides a method for determining a JVM tuning plan, the method comprising: obtaining multiple sets of performance data of a target Java application continuously collected within a target time period, each set of performance data comprising: at least one of garbage collection log information, memory and CPU usage data, and thread data; inputting the multiple sets of performance data into a preset JVM tuning model for processing to obtain a JVM tuning plan for the target Java application, the JVM tuning model being a processed large language model, and the JVM tuning plan comprising: JVM adjustment suggestions.
[0006] The first aspect provides a method for determining a JVM tuning solution, using a processed large language model as a JVM tuning model, and obtaining a JVM tuning solution for a target Java application by inputting multiple sets of performance data collected continuously from the target Java application into the JVM tuning model. The method uses the JVM tuning model to generate a JVM tuning solution, and does not require manual analysis of the performance data, so the efficiency is high; and the method uses the processed large language model as the JVM tuning model, making full use of the text generation capability of the large language model itself, and the processed pre-trained large language model has better adaptability to the JVM tuning process, so that the JVM tuning solution obtained based on the JVM tuning model has higher accuracy; and because the method generates the JVM tuning solution with the help of a preset JVM tuning model, the requirements for technical personnel are relatively low, so the labor cost can be reduced.
[0007] In a possible implementation of the first aspect, the large language model includes: any one of GPT-2, GPT-3, BERT, RoBERTa, XLNet, and T5.
[0008] In a possible implementation of the first aspect, the method further includes: obtaining historical performance data, the historical performance data including multiple sets of performance data generated by multiple different Java applications before the target time period; constructing a training sample set based on the historical performance data, the training sample set including multiple training samples; using the training sample set, training the large language model to obtain a preset JVM tuning model. In this implementation, the large language model is trained using the historical performance data of multiple different Java applications to obtain the JVM tuning model, so that the JVM tuning model has good applicability to different Java applications, and the method for determining the JVM tuning solution has a wide range of applications.
[0009] In a possible implementation of the first aspect, a training sample set is constructed based on historical performance data, including: determining multiple initial samples based on historical performance data, each initial sample includes N groups of performance data belonging to the same Java application, where N is a positive integer greater than 1, the N groups of performance data of each initial sample are collected continuously, and each group of performance data belongs to only one initial sample; labeling each initial sample based on the N groups of performance data of each initial sample to obtain a labeled sample corresponding to each initial sample, the labeled sample including the corresponding initial sample and a tuning label; determining a training sample set based on multiple labeled samples, each training sample in the training sample set includes a labeled sample. In this embodiment, each initial sample includes N groups of performance data collected continuously, and N is an integer greater than 1; and the labeled sample is obtained by labeling the initial sample with the N groups of performance data in the corresponding initial sample, so each labeled sample corresponds to N groups of performance data collected continuously. Each training sample in the training sample set is a standard sample, that is, each training sample corresponds to N sets of performance data collected continuously. Since each training sample includes multiple sets of performance data collected continuously instead of a single set of performance data, each training sample can reflect the performance of the target Java application within a period of time instead of sudden performance, thus improving the accuracy of the JVM tuning model judgment.
[0010] In a possible implementation manner of the first aspect, each set of performance data in the historical performance data includes garbage collection log information, and each initial sample is labeled according to the N sets of performance data of each initial sample, including:
[0011] Using garbage collection log information of each set of performance data in the N sets of performance data of each initial sample, determine the heap memory usage corresponding to each set of performance data;
[0012] If the N heap memory usage rates of each initial sample are all greater than the first threshold, then determining the tuning label of each initial sample includes: According to the analysis, the current application may have the following problems: the heap memory usage rate is continuously higher than the first threshold, the application generates many objects, and the required memory space is insufficient, and it is recommended to increase the heap memory;
[0013] If the N heap memory usage rates of each initial sample are all less than the second threshold, then the tuning label of each initial sample is determined to include: According to the analysis, the current application may have the following problems: the heap memory usage rate continues to be lower than the second threshold. In order to avoid resource waste, it is recommended to reduce the heap memory, where the first threshold is greater than the second threshold. In this implementation, the N heap memory usage rates of an initial sample are all greater than the first threshold, and the tuning label of the initial sample includes content that recommends reducing the heap memory; or when the N heap memory usage rates of an initial sample are both greater than and less than the second threshold, the tuning label of the initial sample includes content that recommends increasing the heap memory. Since the heap memory in the N groups of performance data of the initial sample needs to meet the same conditions, the corresponding tuning label will be marked on the initial sample, so that the tuning label can reflect the actual performance of the target Java application, avoid marking of occasional situations, and make the marked tuning label more accurate.
[0014] In a possible implementation of the first aspect, the garbage collection log information includes: the total amount and used amount of memory in the old generation after the garbage collection is triggered, and the total amount and used amount of memory in the young generation after the garbage collection is triggered; the heap memory usage rate is obtained according to the following formula:
[0015]
[0016] In the formula, p H Indicates the heap memory usage, G Oused Indicates the amount of memory used in the old generation after garbage collection is triggered, G Yused Indicates the amount of memory used by the young generation after garbage collection is triggered, G Ototal Indicates the total amount of memory in the old generation after garbage collection is triggered, G Ytotal Represents the total amount of memory in the young generation after garbage collection is triggered.
[0017] In a possible implementation manner of the first aspect, each set of performance data in the historical performance data includes garbage collection log information, and each initial sample is labeled according to the N sets of performance data of each initial sample, including:
[0018] Using garbage collection log information of each set of performance data in the N sets of performance data of each initial sample, determine the metadata space usage rate corresponding to each set of performance data;
[0019] If the N metadata space usage rates of each initial sample are greater than the third threshold, determining the tuning label of each initial sample includes: according to the metadata space usage rate, recommending to increase the metadata space memory;
[0020] If the N metadata space usage rates of each initial sample are all less than the fourth threshold, then the tuning label of each initial sample is determined to include: based on the metadata space usage rate, it is recommended to reduce the metadata space memory; wherein the third threshold is greater than the fourth threshold. In this implementation, the N metadata space usage rates of an initial sample are all greater than the third threshold, and the tuning label of the initial sample includes content that recommends increasing the metadata space memory; or when the N metadata space usage rates of an initial sample are all greater than and less than the fourth threshold, the tuning label of the initial sample includes content that recommends reducing the heap memory. Since the metadata space usage rates in the N groups of performance data of the initial sample need to meet the same conditions, the initial sample will be labeled with the corresponding tuning label, so that the tuning label can reflect the actual performance of the target Java application, avoid labeling of occasional situations, and make the labeled tuning label more accurate.
[0021] In a possible implementation of the first aspect, the garbage collection log information includes: the used amount and capacity of the metadata space after the garbage collection is triggered; and the metadata space usage rate is obtained according to the following formula:
[0022]
[0023] In the formula, p M Indicates the metadata space usage, G Mused Indicates the amount of metadata space used after garbage collection is triggered, G Mtotal Indicates the capacity of the metadata space after garbage collection is triggered.
[0024] In a possible implementation manner of the first aspect, if each set of performance data in the N sets of performance data of the first initial sample includes a memory usage rate, and the first initial sample is any one of the multiple initial samples; labeling each initial sample according to the N sets of performance data of each initial sample includes:
[0025] If the N memory usage rates of the first initial sample are all greater than the fifth threshold, then the tuning label of the first initial sample is determined to include: According to the analysis, the current application may have the following problems: the system has a memory leak and the code needs to be fixed, or the server memory needs to be increased. In this implementation, each set of performance data in the N sets of performance data of the first initial sample includes memory usage. When the N memory usage rates of the first initial sample are all greater than the fifth threshold, the tuning label of the first initial sample includes that the system has a memory leak and the code needs to be fixed, or it is recommended to increase the server memory. Since the memory usage rates in the N sets of performance data of the first initial sample need to meet the same conditions, the corresponding tuning label will be marked on the first initial sample, so that the tuning label can reflect the actual performance of the target Java application, avoid marking of occasional situations, and make the marked tuning label more accurate.
[0026] In a possible implementation manner of the first aspect, if each set of performance data in the N sets of performance data of the second initial sample includes: memory usage, CPU usage, and thread status, and the second initial sample is any one of the multiple initial samples; according to the N sets of performance data of each initial sample, each initial sample is labeled, including:
[0027] If the N CPU usages of the second initial sample are all greater than the sixth threshold, the N thread states of the second initial sample are all runnable, and the difference between the maximum and minimum values of the N memory usages of the second initial sample is less than the seventh threshold, then determining the tuning tag of the second initial sample includes: According to the analysis, the current application may have the following problems: There may be a code dead loop, and it is recommended to check the relevant threads and codes;
[0028] If the N CPU usage rates of the second initial sample are all less than the eighth threshold, the tuning label of the second initial sample is determined to include: according to analysis, the JVM parameter settings are reasonable, the performance is good, and no adjustment is required; the eighth threshold is less than the sixth threshold.
[0029] In a second aspect, an embodiment of the present application provides a device for determining a JVM tuning solution, the device comprising: a unit for executing each step of the method described in any implementation manner of the first aspect above.
[0030] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method described in any one of the embodiments of the first aspect above are implemented.
[0031] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When a computer reads and executes the computer program or instructions, the computer executes the steps of the method described in any embodiment of the first aspect above.
[0032] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a server, enables the server to execute the steps of the method described in any one of the embodiments of the first aspect above.
[0033] In a sixth aspect, an embodiment of the present application provides a chip, comprising: a processor, configured to call and run a computer program from a memory, so that a computer device equipped with the chip executes a method as described in any one of the embodiments of the first aspect above.
[0034] It can be understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0036] Figure 1 It is a flowchart of a method for determining a JVM tuning solution provided by an embodiment of the present application;
[0037] Figure 2 It is a flowchart of a process of obtaining a JVM model in a method for determining a JVM tuning solution provided in an embodiment of the present application;
[0038] Figure 3 It is a flowchart of a process of determining a training sample set in a method for determining a JVM tuning solution provided in an embodiment of the present application;
[0039] Figure 4 It is a structural block diagram of a device for determining a JVM tuning solution provided by an embodiment of the present application;
[0040] Figure 5 It is a schematic diagram of the internal structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0041] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0042] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0043] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0044] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0045] In addition, in the description of the specification of this application and the attached claims, the terms "first", "second", "third", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0046] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0047] In order to make the present application easier to understand, some terms involved in the present application are explained below.
[0048] Large Language Model (LLM) refers to a deep learning model trained with a large amount of text data; a large language model can generate natural language text and understand the meaning of language text. Therefore, a large language model can be used to process a variety of natural language tasks, such as text classification, question answering, and dialogue.
[0049] GPT-2 and GPT-3: GPT is the abbreviation of Generative Pre-trained Transformer, which is a natural language processing model based on Transformer; GPT-2 and GPT-3 are both natural language processing models launched by OpenAI. GPT-3 is larger than GPT-2 and has more parameters, so GPT-3 can handle more complex natural language tasks than GPT-2 and perform better on some specific tasks.
[0050] BERT: The full name is Bidirectional Encoder Representation from Transformers. This model is a pre-training model proposed by Google AI Research Institute.
[0051] XLNet: XLNet is a natural language processing model based on autoregression and autoencoding. It is jointly developed by CMU and Google. The basic idea of XLNet is to combine autoregression and autoencoding to improve the performance of pre-trained language models.
[0052] RoBERTa: A natural language processing model launched by Facebook. The full name of the model is A RobustlyOptimized BERT, which means the powerfully optimized BERT method. Therefore, this model is an improved version of BERT.
[0053] T5: A natural language processing model launched by Google, which can be used for text generation, machine translation, etc.
[0054] Java, as a widely used computer programming language, is used to develop various types of applications. When necessary, Java applications need to be tuned to ensure the performance of Java applications. JVM tuning is one of the important means to optimize the performance of Java applications, which can effectively improve the operating efficiency and stability of Java applications.
[0055] The JVM tuning plan is the basis for JVM tuning, so an accurate JVM tuning plan is a necessary condition to ensure accurate JVM tuning. However, determining the JVM tuning plan is a complex task. In the process of determining the JVM tuning plan, multiple factors need to be considered, such as memory management, garbage collection strategy, and program execution efficiency. At present, the JVM tuning plan is generally determined by technicians based on their own experience and in combination with multiple factors. However, this method of determining the JVM tuning plan requires technicians to perform a large amount of data processing, and the accuracy of the JVM tuning plan is heavily dependent on the experience of the technicians. Therefore, there are technical problems such as low efficiency, easy errors, and high labor costs.
[0056] In view of the above technical problems, the present application provides a method for determining a JVM tuning scheme, the method comprising: obtaining multiple sets of performance data of a target Java application program continuously collected within a target time period, each set of performance data comprising: at least one of: garbage collection log information, memory and CPU usage data, and thread data; inputting the multiple sets of performance data into a preset JVM tuning model for processing, and obtaining a JVM tuning scheme for the target Java application program, the JVM tuning model being a processed large language model, and the JVM tuning scheme comprising: JVM adjustment suggestions. The method utilizes the JVM tuning model to generate a JVM tuning scheme, and does not require manual analysis of the performance data, so the efficiency is high; and the method uses the processed large language model as the JVM tuning model, making full use of the text generation capability of the large language model itself, and the processed pre-trained large language model has better adaptability to the JVM tuning process, so that the JVM tuning scheme obtained based on the JVM tuning model has a higher accuracy; and since the method mainly generates the JVM tuning scheme with the help of a preset JVM tuning model, the requirements for technical personnel are relatively low, so the labor cost can be reduced.
[0057] The following is an exemplary description of the method for determining the JVM tuning solution in the embodiment of the present application in conjunction with the accompanying drawings.
[0058] Figure 1 FIG. 1 is a flow chart of a method for determining a JVM tuning solution provided in an embodiment of the present application, such as Figure 1 As shown, the method may include S101 to S104. Each step is described below.
[0059] S101: Acquire multiple groups of performance data of a target Java application program collected continuously within a target time period, each group of performance data including at least one of garbage collection log information, memory and CPU usage data, and thread data.
[0060] Exemplarily, each set of performance data may include one of garbage collection log information, memory and CPU usage data, and thread data, or may include multiple types of garbage collection log information, memory and CPU usage data, and thread data.
[0061] In some embodiments, each set of performance data includes garbage collection log information. Since garbage collection log information is the best quality data for JVM tuning solutions, the accuracy of JVM tuning solutions can be guaranteed by making each set of performance data include garbage collection log information.
[0062] It can be understood that the method for obtaining multiple sets of performance data may include two processes: data collection and data preprocessing. The data collection process and the data preprocessing process are respectively described below.
[0063] Exemplarily, the data acquired during the data collection process may include initial garbage collection log information, initial memory and CPU usage data, and initial thread data.
[0064] It should be understood that the initial garbage collection log information is generally collected when the system GC (Garbage Collection) is triggered. The scenarios in which the system GC is triggered are mainly divided into two categories: 1. System triggering, that is, when the Java application is running, it checks according to the built-in conditions, and triggers GC if the trigger conditions are met; 2. Manual triggering, that is, the developer of the Java application triggers GC by calling the runtime.GC method in the business code.
[0065] The following is an exemplary description of the collection method of initial garbage collection log information, initial memory and CPU usage data, and initial thread data.
[0066] For example, the initial garbage collection log information can be obtained by adding the following JVM parameters to the Java application: -XX:+PrintGCDetails-XX:+PrintGCDateStamps-XX:+PrintHeapAtGC-Xloggc:. / logs / gc.log. The collection frequency of the initial garbage collection log information can be set as needed, for example, it can be set to collect once per second.
[0067] For example, the initial memory and CPU usage data can use the Prometheus monitoring tool, and the data collection frequency can be set as needed, for example, memory and CPU usage data can be collected once per second.
[0068] For another example, the initial thread data can be collected by using jstack, and the collection frequency can be set as needed, for example, once every 10 minutes.
[0069] It should be understood that the above data collection method is only an example and does not constitute a limitation on the scope of protection of this application.
[0070] In some embodiments, the process of preprocessing the initial garbage collection log information, initial memory and CPU usage data, and initial thread data may include data cleaning and formatting. After processing the initial garbage collection log information, initial memory and CPU usage data, and initial thread data, garbage collection log information, memory and CPU usage data, and thread data are obtained respectively.
[0071] Exemplarily, data cleaning may include: removing useless characters, blanks, line breaks, etc. from the collected data, and retaining key data that is helpful for performance analysis; formatting may include: arranging the cleaned data in chronological order, and organizing it into a text according to a preset format, and the formatted text corresponding to each type of performance data includes multiple features, that is, each type of data includes multiple features.
[0072] It is understandable that different types of data have different features after preprocessing. The features of different types of data are described below by way of example:
[0073] (1) Garbage collection log information may include the following features: timestamp, GC type, total amount and used amount of old generation (cms_generation) memory before GC is triggered, total amount and used amount of young generation (par_new_generation) memory before GC is triggered, used amount and capacity of metadata space (metaspace) before GC is triggered, total amount and used amount of old generation (cms_generation) memory after GC is triggered, total amount and used amount of young generation (par_new_generation) memory after GC is triggered, used amount and capacity of metadata space (metaspace) after GC is triggered, and GC duration (gc_duration).
[0074] (2) Memory and CPU usage data may include the following features: total memory, used memory, memory usage rate, and CPU usage rate.
[0075] (3) Thread data may include the following features: thread name, priority, thread state, thread ID, thread wait condition, and thread stack information.
[0076] It should be understood that those skilled in the art can increase or decrease the features included in different types of performance data as needed, and this application does not impose specific limitations on this.
[0077] S102: Input multiple groups of performance data into a preset JVM tuning model for processing to obtain a JVM tuning solution for a target Java application. The JVM tuning model is a processed large language model. The JVM tuning solution includes JVM adjustment suggestions.
[0078] Exemplarily, the JVM adjustment suggestion may be a text string, and may include suggestions on memory adjustment, thread optimization, JVM parameter adjustment, etc.
[0079] Exemplarily, the large language model may include: any one of GPT-2, GPT-3, BERT, RoBERTa, XLNet, and T5. For the explanation of each large language model, please refer to the glossary section in the previous text, which will not be repeated here.
[0080] It should be understood that the processed large language model may be a large language model that has been fine-tuned (or retrained).
[0081] In some embodiments, the tuning scheme may further include: adjusted JVM parameters, wherein the adjusted JVM parameters may be obtained according to the JVM adjustment suggestion and the JVM parameters before adjustment. By displaying the adjusted JVM parameters in the tuning scheme, it is convenient for the user to directly adjust the JVM parameters according to the adjusted JVM parameters.
[0082] Exemplarily, the tuning plan may also include problem analysis information, which includes an analysis process based on performance data. By displaying the problem analysis information in the tuning plan, the user can clearly understand the basis for obtaining the JVM adjustment suggestion, which facilitates the user to judge the rationality of the tuning plan.
[0083] In the above method for determining the JVM tuning scheme, the processed large language model is used as the JVM tuning model, and the JVM tuning scheme of the target Java application is obtained by inputting multiple sets of performance data collected continuously from the target Java application into the JVM tuning model. The method uses the JVM tuning model to generate the JVM tuning scheme, and does not require manual analysis of the performance data, so it is highly efficient; and the method uses the processed large language model as the JVM tuning model, making full use of the text generation ability of the large language model itself, and the processed pre-trained large language model has better adaptability to the JVM tuning process, so that the JVM tuning scheme obtained based on the JVM tuning model has higher accuracy; and because the method generates the JVM tuning scheme with the help of a preset JVM tuning model, the requirements for technicians are relatively low, so the labor cost can be reduced.
[0084] For ease of understanding, the process of obtaining the JVM model is exemplarily described below with reference to the accompanying drawings. Figure 2 FIG. 1 is a flow chart of the process of obtaining a JVM model in a method for determining a JVM tuning solution in an embodiment of the present application. Figure 2 As shown, the process of obtaining the JVM model includes: S201 to S203. Each step is described below.
[0085] S201. Acquire historical performance data, where the historical performance data includes multiple groups of performance data generated by multiple different Java applications before a target time period.
[0086] It should be understood that the historical performance data is the performance data before the target time period, and the historical performance data includes the performance data of multiple different Java applications, wherein the multiple different Java applications may include the target Java application or may not include the target Java application, which is not described in detail in this application.
[0087] Exemplarily, the multiple different Java applications may be Java applications of two or more types, so that the historical performance data can represent more types of Java applications, fully broadening the application scope of the method for determining a JVM tuning solution.
[0088] Exemplarily, the historical performance data is the same as the aforementioned performance data. In the multiple groups of performance data of the historical performance data, each group of performance data may include: at least one of garbage collection log information, memory and CPU usage data, and thread data.
[0089] In some embodiments, each set of performance data in the multiple sets of performance data of the historical performance data includes garbage collection log information. Since garbage collection log information is the best quality data for performing JVM tuning schemes, the accuracy of JVM tuning schemes can be ensured by making each set of performance data include garbage collection log information.
[0090] In some embodiments, the method for obtaining historical performance data is similar to the aforementioned method for obtaining multiple sets of performance data of the target Java application, and can also be divided into two processes: data collection and data preprocessing. The specific method can be described in the previous article and will not be repeated here.
[0091] S202: Construct a training sample set based on historical performance data, where the training sample set includes multiple training samples.
[0092] S203: Use the training sample set to train the large language model to obtain a preset JVM tuning model.
[0093] It can be understood that the large language model is a model that has been pre-trained on a large-scale data set. In the embodiment of the present application, historical performance data is used to construct a training sample set, and the pre-trained large language model is trained again (also called fine-tuning) using the training sample set to obtain a JVM tuning model with better accuracy.
[0094] For ease of understanding, the process of determining a training sample set is exemplarily described below with reference to the accompanying drawings. Figure 3 FIG. 1 is a flow chart of the process of determining a training sample set in a method for determining a JVM tuning solution in an embodiment of the present application. Figure 3 As shown, the process of determining the training sample set may include: S301 to S303. Each step is described below.
[0095] S301. Determine multiple initial samples based on historical performance data, each initial sample includes N groups of performance data belonging to the same Java application, where N is a positive integer greater than 1, the N groups of performance data of each initial sample are collected continuously, and each group of performance data belongs to only one initial sample.
[0096] For example, suppose that the historical performance data includes 50,000 sets of performance data in total, and the 50,000 sets of performance data belong to the performance data of 5 different Java applications, and each Java application corresponds to 10,000 sets of performance data. If N is 10, that is, 10 sets of performance data collected continuously from each Java application are used as an initial sample. Then each Java application corresponds to 1,000 initial samples, so a total of 50,000 initial samples.
[0097] It is understandable that the value of N can be set as needed, and this application does not impose any limitation on this.
[0098] In some embodiments, each set of performance data in the multiple sets of performance data of the historical performance data includes garbage collection log information. In order to ensure that each set of performance data includes garbage collection log information, the GC trigger frequency of the system can be set to be greater than the first frequency (i.e., the initial collection frequency of memory and CPU usage data) and the second frequency (i.e., the initial collection frequency of thread data). Therefore, each set of performance data includes garbage collection log information, but not necessarily memory and CPU usage data and thread data.
[0099] S302 . Label each initial sample according to the N groups of performance data of each initial sample to obtain a labeled sample corresponding to each initial sample, where the labeled sample includes the corresponding initial sample and a tuning label.
[0100] Exemplarily, each initial sample may be labeled according to a preset tuning label, and the labeling process is the process of assigning a tuning label to each initial sample. The tuning label may include: JVM adjustment suggestions.
[0101] It is understandable that the JVM tuning suggestions included in the tuning tags are used to guide the output content of the large language model. In the subsequent model use process, the output content (i.e., JVM tuning solution) of the trained large language model (i.e., JVM tuning model) can come directly from a tuning tag, or other content can be added on the basis of the tuning tag.
[0102] For example, in a JVM tuning solution, the JVM tuning suggestions included may be JVM tuning suggestions in a certain tuning tag, and adjusted JVM parameters, wherein the adjusted JVM parameters may be obtained according to the JVM tuning suggestions and the JVM parameters before adjustment.
[0103] It is understandable that the tuning tags may include: tuning suggestions for server memory, tuning suggestions for heap memory, tuning suggestions for metadata control memory, etc. The type of tuning suggestion is related to the type of data included in the N groups of performance data. The following is an exemplary description of the labeling process.
[0104] Exemplarily, garbage collection log information may include the following features: timestamp, GC type, total amount and used amount of old generation (cms_generation) memory before GC is triggered, total amount and used amount of young generation (par_new_generation) memory before GC is triggered, used amount and capacity of metadata space (metaspace) before GC is triggered, total amount and used amount of old generation (cms_generation) memory after GC is triggered, total amount and used amount of young generation (par_new_generation) memory after GC is triggered, used amount and capacity of metadata space (metaspace) after GC is triggered, GC duration (gc_duration). Memory and CPU usage data may include the following features: total memory, used memory, memory usage, and CPU usage. Thread data may include the following features: thread name, priority, thread state, thread ID, thread wait condition, and thread stack information.
[0105] The following describes the process of labeling the initial samples based on the local features in the garbage collection log information, memory and CPU usage data, and thread data.
[0106] In some embodiments, each set of performance data in the historical performance data includes garbage collection log information. When annotating the initial sample:
[0107] First, the garbage collection log information of each set of performance data in each of the N sets of performance data of each initial sample is used to determine the heap memory usage corresponding to each set of performance data. Specifically, the heap memory usage can be determined according to formula (1):
[0108]
[0109] In formula (1), p H Indicates the heap memory usage, G Oused Indicates the amount of memory used in the old generation after garbage collection is triggered, G Yused Indicates the amount of memory used by the young generation after garbage collection is triggered, G Ototal Indicates the total amount of memory in the old generation after garbage collection is triggered, G Ytotal Represents the total amount of memory in the young generation after garbage collection is triggered.
[0110] If the N heap memory usage rates of any initial sample are greater than the first threshold (for example, the first threshold may be 90%), the tuning label of the initial sample T1 is determined to include: According to the analysis, the current application may have the following problems: the heap memory usage rate is continuously higher than the first threshold, the application generates many objects and requires insufficient memory space, and it is recommended to increase the heap memory.
[0111] If the N heap memory usage rates of any initial sample are less than the second threshold (for example, the second threshold may be 30%), then the tuning label of the initial sample is determined to include: According to the analysis, the current application may have the following problems: The heap memory usage rate is continuously lower than the second threshold. To avoid wasting resources, it is recommended to reduce the heap memory.
[0112] In some embodiments, each set of performance data in the historical performance data includes garbage collection log information. When annotating the initial sample:
[0113] First, the garbage collection log information of each group of performance data in each initial sample is used to determine the metadata space usage rate corresponding to each group of performance data. The metadata space usage rate can be obtained according to formula (2):
[0114]
[0115] In the formula, p M Indicates the metadata space usage, G Mused Indicates the amount of metadata space used after garbage collection is triggered, G Mtotal Indicates the capacity of the metadata space after garbage collection is triggered.
[0116] If the N metadata space usage rates of any initial sample are greater than a third threshold (for example, the third threshold may be 95%), determining the tuning tag of the initial sample includes: according to the metadata space usage rate, suggesting to increase the metadata space memory;
[0117] If the N metadata space usage rates of any initial sample are less than the fourth threshold (for example, the fourth threshold may be 50%), then determining the tuning label of the initial sample includes: based on the metadata space usage rate, it is recommended to reduce the metadata space memory; wherein the third threshold is greater than the fourth threshold.
[0118] In some embodiments, if each of the N groups of performance data of the first initial sample includes memory and CPU usage data (that is, includes memory usage), and the first initial sample is any one of the multiple initial samples; then when marking the first initial sample:
[0119] If the N memory usage rates of the first initial sample are all greater than the fifth threshold (for example, the fifth threshold may be 80%), determining the tuning label of the first initial sample includes: based on analysis, the current application may have the following problems: the system has a memory leak and the code is fixed, or the server memory is increased.
[0120] In some embodiments, if each of the N groups of performance data of the second initial sample includes: memory and CPU usage data (i.e., including memory usage and CPU usage) and thread data (i.e., including thread status), and the second initial sample is any one of the multiple initial samples; then when marking the second initial sample:
[0121] If the N CPU usages of the second initial sample are all greater than the sixth threshold (for example, the sixth threshold may be 90%), the N thread states of the second initial sample are all runnable, and the difference between the maximum and minimum values of the N memory usages of the second initial sample is less than the seventh threshold (for example, the sixth threshold may be 20%), then the tuning tag of the second initial sample is determined to include: According to the analysis, the current application may have the following problems: There may be a code dead loop, and it is recommended to check the relevant threads and codes. It can be understood that the seventh threshold is a relatively small percentage, and the difference between the N memory usages in the second initial sample is relatively small.
[0122] If the N CPU usage rates of the second initial sample are all less than the eighth threshold (for example, the sixth threshold may be 50% or 60%), then the tuning label of the second initial sample is determined to include: according to the analysis, the JVM parameter settings are reasonable, the performance is good, and no adjustment is required; wherein the eighth threshold is less than the sixth threshold. It can be understood that since the initial sample is labeled according to the N groups of performance data included in the initial sample, the correspondence between the tuning label of the initial sample and the initial sample is improved.
[0123] It should be understood that each of the above steps of determining the tuning label corresponds to a sample labeling rule. The above rule of labeling by N CPU usage rates being less than the eighth threshold is that when it is determined that the second initial sample does not meet any of the above sample labeling rules, the second initial sample is judged whether it meets the "N CPU usage rates are less than the eighth threshold".
[0124] It can be understood that the above content is only an exemplary explanation of the annotation rules. Based on the above examples, technical personnel in this field can clearly understand the method for determining the JVM tuning solution in the embodiment of the present application. For the sake of simplicity, the annotation rules will not be enumerated.
[0125] In some embodiments, the tuning tag also includes: adjusted JVM parameters, which can be obtained according to the JVM adjustment suggestion and the JVM parameters before adjustment. This application will not elaborate on this.
[0126] S303: Determine a training sample set according to the multiple labeled samples, where each training sample in the training sample set includes a labeled sample.
[0127] In some embodiments, the multiple labeled samples can be divided into a training sample set and a test sample set, that is, some samples in the multiple standard samples constitute the training samples, and some samples constitute the test sample set. The training sample set is used to train (or fine-tune) the large language model, and the test sample set is used to test the trained model to determine the accuracy of the model.
[0128] After introducing sample annotation, the following uses the GT-2 model as an example to illustrate the process of training (or fine-tuning) a large language model.
[0129] The GPT-2 model has been pre-trained on a large-scale dataset and can provide good performance and efficiency. We use deep learning frameworks such as Hugging Face Transformers to fine-tune the GPT-2 model to adapt to the unstructured characteristics of performance data and tuning solutions. The GPT-2 model is fine-tuned using the pre-processed performance data to obtain a JVM tuning model, thereby predicting the causes and solutions to JVM performance issues (i.e., obtaining a JVM tuning solution). The specific fine-tuning process includes the following steps:
[0130] 1. Define the goal of the fine-tuning task
[0131] Prediction target: Classification prediction provides corresponding tuning suggestions for JVM garbage collection log information, monitoring indicators (such as memory and CPU usage data, thread data), etc.
[0132] Evaluation indicator: classification accuracy.
[0133] 2. Import the PyTorch GPT-2 model and create a new model for JVM tuning.
[0134] 3. Fine-tune parameter settings
[0135] Set the hyperparameters for fine-tuning such as learning rate, batch size, and number of epochs. These parameters can be adjusted through experiments to achieve the best performance.
[0136] 4. Freeze some layers
[0137] The GPT-2 model is a neural network model based on the Transformer architecture. The architecture of the GPT-2 model is composed of multiple blocks, each of which contains two sub-layers: a multi-head self-attention layer and a feedforward neural network layer. For example, in some embodiments, the large language model can select the GPT-2Small model, which includes more than 12 block structures, namely, 12 multi-head self-attention layers and 12 feedforward neural network layers respectively arranged in 12 blocks.
[0138] In fine-tuning, only some blocks of the model are fine-tuned, while the weights of other blocks are kept unchanged (i.e., other blocks are frozen). It is understandable that different fine-tuning methods can be tried by changing the frozen blocks, so that the optimal model can be determined as the JVM tuning model from multiple fine-tuned models obtained by multiple different fine-tuning methods.
[0139] Fine-tuning a model by freezing some blocks has the following advantages:
[0140] (1) It can reduce computational overhead: Since pre-trained Transformer models such as GPT-2 usually contain millions or even hundreds of millions of parameters, if backpropagation and parameter updates are performed on all layers during fine-tuning, the computational cost will be very high. Freezing some blocks can significantly reduce the number of parameters that need to be updated, thereby reducing the computational overhead of the training process.
[0141] (2) Preserve the model’s language understanding ability: Since the GPT-2 pre-trained model is trained on large-scale data, it has learned rich language representation and context understanding capabilities, which are beneficial for most NLP tasks. Therefore, freezing some blocks can preserve these capabilities of the GPT-2 pre-trained model.
[0142] (3) Preventing overfitting: When the dataset size of the training sample set is relatively small, fine-tuning the entire pre-trained model using the sample set may lead to the risk of overfitting. Freezing some blocks can reduce the risk of overfitting.
[0143] 5. Fine-tune the model (or train the model)
[0144] In order to avoid overfitting, some regularization techniques can be used, such as Dropout. Dropout is a very effective regularization technique, often used in neural networks to avoid overfitting. Its working principle is that during the training process, a part of the neurons are randomly set to output 0, that is, these neurons are "discarded". The neurons randomly discarded are different in each iterative learning. This can enhance the generalization ability of the model, prevent the model from over-relying on the weights of certain neurons, and avoid "overfitting" of the training data.
[0145] In the embodiment of the present application, the specific method of adding Dropout in the GPT-2 model fine-tuning process includes: (1) adding a Dropout layer after the multi-head self-attention mechanism (Multi-head Attention) layer in each block of the GPT-2 model. (2) Setting the dropout ratio (dropout_rate), for example, when the dropout ratio is 0.1, it means randomly dropping 10% of the neurons. During training, the Dropout layer will randomly set the neuron output to 0 in proportion. During inference, dropout is not used, but the dropout ratio (dropout_rate) is used as a scaling factor.
[0146] By adding the Dropout layer, overfitting can be effectively combated without requiring a lot of extra calculations. The specific dropout ratio setting can be selected based on multiple experiments to select the optimal value.
[0147] 6. Verify the model
[0148] During the fine-tuning process, we need to validate the model to determine its performance and accuracy. We can use a portion of the reserved labeled samples as a validation dataset for validation, such as using cross-validation techniques. During the validation process, we can record the model's loss function value, accuracy, and other indicators to evaluate the model's performance.
[0149] 7. Test Model
[0150] After the fine-tuning process is completed, we need to test the obtained model to evaluate the generalization ability and actual application effect of the model. Another part of the data (such as the reserved test set) can be used for testing. During the test process, we can record the model's loss function value, accuracy and other indicators to evaluate the performance of the model and its actual application effect.
[0151] In the GPT-2 fine-tuning code, the model training results can be detected in the following ways:
[0152] (1) Check the training log: trainer.train() will output a log by default, which contains the training loss function value of each epoch, so as to determine whether the loss function value is decreasing.
[0153] (2) Set up evaluation: Separate part of the data set as the evaluation set. Do not use this part of the data during training. At the end of each training iteration, test the model on the evaluation set and record indicators such as the loss function value. Observe whether these indicators continue to optimize on the evaluation set to determine overfitting. Based on the results of the evaluation set, select the best model parameters or stop training early.
[0154] (3) Use training process callback: You can customize the callback function, which is executed after each training step and obtains the current model status.
[0155] (4) Save model checkpoints: By default, train will save checkpoints regularly. You can load the checkpoints and test the performance of the model on the samples.
[0156] (5) TensorBoard log analysis: Enable TensorBoard log and view the loss and accuracy curves after training.
[0157] In some embodiments, a Dubbo application often encounters problems of excessive memory usage and frequent GC in high concurrency scenarios. The JVM tuning model in the embodiment of this application is used to predict the cause and solution of the problem. The specific steps are as follows:
[0158] 1. Data collection: Get the initial garbage collection log information (i.e. JVM log), initial memory and CPU usage data, initial thread data, etc. of the Dubbo application.
[0159] 2. Data preprocessing: Preprocess the collected data, such as data cleaning and formatting. You can use the Python programming language and related libraries to preprocess the collected data, such as using regular expressions to extract key information from logs and normalize performance indicators.
[0160] 3. Model analysis: Input the preprocessed data into the JVM tuning model (i.e., the fine-tuned GPT-2 model), analyze the preprocessed data, extract performance bottlenecks and potential optimization directions, and obtain specific suggestions as follows:
[0161] (1) Adjust the heap size: Based on the predicted memory usage, we recommend adjusting the heap size appropriately to reduce GC frequency and pause time.
[0162] (2) Selecting a suitable garbage collector: We recommend selecting a garbage collector that is suitable for your application, such as G1 or CMS, to optimize GC performance.
[0163] (3) Optimize object creation and destruction: We recommend optimizing the creation and destruction of objects in your application, such as using object pools and avoiding frequent object creation, to reduce memory usage and GC frequency.
[0164] (4) Adjust thread pool parameters: We recommend adjusting thread pool parameters, such as thread pool size and queue capacity, to optimize the concurrent performance of the application.
[0165] (5) Code optimization: We recommend optimizing the application code for performance, such as reducing lock contention and avoiding frequent calls to synchronization methods, to improve application performance.
[0166] Through the above steps, we can use the GPT-2 model to achieve JVM performance tuning and provide intelligent performance optimization suggestions for applications.
[0167] It can be understood that the JVM tuning solution obtained according to the method in the embodiment of the present application can be used as the final JVM tuning; the JVM tuning solution obtained according to the method in the embodiment of the present application can also be used as a reference material for technicians, who can verify and optimize the JVM tuning solution before using it for JVM tuning.
[0168] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0169] Corresponding to the method for determining a JVM tuning solution in the above embodiment, an embodiment of the present application also provides a device for determining a JVM tuning solution, which includes a unit for executing each step executed by the server in the method for determining a JVM tuning solution in any of the above embodiments.
[0170] The following is an exemplary description of the device for determining the JVM tuning solution in the embodiment of the present application in conjunction with the accompanying drawings.
[0171] like Figure 4 FIG. 1 is a block diagram of a device for determining a JVM tuning solution according to an embodiment of the present application. For ease of explanation, only the part related to the embodiment of the present application is shown. Figure 4 The device 400 for determining a JVM tuning solution includes: a first data acquisition unit 410 and a tuning solution determination unit 420: wherein:
[0172] The first data acquisition unit 410 is used to acquire multiple sets of performance data of the target Java application program continuously collected within a target time period, each set of performance data includes: garbage collection log information, memory and CPU usage data, and thread data.
[0173] The tuning scheme determination unit 420 is used to input multiple sets of performance data into a preset JVM tuning model for processing to obtain a JVM tuning scheme for a target Java application. The JVM tuning model is a processed large language model. The JVM tuning scheme includes JVM adjustment suggestions.
[0174] Optionally, the large language model includes: any one of GPT-2, GPT-3, BERT, RoBERTa, XLNet, and T5.
[0175] Optionally, the device 400 for determining a JVM tuning solution further includes: a second data acquisition unit, a training sample set determination unit, and a model training unit, wherein:
[0176] A second data acquisition unit is used to acquire historical performance data, where the historical performance data includes multiple groups of performance data generated by multiple different Java applications before a target time period;
[0177] A training sample set determination unit, used to construct a training sample set according to historical performance data, wherein the training sample set includes a plurality of training samples;
[0178] The model training unit is used to train the large language model using the training sample set to obtain a preset JVM tuning model.
[0179] Optionally, the training sample set determination unit is used to construct a training sample set according to the historical performance data, where the training sample set includes multiple training samples, including:
[0180] Determine multiple initial samples according to the historical performance data, each initial sample includes N groups of performance data belonging to the same Java application, where N is a positive integer greater than 1, the N groups of performance data of each initial sample are collected continuously, and each group of performance data belongs to only one initial sample;
[0181] According to the N groups of performance data of each initial sample, each initial sample is labeled to obtain a labeled sample corresponding to each initial sample, where the labeled sample includes the corresponding initial sample and a tuning label;
[0182] A training sample set is determined according to the multiple labeled samples, wherein each training sample in the training sample set includes a labeled sample.
[0183] Optionally, each set of performance data in the historical performance data includes garbage collection log information, and the training sample set determination unit is used to label each initial sample according to the N sets of performance data of each initial sample, including:
[0184] Using garbage collection log information of each set of performance data in the N sets of performance data of each initial sample, determine the heap memory usage corresponding to each set of performance data;
[0185] If the N heap memory usage rates of each initial sample are all greater than the first threshold, then determining the tuning label of each initial sample includes: According to the analysis, the current application may have the following problems: the heap memory usage rate is continuously higher than the first threshold, the application generates many objects, and the required memory space is insufficient, and it is recommended to increase the heap memory;
[0186] If the N heap memory usage rates of each initial sample are all less than the second threshold, then the tuning label of each initial sample is determined to include: Based on the analysis, the current application may have the following problems: The heap memory usage rate is continuously lower than the second threshold. To avoid wasting resources, it is recommended to reduce the heap memory, where the first threshold is greater than the second threshold.
[0187] Optionally, the garbage collection log information includes: the total amount and used amount of the old generation memory after the garbage collection is triggered, the total amount and used amount of the young generation memory after the garbage collection is triggered; the heap memory usage rate is obtained according to the following formula:
[0188]
[0189] In the formula, p H Indicates the heap memory usage, G Oused Indicates the amount of memory used in the old generation after garbage collection is triggered, G Yused Indicates the amount of memory used by the young generation after garbage collection is triggered, G Ototal Indicates the total amount of memory in the old generation after garbage collection is triggered, G Ytotal Represents the total amount of memory in the young generation after garbage collection is triggered.
[0190] Optionally, each set of performance data in the historical performance data includes garbage collection log information, and the training sample set determination unit is used to label each initial sample according to the N sets of performance data of each initial sample, including:
[0191] Using garbage collection log information of each set of performance data in the N sets of performance data of each initial sample, determine the metadata space usage rate corresponding to each set of performance data;
[0192] If the N metadata space usage rates of each initial sample are greater than the third threshold, determining the tuning label of each initial sample includes: according to the metadata space usage rate, recommending to increase the metadata space memory;
[0193] If the N metadata space usage rates of each initial sample are less than the fourth threshold, determining the tuning label of each initial sample includes: based on the metadata space usage rate, it is recommended to reduce the metadata space memory; wherein the third threshold is greater than the fourth threshold.
[0194] Optionally, the garbage collection log information includes: the used amount and capacity of the metadata space after the garbage collection is triggered; the metadata space usage rate is obtained according to the following formula:
[0195]
[0196] In the formula, p M Indicates the metadata space usage, G Mused Indicates the amount of metadata space used after garbage collection is triggered, G Mtotal Indicates the capacity of the metadata space after garbage collection is triggered.
[0197] Optionally, if each of the N groups of performance data of the first initial sample includes memory usage, and the first initial sample is any one of the multiple initial samples; the training sample set determination unit is used to label each initial sample according to the N groups of performance data of each initial sample, including:
[0198] If the N memory usage rates of the first initial sample are all greater than the fifth threshold, determining the tuning label of the first initial sample includes: based on the analysis, the current application may have the following problems: the system has a memory leak and the code is fixed, or the server memory is increased.
[0199] Optionally, if each of the N groups of performance data of the second initial sample includes: memory usage, CPU usage, and thread status, and the second initial sample is any one of the multiple initial samples; the training sample set determination unit is used to label each initial sample according to the N groups of performance data of each initial sample, including:
[0200] If the N CPU usages of the second initial sample are all greater than the sixth threshold, the N thread states of the second initial sample are all runnable, and the difference between the maximum and minimum values of the N memory usages of the second initial sample is less than the seventh threshold, then determining the tuning tag of the second initial sample includes: According to the analysis, the current application may have the following problems: There may be a code dead loop, and it is recommended to check the relevant threads and codes;
[0201] If the N CPU usage rates of the second initial sample are all less than the eighth threshold, the tuning label of the second initial sample is determined to include: according to analysis, the JVM parameter settings are reasonable, the performance is good, and no adjustment is required; the eighth threshold is less than the sixth threshold.
[0202] It should be understood that the specific process of each unit in the device 400 for determining the JVM tuning solution executing the above corresponding steps can be referred to the description related to the method for determining the JVM tuning solution in the previous text, and for the sake of brevity, it is not repeated here.
[0203] An embodiment of the present application also provides a computer device 500. Figure 5 As shown, the computer device 500 of this embodiment includes: a processor 501, a memory 502, and a computer program 504 stored in the memory 502 and executable on the processor 501. The computer program 504 can be executed by the processor 501 to generate instructions 503, and the processor 501 can implement the steps in the above-mentioned method embodiments for determining a JVM tuning solution according to the instructions 503. Alternatively, when the processor 501 executes the computer program 504, the functions of the modules / units in the above-mentioned device embodiments are implemented, such as Figure 4 The functions of the first data acquisition unit 410 to the tuning solution determination unit 420 are shown.
[0204] Exemplarily, the computer program 504 may be divided into one or more modules / units, one or more modules / units are stored in the memory 502, and are executed by the processor 501 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program 504 in the computer device 500.
[0205] Those skilled in the art will understand that Figure 5 This is only an example of the computer device 500 and does not constitute a limitation of the computer device 500. The computer device 500 may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, the computer device 500 may also include input and output devices, network access devices, buses, etc.
[0206] The processor 501 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0207] The memory 502 may be an internal storage unit of the computer device 500, such as a hard disk or memory of the computer device 500. The memory 502 may also be an external storage device of the computer device 500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 500. Further, the memory 502 may also include both an internal storage unit of the computer device 500 and an external storage device. The memory 502 is used to store computer programs and other programs and data required by the computer device 500. The memory 502 may also be used to temporarily store data that has been output or is to be output.
[0208] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0209] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program or instruction is stored, and when the computer reads and executes the computer program or instruction, the computer executes the steps in the above-mentioned various method embodiments. The readable medium can be a read-only memory (ROM) or a random access memory (RAM), which is not limited in the embodiment of the present application.
[0210] Exemplarily, the computer program or instructions in the computer-readable storage medium are implemented using aspect-oriented programming techniques.
[0211] An embodiment of the present application provides a computer program product. When the computer program product runs on a server, the server can implement the steps in the above-mentioned method embodiments when executing the server.
[0212] The present application also provides a chip, which includes: a processing unit and a communication unit, wherein the processing unit may be, for example, a processor, and the communication unit may be, for example, an input / output interface, a pin or a circuit, etc. The processing unit may execute computer instructions to enable a computer device to execute a method in any of the above-mentioned method embodiments.
[0213] Optionally, the computer instructions are stored in a storage unit.
[0214] Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the terminal, such as a ROM or other types of static storage devices that can store static information and instructions, random RAM, etc. Among them, the processor mentioned in any of the above can be a CPU, a microprocessor, an ASIC, or one or more integrated circuits for controlling the display of the above-mentioned electronic device and the execution of the program of the control method. The processing unit and the storage unit can be decoupled and respectively set on different physical devices, and connected by wired or wireless means to realize the respective functions of the processing unit and the storage unit, so as to support the system chip to realize the various functions in the above-mentioned embodiments. Alternatively, the processing unit and the memory can also be coupled on the same device.
[0215] It can be understood that the chip provided in the embodiment of the present application can be an integrated circuit for implementing any of the above methods for determining a JVM tuning solution, and the main function of the chip is to execute the steps or processes defined by the method for determining a JVM tuning solution in the embodiment of the present application, that is, to implement the method for determining a JVM tuning solution in the embodiment of the present application by hardware. The computer-readable storage medium provided in the embodiment of the present application is mainly used to store a computer program, which, when executed, implements the steps or processes defined by any of the above methods for determining a JVM tuning solution, that is, to implement the method for determining a JVM tuning solution in the embodiment of the present application by computer software.
[0216] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0217] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0218] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are merely schematic, for example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0219] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0220] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0221] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the device / server, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0222] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for determining a JVM tuning solution, characterized in that: The method comprises: Acquire multiple sets of performance data of a target Java application program collected continuously within a target time period, each set of performance data including at least one of: garbage collection log information, memory and CPU usage data, and thread data; The multiple groups of performance data are input into a preset JVM tuning model for processing to obtain a JVM tuning solution for the target Java application. The JVM tuning model is a processed large language model. The JVM tuning solution includes: JVM adjustment suggestions.
2. The method according to claim 1, characterized in that The large language model includes: any one of GPT-2, GPT-3, BERT, RoBERTa, XLNet, and T5.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: Acquire historical performance data, the historical performance data including multiple groups of performance data generated by multiple different Java applications before the target time period; Constructing a training sample set according to the historical performance data, wherein the training sample set includes a plurality of training samples; The large language model is trained using the training sample set to obtain the preset JVM tuning model.
4. The method according to claim 3, characterized in that The step of constructing a training sample set according to the historical performance data includes: Determine a plurality of initial samples according to the historical performance data, each initial sample including N groups of performance data belonging to the same Java application, wherein N is a positive integer greater than 1, the N groups of performance data of each initial sample are collected continuously, and each group of performance data belongs to only one initial sample; According to the N groups of performance data of each initial sample, each initial sample is labeled to obtain a labeled sample corresponding to each initial sample, wherein the labeled sample includes the corresponding initial sample and a tuning label; The training sample set is determined according to the multiple labeled samples, wherein each training sample in the training sample set includes a labeled sample.
5. The method according to claim 4, characterized in that Each set of performance data in the historical performance data includes garbage collection log information, and the marking of each initial sample according to the N sets of performance data of each initial sample includes: Determine the heap memory usage corresponding to each set of performance data by using garbage collection log information of each set of performance data in the N sets of performance data of each initial sample; If the N heap memory usage rates of each of the initial samples are greater than the first threshold, determining the tuning label of each of the initial samples includes: according to the analysis, the current application may have the following problems: the heap memory usage rate is continuously higher than the first threshold, the application generates many objects, and the required memory space is insufficient, and it is recommended to increase the heap memory; If the N heap memory usage rates of each of the initial samples are less than the second threshold, determining the tuning label of each of the initial samples includes: based on analysis, the current application may have the following problems: the heap memory usage rate is continuously lower than the second threshold, and to avoid waste of resources, it is recommended to reduce the heap memory, where the first threshold is greater than the second threshold.
6. The method according to claim 5, characterized in that The garbage collection log information includes: the total amount and used amount of memory in the old generation after the garbage collection is triggered, and the total amount and used amount of memory in the young generation after the garbage collection is triggered; the heap memory usage rate is obtained according to the following formula: In the formula, p H Indicates the heap memory usage, G Oused Indicates the amount of memory used in the old generation after garbage collection is triggered, G Yused Indicates the amount of memory used by the young generation after garbage collection is triggered, G Ototal Indicates the total amount of memory in the old generation after garbage collection is triggered, G Ytotal Represents the total amount of memory in the young generation after garbage collection is triggered.
7. The method according to claim 4, characterized in that Each set of performance data in the historical performance data includes garbage collection log information, and the marking of each initial sample according to the N sets of performance data of each initial sample includes: Determine the metadata space usage rate corresponding to each set of performance data by using garbage collection log information of each set of performance data in the N sets of performance data of each initial sample; If the N metadata space usage rates of each of the initial samples are greater than the third threshold, determining the tuning label of each of the initial samples includes: recommending increasing the metadata space memory according to the metadata space usage rate; If the N metadata space usage rates of each of the initial samples are less than the fourth threshold, determining the tuning label of each of the initial samples includes: based on the metadata space usage rate, it is recommended to reduce the metadata space memory; wherein the third threshold is greater than the fourth threshold.
8. The method according to claim 7, characterized in that The garbage collection log information includes: the used amount and capacity of the metadata space after the garbage collection is triggered; the metadata space usage rate is obtained according to the following formula: In the formula, p M Indicates the metadata space usage, G Mused Indicates the amount of metadata space used after garbage collection is triggered, G Mtotal Indicates the capacity of the metadata space after garbage collection is triggered.
9. The method according to claim 4, characterized in that If each of the N groups of performance data of the first initial sample includes memory usage, the first initial sample is any one of the multiple initial samples; The step of labeling each initial sample according to the N groups of performance data of each initial sample includes: If the N memory usage rates of the first initial sample are all greater than the fifth threshold, determining the tuning label of the first initial sample includes: based on analysis, the current application may have the following problems: the system has a memory leak and the code is fixed, or the server memory is increased.
10. The method according to claim 4, characterized in that If each of the N groups of performance data of the second initial sample includes: memory usage, CPU usage, and thread status, and the second initial sample is any one of the multiple initial samples; the marking of each initial sample according to the N groups of performance data of each initial sample includes: If the N CPU usages of the second initial sample are all greater than the sixth threshold, the N thread states of the second initial sample are all runnable, and the difference between the maximum and minimum values of the N memory usages of the second initial sample is less than the seventh threshold, then determining the tuning tag of the second initial sample includes: according to the analysis, the current application may have the following problems: there may be a code dead loop, and it is recommended to check the relevant threads and codes; If the N CPU usage rates of the second initial sample are all less than the eighth threshold, determining the tuning label of the second initial sample includes: according to analysis, the JVM parameter settings are reasonable, the performance is good, and no adjustment is required; wherein the eighth threshold is less than the sixth threshold.
11. A device for determining a JVM tuning solution, characterized in that: The device comprises means for performing the steps of the method according to any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or instructions. When a computer reads and executes the computer program or instructions, the computer executes the method according to any one of claims 1 to 10.