Parameter tuning method of virtual machine
By detecting the performance indicators of the virtual machine garbage collector and dynamically adjusting, the problem of poor JVM parameter optimization is solved, and more efficient virtual machine performance optimization is achieved.
Patent Information
- Application Number
- CN202411591569.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-28
AI Technical Summary
When optimizing Java virtual machine (JVM) parameters, developers and system administrators are required to have high professional knowledge. Lack of experience may lead to poor optimization of JVM parameters and inability to achieve target performance.
A virtual machine parameter tuning method is proposed. By detecting the performance indicators of the garbage collector of the virtual machine, evaluating the effect of the adjustment operation, and dynamically adjusting it according to the target usage rate and performance indicators, ensuring that the adjustment operation achieves the expected effect.
It improves the effectiveness of virtual machine parameter optimization, can monitor and analyze tuned performance indicators, identify potential performance bottlenecks and optimization space, and adjust parameters in a timely manner to improve the operating performance of virtual machines.
Smart Images

Figure CN119537005A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of parameter tuning, and in particular to a method for tuning parameters of a virtual machine. Background Art
[0002] When it comes to optimizing the internal principles of the Java virtual machine and parameter tuning techniques, developers and system administrators are required to have high professional knowledge, such as virtual machine (JVM) parameter tuning, JVM parameters include heap memory size, garbage collector (garbage collector) parameters, and GC (garbage collection) strategy parameters, etc. If there is a lack of sufficient experience and understanding, the JVM parameter optimization effect may be poor, and the JVM may not be able to achieve the target performance.
[0003] Therefore, a method is urgently needed to avoid the problem of poor JVM parameter optimization effect. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a method and device for tuning parameters of a virtual machine, an electronic device and a storage medium, aiming to improve the effectiveness of parameter optimization of the virtual machine.
[0005] To achieve the above object, a first aspect of an embodiment of the present application provides a method for tuning parameters of a virtual machine, the method comprising:
[0006] In some embodiments, when the Nth adjustment operation is performed on the target operating performance parameters of the virtual machine according to the current target usage rate of the virtual machine, the performance indicator of the garbage collector of the virtual machine is detected, the target usage rate is associated with the target operating performance parameters, and N is a positive integer.
[0007] In some embodiments, the adjustment operation is evaluated according to the performance indicator of the garbage collector to obtain an evaluation result, and the evaluation result is used to indicate whether the adjustment operation meets the adjustment expectation.
[0008] In some embodiments, when the evaluation result indicates that the adjustment operation does not meet the adjustment expectation, an N+1th adjustment operation is performed on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine.
[0009] In combination with the first aspect, in a possible implementation, the target usage rate includes at least one of heap usage rate, CPU usage rate and memory usage rate, and the target operating performance parameter includes at least one of heap memory size and number of garbage collection threads.
[0010] In combination with the first aspect, in a possible implementation manner, when the target usage rate includes the heap usage rate, the performing the Nth adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine includes:
[0011] Compare the current heap usage of the virtual machine with a preset heap usage threshold to obtain a first comparison result;
[0012] According to the first comparison result, an Nth adjustment operation is performed using an adjustment method corresponding to the first comparison result, where the adjustment method includes at least one of the following:
[0013] In the case where the target operating performance parameter includes a heap memory size, when the first comparison result is that the current heap usage of the virtual machine is greater than the preset heap usage threshold, adjusting the heap memory size;
[0014] In the case where the target operating performance parameter includes the number of garbage collection threads, when the first comparison result is that the current heap usage of the virtual machine is less than or equal to the preset heap usage threshold, the number of garbage collection threads is adjusted.
[0015] In combination with the first aspect, in a possible implementation manner, before the number of garbage collection threads is adjusted, the method includes:
[0016] Obtaining the current garbage collection pause duration of the virtual machine;
[0017] If the garbage collection pause duration is greater than a preset pause duration threshold, a step of adjusting the number of garbage collection threads is performed.
[0018] In combination with the first aspect, in a possible implementation manner, the adjusting the number of garbage collection threads includes:
[0019] The target number of threads is calculated according to the current number of garbage collection threads, the preset pause duration threshold, and the garbage collection pause duration.
[0020] The number of garbage collection threads is adjusted to the target number of threads.
[0021] In combination with the first aspect, in a possible implementation manner, when the target usage includes the CPU usage and the target operating performance parameter includes the number of garbage collection threads, performing the Nth adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage of the virtual machine includes:
[0022] When the current CPU usage of the virtual machine is greater than a preset CPU usage threshold, the number of garbage collection threads is increased.
[0023] In combination with the first aspect, in a possible implementation manner, increasing the number of garbage collection threads includes:
[0024] Calculate the target number of threads to be increased based on the set maximum number of CPU threads, the current number of garbage collection threads, the current CPU usage rate, and the preset CPU usage rate threshold;
[0025] Increase the number of threads according to the target and increase the number of garbage collection threads.
[0026] In combination with the first aspect, in a possible implementation manner, when the target usage includes the memory usage and the target operating performance parameter includes the heap memory size, performing the Nth adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage of the virtual machine includes:
[0027] Compare the current memory usage of the virtual machine with a preset memory usage threshold to obtain a second comparison result;
[0028] According to the second comparison result, an Nth adjustment operation is performed using an adjustment method corresponding to the second comparison result, where the adjustment method includes at least one of the following:
[0029] When the second comparison result is that the current memory usage of the virtual machine is greater than the preset memory usage threshold, increasing the heap memory size;
[0030] When the second comparison result is that the current memory usage of the virtual machine is less than or equal to the preset memory usage threshold, the heap memory size is reduced.
[0031] In combination with the first aspect, in a possible implementation manner, increasing the heap memory size includes:
[0032] Calculate a first difference between the memory usage rate and the preset memory usage rate threshold;
[0033] Calculating a ratio of the first difference to the preset memory usage threshold to obtain an increase ratio;
[0034] Increase the heap memory size according to the increase ratio;
[0035] The reducing the heap memory size comprises:
[0036] Calculate a second difference value of the preset memory usage threshold minus the memory usage;
[0037] Calculating a ratio of the second difference to the preset memory usage threshold to obtain a reduction ratio;
[0038] The heap memory size is reduced according to the reduction ratio.
[0039] In combination with the first aspect, in a possible implementation, the above performance indicator includes at least one of the occurrence frequency of Minor GC and the occurrence frequency of Full GC, and the adjustment operation is evaluated according to the performance indicator of the garbage collector to obtain an evaluation result, including:
[0040] In the case where the performance indicator includes the occurrence frequency of Minor GC, if the occurrence frequency of the Minor GC is greater than a preset first frequency threshold, the evaluation result indicates that the adjustment operation does not meet the adjustment expectation;
[0041] In the case where the performance indicator includes the occurrence frequency of Full GC, if the occurrence frequency of Full GC is greater than a preset second frequency threshold, the evaluation result indicates that the adjustment operation does not meet the adjustment expectation.
[0042] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a parameter tuning device for a virtual machine, the device comprising:
[0043] An indicator detection device is used to detect the performance indicator of the garbage collector of the virtual machine when the target operating performance parameter of the virtual machine is adjusted for the Nth time according to the current target usage rate of the virtual machine, the target usage rate is associated with the target operating performance parameter, and N is a positive integer.
[0044] The adjustment evaluation device is used to evaluate the adjustment operation according to the performance index of the garbage collector to obtain an evaluation result, and the evaluation result is used to indicate whether the adjustment operation meets the adjustment expectation.
[0045] A loop device is used to perform an N+1th adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine when the evaluation result indicates that the adjustment operation does not meet the adjustment expectation.
[0046] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0047] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0048] A method for tuning parameters of a virtual machine proposed in this application 、 The device, electronic device and storage medium perform adjustment operations on the target operating performance parameters of the virtual machine according to the current target usage rate of the virtual machine, detect the performance indicators of the garbage collector of the virtual machine after performing an adjustment operation, evaluate the adjustment operation based on the performance indicators of the garbage collector, and if the adjustment operation does not meet the adjustment expectations, perform adjustment operations on the target operating performance parameters of the virtual machine again according to the current target usage rate of the virtual machine, and so on. In this way, the performance indicators of the virtual machine after parameter tuning are monitored, the tuning effect is analyzed, potential performance bottlenecks and optimization space can be identified, the parameter tuning effect can be judged in time, and further optimization measures can be taken. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 is a flow chart of a method for tuning parameters of a virtual machine provided in an embodiment of the present application;
[0050] Figure 2 yes Figure 1 Flow chart of step S101 in FIG.
[0051] Figure 3 yes Figure 2 Flowchart of steps before step S202 in FIG. 1 ;
[0052] Figure 4 yes Figure 3 Flow chart of step S302 in FIG.
[0053] Figure 5 yes Figure 1 Flow chart of step S101 in FIG.
[0054] Figure 6 yes Figure 5 Flow chart of step S501 in FIG.
[0055] Figure 7 yes Figure 1 Flow chart of step S101 in FIG.
[0056] Figure 8 yes Figure 7 Flowchart of step S702 in FIG.
[0057] Fig. 9 yes Figure 7 Flowchart of step S702 in FIG.
[0058] Fig.10 yes Figure 1 Flow chart of step S103 in FIG.
[0059] Fig.11 It is a flowchart of a complete example of a method for tuning parameters of a virtual machine;
[0060] Fig.12 It is a structural diagram of a parameter tuning device for a virtual machine provided in an embodiment of the present application;
[0061] Fig.13 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0063] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0064] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0065] The embodiments of the present application provide a method, device, electronic device and storage medium for tuning parameters of a virtual machine, aiming to improve the effectiveness of tuning parameters of the virtual machine.
[0066] The virtual machine parameter tuning method and device, electronic device and storage medium provided in the embodiments of the present application are specifically described through the following embodiments. First, the virtual machine parameter tuning method in the embodiments of the present application is described.
[0067] The parameter tuning method of the virtual machine provided in the embodiment of the present application relates to the field of parameter tuning technology. The parameter tuning method of the virtual machine provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the parameter tuning method of the virtual machine, etc., but is not limited to the above forms.
[0068] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0069] Figure 1 is an optional flow chart of a method for tuning parameters of a virtual machine provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S103.
[0070] Step S101 , when performing an Nth adjustment operation on a target operating performance parameter of the virtual machine according to a current target usage rate of the virtual machine, detecting a performance indicator of a garbage collector of the virtual machine.
[0071] Step S102: Evaluate the adjustment operation according to the performance indicator of the garbage collector to obtain an evaluation result.
[0072] Step S103 , when the evaluation result indicates that the adjustment operation does not meet the adjustment expectation, perform an N+1th adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine.
[0073] Virtual machines can be used in applications. Applications refer to computer programs that are used to complete one or more specific tasks. Virtual machines can be used in financial applications. The performance of applications can be improved by tuning the parameters of the virtual machines.
[0074] The above-mentioned target usage is a usage parameter associated with the target operating performance parameter in the virtual machine, such as the heap usage, CPU usage, memory usage, etc. in the virtual machine. The CPU usage is a measure of the amount of time the CPU spends executing various tasks and processes on the computer. When the virtual machine is used to execute an application, the CPU usage can represent the time the CPU spends executing the application and process, and the heap usage represents the occupancy rate of the heap memory.
[0075] The above target operating performance parameters can be understood as relevant parameters that affect the target usage rate, and the above performance indicators are used to indicate the goodness of the operating status of the virtual machine.
[0076] Wherein, N is a positive integer and its initial value is 1.
[0077] In step S101 of some embodiments, a monitoring tool VisualVM can be used to monitor the performance indicators and target usage of the virtual machine. By analyzing the monitoring data, potential performance bottlenecks and optimization space can be identified, and the target operating performance parameters of the virtual machine can be adjusted in time to realize timely discovery of problems and take corresponding optimization measures.
[0078] The evaluation results are used to indicate whether the adjustment actions have met the adjustment expectations.
[0079] In step S102 of some embodiments, the effectiveness of the adjustment is evaluated based on the performance indicators of the garbage collector after adjusting the target operating performance parameters. The evaluation result is divided into a first evaluation result and a second evaluation result. The first evaluation result indicates that the adjustment operation does not meet the adjustment expectations, and the second evaluation result indicates that the adjustment operation meets the adjustment expectations.
[0080] In step S103 of some embodiments, when the evaluation result is the first evaluation result, it indicates that the effectiveness of this adjustment is not high and the target operating performance parameters need to be further adjusted. Then, the adjustment operation of the target operating performance parameters of the virtual machine is performed again according to the current target usage rate of the virtual machine.
[0081] This embodiment performs adjustment operations on the target operating performance parameters of the virtual machine according to the current target usage rate of the virtual machine through steps S101 to S103, and can effectively dynamically adjust the relevant target operating performance parameters based on the usage rate of the virtual machine to improve the operating performance of the virtual machine. When the adjustment operation does not meet the adjustment expectations, the target operating performance parameters of the virtual machine are further adjusted according to the current target usage rate of the virtual machine, thereby continuously adjusting the target operating performance parameters and ensuring the effectiveness of the adjustment of the target operating performance parameters.
[0082] In a possible implementation, the target usage rate includes at least one of a heap usage rate, a CPU usage rate, and a memory usage rate, and the target operating performance parameter includes at least one of a heap memory size and a number of garbage collection threads.
[0083] The above-mentioned garbage collection thread is a thread used for garbage collection.
[0084] See also Figure 2 In some embodiments, when the target usage rate includes the heap usage rate, step S101 may include but is not limited to steps S201 to S205:
[0085] Step S201, comparing the current heap usage of the virtual machine with a preset heap usage threshold to obtain a first comparison result.
[0086] Step S202: According to the first comparison result, an Nth adjustment operation is performed using an adjustment method corresponding to the first comparison result.
[0087] The adjustment method includes at least one of the following:
[0088] In the case where the target operating performance parameter includes a heap memory size, when the first comparison result is that the current heap usage of the virtual machine is greater than the preset heap usage threshold, adjusting the heap memory size;
[0089] In the case where the target operating performance parameter includes the number of garbage collection threads, when the first comparison result is that the current heap usage of the virtual machine is less than or equal to the preset heap usage threshold, the number of garbage collection threads is adjusted.
[0090] The above-mentioned preset heap usage threshold is a pre-set threshold value, which can be used as a boundary value for judging the high and low heap usage. When the current heap usage is greater than the preset heap usage threshold, the heap usage is high, and when the current heap usage is less than or equal to the preset heap usage threshold, the heap usage is low. In a possible implementation, the preset heap usage threshold can be 70%.
[0091] In step S201 of some embodiments, the first comparison result is that the current heap usage is greater than a preset heap usage threshold, or the current heap usage is less than or equal to the preset heap usage threshold.
[0092] In step S202 of some embodiments, different adjustment schemes are executed for different comparison results. In one possible implementation, the corresponding adjustment operation may be executed only for the case where the current heap usage is greater than a preset heap usage threshold, or the corresponding adjustment operation may be executed only for the case where the current heap usage is less than or equal to the preset heap usage threshold. In another possible implementation, the corresponding adjustment operation may be executed for each of the above two comparison results.
[0093] Specifically, when the first comparison result is that the current heap usage of the virtual machine is greater than the preset heap usage threshold, the heap memory size is adjusted by increasing the heap memory size according to the preset increase value. For example, if the preset increase value is 5 and the current heap memory size is 1, the current heap memory size is increased to 6.
[0094] Through step S201-step S202, the target operating performance parameter associated with the heap usage rate is adjusted in a targeted manner. In addition, based on the difference between the heap memory usage rate and the preset heap usage rate threshold, the heap memory size is increased, so that when the heap memory occupancy rate is too large, the heap memory size can be expanded in time to reduce the usage pressure of the heap memory.
[0095] See also Figure 3 In some embodiments, the process before step S202 may include but is not limited to step S301 to step S302:
[0096] Step S301, obtaining the current garbage collection pause duration of the virtual machine.
[0097] Step S302: If the garbage collection pause duration is greater than a preset pause duration threshold, a step of adjusting the number of garbage collection threads is performed.
[0098] In step S301 of some embodiments, the garbage collection pause duration of the virtual machine is monitored by using a monitoring tool VisualVM. If the first comparison result is that the current heap usage of the virtual machine is less than or equal to a preset heap usage threshold, the current garbage collection pause duration of the virtual machine is obtained.
[0099] The above preset pause time threshold can be set according to demand, and can be set to 200ms.
[0100] In step S302 of some embodiments, if the garbage collection pause duration is greater than a preset pause duration threshold, the number of garbage collection threads is adjusted by increasing the number of garbage collection threads.
[0101] In a possible implementation, if the garbage collection pause duration is less than or equal to a preset pause duration threshold, the current number of garbage collection threads is maintained unchanged and the current number of garbage collection threads is not adjusted.
[0102] In the embodiment of the present invention, through step S301 and step S302, the number of garbage collection threads is adjusted based on the difference between the garbage collection pause duration and the preset pause duration threshold, so that the garbage collection speed can be adjusted.
[0103] See also Figure 4 In some embodiments, step S302 may include but is not limited to steps S401 to S402:
[0104] Step S401, calculating the target number of threads according to the current number of garbage collection threads, the preset pause time threshold and the garbage collection pause time.
[0105] Step S402, adjusting the number of garbage collection threads to the target number of threads.
[0106] The above target number of threads is the target value to which the number of garbage collection threads is adjusted.
[0107] In step S401 of some embodiments, when this is the first time that the number of garbage collection threads is adjusted, the current number of garbage collection threads is the basic number of threads (eg, the initially set number of garbage collection threads).
[0108] In one possible implementation, the target number of threads is calculated as follows:
[0109]
[0110] Among them, T adjusted Indicates the target number of threads, T base Indicates the current number of garbage collection threads, S current Indicates the current garbage collection pause duration, S threshold Indicates the preset pause duration threshold.
[0111] In one possible implementation, since the value calculated according to the calculation formula for the target number of threads may be a decimal, the value calculated according to the calculation formula for the target number of threads may be rounded to obtain the target number of threads. For example, if the value calculated according to the calculation formula for the target number of threads is 5.7, the target number of threads may be 6 or 5.
[0112] In step S402 of some embodiments, for example, the current garbage collection pause duration is 220ms and the preset pause duration threshold is 200ms, then 220ms is greater than 200ms. If the target number of threads calculated based on the current number of garbage collection threads, the preset pause duration threshold and the garbage collection pause duration is 30, and the current number of garbage collection threads is 20, then 10 garbage collection threads are added to adjust the number of garbage collection threads to 30.
[0113] This embodiment implements, through steps S401-S402, that if the garbage collection pause duration is greater than the preset pause duration threshold, the number of garbage collection threads to be increased is calculated based on the current number of garbage collection threads, the garbage collection pause duration and the preset pause duration threshold, so as to effectively obtain a reasonable number of garbage collection threads to be increased and avoid blindly adjusting the number of garbage collection threads.
[0114] See also Figure 5 In some embodiments, when the target usage rate includes the CPU usage rate and the target operating performance parameter includes the number of garbage collection threads, step S101 may also include but is not limited to step S501:
[0115] Step S501, when the current CPU usage of the virtual machine is greater than a preset CPU usage threshold, increase the number of garbage collection threads.
[0116] The preset CPU usage threshold is a pre-set threshold used as a critical value for determining whether the CPU usage is high or low.
[0117] In a possible implementation, if the current CPU usage of the virtual machine is less than or equal to a preset CPU usage threshold, the number of garbage collection threads is not adjusted.
[0118] Through step S501, when the CPU usage rate is too high, the associated target motion performance parameters are adjusted to reduce the CPU usage pressure.
[0119] See also Figure 6 In some embodiments, step S501 includes but is not limited to steps S601 to S602:
[0120] Step S601, calculating the target number of threads to be increased according to the set maximum number of threads of the CPU, the current number of garbage collection threads, the current CPU usage rate and the preset CPU usage rate threshold.
[0121] Step S602: Increase the number of garbage collection threads according to the target.
[0122] The maximum number of threads of the CPU mentioned above is pre-configured by the system and can be understood as the number of CPU cores. The target number of threads to be increased is the number of garbage collection threads to be increased.
[0123] In step S601 of some embodiments, the calculation formula for the target number of threads to be increased may be as follows:
[0124]
[0125] Among them, I increase Indicates the target number of threads to be increased, T max Indicates the maximum number of threads in the CPU, T current Indicates the current number of garbage collection threads, U threshold Indicates the preset CPU usage threshold, U cpu Indicates the current CPU usage.
[0126] Since the value calculated according to the calculation formula for the target number of threads to be increased may be a decimal, the value calculated according to the calculation formula for the target number of threads to be increased may be rounded to obtain the target number of threads to be increased. For example, if the value calculated according to the calculation formula for the target number of threads to be increased is 5.7, the target number of threads to be increased may be 6 or 5.
[0127] In step S602 of some embodiments, if the target number of threads to be increased is 10, 10 garbage collection threads are added.
[0128] Through step S601 and step S602, the number of garbage collection threads can be dynamically adjusted according to the current CPU usage rate, thereby accelerating the garbage collection speed and improving the performance of the virtual machine.
[0129] See also Figure 7 In some embodiments, when the target usage rate includes memory usage rate and the target operating performance parameter includes heap memory size, step S101 may include but is not limited to steps S701 to S702:
[0130] Step S701, comparing the current memory usage of the virtual machine with a preset memory usage threshold to obtain a second comparison result.
[0131] Step S702: According to the second comparison result, an Nth adjustment operation is performed using an adjustment method corresponding to the second comparison result.
[0132] The adjustment method includes at least one of the following:
[0133] When the second comparison result is that the current memory usage of the virtual machine is greater than the preset memory usage threshold, increasing the heap memory size;
[0134] When the second comparison result is that the current memory usage of the virtual machine is less than or equal to the preset memory usage threshold, the heap memory size is reduced.
[0135] The above preset memory usage threshold is a preset threshold and can be set according to needs.
[0136] In step S701 of some embodiments, the second comparison result is that the current memory usage is greater than a preset memory usage threshold, or the current memory usage is less than or equal to the preset memory usage threshold.
[0137] In step S702 of some embodiments, different adjustment schemes are executed for different comparison results. In one possible implementation, there may be only an adjustment operation of increasing the heap memory size when the current memory usage is greater than a preset memory usage threshold, or there may be only an adjustment operation of reducing the heap memory size when the current memory usage is less than or equal to the preset heap usage threshold. In another possible implementation, there may be corresponding adjustment operations executed for the above two comparison results respectively.
[0138] Through step S701 and step S702, it is possible to timely adjust the heap memory size based on the comparison between the memory usage rate and the preset memory usage rate threshold, reduce the memory usage pressure and avoid wasting memory resources.
[0139] See also Figure 8 In some embodiments, step S702 may include but is not limited to steps S801 to S803:
[0140] Step S801, calculating a first difference between the memory usage rate and the preset memory usage rate threshold.
[0141] Step S802, calculating the ratio of the first difference to the preset memory usage threshold to obtain an increase ratio.
[0142] Step S803: Increase the heap memory size according to the increase ratio.
[0143] In step S802 of some embodiments, the calculation formula for the increase ratio may be as follows:
[0144]
[0145] Among them, P1 is the increase ratio, T is the preset memory usage threshold, t is the current actual memory usage, and tT represents the first difference.
[0146] In step S803 of some embodiments, if P1=50%, the heap memory size needs to be increased by 50% on the existing basis.
[0147] See also Fig. 9 In some embodiments, step S702 may include but is not limited to steps S901 to S903:
[0148] Step S901, calculating a second difference between the preset memory usage threshold and the memory usage.
[0149] Step S902, calculating the ratio of the second difference to the preset memory usage threshold to obtain a reduction ratio.
[0150] Step S903: reducing the heap memory size according to the reduction ratio.
[0151] In step S902 of some embodiments, the calculation formula for the reduction ratio may be as follows:
[0152]
[0153] Among them, P2 is the reduction ratio, T is the preset memory usage threshold, t is the current actual memory usage, and Tt represents the second difference.
[0154] In step S903 of some embodiments, if P2=50%, the heap memory size needs to be reduced by 50% on the existing basis.
[0155] Through steps S801 to S803 and steps S901 to S903, it is possible to determine a suitable adjustment range of the number of threads based on the current memory usage rate and the preset memory usage rate threshold, so as to ensure the effectiveness of the adjustment.
[0156] It should be noted that, when the target usage includes heap usage, CPU usage and memory usage, in a first possible implementation, step S702 may be before step S201, and step S202 may be before step S501, in a second possible implementation, step S702 may be before step S501, and step S501 may be before step S201, in a third possible implementation, step S202 may be before step S501, and step S501 may be before step S701, in a fourth possible implementation, step S202 may be before step S701, and step S702 may be before step S501, in a fifth possible implementation, step S501 may be before step S701, and step S702 may be before step S201, and in a sixth possible implementation, step S501 may be before step S201, and step S202 may be before step S701.
[0157] In another possible implementation, step S201, step S501 and step S701 may be performed simultaneously.
[0158] In one possible implementation, the heap memory size can also be adjusted according to the garbage collection frequency. The specific method is as follows:
[0159] Get the current garbage collection frequency of the virtual machine;
[0160] If the garbage collection frequency is greater than a preset collection frequency threshold, the heap memory size is increased.
[0161] Among them, the preset recycling frequency threshold is a preset garbage collection frequency threshold, and the method for increasing the heap memory size is specifically to calculate the target memory appreciation according to the preset recycling frequency threshold, the current garbage collection frequency and the current heap memory size, and increase the heap memory size according to the target memory appreciation.
[0162] The target memory increment calculation formula can be as follows:
[0163]
[0164] Among them, ΔH1 represents the target memory increment, H0 represents the current heap memory size, f Indicates the current garbage collection frequency, F Indicates the preset recycling frequency threshold.
[0165] It should be noted that the step of adjusting the heap memory size according to the garbage collection frequency may be performed before step S201 or after step S202, before step S501 or after step S502, before step S701 or after step S702, or simultaneously with step S201, step S501 and step S701.
[0166] See also Fig.10 In some embodiments, the performance indicator includes at least one of the occurrence frequency of Mini GC and the occurrence frequency of Full GC. Step S103 may include but is not limited to steps S110 to S111:
[0167] Step S110, when the performance indicator includes the occurrence frequency of Minor GC, if the occurrence frequency of Minor GC is greater than a preset first frequency threshold, the evaluation result indicates that the adjustment operation does not meet the adjustment expectation.
[0168] Step S111, when the performance indicator includes the occurrence frequency of Full GC, if the occurrence frequency of Full GC is greater than a preset second frequency threshold, the evaluation result indicates that the adjustment operation does not meet the adjustment expectation.
[0169] The occurrence frequency of Minor GC is the number of Minor GC occurrences within a preset time. Minor GC, also known as new generation GC (garbage collection for the new generation), refers to the garbage collection action that occurs in the new generation of the JVM.
[0170] The above-mentioned Full GC (full garbage collection) is a garbage collection mechanism in the Java Virtual Machine (JVM), which cleans up the entire heap memory, including the new generation, old generation, and metaspace. Full GC is usually much slower than Minor GC (garbage collection only for the new generation) because it needs to check the entire heap memory. Therefore, frequent occurrence of Full GC may seriously affect the performance of the application.
[0171] In a possible implementation, the evaluation result may be obtained based only on the occurrence frequency of Minor GC, or based only on the occurrence frequency of Full GC, or based on a combination of the occurrence frequency of Minor GC and the occurrence frequency of Full GC.
[0172] In step S110 of some embodiments, if the performance indicator only includes the occurrence frequency of Minor GC, when the occurrence frequency of Minor GC is less than or equal to a preset first frequency threshold, the evaluation result indicates that the adjustment operation meets the adjustment expectation.
[0173] In step S111 of some embodiments, if the performance indicator only includes the occurrence frequency of Full GC, when the occurrence frequency of Full GC is less than or equal to a preset second frequency threshold, the evaluation result indicates that the adjustment operation meets the adjustment expectation.
[0174] In a possible implementation, if the performance indicator includes the occurrence frequency of Minor GC and the occurrence frequency of Full GC, when the occurrence frequency of Minor GC is less than or equal to a preset first frequency threshold, and the occurrence frequency of Full GC is less than or equal to a preset second frequency threshold, the evaluation result indicates that the adjustment operation meets the adjustment expectations.
[0175] In a possible implementation, the performance indicators may also include response time, memory, CPU performance indicators (such as the number of cores), and the like.
[0176] Through step S110-step S111, an evaluation result is obtained based on the occurrence frequency of Full GC and / or the occurrence frequency of Minor GC. The occurrence frequency of Full GC and the occurrence frequency of Minor GC can well reflect the performance of the virtual machine and can effectively evaluate the adjustment operation.
[0177] In order to better understand the above virtual machine parameter tuning method, a complete embodiment is provided below for description. Fig.11 , an embodiment of the present application also provides a flowchart of a complete example of a method for tuning parameters of a virtual machine.
[0178] like Fig.11 As shown, assuming that the preset heap usage threshold, the preset CPU usage threshold, and the preset memory usage threshold are all 70%, and the preset pause duration threshold is 200ms, first, obtain the current memory usage of the virtual machine. When the current memory usage is greater than 70%, increase the heap memory size; when the current memory usage is less than or equal to 70%, reduce the heap memory size.
[0179] Get the current heap usage after adjusting the heap memory size for memory usage. If the current heap usage is greater than 70%, increase the heap memory size. Get the current CPU usage after increasing the heap memory size. If the current CPU usage is greater than 70%, increase the number of garbage collection threads. If the current heap usage is less than or equal to 70%, check the current garbage collection pause duration of the virtual machine. If the garbage collection pause duration is greater than 200ms, increase the number of garbage collection threads. Get the current CPU usage after increasing the number of garbage collection threads. If the current CPU usage is greater than 70%, increase the number of garbage collection threads. If the garbage collection pause duration is less than or equal to 200ms, get the current CPU usage. If the current CPU usage is greater than 70%, increase the number of garbage collection threads.
[0180] Get the current Minor GC occurrence frequency and Full GC occurrence frequency. If the Minor GC occurrence frequency is greater than the preset first frequency threshold or the Full GC occurrence frequency is greater than the preset second frequency threshold, the adjustment operation does not meet the adjustment expectations. Re-execute the adjustment operation, that is, re-execute the step of obtaining the current memory usage of the virtual machine.
[0181] In the embodiment of the present application, an adjustment operation is performed on the target operating performance parameters of the virtual machine according to the current target usage rate of the virtual machine. After performing an adjustment operation, the performance index of the garbage collector of the virtual machine is detected, and the adjustment operation is evaluated based on the performance index of the garbage collector. If the adjustment operation does not meet the adjustment expectation, the adjustment operation is performed again on the target operating performance parameters of the virtual machine according to the current target usage rate of the virtual machine, and so on. In this way, the performance index of the virtual machine after parameter tuning is monitored and the tuning effect is analyzed, so that potential performance bottlenecks and optimization space can be identified, the parameter tuning effect can be judged in time, and further optimization measures can be taken.
[0182] See also Fig.12The embodiment of the present application also provides a virtual machine parameter tuning device, which can implement the above virtual machine parameter tuning method, and the device includes:
[0183] The indicator detection device 120 is used to detect the performance indicator of the garbage collector of the virtual machine when the Nth adjustment operation is performed on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine, the target usage rate is associated with the target operating performance parameter, and N is a positive integer.
[0184] The adjustment evaluation device 121 is used to evaluate the adjustment operation according to the performance index of the garbage collector to obtain an evaluation result, and the evaluation result is used to indicate whether the adjustment operation meets the adjustment expectation.
[0185] The loop device 122 is used to perform the N+1th adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine when the evaluation result indicates that the adjustment operation does not meet the adjustment expectation.
[0186] In a possible design, when the target usage rate includes a heap usage rate, the indicator detection device 120 is specifically used to: compare the current heap usage rate of the virtual machine with a preset heap usage rate threshold to obtain a first comparison result; and according to the first comparison result, perform an Nth adjustment operation using an adjustment method corresponding to the first comparison result, wherein the adjustment method includes at least one of the following:
[0187] In the case where the target operating performance parameter includes a heap memory size, when the first comparison result is that the current heap usage of the virtual machine is greater than the preset heap usage threshold, adjusting the heap memory size;
[0188] In the case where the target operating performance parameter includes the number of garbage collection threads, when the first comparison result is that the current heap usage of the virtual machine is less than or equal to the preset heap usage threshold, the number of garbage collection threads is adjusted.
[0189] In one possible design, the indicator detection device 120 is specifically used to: obtain the current garbage collection pause duration of the virtual machine; if the garbage collection pause duration is greater than a preset pause duration threshold, execute the step of adjusting the number of garbage collection threads.
[0190] In a possible design, the indicator detection device 120 is specifically used to: calculate the target number of threads according to the current number of garbage collection threads, the preset pause time threshold and the garbage collection pause time, and adjust the number of garbage collection threads to the target number of threads.
[0191] In one possible design, when the target usage includes the CPU usage and the target operating performance parameter includes the number of garbage collection threads, the indicator detection device 120 is specifically used to: when the current CPU usage of the virtual machine is greater than a preset CPU usage threshold, increase the number of garbage collection threads.
[0192] In one possible design, the indicator detection device 120 is specifically used to: calculate the target number of increased threads based on the set maximum number of CPU threads, the current number of garbage collection threads, the current CPU usage rate and the preset CPU usage rate threshold; and increase the number of garbage collection threads according to the target number of increased threads.
[0193] In a possible design, when the target usage includes the memory usage and the target operating performance parameter includes the heap memory size, the indicator detection device 120 is specifically used to: compare the current memory usage of the virtual machine with a preset memory usage threshold to obtain a second comparison result; and according to the second comparison result, perform the Nth adjustment operation using an adjustment method corresponding to the second comparison result, wherein the adjustment method includes at least one of the following:
[0194] When the second comparison result is that the current memory usage of the virtual machine is greater than the preset memory usage threshold, increasing the heap memory size;
[0195] When the second comparison result is that the current memory usage of the virtual machine is less than or equal to the preset memory usage threshold, the heap memory size is reduced.
[0196] In one possible design, the indicator detection device 120 is specifically used to: calculate a first difference between the memory usage rate and the preset memory usage rate threshold; calculate a ratio of the first difference to the preset memory usage rate threshold to obtain an increase ratio; and increase the heap memory size according to the increase ratio.
[0197] In one possible design, the indicator detection device 120 is specifically used to: calculate a second difference between the preset memory usage threshold and the memory usage; calculate a ratio of the second difference to the preset memory usage threshold to obtain a reduction ratio; and reduce the heap memory size according to the reduction ratio.
[0198] In one possible design, the performance indicator includes at least one of the occurrence frequency of Minor GC and the occurrence frequency of Full GC, and the adjustment evaluation device 121 is specifically used to: when the performance indicator includes the occurrence frequency of Minor GC, if the occurrence frequency of Minor GC is greater than a preset first frequency threshold, then the evaluation result indicates that the adjustment operation does not meet the adjustment expectation; when the performance indicator includes the occurrence frequency of Full GC, if the occurrence frequency of Full GC is greater than a preset second frequency threshold, then the evaluation result indicates that the adjustment operation does not meet the adjustment expectation.
[0199] The specific implementation of the parameter tuning device for the virtual machine is substantially the same as the specific implementation of the parameter tuning method for the virtual machine described above, and will not be described in detail herein.
[0200] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the parameter tuning method of the virtual machine when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0201] See also Fig.13 , Fig.13 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0202] The processor 130 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0203] The memory 131 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 131 can store an operating system and other applications. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 131, and the processor 130 calls and executes the parameter tuning method of the virtual machine in the embodiments of this application;
[0204] Input / output interface 132, used to implement information input and output;
[0205] The communication interface 133 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WI FI, Bluetooth, etc.);
[0206] A bus 134 that transmits information between the various components of the device (e.g., the processor 130, the memory 131, the input / output interface 132, and the communication interface 133);
[0207] The processor 130 , the memory 131 , the input / output interface 132 and the communication interface 133 are connected to each other in communication within the device via a bus 134 .
[0208] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the parameter tuning method of the virtual machine is implemented.
[0209] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0210] The virtual machine parameter tuning method, virtual machine parameter tuning device, electronic device and storage medium provided in the embodiments of the present application perform adjustment operations on the target operating performance parameters of the virtual machine according to the current target usage rate of the virtual machine, detect the performance indicators of the garbage collector of the virtual machine after performing an adjustment operation, evaluate the adjustment operation based on the performance indicators of the garbage collector, and if the adjustment operation does not meet the adjustment expectations, perform adjustment operations on the target operating performance parameters of the virtual machine again according to the current target usage rate of the virtual machine, and so on. In this way, the performance indicators of the virtual machine after parameter tuning are monitored and the tuning effect is analyzed, so that potential performance bottlenecks and optimization space can be identified, the parameter tuning effect can be judged in time, and further optimization measures can be taken.
[0211] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0212] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0213] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0214] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0215] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0216] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0217] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. 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.
[0218] The units described above 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.
[0219] 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.
[0220] If the integrated 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 technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0221] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for tuning parameters of a virtual machine, characterized in that: The method comprises: In the case where an Nth adjustment operation is performed on a target operating performance parameter of the virtual machine according to a current target usage rate of the virtual machine, detecting a performance indicator of a garbage collector of the virtual machine, the target usage rate being associated with the target operating performance parameter, and N being a positive integer; The adjustment operation is evaluated according to the performance index of the garbage collector to obtain an evaluation result, wherein the evaluation result is used to indicate whether the adjustment operation meets the adjustment expectation; When the evaluation result indicates that the adjustment operation does not meet the adjustment expectation, an N+1th adjustment operation is performed on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine.
2. The method according to claim 1, characterized in that: The target usage rate includes at least one of a heap usage rate, a CPU usage rate, and a memory usage rate, and the target operating performance parameter includes at least one of a heap memory size and a number of garbage collection threads.
3. The method according to claim 2, characterized in that In a case where the target usage rate includes the heap usage rate, performing the Nth adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine includes: Compare the current heap usage of the virtual machine with a preset heap usage threshold to obtain a first comparison result; According to the first comparison result, an Nth adjustment operation is performed using an adjustment method corresponding to the first comparison result, where the adjustment method includes at least one of the following: In the case where the target operating performance parameter includes a heap memory size, when the first comparison result is that the current heap usage of the virtual machine is greater than the preset heap usage threshold, adjusting the heap memory size; In the case where the target operating performance parameter includes the number of garbage collection threads, when the first comparison result is that the current heap usage of the virtual machine is less than or equal to the preset heap usage threshold, the number of garbage collection threads is adjusted.
4. The method according to claim 3, characterized in that: Before adjusting the number of garbage collection threads, the method includes: Obtaining the current garbage collection pause duration of the virtual machine; If the garbage collection pause duration is greater than a preset pause duration threshold, a step of adjusting the number of garbage collection threads is performed.
5. The method according to claim 4, characterized in that The adjusting the number of garbage collection threads includes: Calculate the target number of threads according to the current number of garbage collection threads, the preset pause duration threshold, and the garbage collection pause duration; The number of garbage collection threads is adjusted to the target number of threads.
6. The method according to claim 2, characterized in that In a case where the target usage rate includes the CPU usage rate and the target operating performance parameter includes the number of garbage collection threads, performing the Nth adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine includes: When the current CPU usage of the virtual machine is greater than a preset CPU usage threshold, the number of garbage collection threads is increased.
7. The method according to claim 6, characterized in that The increasing the number of garbage collection threads includes: Calculate the target number of threads to be increased based on the set maximum number of CPU threads, the current number of garbage collection threads, the current CPU usage rate, and the preset CPU usage rate threshold; Increase the number of threads according to the target and increase the number of garbage collection threads.
8. The method according to claim 2, characterized in that: In a case where the target usage rate includes the memory usage rate and the target operating performance parameter includes the heap memory size, performing the Nth adjustment operation on the target operating performance parameter of the virtual machine according to the current target usage rate of the virtual machine includes: Compare the current memory usage of the virtual machine with a preset memory usage threshold to obtain a second comparison result; According to the second comparison result, an Nth adjustment operation is performed using an adjustment method corresponding to the second comparison result, where the adjustment method includes at least one of the following: When the second comparison result is that the current memory usage of the virtual machine is greater than the preset memory usage threshold, increasing the heap memory size; When the second comparison result is that the current memory usage of the virtual machine is less than or equal to the preset memory usage threshold, the heap memory size is reduced.
9. The method according to claim 8, characterized in that The increasing the heap memory size includes: Calculate a first difference between the memory usage rate and the preset memory usage rate threshold; Calculating a ratio of the first difference to the preset memory usage threshold to obtain an increase ratio; Increase the heap memory size according to the increase ratio; The reducing the heap memory size comprises: Calculate a second difference value of the preset memory usage threshold minus the memory usage; Calculating a ratio of the second difference to the preset memory usage threshold to obtain a reduction ratio; The heap memory size is reduced according to the reduction ratio.
10. The method according to claim 1, characterized in that The performance indicator includes at least one of the occurrence frequency of Minor GC and the occurrence frequency of Full GC. The adjustment operation is evaluated according to the performance indicator of the garbage collector to obtain an evaluation result, including: In the case where the performance indicator includes the occurrence frequency of Minor GC, if the occurrence frequency of Minor GC is greater than a preset first frequency threshold, the evaluation result indicates that the adjustment operation does not meet the adjustment expectation; In the case where the performance indicator includes the occurrence frequency of Full GC, if the occurrence frequency of Full GC is greater than a preset second frequency threshold, the evaluation result indicates that the adjustment operation does not meet the adjustment expectation.